/// <summary>
        /// 修改策略
        /// </summary>
        /// <param name="strtag">开始时间num|策略编码|服务器IP资源编码</param>
        private void EncrytionObjectStrategyModify(string strtag)
        {
            string[] strIPAndStartNum = strtag.Split('|');
            if (strIPAndStartNum.Count() == 3)
            {
                PolicyInfoInList selPolicy = new PolicyInfoInList();
                GetCurrentPolicy(ref selPolicy, strIPAndStartNum);
                mcurrentPoBind = lstPolicyBindding.Where(p => p.Durationbegin.ToString() == strIPAndStartNum[0] &&
                                                         p.Bindingpolicyid.ToString() == strIPAndStartNum[1] &&
                                                         p.CusFiled1 == strIPAndStartNum[2]).FirstOrDefault();

                if (selPolicy.PolicyID != null && mcurrentPoBind.Bindingpolicyid != null)
                {
                    //if (mcurrentPoBind != null && mcurrentPoBind.Durationend > Convert.ToInt64(DateTime.UtcNow.ToString("yyyyMMddHHmmss")))
                    //{
                    AppendOrInsertBindStrategy02 abs2 = new AppendOrInsertBindStrategy02();
                    abs2.CurrentApp     = CurrentApp;
                    abs2.mFirstPage     = this;
                    abs2.selPolicyInfo  = selPolicy;
                    abs2.lstAllPolicies = lstAllPolicies;
                    abs2.mOpType        = "2";
                    PopupPanel.Content  = abs2;
                    PopupPanel.Title    = CurrentApp.GetLanguageInfo("FO2403006", "Modify Binding Time");
                    PopupPanel.IsOpen   = true;
                    //}
                    //else
                    //    ShowInformation(CurrentApp.GetLanguageInfo("240300021", "Cannot be modified"));
                }
            }
        }
