public bool SendMsgToService00(string voiceIP, ref string msg)
 {
     try
     {
         WebRequest webRequest = new WebRequest();
         webRequest.Code    = (int)S2400RequestCode.SendMsgToService00;
         webRequest.Session = CurrentApp.Session;
         webRequest.ListData.Add(voiceIP);
         //Service24011Client client = new Service24011Client();
         Service24011Client client    = new Service24011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24011"));
         WebReturn          webReturn = client.DoOperation(webRequest);
         CurrentApp.MonitorHelper.AddWebReturn(webReturn);
         client.Close();
         if (!webReturn.Result)
         {
             msg = webReturn.Message;
             return(false);
         }
         return(true);
     }
     catch (Exception ex)
     {
         msg = ex.Message;
         return(false);
     }
 }
        private void ModifyKeyGenServer(StringValuePairs machineInfo)
        {
            string    strHost      = machineInfo.Value;
            string    strMachineID = machineInfo.Key;
            WebReturn webReturn    = null;
            string    strPort      = TxtPort.Text;

            string strStatusMsg = CurrentApp.GetLanguageInfo("2401022", "Is being revised, please later... .");

            mainPage.ShowStausMessage(strStatusMsg, true);
            mBackgroundWorker         = new BackgroundWorker();
            mBackgroundWorker.DoWork += (s, de) =>
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S2400RequestCode.ModifyKeyGenServer;
                webRequest.Session = CurrentApp.Session;
                webRequest.ListData.Add(strMachineID);
                webRequest.ListData.Add(strHost);
                webRequest.ListData.Add(strPort);
                Service24011Client client = new Service24011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                                   WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24011"));
                webReturn = client.DoOperation(webRequest);
                CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                client.Close();
            };
            mBackgroundWorker.RunWorkerCompleted += (s, de) =>
            {
                mainPage.ShowStausMessage(string.Empty, false);
                if (!webReturn.Result)
                {
                    if (webReturn.Code == (int)S2400WcfErrorCode.KeyGenServerExists)
                    {
                        BtnApply.IsEnabled = true;
                        ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, CurrentApp.GetLanguageInfo(webReturn.Code.ToString(), webReturn.Message)));
                    }
                    else
                    {
                        BtnApply.IsEnabled = true;
                        ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                    }
                    string msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2401004")), strHost);
                    CurrentApp.WriteOperationLog("2401004", ConstValue.OPT_RESULT_FAIL, msg);
                }
                else
                {
                    string msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2401004")), strHost);
                    CurrentApp.WriteOperationLog("2401004", ConstValue.OPT_RESULT_SUCCESS, msg);
                    //添加成功 关闭当前popupPanel 刷新父窗口list
                    BtnApply.IsEnabled         = true;
                    mainPage.PopupPanel.IsOpen = false;
                    //mainPage.InitKeyGenServerList();
                    keyGenServerModifying.HostPort = TxtPort.Text;
                    keyGenServerModifying.Status   = true;
                    mainPage.UpdateKeyGenServerList(keyGenServerModifying, OperationType.Modify);
                    ShowInformation(CurrentApp.GetLanguageInfo("COMN001", "Success"));
                }
            };
            mBackgroundWorker.RunWorkerAsync();
        }
        /// <summary>
        /// 删除策略
        /// </summary>
        /// <param name="strtag">开始时间num|策略编码|服务器IP资源编码</param>
        private void EncrytionObjectStrategyDelete(string strtag)
        {
            try
            {
                string[] strIPAndStartNum = strtag.Split('|');
                string   temppolicname    = "";
                if (strIPAndStartNum.Count() == 3)
                {
                    temppolicname = lstPolicyBindding.Where(p => p.Bindingpolicyid == long.Parse(strIPAndStartNum[1])).First().CusFiled3;
                    WebRequest webRequest = new WebRequest();
                    webRequest.Code    = (int)S2400RequestCode.DeleteBindedStragegy;
                    webRequest.Session = CurrentApp.Session;
                    webRequest.ListData.Add(strIPAndStartNum[0]);
                    webRequest.ListData.Add(strIPAndStartNum[1]);
                    webRequest.ListData.Add(strIPAndStartNum[2]);
                    //Service24011Client client = new Service24011Client();
                    Service24011Client client    = new Service24011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24011"));
                    WebReturn          webReturn = client.DoOperation(webRequest);
                    CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                    client.Close();
                    if (!webReturn.Result)
                    {
                        if (webReturn.Message == S2400Const.Msg_StragegyExit)
                        {
                            ShowInformation(CurrentApp.GetLanguageInfo("240300023", "Strategy Is Used,Can not Delete."));
                        }
                        else
                        {
                            ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                        }
                        return;
                    }
                    else
                    {
                        string strLog = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2403005")), temppolicname);
                        CurrentApp.WriteOperationLog("2403005", ConstValue.OPT_RESULT_SUCCESS, strLog);

                        CVoiceServerBindStrategy podel = lstPolicyBindding.Where(p => p.Durationbegin.ToString() == strIPAndStartNum[0] &&
                                                                                 p.Bindingpolicyid.ToString() == strIPAndStartNum[1]).FirstOrDefault();
                        lstPolicyBindding.Remove(podel);
                        if (podel != null)
                        {
                            BindStrategyContextMenu();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CurrentApp.WriteOperationLog("2403005", ConstValue.OPT_RESULT_FAIL, "");
                ShowException(ex.Message);
            }
        }
Exemple #4
0
        private void ModyfyData224002(CVoiceServerBindStrategy cvsbs, string strStart, string strEnd)
        {
            if (cvsbs == null)
            {
                return;
            }
            //修改需要传入的值

            string strSetuser    = CurrentApp.Session.UserID.ToString();
            string strSettime    = DateTime.UtcNow.ToString("yyyyMMddHHmmss");
            string strSetaccount = CurrentApp.Session.UserInfo.Account;

            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Code = (int)S2400RequestCode.ModyfyData224002;
                OperationReturn optReturn = XMLHelper.SeriallizeObject(cvsbs);
                if (!optReturn.Result)
                {
                    ShowException(string.Format("{0}\t{1}", "Field.", optReturn.Message));
                    return;
                }
                webRequest.Data = optReturn.Data.ToString();
                webRequest.ListData.Add(strStart);
                webRequest.ListData.Add(strEnd);
                webRequest.ListData.Add(strSetuser);
                webRequest.ListData.Add(strSettime);
                webRequest.ListData.Add(strSetaccount);
                webRequest.Session = CurrentApp.Session;
                //Service24011Client client = new Service24011Client();
                Service24011Client client    = new Service24011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24011"));
                WebReturn          webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    CurrentApp.WriteOperationLog("2403006", ConstValue.OPT_RESULT_FAIL, "");
                    ShowException(string.Format("{0}\t{1}", "Field.", webReturn.Message));
                }
                else
                {
                    string tempstrend = Convert.ToDateTime(strEnd.Insert(4, "-").Insert(7, "-").Insert(10, " ").Insert(13, ":").Insert(16, ":")).ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
                    string strLog     = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2403006")),
                                                      cvsbs.CusFiled3 + "," + cvsbs.DurationendStr + "->" + tempstrend);
                    CurrentApp.WriteOperationLog("2403006", ConstValue.OPT_RESULT_SUCCESS, strLog);
                }
            }
            catch (Exception ex)
            {
                CurrentApp.WriteOperationLog("2403006", ConstValue.OPT_RESULT_FAIL, "");
                ShowException(ex.Message);
            }
        }
        /// <summary>
        /// 获取录音服务器
        /// </summary>
        private void InitListResourceInfo()
        {
            mListResourcesInfo.Clear();
            WebRequest webRequest = new WebRequest();

            webRequest.Session = CurrentApp.Session;
            webRequest.Code    = (int)S2400RequestCode.GetVoiceIP_Name201;
            Service24011Client client = new Service24011Client(
                WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                WebHelper.CreateEndpointAddress(
                    CurrentApp.Session.AppServerInfo,
                    "Service24011"));

            //Service24011Client client = new Service24011Client();
            WebHelper.SetServiceClient(client);
            WebReturn webReturn = client.DoOperation(webRequest);

            client.Close();
            if (!webReturn.Result)
            {
                ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                return;
            }
            if (webReturn.ListData == null)
            {
                ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                return;
            }
            OperationReturn optReturn;

            for (int i = 0; i < webReturn.ListData.Count; i++)
            {
                optReturn = XMLHelper.DeserializeObject <ResourceInfo>(webReturn.ListData[i]);
                if (!optReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                    return;
                }
                ResourceInfo info = optReturn.Data as ResourceInfo;
                if (info == null)
                {
                    ShowException(string.Format("ResourcePropertyInfo is null"));
                    return;
                }
                //info.Description = info.ToString();
                mListResourcesInfo.Add(info);
            }
            CurrentApp.WriteLog("PageLoad", string.Format("Init ResourceInfo"));
        }
        private void InitMachines()
        {
            WebRequest webRequest = new WebRequest();

            webRequest.Code    = (int)S2400RequestCode.GetAllMachines;
            webRequest.Session = CurrentApp.Session;
            webRequest.ListData.Add(CurrentApp.Session.UserInfo.UserID.ToString());
            webRequest.ListData.Add(CurrentApp.Session.UserID.ToString());
            Service24011Client client = new Service24011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                               WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24011"));
            WebReturn webReturn = client.DoOperation(webRequest);

            CurrentApp.MonitorHelper.AddWebReturn(webReturn);
            client.Close();
            if (!webReturn.Result)
            {
                ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                return;
            }
            StringValuePairs obj = null;
            OperationReturn  optReturn;
            ComboBoxItem     item = null;

            for (int i = 0; i < webReturn.ListData.Count; i++)
            {
                optReturn = XMLHelper.DeserializeObject <StringValuePairs>(webReturn.ListData[i]);
                if (!optReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                    return;
                }
                obj              = optReturn.Data as StringValuePairs;
                obj.Value        = S2400EncryptOperation.DecryptWithM004(S2400EncryptOperation.DecodeEncryptValue(obj.Value));
                item             = new ComboBoxItem();
                item.Content     = obj.Value;
                item.DataContext = obj;
                cmbServers.Items.Add(item);
            }
            if (cmbServers.Items.Count > 0)
            {
                cmbServers.SelectedIndex = 0;
            }
        }
        public static bool TryConnectToGeneratorServer(string AStrServerName, string AStrServerPort, ref string AStrReturn)
        {
            WebRequest webRequest = new WebRequest();

            webRequest.Code    = (int)S2400RequestCode.TryConnToKeyGenServer;
            webRequest.Session = App.CurrentApp.Session;
            webRequest.ListData.Add(AStrServerName);
            webRequest.ListData.Add(AStrServerPort);
            Service24011Client client = new Service24011Client(WebHelper.CreateBasicHttpBinding(App.CurrentApp.Session),
                                                               WebHelper.CreateEndpointAddress(App.CurrentApp.Session.AppServerInfo, "Service24011"));
            WebReturn webReturn = client.DoOperation(webRequest);

            App.CurrentApp.MonitorHelper.AddWebReturn(webReturn);
            client.Close();
            if (!webReturn.Result)
            {
                AStrReturn = string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message);
                return(false);
            }
            return(true);
        }
