using CK.SCP.Controller.WebReference;
using CK.SCP.Models.UniApiEntity;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CK.SCP.Controller
{
public class ExchangeCenterFactoryController
{
public IExchangeCenterService CreateExchangeCenterService(string doMain)
{
switch (doMain.ToUpper())
{
case "BJBMPT": //北京
return new BJExchangeCenterService();
case "CQBMPT": //重庆
return new CQExchangeCenterService();
case "HFBMPT": //合肥
return new HFExchangeCenterService();
case "CDBMPT": //成都
return new CDExchangeCenterService();
case "ZZBMPT": //株洲
return new ZZExchangeCenterService();
default:
throw new ArgumentException("Invalid Domain is empty!");
}
}
}
public interface IExchangeCenterService
{
string GetSessionId();
string UpdateTaskState(string sessionId, string taskID, int taskState, int failedCount, string failedInfo);
}
///
/// 北京
/// http://10.60.101.3:8009/ExchangeCenterService.asmx
///
public class BJExchangeCenterService : IExchangeCenterService
{
private BJ.ExchangeCenterService service;
public BJExchangeCenterService()
{
service = new BJ.ExchangeCenterService();
}
public string GetSessionId()
{
var jsonResult = service.GetSessionId("SCP", "5C2DE907DB859810", "");
var serviceResultEntityList = JsonConvert.DeserializeObject>(jsonResult);
string sessionId = serviceResultEntityList.First().Data;
return sessionId;
}
public string UpdateTaskState(string sessionId, string taskID, int taskState, int failedCount, string failedInfo)
{
string result = service.UpdateTaskState(sessionId, taskID, taskState, failedCount, failedInfo);
return result;
}
}
///
/// 重庆
/// http://10.60.101.85:8010/ExchangeCenterService.asmx
///
public class CQExchangeCenterService : IExchangeCenterService
{
private CQ.ExchangeCenterService service;
public CQExchangeCenterService()
{
service = new CQ.ExchangeCenterService();
}
public string GetSessionId()
{
var jsonResult = service.GetSessionId("SCP", "5C2DE907DB859810", "");
var serviceResultEntityList = JsonConvert.DeserializeObject>(jsonResult);
string sessionId = serviceResultEntityList.First().Data;
return sessionId;
}
public string UpdateTaskState(string sessionId, string taskID, int taskState, int failedCount, string failedInfo)
{
string result = service.UpdateTaskState(sessionId, taskID, taskState, failedCount, failedInfo);
return result;
}
}
///
/// 合肥
/// http://10.60.101.3:8012/ExchangeCenterService.asmx
///
public class HFExchangeCenterService : IExchangeCenterService
{
private HF.ExchangeCenterService service;
public HFExchangeCenterService()
{
service = new HF.ExchangeCenterService();
}
public string GetSessionId()
{
var jsonResult = service.GetSessionId("SCP", "5C2DE907DB859810", "");
var serviceResultEntityList = JsonConvert.DeserializeObject>(jsonResult);
string sessionId = serviceResultEntityList.First().Data;
return sessionId;
}
public string UpdateTaskState(string sessionId, string taskID, int taskState, int failedCount, string failedInfo)
{
string result = service.UpdateTaskState(sessionId, taskID, taskState, failedCount, failedInfo);
return result;
}
}
///
/// 成都
/// http://10.60.101.85:8070/ExchangeCenterService.asmx
///
public class CDExchangeCenterService : IExchangeCenterService
{
private CD.ExchangeCenterService service;
public CDExchangeCenterService()
{
service = new CD.ExchangeCenterService();
}
public string GetSessionId()
{
var jsonResult = service.GetSessionId("SCP", "5C2DE907DB859810", "");
var serviceResultEntityList = JsonConvert.DeserializeObject>(jsonResult);
string sessionId = serviceResultEntityList.First().Data;
return sessionId;
}
public string UpdateTaskState(string sessionId, string taskID, int taskState, int failedCount, string failedInfo)
{
string result = service.UpdateTaskState(sessionId, taskID, taskState, failedCount, failedInfo);
return result;
}
}
///
/// 株洲
/// http://10.60.101.3:8011/ExchangeCenterService.asmx
///
public class ZZExchangeCenterService : IExchangeCenterService
{
private ZZ.ExchangeCenterService service;
public ZZExchangeCenterService()
{
service = new ZZ.ExchangeCenterService();
}
public string GetSessionId()
{
var jsonResult = service.GetSessionId("SCP", "5C2DE907DB859810", "");
var serviceResultEntityList = JsonConvert.DeserializeObject>(jsonResult);
string sessionId = serviceResultEntityList.First().Data;
return sessionId;
}
public string UpdateTaskState(string sessionId, string taskID, int taskState, int failedCount, string failedInfo)
{
string result = service.UpdateTaskState(sessionId, taskID, taskState, failedCount, failedInfo);
return result;
}
}
}