Exemplo n.º 2
0
        void BasicOpt_Click(object sender, RoutedEventArgs e)
        {
            var btn = e.Source as Button;

            if (btn != null)
            {
                var optItem = btn.DataContext as OperationInfo;
                if (optItem == null)
                {
                    return;
                }
                UC_AddPolicy uc_AddPolicy = null;
                switch (optItem.ID)
                {
                case S2400Const.OPT_EncryptionPolicyAdd:
                    uc_AddPolicy            = new UC_AddPolicy();
                    uc_AddPolicy.CurrentApp = CurrentApp;
                    uc_AddPolicy.ChangeLanguage();
                    uc_AddPolicy.iAddOrModify = (int)OperationType.Add;
                    uc_AddPolicy.mainPage     = this;
                    PopupPanel.Content        = uc_AddPolicy;
                    PopupPanel.Title          = CurrentApp.GetLanguageInfo("2402T001", "Add encryption policy");
                    PopupPanel.IsOpen         = true;
                    break;

                case S2400Const.OPT_EncryptionPolicyModify:
                    uc_AddPolicy            = new UC_AddPolicy();
                    uc_AddPolicy.CurrentApp = CurrentApp;
                    //根据listview的选中项 获得策略实体类
                    UMPEncryptionPolicy policy = null;
                    if (lvEncryptionPolicyObject.SelectedItem == null)
                    {
                        return;
                    }
                    PolicyInfoInList policyInList = lvEncryptionPolicyObject.SelectedItem as PolicyInfoInList;
                    bool             bo           = GetSelectedPolicyInfo(ref policy);
                    if (!bo)
                    {
                        return;
                    }
                    uc_AddPolicy.policyModifying = policy;
                    uc_AddPolicy.ChangeLanguage();
                    uc_AddPolicy.iAddOrModify          = (int)OperationType.Modify;
                    uc_AddPolicy.mainPage              = this;
                    uc_AddPolicy.PolicyModifyingInList = policyInList;
                    PopupPanel.Content = uc_AddPolicy;
                    PopupPanel.Title   = CurrentApp.GetLanguageInfo("2402T002", "Update encryption policy " + policy.PolicyName);
                    PopupPanel.IsOpen  = true;
                    break;

                case S2400Const.Opt_EncryptionPolicyDisable:
                    EnableDisablePolicy("2");
                    break;

                case S2400Const.OPT_EncryptionPolicyEnable:
                    EnableDisablePolicy("1");
                    break;
                }
            }
        }
 /// <summary>
 /// 追加策略
 /// </summary>
 /// <param name="strtag">开始时间num|策略编码|服务器IP资源编码</param>
 private void EncrytionObjectAppendStrategy(string strtag)
 {
     string[] strIPAndStartNum = strtag.Split('|');
     if (strIPAndStartNum.Count() == 3)
     {
         PolicyInfoInList selPolicy = new PolicyInfoInList();
         GetCurrentPolicy(ref selPolicy, strIPAndStartNum);
         mcurrentPoBind = lstPolicyBindding.Where(p => p.Durationbegin.ToString() == strIPAndStartNum[0] &&
                                                  p.Bindingpolicyid.ToString() == strIPAndStartNum[1] &&
                                                  p.CusFiled1 == strIPAndStartNum[2]).FirstOrDefault();
         AppendOrInsertBindStrategy abs = new AppendOrInsertBindStrategy();
         abs.CurrentApp     = CurrentApp;
         abs.mOperationType = "1";
         abs.mParentpage    = this;
         PopupPanel.Content = abs;
         PopupPanel.Title   = CurrentApp.GetLanguageInfo("240300008", "Binding Key Strategy") + "";
         PopupPanel.IsOpen  = true;
     }
     else if (strIPAndStartNum.Count() == 1)
     {
         AppendOrInsertBindStrategy abs = new AppendOrInsertBindStrategy();
         abs.CurrentApp     = CurrentApp;
         abs.mOperationType = "1";
         abs.mParentpage    = this;
         PopupPanel.Content = abs;
         PopupPanel.Title   = CurrentApp.GetLanguageInfo("240300008", "Binding Key Strategy") + "";
         PopupPanel.IsOpen  = true;
     }
 }
        private void BtnApply_Click(object sender, RoutedEventArgs e)
        {
            PolicyInfoInList item = LvAllStrategies.SelectedItem as PolicyInfoInList;

            if (item != null)
            {
                SelectAnd2SetTimeSpan(item);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获得listview选中项的策略信息
        /// </summary>
        /// <returns></returns>
        private bool GetSelectedPolicyInfo(ref UMPEncryptionPolicy policy)
        {
            PolicyInfoInList   policyInList = lvEncryptionPolicyObject.SelectedItem as PolicyInfoInList;
            Service24021Client client       = null;

            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S2400RequestCode.GetPolicyByID;
                webRequest.Session = CurrentApp.Session;
                webRequest.ListData.Add(policyInList.PolicyID);
                client = new Service24021Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24021"));
                WebReturn 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(false);
                }
                OperationReturn optReturn = XMLHelper.DeserializeObject <UMPEncryptionPolicy>(webReturn.Data);
                if (!optReturn.Result)
                {
                    ShowException(string.Format("WSFail.\t{0}\t{1}", optReturn.Code, CurrentApp.GetLanguageInfo(optReturn.Code.ToString(), optReturn.Message)));
                    return(false);
                }
                policy = optReturn.Data as UMPEncryptionPolicy;
                return(true);
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == System.ServiceModel.CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
            }
            return(true);
        }
 /// <summary>
 /// 选中策略,进入设置时间
 /// </summary>
 private void SelectAnd2SetTimeSpan(PolicyInfoInList item)
 {
     try
     {
         AppendOrInsertBindStrategy02 abs2 = new AppendOrInsertBindStrategy02();
         abs2.CurrentApp     = CurrentApp;
         abs2.mParentpage    = this;
         abs2.mFirstPage     = mParentpage;
         abs2.selPolicyInfo  = item;
         abs2.lstAllPolicies = lstAllPolicies;
         abs2.mOpType        = "1";
         PopupPanel.Content  = abs2;
         PopupPanel.Title    = CurrentApp.GetLanguageInfo("240300008", "Binding Key Strategy");
         PopupPanel.IsOpen   = true;
     }
     catch (Exception ex)
     { }
 }
        private void GetCurrentPolicy(ref PolicyInfoInList selPolicy, string[] strIPAndStartNum)
        {
            Service24021Client client = null;

            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S2400RequestCode.GetAllPolicies;
                webRequest.Session = CurrentApp.Session;
                webRequest.ListData.Add(CurrentApp.Session.UserInfo.UserID.ToString());
                client = new Service24021Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24021"));
                WebReturn 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.DataSetData.Tables.Count <= 0)
                {
                    return;
                }
                DataTable        dt         = webReturn.DataSetData.Tables[0];
                PolicyInfoInList policyItem = null;
                foreach (DataRow row in dt.Rows)
                {
                    policyItem            = new PolicyInfoInList();
                    policyItem.PolicyID   = row["C001"].ToString();
                    policyItem.PolicyName = row["C002"].ToString();
                    //= row["004"].ToString();
                    string strType = row["C004"].ToString();
                    policyItem.PolicyType = strType == "U" ? CurrentApp.GetLanguageInfo("240300027", "Custom (user input)") : CurrentApp.GetLanguageInfo("240300028", "Periodic update key (randomly generated)");
                    if (strType == "C")
                    {
                        string strOccursFrequency = row["C007"].ToString();
                        switch (strOccursFrequency)
                        {
                        case "D":
                            policyItem.PolicyOccursFrequency = CurrentApp.GetLanguageInfo("240300029", "Day");
                            break;

                        case "W":
                            policyItem.PolicyOccursFrequency = CurrentApp.GetLanguageInfo("240300030", "Week");
                            break;

                        case "M":
                            policyItem.PolicyOccursFrequency = CurrentApp.GetLanguageInfo("240300031", "Month");
                            break;

                        case "U":
                            policyItem.PolicyOccursFrequency = row["C010"].ToString() + CurrentApp.GetLanguageInfo("240300029", "Day");
                            break;
                        }
                    }
                    else
                    {
                        policyItem.PolicyOccursFrequency = string.Empty;
                    }
                    policyItem.PolicyStartTime = CommonFunctions.StringToDateTime(row["C008"].ToString()).ToString();
                    long longTime = 0;
                    long.TryParse(row["C008"].ToString(), out longTime);
                    policyItem.PolicyStartTimeNumber = longTime;
                    if (row["C009"].ToString() != "20991231235959")
                    {
                        policyItem.PolicyEndTime = CommonFunctions.StringToDateTime(row["C009"].ToString()).ToString();
                    }
                    else
                    {
                        policyItem.PolicyEndTime = CurrentApp.GetLanguageInfo("240300032", "Never expires");
                    }
                    long.TryParse(row["C009"].ToString(), out longTime);
                    policyItem.PolicyEndTimeNumber = longTime;
                    policyItem.PolicyIsEnabled     = row["C003"].ToString();
                    if (strType == "C")
                    {
                        policyItem.IsStrongPwd = row["C012"].ToString() == "1" ? CurrentApp.GetLanguageInfo("240300003", "Yes") : string.Empty;
                    }
                    else
                    {
                        policyItem.IsStrongPwd = string.Empty;
                    }
                    long lNow = 0;
                    CommonFunctions.DateTimeToNumber(DateTime.Now, ref lNow);
                    if (policyItem.PolicyID == strIPAndStartNum[1])
                    {
                        selPolicy = policyItem;
                    }
                }
            }
            catch (Exception ex)
            {
                ShowException("Failed." + ex.Message);
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == System.ServiceModel.CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 在添加、删除、修改策略后 刷新界面
        /// </summary>
        public void UpdatePolicyList(PolicyInfoInList policy, OperationType optType)
        {
            long lNow = 0;

            GetAppServerCurrentTime();
            bool bo = CommonFunctions.DateTimeToNumber(S2400App.GolbalCurrentEncryptionDBTime, ref lNow);

            switch (optType)
            {
            case OperationType.Add:
                lstAllPolicies.Add(policy);
                if (policy.PolicyStartTimeNumber <= lNow)
                {
                    lstUsing.Add(policy);
                    CmbPolicyType.SelectedIndex = 0;
                }
                else
                {
                    lstWillBeUse.Add(policy);
                    CmbPolicyType.SelectedIndex = 1;
                }
                break;

            case OperationType.Modify:
                for (int i = 0; i < lstAllPolicies.Count; i++)
                {
                    PolicyInfoInList po = lstAllPolicies[i];
                    if (po.PolicyID == policy.PolicyID)
                    {
                        lstAllPolicies[i] = policy;
                    }
                }
                break;

            case OperationType.Delete:
                lstAllPolicies.Remove(policy);
                break;

            case OperationType.Enable:
                lstDisabled.Remove(policy);
                if (policy.PolicyStartTimeNumber >= lNow)
                {
                    lstWillBeUse.Add(policy);
                    CmbPolicyType.SelectedIndex = 1;
                }
                else if (policy.PolicyStartTimeNumber < lNow && policy.PolicyEndTimeNumber >= lNow)
                {
                    lstUsing.Add(policy);
                    CmbPolicyType.SelectedIndex = 0;
                }
                else if (policy.PolicyEndTimeNumber < lNow)
                {
                    lstExpried.Add(policy);
                    CmbPolicyType.SelectedIndex = 2;
                }
                break;

            case OperationType.Disable:
                if (policy.PolicyStartTimeNumber >= lNow)
                {
                    lstWillBeUse.Remove(policy);
                }
                else if (policy.PolicyStartTimeNumber < lNow && policy.PolicyEndTimeNumber >= lNow)
                {
                    lstUsing.Remove(policy);
                }
                else if (policy.PolicyEndTimeNumber < lNow)
                {
                    lstExpried.Remove(policy);
                }
                lstDisabled.Add(policy);
                CmbPolicyType.SelectedIndex = 3;
                break;
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 启用或禁用策略
        /// </summary>
        /// <param name="strOptType">1 : 启用   2:禁用</param>
        private void EnableDisablePolicy(string strOptType)
        {
            if (lvEncryptionPolicyObject.SelectedItem == null)
            {
                return;
            }
            PolicyInfoInList   policyInList = lvEncryptionPolicyObject.SelectedItem as PolicyInfoInList;
            Service24021Client client       = null;

            try
            {
                WebRequest webRequest = new WebRequest();
                switch (strOptType)
                {
                case "1":
                    if (policyInList.PolicyIsEnabled == "1")
                    {
                        return;
                    }
                    webRequest.Code = (int)S2400RequestCode.EnablePolicy;
                    break;

                case "2":
                    if (policyInList.PolicyIsEnabled == "2")
                    {
                        return;
                    }
                    webRequest.Code = (int)S2400RequestCode.DisablePolicy;
                    break;
                }

                webRequest.Session = CurrentApp.Session;
                webRequest.ListData.Add(policyInList.PolicyID);
                client = new Service24021Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24021"));
                WebReturn 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;
                }

                //写日志
                string strLog = string.Empty;
                if (strOptType == "1")
                {
                    strLog = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2402001")), policyInList.PolicyID);
                    CurrentApp.WriteOperationLog("2402001", ConstValue.OPT_RESULT_SUCCESS, strLog);
                }
                else if (strOptType == "2")
                {
                    strLog = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2402002")), policyInList.PolicyID);
                    CurrentApp.WriteOperationLog("2402002", ConstValue.OPT_RESULT_SUCCESS, strLog);
                }

                policyInList.PolicyIsEnabled = strOptType;
                if (strOptType == "1")
                {
                    UpdatePolicyList(policyInList, OperationType.Enable);
                }
                else
                {
                    UpdatePolicyList(policyInList, OperationType.Disable);
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
                string strLog = string.Empty;
                if (strOptType == "1")
                {
                    strLog = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2402001")), policyInList.PolicyID);
                    CurrentApp.WriteOperationLog("2402001", ConstValue.OPT_RESULT_FAIL, strLog);
                }
                else if (strOptType == "2")
                {
                    strLog = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2402002")), policyInList.PolicyID);
                    CurrentApp.WriteOperationLog("2402002", ConstValue.OPT_RESULT_FAIL, strLog);
                }
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == System.ServiceModel.CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
            }
        }