public void Equality() { var yearOffset = new ZoneYearOffset(TransitionMode.Utc, 10, 31, (int)IsoDayOfWeek.Wednesday, true, LocalTime.Midnight); var recurrence = new ZoneRecurrence("bob", Offset.Zero, yearOffset, 1971, 2009); var actual = new RuleLine(recurrence, "D", null); var expected = new RuleLine(recurrence, "D", null); Assert.AreEqual(expected, actual); }
/// <summary> /// Adds the given rule to the appropriate rule set. If there is no existing /// rule set, one is created and added to the database. /// </summary> /// <param name="rule">The rule to add.</param> internal void AddRule(RuleLine rule) { IList<RuleLine> ruleSet; if (!Rules.TryGetValue(rule.Name, out ruleSet)) { ruleSet = new List<RuleLine>(); Rules[rule.Name] = ruleSet; } ruleSet.Add(rule); }
public void FormatName_Slash_Daylight() { var yearOffset = new ZoneYearOffset(TransitionMode.Utc, 10, 31, (int) IsoDayOfWeek.Wednesday, true, LocalTime.Midnight); var recurrence = new ZoneRecurrence("ignored", Offset.FromHours(1), yearOffset, 1971, 2009); var rule = new RuleLine(recurrence, "!", null); var zone = GetZone("X/Y", Offset.FromHours(1)); var zoneRecurrence = rule.GetRecurrences(zone).Single(); Assert.AreEqual("Y", zoneRecurrence.Name); }
public void FormatName_Slash_Daylight() { var yearOffset = new ZoneYearOffset(TransitionMode.Utc, 10, 31, (int)IsoDayOfWeek.Wednesday, true, LocalTime.Midnight); var recurrence = new ZoneRecurrence("ignored", Offset.FromHours(1), yearOffset, 1971, 2009); var rule = new RuleLine(recurrence, "!", null); var zone = GetZone("X/Y", Offset.FromHours(1)); var zoneRecurrence = rule.GetRecurrences(zone).Single(); Assert.AreEqual("Y", zoneRecurrence.Name); }
public void FormatName_PercentS() { // Note that the offset is irrelevant here - the "daylight saving indicator" is replaced either way. var yearOffset = new ZoneYearOffset(TransitionMode.Utc, 10, 31, (int) IsoDayOfWeek.Wednesday, true, LocalTime.Midnight); var recurrence = new ZoneRecurrence("ignored", Offset.Zero, yearOffset, 1971, 2009); var rule = new RuleLine(recurrence, "!", null); var zone = GetZone("X%sY", Offset.Zero); var zoneRecurrence = rule.GetRecurrences(zone).Single(); Assert.AreEqual("X!Y", zoneRecurrence.Name); }
public void FormatName_PercentS() { // Note that the offset is irrelevant here - the "daylight saving indicator" is replaced either way. var yearOffset = new ZoneYearOffset(TransitionMode.Utc, 10, 31, (int)IsoDayOfWeek.Wednesday, true, LocalTime.Midnight); var recurrence = new ZoneRecurrence("ignored", Offset.Zero, yearOffset, 1971, 2009); var rule = new RuleLine(recurrence, "!", null); var zone = GetZone("X%sY", Offset.Zero); var zoneRecurrence = rule.GetRecurrences(zone).Single(); Assert.AreEqual("X!Y", zoneRecurrence.Name); }
/// <summary> /// 设置规则 /// </summary> /// <param name="ActiveName"></param> public void RuleActiveSet(string RuleName) { RuleLine a = FindName(RuleName) as RuleLine; RuleActiveSet RuleActiveSetS = new RuleActiveSet(); RuleActiveSetS.OptState = OptState.Update; // RuleActiveSetS.btnDele.Visibility = Visibility.Visible; RuleActiveSetS.RuleName = RuleName; RuleActiveSetS.BOSystem = BOSystem; RuleActiveSetS.BOObject = BOObject; RuleActiveSetS.StartStateName = a.StrStartActive; RuleActiveSetS.EndStateName = a.StrEndActive; RuleActiveSetS.SetRuleList(Actives); RuleActiveSetS.BOSystem = this.BOSystem; RuleActiveSetS.BOObject = this.BOObject; RuleActiveSetS.chkUseCondition.IsChecked = false; RuleActiveSetS.CoditionList.Clear(); RuleActiveSetS.dgCodition.ItemsSource = null; RuleActiveSetS.dgCodition.ItemsSource = RuleActiveSetS.CoditionList; RuleActiveSetS.txtCompareValue.Text = ""; RuleActiveSetS.cboOperate.SelectedIndex = 0; RuleActiveSetS.requestSystemBOAttributeList(); RuleActiveSetS.Rule_OnClick += new EventHandler <Rule_OnClickEventArgs>(RuleActiveSetS_Rule_OnClick); if (a.ruleCoditions != null) { if (a.ruleCoditions.subCondition.Count > 0) { foreach (CompareCondition cpItem in a.ruleCoditions.subCondition) { RuleActiveSetS.CoditionList.Add(cpItem); } RuleActiveSetS.chkUseCondition.IsChecked = true; RuleActiveSetS.conditionPanel.Visibility = Visibility.Visible; } else { RuleActiveSetS.chkUseCondition.IsChecked = false; RuleActiveSetS.conditionPanel.Visibility = Visibility.Collapsed; } } else { RuleActiveSetS.chkUseCondition.IsChecked = false; RuleActiveSetS.conditionPanel.Visibility = Visibility.Collapsed; } // RuleActiveSetS.Show(); EntityBrowser rule_browser = new EntityBrowser(RuleActiveSetS); rule_browser.Show <string>(DialogMode.ApplicationModal, Common.ParentLayoutRoot, "", (result) => { }); }
private void LineSelect() { try { if (!String.IsNullOrWhiteSpace(cmbLine.Text)) { if (cmbLine.SelectedValue != null && cmbLine.SelectedIndex > -1) { cmbMark.Focus(); } else { var lineName = cmbLine.Text.Trim(); this.LineList(); cmbLine.Text = lineName; if (cmbLine.SelectedValue != null && cmbLine.SelectedIndex > -1) { cmbMark.Focus(); } else { if (XtraMessageBox.Show("No se encuentra esta Linea ¿Desea crearla?", "Pregunta de seguridad", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Yes) { var line = new RuleLine(); line.Save(new LineEntity() { LineID = Guid.NewGuid(), LineName = lineName }); this.LineList(); cmbLine.Text = lineName; cmbMark.Focus(); } } } } else { cmbLine.SelectedIndex = -1; cmbMark.Focus(); } } catch (Exception ex) { Msg.Err(ex.Message); } }
public void FormatName_PercentZ() { var yearOffset = new ZoneYearOffset(TransitionMode.Utc, 10, 31, (int) IsoDayOfWeek.Wednesday, true, LocalTime.Midnight); var recurrence = new ZoneRecurrence("Rule", Offset.FromHoursAndMinutes(5, 30), yearOffset, 1971, 2009); var rule = new RuleLine(recurrence, "D", null); var zoneRecurrence = rule.GetRecurrences(GetZone("X%zY", Offset.Zero)).Single(); Assert.AreEqual("X+0530Y", zoneRecurrence.Name); zoneRecurrence = rule.GetRecurrences(GetZone("X%zY", Offset.FromHoursAndMinutes(0, 30))).Single(); Assert.AreEqual("X+06Y", zoneRecurrence.Name); zoneRecurrence = rule.GetRecurrences(GetZone("X%zY", Offset.FromHoursAndMinutes(-6, -30))).Single(); Assert.AreEqual("X-01Y", zoneRecurrence.Name); }
public void LineList() { try { var line = new RuleLine(); cmbCliente.DataSource = line.List(); cmbCliente.ValueMember = "LineID"; cmbCliente.DisplayMember = "LineName"; cmbCliente.SelectedIndex = -1; } catch (Exception ex) { Msg.Err(ex.Message); } }
public void FormatName_PercentZ() { var yearOffset = new ZoneYearOffset(TransitionMode.Utc, 10, 31, (int)IsoDayOfWeek.Wednesday, true, LocalTime.Midnight); var recurrence = new ZoneRecurrence("Rule", Offset.FromHoursAndMinutes(5, 30), yearOffset, 1971, 2009); var rule = new RuleLine(recurrence, "D", null); var zoneRecurrence = rule.GetRecurrences(GetZone("X%zY", Offset.Zero)).Single(); Assert.AreEqual("X+0530Y", zoneRecurrence.Name); zoneRecurrence = rule.GetRecurrences(GetZone("X%zY", Offset.FromHoursAndMinutes(0, 30))).Single(); Assert.AreEqual("X+06Y", zoneRecurrence.Name); zoneRecurrence = rule.GetRecurrences(GetZone("X%zY", Offset.FromHoursAndMinutes(-6, -30))).Single(); Assert.AreEqual("X-01Y", zoneRecurrence.Name); }
private void LineSelect() { try { if (!String.IsNullOrWhiteSpace(cmbCliente.Text.Trim())) { if (cmbCliente.SelectedValue == null) { var LineName = cmbCliente.Text; this.LineList(); cmbCliente.Text = LineName; if (cmbCliente.SelectedValue != null) { cmbCliente.Focus(); } else { if (XtraMessageBox.Show("No se encuentra esta linea ¿Desea agregarla?", "Información del Sistema", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { var line = new RuleLine(); line.Save(new LineEntity() { LineName = cmbCliente.Text }); this.LineList(); cmbCliente.Text = LineName; //cmbMark.Focus(); } } } else { //cmbMark.Focus(); } } } catch (Exception ex) { Msg.Err(ex.Message); } }
/// <summary> /// 设置规则线位置 /// </summary> /// <param name="RuleName"></param> void SetRuleLinePos(string RuleName)//,string ActiveName,Point Pos) { RuleLine class2 = FindName(RuleName) as RuleLine; StateActive StartActive = FindName(class2.StrStartActive) as StateActive; StateActive EndActive = FindName(class2.StrEndActive) as StateActive; Double X1 = StartActive.ActualHeight + Convert.ToDouble(StartActive.GetValue(Canvas.TopProperty).ToString()); Double Y1 = StartActive.ActualWidth / 2 + Convert.ToDouble(StartActive.GetValue(Canvas.LeftProperty).ToString()); Double X2 = Convert.ToDouble(EndActive.GetValue(Canvas.TopProperty).ToString()) - X1; Double Y2 = Convert.ToDouble(EndActive.GetValue(Canvas.LeftProperty).ToString()) - Y1 + EndActive.ActualWidth / 2; class2.SetValue(Canvas.TopProperty, X1); class2.SetValue(Canvas.LeftProperty, Y1); class2.line.X2 = Y2; class2.line.Y2 = X2; class2.SetAngleByPoint(new Point(Y2, X2)); }
void rule_browser_ReloadDataEvent(RuleActiveSet RuleActiveSetS) { if (d_RuleActiveSet == true) { #region 添加新规则 if (RuleActiveSetS.OptState == OptState.Add && RuleActiveSetS.StartStateName != "" && RuleActiveSetS.EndStateName != "") { //检测是否已添加此状态 for (int i = 0; i < Rules.Count; i++) { if (Rules[i].StrStartActive == RuleActiveSetS.StartStateName && Rules[i].StrEndActive == RuleActiveSetS.EndStateName) { ComfirmWindow.ConfirmationBox(Utility.GetResourceStr("PROMPT"), Utility.GetResourceStr("M00008"), Utility.GetResourceStr("CONFIRMBUTTON")); //MessageBox.Show("此规则已添加,不能添加相同的规则!"); return; } } if ((string.IsNullOrEmpty(BOSystem.Name) || string.IsNullOrEmpty(BOObject.Name)) && !string.IsNullOrEmpty(RuleActiveSetS.BOSystem.Name) && !string.IsNullOrEmpty(RuleActiveSetS.BOObject.Name)) { BOSystem = RuleActiveSetS.BOSystem; BOObject = RuleActiveSetS.BOObject; //this.tbSystemAndBusinessObject.Text = } RuleLine a = new RuleLine(); a.Name = System.Guid.NewGuid().ToString(); a.StrStartActive = RuleActiveSetS.StartStateName; a.StrEndActive = RuleActiveSetS.EndStateName; a.Container = this; a.ruleCoditions = new RuleConditions(); a.ruleCoditions.subCondition.Clear(); if (RuleActiveSetS.CoditionList.Count > 0) { a.ruleCoditions.ConditionObject = BOObject.Name; foreach (CompareCondition cpItem in RuleActiveSetS.CoditionList) { a.ruleCoditions.subCondition.Add(cpItem); } } // StartFlow.GetValue(Canvas.TopProperty) ; //Double X1 = 60 + Convert.ToDouble((FindName(a.StrStartActive) as StateActive).GetValue(Canvas.TopProperty).ToString()); //Double Y1 = 50 + Convert.ToDouble((FindName(a.StrStartActive) as StateActive).GetValue(Canvas.LeftProperty).ToString()); //a.SetValue(Canvas.TopProperty, X1);//(double)110); //a.SetValue(Canvas.LeftProperty, Y1);//(double)450); if (!cnsDesignerContainer.Children.Contains(a)) { cnsDesignerContainer.Children.Add(a); SetRuleLinePos(a.Name); Rules.Add(a); // a.ActivityChanged += new ActivityChangeDelegate(OnActivityChanged); } } #endregion #region 修改规则 else if (RuleActiveSetS.OptState == OptState.Update && RuleActiveSetS.StartStateName != "" && RuleActiveSetS.EndStateName != "") { if ((string.IsNullOrEmpty(BOSystem.Name) || string.IsNullOrEmpty(BOObject.Name)) && !string.IsNullOrEmpty(RuleActiveSetS.BOSystem.Name) && !string.IsNullOrEmpty(RuleActiveSetS.BOObject.Name)) { BOSystem = RuleActiveSetS.BOSystem; BOObject = RuleActiveSetS.BOObject; } RuleLine a = FindName(RuleActiveSetS.RuleName) as RuleLine; a.StrStartActive = RuleActiveSetS.StartStateName; a.StrEndActive = RuleActiveSetS.EndStateName; if (a.ruleCoditions == null) { a.ruleCoditions = new RuleConditions(); } a.ruleCoditions.subCondition.Clear(); if (RuleActiveSetS.CoditionList.Count > 0) { a.ruleCoditions.ConditionObject = BOObject.Name; foreach (CompareCondition cpItem in RuleActiveSetS.CoditionList) { a.ruleCoditions.subCondition.Add(cpItem); } } SetRuleLinePos(a.Name); } #endregion #region 除规则 else if (RuleActiveSetS.OptState == OptState.Delete) { RuleLine a = FindName(RuleActiveSetS.RuleName) as RuleLine; if (a == null) { return; } if (a.ruleCoditions != null) { a.ruleCoditions.subCondition.Clear(); } Rules.Remove(a); cnsDesignerContainer.Children.Remove(a); } #endregion } }
void SetLayout() { string Layout = this.FlowDefine; //XmlDocument doc = new XmlDocument(); //doc.LoadXml(Layout); string qq; string WFBOSystemName = string.Empty; string WFBOObjectName = string.Empty; qq = ""; XmlReader XmlReader; StringReader bb = new StringReader(Layout); XmlReader = XmlReader.Create(bb); #region 遍历XML //while (XmlReader.Read()) //{ // qq+="<li>节点类型:" + XmlReader.NodeType + "==<br>"; // switch (XmlReader.NodeType) // { // case XmlNodeType.XmlDeclaration: // for (int i = 0; i < XmlReader.AttributeCount; i++) // { // XmlReader.MoveToAttribute(i); // qq+="属性:" + XmlReader.Name + "=" + XmlReader.Value + " "; // } // break; // case XmlNodeType.Attribute: // for (int i = 0; i < XmlReader.AttributeCount; i++) // { // XmlReader.MoveToAttribute(i); // qq+="属性:" + XmlReader.Name + "=" + XmlReader.Value + " "; // } // break; // case XmlNodeType.CDATA: // qq+="CDATA:" + XmlReader.Value + " "; // break; // case XmlNodeType.Element: // qq+="节点名称:" + XmlReader.LocalName + "<br>"; // for (int i = 0; i < XmlReader.AttributeCount; i++) // { // XmlReader.MoveToAttribute(i); // qq+="属性:" + XmlReader.Name + "=" + XmlReader.Value + " "; // } // break; // case XmlNodeType.Comment: // qq+="Comment:" + XmlReader.Value; // break; // case XmlNodeType.Whitespace: // qq+="Whitespace:" + " "; // break; // case XmlNodeType.ProcessingInstruction: // qq+="ProcessingInstruction:" + XmlReader.Value; // break; // case XmlNodeType.Text: // qq+="Text:" + XmlReader.Value; // break; // } // } #endregion XElement XElementS = XElement.Load(XmlReader); var flowSystem = from c in XElementS.Descendants("System") select c; if (flowSystem != null) { foreach (var tmp in flowSystem) { WFBOSystemName = tmp.Value; } } //BOSystem var a = from c in XElementS.Descendants("Activity") select c; foreach (var tmp in a) { string stepname = tmp.Attribute("Name").Value; if (stepname != "StartFlow" && stepname != "EndFlow") { StateActive Flow = new StateActive(); Flow.MinWidth = 60; Flow.Name = stepname; // 1s 冉龙军 //string tmpStateName = (StateList.Where(s => s.StateCode.ToString() == stepname).ToList().First().StateName); string tmpStateName = tmp.Attribute("Remark").Value; // 1e string StateName = ""; for (int i = 0; i < tmpStateName.Length; i = i + 6) { if (tmpStateName.Length < i + 6) { StateName += (i == 0 ? tmpStateName : "\r\n" + tmpStateName.Substring(i)); } else { StateName += (i == 0 ? tmpStateName.Substring(i, 6) : "\r\n" + tmpStateName.Substring(i, 6)); } } Flow.StateName.Text = StateName;// (StateList.Where(s => s.StateCode.ToString() == stepname).ToList().First().StateName); #region 加载KPI点的信息 if (KPIPointList != null && KPIPointList.Count != 0) { foreach (T_HR_KPIPOINT point in KPIPointList) { if (stepname.Equals(point.STEPID)) { Flow.StateName.Text += "(KPI点)"; } } } #endregion 加载KPI点的信息 Flow.SetValue(Canvas.TopProperty, Convert.ToDouble(tmp.Attribute("X").Value)); Flow.SetValue(Canvas.LeftProperty, Convert.ToDouble(tmp.Attribute("Y").Value)); if (!cnsDesignerContainer.Children.Contains(Flow)) { // 1s 冉龙军 暂不处理错误 //cnsDesignerContainer.Children.Add(Flow); try { cnsDesignerContainer.Children.Add(Flow); } catch (Exception ex) { } // 1e Flow.Container = this; Actives.Add(Flow); } } } var b = from c in XElementS.Descendants("Rule") select c; foreach (var tmp in b) { RuleLine RuleLineS = new RuleLine(); RuleLineS.Name = tmp.Attribute("Name").Value; RuleLineS.StrStartActive = tmp.Attribute("StrStartActive").Value; RuleLineS.StrEndActive = tmp.Attribute("StrEndActive").Value; RuleLineS.Container = this; if (tmp.Element("Conditions") != null) { RuleConditions newRuleCondition = new RuleConditions(); newRuleCondition.Name = tmp.Element("Conditions").Attribute("Name").Value; newRuleCondition.ConditionObject = tmp.Element("Conditions").Attribute("Object").Value; newRuleCondition.CodiCombMode = tmp.Element("Conditions").Attribute("CodiCombMode").Value; if (!string.IsNullOrEmpty(newRuleCondition.ConditionObject)) { WFBOObjectName = newRuleCondition.ConditionObject; } if (tmp.Element("Conditions").Elements("Condition").Count() > 0) { var e = from f in tmp.Element("Conditions").Descendants("Condition") select f; foreach (var tmp2 in e) { CompareCondition newCD = new CompareCondition(); newCD.Name = tmp2.Attribute("Name").Value; newCD.Description = tmp2.Attribute("Description").Value; newCD.CompAttr = tmp2.Attribute("CompAttr").Value; newCD.Operate = backEscapeXMLChar(tmp2.Attribute("Operate").Value); newCD.DataType = tmp2.Attribute("DataType").Value; newCD.CompareValue = tmp2.Attribute("CompareValue").Value; newRuleCondition.subCondition.Add(newCD); } } RuleLineS.ruleCoditions = newRuleCondition; } if (!cnsDesignerContainer.Children.Contains(RuleLineS)) { // 1s 冉龙军 暂不处理错误 //cnsDesignerContainer.Children.Add(RuleLineS); try { cnsDesignerContainer.Children.Add(RuleLineS); } catch (Exception ex) { } // 1e SetRuleLinePos(RuleLineS.Name); Rules.Add(RuleLineS); // a.ActivityChanged += new ActivityChangeDelegate(OnActivityChanged); } // MessageBox.Show(tmp.Attribute("Name").Value); } }