/// <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")); } } }
/// <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; } }
/// <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); } }
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); } }
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 AppendOrInsertBindStrategy_Loaded(object sender, RoutedEventArgs e) { BindContent(); StartDate.SelectedDateChanged += new EventHandler <SelectionChangedEventArgs>(ButtonControl_SelectedDateChanged); EndDate.SelectedDateChanged += new EventHandler <SelectionChangedEventArgs>(ButtonControl_SelectedDateChanged); LvPropertyAndValues.ItemsSource = lstPropertyAndValues; lstPropertyAndValues.Clear(); if (selPolicyInfo != null) { string[] lans = "PolicyName,PolicyType,PolicyOccursFrequency,PolicyStartTime,PolicyEndTime,IsStrongPwd".Split(','); string[] vals = (GetStrValue(selPolicyInfo.PolicyName) + "|" + GetStrValue(selPolicyInfo.PolicyType) + "|" + GetStrValue(selPolicyInfo.PolicyOccursFrequency) + "|" + GetStrValue(selPolicyInfo.PolicyStartTime) + "|" + GetStrValue(selPolicyInfo.PolicyEndTime) + "|" + GetStrValue(selPolicyInfo.IsStrongPwd) ).Split('|'); for (int i = 0; i < 6; i++) { try { CPropertyAndValues cav = new CPropertyAndValues(); cav.AppendProperty = CurrentApp.GetLanguageInfo(lans[i], lans[i].Substring(10)); cav.AppendValues = vals[i]; lstPropertyAndValues.Add(cav); } catch (Exception ex) { ShowException(ex.Message); } } TextStartDateTime.Text = DateTime.Parse(selPolicyInfo.PolicyStartTime).ToString("yyyy-MM-dd HH:mm:ss"); TextEndDateTime.Text = DateTime.Parse(selPolicyInfo.PolicyEndTime).ToString("yyyy-MM-dd HH:mm:ss"); if (selPolicyInfo.PolicyEndTimeNumber > 20990000000000) { RadioNoEndDate.IsChecked = true; TextEndDateTime.IsEnabled = false; } else { RadioEndDate.IsChecked = true; } } if (mOpType == "1") { #region 1:追加策略 RadioBeginDate.IsChecked = true; RadioBeginImmediately.IsChecked = false; if (mFirstPage.lstPolicyBindding.Count > 0)//之前绑定过策略 { if (mFirstPage.mcurrentPoBind.Durationend > 20990000000000) { TextStartDateTime.Text = "2099-12-31 23:59:59"; } else { TextStartDateTime.Text = DateTime.Parse(mFirstPage.mcurrentPoBind.DurationendStr).AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss"); } } else { if (selPolicyInfo.PolicyEndTimeNumber == 20991231235959) { RadioNoEndDate.IsChecked = true; TextEndDateTime.IsEnabled = false; TextEndDateTime.Text = (DateTime.Parse(selPolicyInfo.PolicyStartTime).AddDays(1)).ToString("yyyy-MM-dd") + " 23:59:59"; } else { RadioEndDate.IsChecked = true; TextEndDateTime.Text = (DateTime.Parse(selPolicyInfo.PolicyEndTime)).ToString("yyyy-MM-dd") + " 23:59:59"; } } #endregion } else if (mOpType == "2") { #region 2:修改策略时间 CVoiceServerBindStrategy selBinded = mFirstPage.mcurrentPoBind; RadioBeginDate.IsChecked = true; RadioBeginImmediately.IsEnabled = false; if (selBinded == null) { TextStartDateTime.Text = (DateTime.Parse(selPolicyInfo.PolicyStartTime)).AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00"; if (selPolicyInfo.PolicyEndTimeNumber > 20990000000000) { RadioNoEndDate.IsChecked = true; TextEndDateTime.IsEnabled = false; TextEndDateTime.Text = (DateTime.Parse(selPolicyInfo.PolicyStartTime).AddDays(1)).ToString("yyyy-MM-dd") + " 23:59:59"; } else { RadioEndDate.IsChecked = true; TextEndDateTime.Text = (DateTime.Parse(selPolicyInfo.PolicyEndTime)).ToString("yyyy-MM-dd") + " 23:59:59"; } } else { long selStart = selBinded.Durationbegin; long selEnd = selBinded.Durationend; long curNow = Convert.ToInt64(DateTime.UtcNow.ToString("yyyyMMddHHmmss")); TextStartDateTime.Text = Convert.ToDateTime(selBinded.DurationbeginStr).ToString("yyyy-MM-dd HH:mm:ss"); if (selEnd > 20990000000000)//结束时间无限制 { RadioNoEndDate.IsChecked = true; TextEndDateTime.IsEnabled = false; TextEndDateTime.Text = (DateTime.Parse(selPolicyInfo.PolicyStartTime).AddDays(1)).ToString("yyyy-MM-dd") + " 23:59:59"; } else { RadioEndDate.IsChecked = true; TextEndDateTime.Text = Convert.ToDateTime(selBinded.DurationendStr).ToString("yyyy-MM-dd HH:mm:ss"); } if (selStart < curNow)//开始时间<当前时间 { RadioBeginDate.IsEnabled = false; TextStartDateTime.IsEnabled = false; } } #endregion } }
/// <summary> /// 检测添加的策略时间是否合法 /// </summary> /// <param name="lstBindedStrategy">已经绑定的策略</param> /// <param name="cvs">需要添加的策略</param> private bool IsInputDateValied(IList <CVoiceServerBindStrategy> mlstBindedStrategy, CVoiceServerBindStrategy mCvs) { bool ret = true; bool isCvsNopre = mCvs.Durationend > 20990000000000 ? true : false; bool hasNopre = mlstBindedStrategy.Where(p => p.Durationend > 20990000000000).Count() > 0 ? true : false; foreach (CVoiceServerBindStrategy tmpcvs in mlstBindedStrategy) { if (mCvs.Durationbegin >= tmpcvs.Durationbegin && mCvs.Durationbegin <= tmpcvs.Durationend)//时间重叠1 { ret = false; } else if (mCvs.Durationend >= tmpcvs.Durationbegin && mCvs.Durationend <= tmpcvs.Durationend)//时间重叠2 { ret = false; } else if (isCvsNopre && hasNopre) { ret = false; } } return(ret); }
/// <summary> /// 添加策略绑定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnApply_Click(object sender, RoutedEventArgs e) { try { try { if (Convert.ToDateTime(TextEndDateTime.Text) == null || Convert.ToDateTime(TextStartDateTime.Text) == null) { ShowException(CurrentApp.GetLanguageInfo("240300020", "Input Error")); return; } } catch (Exception ex) { ShowException(CurrentApp.GetLanguageInfo("240300020", "Input Error")); return; } string mSelVoiceIP = mFirstPage.LLstVoiceServer.Where(p => p.IPResourceID == mFirstPage.mCurrentSelectIPSourceID).FirstOrDefault().VoiceServer; if (string.IsNullOrEmpty(mSelVoiceIP)) { ShowInformation("VoiceIP Is NULL."); return; } IList <CVoiceServerBindStrategy> lstPolicyBindding = mFirstPage.lstPolicyBindding; //追加策略时,该录音服务器已经绑定的策略 CVoiceServerBindStrategy cvsbs = new CVoiceServerBindStrategy(); if (mOpType == "1") //追加策略 { cvsbs.Objecttype = "1"; cvsbs.Objectvalue = mSelVoiceIP; cvsbs.Bindingpolicyid = Convert.ToInt64(selPolicyInfo.PolicyID); if (RadioBeginImmediately.IsChecked == true) { cvsbs.Durationbegin = Convert.ToInt64(DateTime.UtcNow.ToString("yyyyMMddHHmmss")); } else { cvsbs.Durationbegin = Convert.ToInt64((Convert.ToDateTime(TextStartDateTime.Text).ToUniversalTime()).ToString("yyyyMMddHHmmss")); } if (RadioNoEndDate.IsChecked == true) { cvsbs.Durationend = Convert.ToInt64(DateTime.Parse("2099-12-31 23:59:59").ToUniversalTime().ToString("yyyyMMddHHmmss")); } else { cvsbs.Durationend = Convert.ToInt64((Convert.ToDateTime(TextEndDateTime.Text).ToUniversalTime()).ToString("yyyyMMddHHmmss")); } cvsbs.Setteduserid = CurrentApp.Session.UserID; cvsbs.Settedtime = Convert.ToInt64(DateTime.UtcNow.ToString("yyyyMMddHHmmss")); cvsbs.Grantencryption = "1"; cvsbs.Description = ""; cvsbs.CusFiled1 = mFirstPage.mCurrentSelectIPSourceID; cvsbs.CusFiled2 = CurrentApp.Session.UserInfo.Account; cvsbs.CusFiled3 = selPolicyInfo.PolicyName; if (cvsbs.Durationbegin < selPolicyInfo.PolicyStartTimeNumber || ((cvsbs.Durationend > selPolicyInfo.PolicyEndTimeNumber))) { //策略期限判断 ShowInformation(CurrentApp.GetLanguageInfo("240300026", "Please check the policy period.")); return; } if (!IsInputDateValied(lstPolicyBindding, cvsbs) || cvsbs.Durationbegin > cvsbs.Durationend) { ShowInformation(CurrentApp.GetLanguageInfo("240300020", "Time-overlap")); return; } SaveData224002(cvsbs); mParentpage.SetPanelOpenState(false); mFirstPage.SetPanelOpenState(false); mFirstPage.GetPoliciesByVoiceIPSource(mFirstPage.mCurrentSelectIPSourceID); } else if (mOpType == "2") { CVoiceServerBindStrategy selBinded = mFirstPage.mcurrentPoBind; lstPolicyBindding.Remove(selBinded); CVoiceServerBindStrategy newStrategy = selBinded; string strStart = (Convert.ToDateTime(TextStartDateTime.Text).ToUniversalTime()).ToString("yyyyMMddHHmmss"); string strEnd = ""; if (RadioNoEndDate.IsChecked == true) { strEnd = "20991231235959"; } else { strEnd = (Convert.ToDateTime(TextEndDateTime.Text).ToUniversalTime()).ToString("yyyyMMddHHmmss"); } newStrategy.Durationbegin = Convert.ToInt64(strStart); newStrategy.Durationend = Convert.ToInt64(strEnd); if (!IsInputDateValied(lstPolicyBindding, newStrategy) || newStrategy.Durationbegin > newStrategy.Durationend) { lstPolicyBindding.Add(selBinded); ShowInformation(CurrentApp.GetLanguageInfo("240300020", "Time-overlap")); return; } ModyfyData224002(selBinded, strStart, strEnd); mFirstPage.SetPanelOpenState(false); mFirstPage.GetPoliciesByVoiceIPSource(mFirstPage.mCurrentSelectIPSourceID); } } catch (Exception ex) { ShowException(ex.Message); } }
/// <summary> /// 根据录音服务器IP的资源编码 获取绑定的策略 /// </summary> /// <param name="stripSource"></param> public void GetPoliciesByVoiceIPSource(string stripSource) { lstPolicyBindding.Clear(); mCurrentSelectIPSourceID = stripSource; Service24021Client client = null; try { WebRequest webRequest = new WebRequest(); webRequest.Code = (int)S2400RequestCode.GetPoliciesByVoiceIPSource; webRequest.Session = CurrentApp.Session; webRequest.ListData.Add(stripSource); 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]; CVoiceServerBindStrategy policyItem = null; foreach (DataRow row in dt.Rows) { if (row["PONAME"] == null || string.IsNullOrEmpty(row["PONAME"].ToString())) { continue; } policyItem = new CVoiceServerBindStrategy(); policyItem.Durationbegin = Convert.ToInt64(GetObjectStr(row["C004"])); policyItem.Durationend = Convert.ToInt64(GetObjectStr(row["C005"])); policyItem.Settedtime = Convert.ToInt64(GetObjectStr(row["C007"])); policyItem.Objecttype = GetObjectStr(row["C001"]); policyItem.Objectvalue = GetObjectStr(row["C002"]); policyItem.Bindingpolicyid = Convert.ToInt64(GetObjectStr(row["C003"])); policyItem.DurationbeginStr = CommonFunctions.StringToDateTime(row["C004"].ToString()).ToString(); if (policyItem.Durationend > 20990000000000) { policyItem.DurationendStr = CurrentApp.GetLanguageInfo("240300032", "Never expires"); } else { policyItem.DurationendStr = CommonFunctions.StringToDateTime(row["C005"].ToString()).ToString(); } policyItem.Setteduserid = Convert.ToInt64(GetObjectStr(row["C006"])); policyItem.SettedtimeStr = CommonFunctions.StringToDateTime(row["C007"].ToString()).ToString(); policyItem.Grantencryption = GetObjectStr(row["C008"]); policyItem.CusFiled1 = GetObjectStr(row["C009"]); policyItem.CusFiled2 = GetObjectStr(row["C010"]); policyItem.CusFiled3 = GetObjectStr(row["C011"]); lstPolicyBindding.Add(policyItem); } BindStrategyContextMenu(); } catch (Exception ex) { ShowException("Failed." + ex.Message); } finally { if (client != null) { if (client.State == System.ServiceModel.CommunicationState.Opened) { client.Close(); } } } }