Exemple #8
0
        private void SaveData224002(CVoiceServerBindStrategy cvsbs)
        {
            if (cvsbs == null)
            {
                return;
            }
            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Code = (int)S2400RequestCode.SaveData224002;
                OperationReturn optReturn = XMLHelper.SeriallizeObject(cvsbs);
                if (!optReturn.Result)
                {
                    ShowException(string.Format("{0}\t{1}", "Field.", optReturn.Message));
                    return;
                }
                webRequest.Data    = optReturn.Data.ToString();
                webRequest.Session = CurrentApp.Session;
                //Service24011Client client = new Service24011Client();
                Service24011Client client    = new Service24011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24011"));
                WebReturn          webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowException(string.Format("{0}\t{1}", "Field.", webReturn.Message));
                    return;
                }

                string strLog = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2403003")), cvsbs.CusFiled3);
                CurrentApp.WriteOperationLog("2403003", ConstValue.OPT_RESULT_SUCCESS, strLog);
            }
            catch (Exception ex)
            {
                string strLog = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2403003")), cvsbs.CusFiled3 + "," + ex.Message);
                CurrentApp.WriteOperationLog("2403003", ConstValue.OPT_RESULT_FAIL, strLog);
                ShowException(ex.Message);
            }
        }
        private void AddKeyGenServer(StringValuePairs machineInfo)
        {
            string    strHost      = machineInfo.Value;
            string    strMachineID = machineInfo.Key;
            WebReturn webReturn    = null;
            string    strPort      = TxtPort.Text;

            mBackgroundWorker         = new BackgroundWorker();
            mBackgroundWorker.DoWork += (s, de) =>
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S2400RequestCode.AddKeyGenServer;
                webRequest.Session = CurrentApp.Session;
                webRequest.ListData.Add(CurrentApp.Session.UserInfo.UserID.ToString());
                webRequest.ListData.Add(strMachineID);
                webRequest.ListData.Add(strHost);
                webRequest.ListData.Add(strPort);
                webRequest.ListData.Add("0");
                Service24011Client client = new Service24011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                                   WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24011"));
                webReturn = client.DoOperation(webRequest);
                CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                client.Close();
            };
            mBackgroundWorker.RunWorkerCompleted += (s, de) =>
            {
                if (!webReturn.Result)
                {
                    if (webReturn.Code == (int)S2400WcfErrorCode.KeyGenServerExists)
                    {
                        BtnApply.IsEnabled = true;
                        ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, CurrentApp.GetLanguageInfo(webReturn.Code.ToString(), webReturn.Message)));
                    }
                    else
                    {
                        BtnApply.IsEnabled = true;
                        ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                    }
                    string msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2401003")), strHost);
                    CurrentApp.WriteOperationLog("2401003", ConstValue.OPT_RESULT_FAIL, msg);
                }
                else
                {
                    string msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2401003")), strHost);
                    CurrentApp.WriteOperationLog("2401003", ConstValue.OPT_RESULT_SUCCESS, msg);
                    //添加成功 关闭当前popupPanel 刷新父窗口list
                    BtnApply.IsEnabled         = true;
                    mainPage.PopupPanel.IsOpen = false;
                    //mainPage.InitKeyGenServerList();
                    KeyGenServerEntryInList server = new KeyGenServerEntryInList();
                    server.HostAddress = strHost;
                    server.ResourceID  = strMachineID;
                    server.HostPort    = TxtPort.Text;
                    server.IsEnable    = "0";
                    server.EnableIcon  = "Images/00001.ico";
                    server.Status      = true;
                    mainPage.UpdateKeyGenServerList(server, OperationType.Add);
                    ShowInformation(CurrentApp.GetLanguageInfo("COMN001", "Success"));
                    mainPage.lvGeneratorObject.SelectedIndex = 0;
                }
            };
            mBackgroundWorker.RunWorkerAsync();
        }
        /// <summary>
        /// 设置或者取消加密绑定
        /// </summary>
        /// <param name="serverip">IP资源ID|IP地址</param>
        /// <param name="enable">1:设置  0:取消</param>
        private void PolicyBinddingEnableOrDisenable(string serverip, string enable)
        {
            string messageBoxText = "";

            if (enable == "1")
            {
                messageBoxText = CurrentApp.GetLanguageInfo("240300024", "Confirm set encryption binding.");
            }
            else
            {
                messageBoxText = CurrentApp.GetLanguageInfo("240300025", "Confirm cancel the encryption binding.");
            }
            MessageBoxButton button = MessageBoxButton.OKCancel;
            MessageBoxImage  icon   = MessageBoxImage.Warning;
            //显示消息框
            MessageBoxResult result = MessageBox.Show(messageBoxText, "2400", button, icon);

            //处理消息框信息
            switch (result)
            {
            case MessageBoxResult.Cancel:
                return;

                break;
            }

            try
            {
                WebReturn webReturn = null;
                string [] arrip     = serverip.Split('|');
                if (arrip.Count() != 2)
                {
                    return;
                }
                string     ipsource   = arrip[0];
                string     ip         = arrip[1];
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S2400RequestCode.SetPolicyBindding;
                webRequest.Session = CurrentApp.Session;
                webRequest.ListData.Add(ipsource);
                webRequest.ListData.Add(enable);
                webRequest.ListData.Add(ip);
                //Service24011Client client = new Service24011Client();
                Service24011Client client = new Service24011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24011"));
                webReturn = client.DoOperation(webRequest);
                CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                client.Close();

                if (enable == "1")
                {
                    GetPoliciesByVoiceIPSource(ipsource);
                }
                else
                {
                    ContextMenuService.SetContextMenu(LvStrategies, null);
                    lstPolicyBindding.Clear();
                    LvStrategies.Items.Clear();
                }
                GetCanOperationVoiceServer();//设置后刷新
                string vsIP = LLstVoiceServer.Where(p => p.IPResourceID == ipsource).FirstOrDefault().VoiceServer;
                string msg  = "";
                if (!SendMsgToService00(vsIP, ref msg))
                {
                    if (enable == "1")
                    {
                        CurrentApp.WriteOperationLog("2403001", ConstValue.OPT_RESULT_FAIL, "");
                    }
                    else
                    {
                        CurrentApp.WriteOperationLog("2403002", ConstValue.OPT_RESULT_FAIL, "");
                    }
                    ShowException(string.Format("{0}\t{1}", CurrentApp.GetLanguageInfo("240300022", "Message sent failure."), msg));
                }
                else
                {
                    if (enable == "1")
                    {
                        string strLog = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2403001")), ip);
                        CurrentApp.WriteOperationLog("2403001", ConstValue.OPT_RESULT_SUCCESS, strLog);
                    }
                    else
                    {
                        string strLog = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2403002")), ip);
                        CurrentApp.WriteOperationLog("2403002", ConstValue.OPT_RESULT_SUCCESS, strLog);
                    }
                }
            }
            catch (Exception ex)
            {
                parentWin.ShowStausMessage(string.Empty, false);
                ShowException(ex.Message);
            }
        }
        /// <summary>
        /// 能管理的录音服务器
        /// </summary>
        private void GetCanOperationVoiceServer()
        {
            try
            {
                if (mListResourcesInfo == null)
                {
                    return;
                }
                WebRequest webRequest = new WebRequest();
                webRequest.Session = CurrentApp.Session;
                webRequest.Code    = (int)S2400RequestCode.GetResourceObjList;
                webRequest.ListData.Add(CurrentApp.Session.UserID.ToString());
                webRequest.ListData.Add("221");
                //webRequest.ListData.Add("1");

                //Service24011Client client = new Service24011Client();
                Service24011Client client = new Service24011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24011"));
                WebHelper.SetServiceClient(client);
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                    return;
                }
                if (webReturn.ListData == null)
                {
                    ShowException(string.Format("Fail.\tListData is null"));
                    return;
                }

                LvVoiceServer.Items.Clear();
                for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    ListViewItem AddEncryptionObjectItem = new ListViewItem();
                    ContextMenu  LocalContextMenu        = new ContextMenu();
                    string[]     strInfo = webReturn.ListData[i].Split('|');
                    if (strInfo.Count() == 2)
                    {
                        ResourceInfo ri = mListResourcesInfo.Where(p => p.ResourceID.ToString() == strInfo[0]).FirstOrDefault();
                        if (ri != null)
                        {
                            CVoiceServer cvs = new CVoiceServer();
                            cvs.VoiceServer         = ri.ResourceName;
                            cvs.NumEanbleEncryption = strInfo[1];
                            cvs.IPResourceID        = ri.ResourceID.ToString();
                            cvs.EanbleEncryption    = strInfo[1] == "1" ? CurrentApp.GetLanguageInfo("240300003", "YES") : CurrentApp.GetLanguageInfo("240300004", "NO");
                            LLstVoiceServer.Add(cvs);

                            if (strInfo[1] == "1" && HasPermission(S2400Const.Opt_PolicyBinddingDisable))//已经设置加密绑定
                            {
                                MenuItem LocalMenuItem = new MenuItem();
                                SetMenuItem(ref LocalMenuItem, CurrentApp.GetLanguageInfo("FO2403002", "Deny Encryption Bind"), S2400Const.Opt_PolicyBinddingDisable.ToString(), strInfo[0] + "|" + cvs.VoiceServer);
                                LocalContextMenu.Items.Add(LocalMenuItem);
                            }
                            else if (strInfo[1] == "0" && HasPermission(S2400Const.OPT_PolicyBinddingEnable))
                            {
                                MenuItem LocalMenuItem = new MenuItem();
                                SetMenuItem(ref LocalMenuItem, CurrentApp.GetLanguageInfo("FO2403001", "Grant Encryption Bind"), S2400Const.OPT_PolicyBinddingEnable.ToString(), strInfo[0] + "|" + cvs.VoiceServer);
                                LocalContextMenu.Items.Add(LocalMenuItem);
                            }
                            AddEncryptionObjectItem.Content = cvs;
                            if (LocalContextMenu.Items.Count > 0)
                            {
                                ContextMenuService.SetContextMenu(AddEncryptionObjectItem, LocalContextMenu);
                            }
                            LvVoiceServer.Items.Add(AddEncryptionObjectItem);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
Exemple #12
0
        private void GetCurrentKeyGenServer()
        {
            Service24011Client client = null;

            try
            {
                WebReturn  webReturn  = null;
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S2400RequestCode.GetCurrentKeyGenServer;
                webRequest.Session = CurrentApp.Session;
                client             = new Service24011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                            WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24011"));
                webReturn = client.DoOperation(webRequest);
                CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                if (!webReturn.Result)
                {
                    ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, CurrentApp.GetLanguageInfo(webReturn.Code.ToString(), webReturn.Message)));
                    return;
                }
                if (webReturn.Result && string.IsNullOrEmpty(webReturn.Data))
                {
                    HasKeyGenServer = false;
                    return;
                }
                OperationReturn optReturn = XMLHelper.DeserializeObject <KeyGenServerEntry>(webReturn.Data.ToString());
                if (!optReturn.Result)
                {
                    HasKeyGenServer = false;
                    return;
                }
                KeyGenServerEntry keyGenServer = optReturn.Data as KeyGenServerEntry;
                //尝试连接服务 如果能连接成功 就显示可用的服务
                webRequest         = new WebRequest();
                webRequest.Code    = (int)S2400RequestCode.TryConnToKeyGenServer;
                webRequest.Session = CurrentApp.Session;
                webRequest.ListData.Add(keyGenServer.HostAddress);
                webRequest.ListData.Add(keyGenServer.HostPort);
                client = new Service24011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24011"));
                webReturn = client.DoOperation(webRequest);
                CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                if (!webReturn.Result)
                {
                    HasKeyGenServer = false;
                    return;
                }

                HasKeyGenServer = true;
                keyGenEntry     = keyGenServer;
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == System.ServiceModel.CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
            }
        }