1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- 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));
- }
- }
- }
|