コード例 #1
0
        private void LoadNetworkCardInfos(List <string> listHostAddresses)
        {
            List <NetworkCardInfo> listCardInfo = new List <NetworkCardInfo>();
            WebRequest             webRequest   = new WebRequest();

            webRequest.Session = CurrentApp.Session;
            webRequest.Code    = (int)S1110Codes.GetServerInfo;
            Service11102Client client = new Service11102Client(
                WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                WebHelper.CreateEndpointAddress(
                    CurrentApp.Session.AppServerInfo,
                    "Service11102"));
            bool   isFail = true;
            string strMsg = string.Empty;

            if (MainPage != null)
            {
                MainPage.SetBusy(true, CurrentApp.GetMessageLanguageInfo("005", "Getting server networkcard information"));
            }
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += (s, de) =>
            {
                try
                {
                    for (int i = 0; i < listHostAddresses.Count; i++)
                    {
                        string address = listHostAddresses[i];
                        if (string.IsNullOrEmpty(address))
                        {
                            strMsg += string.Format("Server address is empty!;");
                            continue;
                        }
                        ServerRequestInfo requestInfo = new ServerRequestInfo();
                        requestInfo.ServerHost = address;
                        requestInfo.ServerPort = 8009;
                        requestInfo.Command    = (int)ServerRequestCommand.GetNetworkCardList;
                        OperationReturn optReturn = XMLHelper.SeriallizeObject(requestInfo);
                        if (!optReturn.Result)
                        {
                            strMsg += string.Format("Fail.\t{0}\t{1}\t{2};", address, optReturn.Code, optReturn.Message);
                            continue;
                        }
                        webRequest.Data = optReturn.Data.ToString();
                        WebReturn webReturn = client.DoOperation(webRequest);
                        if (!webReturn.Result)
                        {
                            strMsg += string.Format("WSFail.\t{0}\t{1}\t{2};", address, webReturn.Code, webReturn.Message);
                            continue;
                        }
                        if (webReturn.ListData == null)
                        {
                            strMsg += string.Format("ListData is null;");
                            continue;
                        }
                        for (int j = 0; j < webReturn.ListData.Count; j++)
                        {
                            string   info    = webReturn.ListData[j];
                            string[] arrInfo = info.Split(new[] { ConstValue.SPLITER_CHAR }, StringSplitOptions.RemoveEmptyEntries);
                            if (arrInfo.Length < 2)
                            {
                                continue;
                            }
                            NetworkCardInfo card = new NetworkCardInfo();
                            card.ID          = arrInfo[1];
                            card.Name        = string.Format("{0}[{1}]", arrInfo[0], address);
                            card.Description = string.Format("{0}[{1}]({2})", arrInfo[0], address, arrInfo[1]);
                            listCardInfo.Add(card);
                        }
                    }
                    isFail = false;
                }
                catch (Exception ex)
                {
                    isFail = true;
                    strMsg = ex.Message;
                }
            };
            worker.RunWorkerCompleted += (s, re) =>
            {
                worker.Dispose();

                if (MainPage != null)
                {
                    MainPage.SetBusy(false, string.Empty);
                }

                try
                {
                    if (isFail)
                    {
                        ShowException(strMsg);
                        return;
                    }
                    if (!string.IsNullOrEmpty(strMsg))
                    {
                        ShowException(strMsg);
                    }
                    for (int i = 0; i < listCardInfo.Count; i++)
                    {
                        var card = listCardInfo[i];
                        PropertyValueEnumItem item = new PropertyValueEnumItem();
                        item.Value       = card.ID;
                        item.Display     = card.Name;
                        item.Description = card.Description;
                        item.Info        = card;
                        var temp = mListNetworkCardItems.FirstOrDefault(e => e.Value == item.Value);
                        if (temp == null)
                        {
                            mListNetworkCardItems.Add(item);
                        }
                        else
                        {
                            temp.Display     = item.Display;
                            temp.Description = item.Description;
                            temp.Info        = item.Info;
                        }
                    }
                }
                catch (Exception ex)
                {
                    ShowException(ex.Message);
                }
            };
            worker.RunWorkerAsync();
        }
コード例 #2
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);
     }
 }
コード例 #3
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);
     }
 }