GetWD_NewSIPAccount.aspx.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using HNWD.Pregrant.WebService;
  8. using HNWD.Pregrant.Model;
  9. using System.Text;
  10. using HNWD.Pregrant.DataAccess;
  11. using HNWD.Pregrant.Common;
  12. using HNWD.Pregrant.BusinessLogic;
  13. namespace HNWD.Pregrant.WebService.MgrCSharp
  14. {
  15. public partial class GetWD_NewSIPAccount : PageBase
  16. {
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. string SIP_IPAdd = this.GetValueByKey("SipIPAddr");
  20. string SIP_DeviceType = this.GetValueByKey("DeviceType");
  21. string SIP_DeviceID = this.GetValueByKey("DeviceID");
  22. if(string.IsNullOrEmpty(SIP_IPAdd) || string.IsNullOrEmpty(SIP_DeviceType) || string.IsNullOrEmpty(SIP_DeviceID))
  23. {
  24. this.ResponseDefaultError();
  25. return;
  26. }
  27. if (!this.InitializeDataAccess())
  28. {
  29. this.ResponseDefaultError();
  30. return;
  31. }
  32. WD_PartInfo wd_PartInfo = this.wd_PartInfoDataAccess.ext.messageDataList.Find(f=>f.SIPSEV_IP == SIP_IPAdd);
  33. if(wd_PartInfo == null)
  34. {
  35. this.ResponseDefaultError(PromptingMessage.Error_PartInfo);
  36. return;
  37. }
  38. Str_Mrg_GetWD_NewSIPAccount str_Mrg_GetWD = new Str_Mrg_GetWD_NewSIPAccount();
  39. clsOpenSIPSAccount TempSIPBase = new clsOpenSIPSAccount(this.MapPath(HttpContext.Current.Request.ApplicationPath.ToString()));
  40. str_Mrg_GetWD.Code = "ERROR";
  41. str_Mrg_GetWD.SIPAccount = SIP_DeviceType + SIP_DeviceID.PadLeft(8, '0') + "0";
  42. bool Rult = false;
  43. if(TempSIPBase.OpenSIPs_Connect(SIP_IPAdd , wd_PartInfo.SIPSEV_MYSQLUSERNAME , wd_PartInfo.SIPSEV_MYSQLPASSWORD))
  44. {
  45. if(Convert.ToInt32(SIP_DeviceType.Trim()) < 9 )
  46. {
  47. Rult = TempSIPBase.OpenSIPs_AccountCheck(str_Mrg_GetWD.SIPAccount, true);
  48. }
  49. else
  50. {
  51. for(int i = 0;i<= 9;i++)
  52. {
  53. str_Mrg_GetWD.SIPAccount = SIP_DeviceType + SIP_DeviceID.PadLeft(8, '0') + i.ToString().Trim();
  54. Rult = TempSIPBase.OpenSIPs_AccountCheck(str_Mrg_GetWD.SIPAccount, true);
  55. if (!Rult)
  56. {
  57. break;
  58. }
  59. }
  60. }
  61. }
  62. else
  63. {
  64. if(TempSIPBase.OpenSIPs_AccountAdd(str_Mrg_GetWD.SIPAccount, str_Mrg_GetWD.SIPAccount, SIP_IPAdd))
  65. {
  66. str_Mrg_GetWD.SIPPassword = str_Mrg_GetWD.SIPAccount;
  67. str_Mrg_GetWD.SIPSevIP = SIP_IPAdd;
  68. str_Mrg_GetWD.Code = "OK!";
  69. }
  70. }
  71. Response.Write(JsonHelper.SerializeWithSuffix(str_Mrg_GetWD));
  72. }
  73. }
  74. }