コード例 #1
0
 private void GetChildDirItems(ObjectItem parentItem)
 {
     try
     {
         string strAddress = string.Empty;
         if (string.IsNullOrEmpty(strAddress))
         {
             ShowException(string.Format("Server address is empty"));
             return;
         }
         if (parentItem == null)
         {
             return;
         }
         var parentDir = parentItem.Data as DirInfo;
         if (parentDir == null)
         {
             return;
         }
         ServerRequestInfo requestInfo = new ServerRequestInfo();
         requestInfo.ServerHost = strAddress;
         requestInfo.ServerPort = 8009;
         requestInfo.Command    = (int)ServerRequestCommand.GetChildDirectoryList;
         requestInfo.ListData.Add(parentDir.Path);
         OperationReturn optReturn = XMLHelper.SeriallizeObject(requestInfo);
         if (!optReturn.Result)
         {
             ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
             return;
         }
         WebRequest webRequest = new WebRequest();
         webRequest.Session = CurrentApp.Session;
         webRequest.Code    = (int)S1110Codes.GetServerInfo;
         webRequest.Data    = optReturn.Data.ToString();
         Service11102Client client = new Service11102Client(
             WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
             WebHelper.CreateEndpointAddress(
                 CurrentApp.Session.AppServerInfo,
                 "Service11102"));
         WebReturn webReturn = null;
         if (MainPage != null)
         {
             MainPage.SetBusy(true, CurrentApp.GetMessageLanguageInfo("004", "Getting server directory information"));
         }
         mWorker         = new BackgroundWorker();
         mWorker.DoWork += (s, de) =>
         {
             try
             {
                 webReturn = client.DoOperation(webRequest);
                 client.Close();
             }
             catch (Exception ex)
             {
                 ShowException(ex.Message);
             }
         };
         mWorker.RunWorkerCompleted += (s, re) =>
         {
             mWorker.Dispose();
             if (MainPage != null)
             {
                 MainPage.SetBusy(false, string.Empty);
             }
             if (!webReturn.Result)
             {
                 ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                 return;
             }
             if (webReturn.ListData == null)
             {
                 ShowException(string.Format("ListData is null"));
                 return;
             }
             parentItem.Children.Clear();
             for (int i = 0; i < webReturn.ListData.Count; i++)
             {
                 string   info    = webReturn.ListData[i];
                 string[] arrInfo = info.Split(new[] { ConstValue.SPLITER_CHAR }, StringSplitOptions.None);
                 if (arrInfo.Length < 2)
                 {
                     continue;
                 }
                 DirInfo dirInfo = new DirInfo();
                 dirInfo.Name = arrInfo[0];
                 dirInfo.Path = arrInfo[1];
                 ObjectItem item = new ObjectItem();
                 item.Type        = S1110Consts.OBJECTITEMTYPE_DIRINFO;
                 item.Name        = dirInfo.Name;
                 item.Icon        = string.Format("../Themes/Default/UMPS1110/Images/{0}", "folder.png");
                 item.Description = dirInfo.Path;
                 item.Data        = dirInfo;
                 parentItem.AddChild(item);
             }
             if (mConfigObject != null)
             {
                 switch (mConfigObject.ObjectType)
                 {
                 case S1110Consts.RESOURCE_VOICESERVER:
                 case S1110Consts.RESOURCE_NTIDRVPATH:
                     //GetChildFileItems(parentItem);
                     break;
                 }
             }
             parentItem.IsExpanded = true;
         };
         mWorker.RunWorkerAsync();
     }
     catch (Exception ex)
     {
         ShowException(ex.Message);
     }
 }
コード例 #2
0
 private void LoadCTIServiceNames()
 {
     try
     {
         if (PropertyInfoItem == null || PropertyInfoItem.ListConfigObjects == null)
         {
             return;
         }
         if (mConfigObject == null)
         {
             return;
         }
         var parentObj =
             PropertyInfoItem.ListConfigObjects.FirstOrDefault(
                 o => o.ObjectID == mConfigObject.ParentID);
         if (parentObj == null)
         {
             return;
         }
         //Property 11 is CTI Type
         ResourceProperty propertyValue = parentObj.ListProperties.FirstOrDefault(p => p.PropertyID == 11);
         if (propertyValue == null)
         {
             return;
         }
         //AES, CVCT 才有效
         if (propertyValue.Value != "4" && propertyValue.Value != "5")
         {
             return;
         }
         string strAddress    = GetService00Address();
         string strPBXAddress = GetPBXAddress();
         if (string.IsNullOrEmpty(strAddress) ||
             string.IsNullOrEmpty(strPBXAddress))
         {
             ShowException(string.Format("Server address or PBX address is empty"));
             return;
         }
         ServerRequestInfo requestInfo = new ServerRequestInfo();
         requestInfo.ServerHost = strAddress;
         requestInfo.ServerPort = 8009;
         requestInfo.Command    = (int)ServerRequestCommand.GetCTIServiceName;
         requestInfo.ListData.Add(strPBXAddress);
         OperationReturn optReturn = XMLHelper.SeriallizeObject(requestInfo);
         if (!optReturn.Result)
         {
             ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
             return;
         }
         WebRequest webRequest = new WebRequest();
         webRequest.Session = CurrentApp.Session;
         webRequest.Code    = (int)S1110Codes.GetServerInfo;
         webRequest.Data    = optReturn.Data.ToString();
         Service11102Client client = new Service11102Client(
             WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
             WebHelper.CreateEndpointAddress(
                 CurrentApp.Session.AppServerInfo,
                 "Service11102"));
         WebReturn webReturn = null;
         if (MainPage != null)
         {
             MainPage.SetBusy(true, CurrentApp.GetMessageLanguageInfo("011", "Getting PBX serviceName..."));
         }
         mWorker         = new BackgroundWorker();
         mWorker.DoWork += (s, de) =>
         {
             try
             {
                 webReturn = client.DoOperation(webRequest);
                 client.Close();
             }
             catch (Exception ex)
             {
                 ShowException(ex.Message);
             }
         };
         mWorker.RunWorkerCompleted += (s, re) =>
         {
             mWorker.Dispose();
             if (MainPage != null)
             {
                 MainPage.SetBusy(false, string.Empty);
             }
             if (webReturn == null)
             {
                 return;
             }
             if (!webReturn.Result)
             {
                 ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                 return;
             }
             if (webReturn.ListData == null)
             {
                 ShowException(string.Format("ListData is null"));
                 return;
             }
             for (int i = 0; i < webReturn.ListData.Count; i++)
             {
                 string             name = webReturn.ListData[i];
                 CTIServiceNameInfo info = new CTIServiceNameInfo();
                 info.Name = name;
                 var temp = mListCTIServiceNameItems.FirstOrDefault(t => t.Value == info.Name);
                 if (temp == null)
                 {
                     temp             = new PropertyValueEnumItem();
                     temp.Value       = info.Name;
                     temp.Display     = info.Name;
                     temp.Description = info.Name;
                     temp.Info        = info;
                     mListCTIServiceNameItems.Add(temp);
                 }
             }
         };
         mWorker.RunWorkerAsync();
     }
     catch (Exception ex)
     {
         ShowException(ex.Message);
     }
 }