using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using HNWD.Pregrant.WebService; using HNWD.Pregrant.Model; using System.Text; using HNWD.Pregrant.DataAccess; using HNWD.Pregrant.Common; using HNWD.Pregrant.BusinessLogic; namespace HNWD.Pregrant.WebService.MgrCSharp { public partial class GetWD_NewSIPAccount : PageBase { protected void Page_Load(object sender, EventArgs e) { string SIP_IPAdd = this.GetValueByKey("SipIPAddr"); string SIP_DeviceType = this.GetValueByKey("DeviceType"); string SIP_DeviceID = this.GetValueByKey("DeviceID"); if(string.IsNullOrEmpty(SIP_IPAdd) || string.IsNullOrEmpty(SIP_DeviceType) || string.IsNullOrEmpty(SIP_DeviceID)) { this.ResponseDefaultError(); return; } if (!this.InitializeDataAccess()) { this.ResponseDefaultError(); return; } WD_PartInfo wd_PartInfo = this.wd_PartInfoDataAccess.ext.messageDataList.Find(f=>f.SIPSEV_IP == SIP_IPAdd); if(wd_PartInfo == null) { this.ResponseDefaultError(PromptingMessage.Error_PartInfo); return; } Str_Mrg_GetWD_NewSIPAccount str_Mrg_GetWD = new Str_Mrg_GetWD_NewSIPAccount(); clsOpenSIPSAccount TempSIPBase = new clsOpenSIPSAccount(this.MapPath(HttpContext.Current.Request.ApplicationPath.ToString())); str_Mrg_GetWD.Code = "ERROR"; str_Mrg_GetWD.SIPAccount = SIP_DeviceType + SIP_DeviceID.PadLeft(8, '0') + "0"; bool Rult = false; if(TempSIPBase.OpenSIPs_Connect(SIP_IPAdd , wd_PartInfo.SIPSEV_MYSQLUSERNAME , wd_PartInfo.SIPSEV_MYSQLPASSWORD)) { if(Convert.ToInt32(SIP_DeviceType.Trim()) < 9 ) { Rult = TempSIPBase.OpenSIPs_AccountCheck(str_Mrg_GetWD.SIPAccount, true); } else { for(int i = 0;i<= 9;i++) { str_Mrg_GetWD.SIPAccount = SIP_DeviceType + SIP_DeviceID.PadLeft(8, '0') + i.ToString().Trim(); Rult = TempSIPBase.OpenSIPs_AccountCheck(str_Mrg_GetWD.SIPAccount, true); if (!Rult) { break; } } } } else { if(TempSIPBase.OpenSIPs_AccountAdd(str_Mrg_GetWD.SIPAccount, str_Mrg_GetWD.SIPAccount, SIP_IPAdd)) { str_Mrg_GetWD.SIPPassword = str_Mrg_GetWD.SIPAccount; str_Mrg_GetWD.SIPSevIP = SIP_IPAdd; str_Mrg_GetWD.Code = "OK!"; } } Response.Write(JsonHelper.SerializeWithSuffix(str_Mrg_GetWD)); } } }