public void ShowPropertyWindow(UIElement element) { firstBind = 0; _activity = element as SMT.Workflow.Platform.Designer.DesignerControl.ActivityControl; if (_activity == null) return; _activity.Title = _activity.Title; #region 新建时创建_activityObject if (_activityObject == null) { ActivityObject obj = ActivityObjects.Where(p => p.ActivityId.Equals("State" + _activity.UniqueID)).SingleOrDefault(); if (obj == null) { _activityObject = new ActivityObject(); _activityObject.ActivityId = "State" + _activity.UniqueID; //if(_activity. chkGroupAudit.IsChecked = false; HideRows(); if (_activity.Title.IndexOf("会签") < 0) { stateList = WfUtils.StateList; if (Utility.CurrentUser != null) { List<StateType> StateList = WfUtils.GetRoleListByCompanyID(WfUtils.StateList, Utility.CurrentUser.OWNERCOMPANYID); cboRoles.ItemsSource = StateList.OrderBy(c => c.StateName); if (StateList.Count > 0) { isInit = true; if ((cboRoles.Items[0] as StateType).StateName == _activity.Title) { cboRoles.SelectedIndex = 0; } if (_activity.Title.IndexOf("新建") > -1) { cboRoles.SelectedIndex = 0; } } cboUserType.ItemsSource = WfUtils.GetUserTypeList(); cboUserType.SelectedIndex = 0; } } } else { _activityObject = obj; } } #endregion isInit = false; }
/// <summary> /// 更新活动的集合(如果活动不存在,就加入到集合里) /// </summary> /// <param name="activity">活动</param> /// <returns></returns> public void UpdateActivityObject(ActivityObject activity) { var e = from a in ActivityObjects where a.ActivityId == activity.ActivityId select a; var ent = e.FirstOrDefault(); if (ent != null) { //先删除后增加,保证数据是最新的 ActivityObjects.Remove(ent); ActivityObjects.Add(ent); } else { ActivityObjects.Add(activity); } }
/// <summary> /// 获取流程的集合 /// </summary> private void GetFlowDefine() { _activityObjects.Clear(); _lineObjects.Clear(); XElement root = XElement.Parse(_currentFlow.FlowDefinition.LAYOUT); #region 活动集合 var el = from e in root.Elements("Activitys") select e; foreach (var ent in el.Nodes()) { XElement node = ent as XElement; ActivityObject activity = new ActivityObject(); activity.CounterSignRoleList = new List<CounterSignRole>(); #region 活动 activity.ActivityId = node.Attribute("Name").Value; activity.UserType = node.Attribute("UserType").Value; activity.IsSpecifyCompany = GetAttributeValue(node, "IsOtherCompany").ToLower() == "true" ? true : false; // node.Attribute("IsOtherCompany").Value.ToLower() == "true" ? true : false; activity.OtherCompanyId = GetAttributeValue(node, "OtherCompanyID");// node.Attribute("OtherCompanyID").Value; activity.RoleId = GetAttributeValue(node, "RoleName");// node.Attribute("RoleName").Value; activity.RoleName = GetAttributeValue(node, "RoleName");// node.Attribute("RoleName").Value; activity.Remark = node.Attribute("Remark").Value; activity.OtherCompanyName = GetAttributeValue(node, "OtherCompanyName");//node.Attribute("OtherCompanyName") != null ? node.Attribute("OtherCompanyName").Value : ""; #endregion #region Countersigns XElement xsigns = node.Elements("Countersigns").FirstOrDefault(); if (xsigns != null) { activity.IsCounterSign = xsigns.Nodes().Count() > 0 ? true : false; //xsigns.Attribute("CountersignType").Value == "0" ? true : false; activity.CounterType = xsigns.Attribute("CountersignType").Value; #region Countersign foreach (var sign in xsigns.Nodes()) { XElement de = sign as XElement; CounterSignRole role = new CounterSignRole(); role.StateCode = de.Attribute("StateType").Value; role.StateName = de.Attribute("RoleName").Value; role.IsOtherCompany = de.Attribute("IsOtherCompany").Value.ToLower() == "true" ? true : false; role.OtherCompanyId = de.Attribute("OtherCompanyID").Value; role.OtherCompanyName =de.Attribute("OtherCompanyName")!=null? de.Attribute("OtherCompanyName").Value:""; role.TypeCode = de.Attribute("UserType").Value; role.TypeName = de.Attribute("UserTypeName") != null ? de.Attribute("UserTypeName").Value : ""; activity.CounterSignRoleList.Add(role); } } #endregion #endregion _activityObjects.Add(activity); } #endregion //==added by jason, 02/24/2012=== if (root.Elements("System").FirstOrDefault() != null) _systemNameFromLayout = root.Elements("System").FirstOrDefault().Value; #region 连线集合 var ru = from e in root.Elements("Rules") select e; foreach (var ent in ru.Nodes()) { XElement node = ent as XElement; LineObject line = new LineObject(); line.ConditionList = new List<CompareCondition>(); #region Rule line.LineId = node.Attribute("Name").Value; //added by jason, 02/16/2012 line.Remark = node.Attribute("Remark") != null ? node.Attribute("Remark").Value : ""; //end added by jason, 02/16/2012 #endregion #region Conditions if (node.Elements("Conditions").FirstOrDefault() != null) { //==added by jason, 02/24/2012=== _objectNameFromLayout = node.Elements("Conditions").FirstOrDefault().Attribute("Object").Value; line.Object = node.Elements("Conditions").FirstOrDefault().Attribute("Object").Value; line.CodiCombMode = node.Elements("Conditions").FirstOrDefault().Attribute("CodiCombMode").Value; #endregion #region Condition foreach (var tion in node.Elements("Conditions").Nodes()) { XElement xnode = tion as XElement; CompareCondition cc = new CompareCondition(); cc.Name = xnode.Attribute("Name").Value; cc.Description = xnode.Attribute("Description").Value; cc.CompAttr = xnode.Attribute("CompAttr").Value; cc.DataType = xnode.Attribute("DataType").Value; cc.Operate = xnode.Attribute("Operate").Value; cc.CompareValueMark = GetAttributeValue(xnode, "CompareValueMark"); cc.CompareValue = xnode.Attribute("CompareValue").Value; line.ConditionList.Add(cc); } } #endregion _lineObjects.Add(line); } #endregion }
private void btnOk_Click(object sender, RoutedEventArgs e) { if (_activityObject == null) { _activityObject = new ActivityObject(); _activityObject.ActivityId = _activity.UniqueID; _activityObject.CounterType = cboRule.SelectedIndex.ToString(); } _activityObject.Remark = this.txtActivityName.Text; if (counterSignRoleList == null) counterSignRoleList = new List<CounterSignRole>(); CounterSignRole newCondition = new CounterSignRole(); if (cboUserType.SelectedItem != null) { newCondition.TypeCode = (cboUserType.SelectedItem as UserType).TypeCode; newCondition.TypeName = (cboUserType.SelectedItem as UserType).TypeName; } else { ComfirmWindow.ConfirmationBox("提示信息", "用户类型没有出来,请重新选择!", "确定"); return; } _activityObject.IsCounterSign = true; newCondition.StateCode = (cboCountersignRoles.SelectedItem as StateType).StateCode; if (cbOtherCompany.IsChecked == true) { newCondition.IsOtherCompany = true; newCondition.OtherCompanyId = ((cboOtherCompany.SelectedItem) as SMT.Saas.Tools.OrganizationWS.V_COMPANY).COMPANYID; newCondition.OtherCompanyName = ((cboOtherCompany.SelectedItem) as SMT.Saas.Tools.OrganizationWS.V_COMPANY).CNAME; } else { newCondition.IsOtherCompany = false; newCondition.OtherCompanyId = ""; newCondition.OtherCompanyName = ""; } newCondition.StateName = (cboCountersignRoles.SelectedItem as StateType).StateName; _activityObject.IsSpecifyCompany = false; _activityObject.OtherCompanyId = ""; _activityObject.OtherCompanyName = ""; _activityObject.RoleId = ""; _activityObject.RoleName = ""; _activityObject.UserType = ""; _activityObject.ActivityId = "State" + _activity.UniqueID; _activityObject.CounterType = cboRule.SelectedIndex.ToString(); var item = counterSignRoleList.Where(p => p.StateCode == (cboCountersignRoles.SelectedItem as StateType).StateCode).FirstOrDefault(); if (item == null) { counterSignRoleList.Add(newCondition); dgCountersign.ItemsSource = null; dgCountersign.ItemsSource = counterSignRoleList; } _activityObject.CounterSignRoleList = counterSignRoleList; //if (_activityObject.CounterSignRoleList != null && _activityObject.CounterSignRoleList.Count > 0) //{//已有角色 // if (item == null) // { // counterSignRoleList.Add(newCondition); // dgCountersign.ItemsSource = null; // dgCountersign.ItemsSource = counterSignRoleList; // } //} //else //{//没有角色 // counterSignRoleList.Add(newCondition); // _activityObject.CounterSignRoleList = counterSignRoleList; //} UpdateActivityObject(_activityObject); if (this.chkGroupAudit.IsChecked == true) { this.txtActivityName.Text = ""; this.txtActivityName.Text = "会签节点"; } }
/// <summary> /// 刷新活动数据 /// </summary> /// <param name="id"></param> private void RefreshActivityData(string id) { ActivityObject activityObject = _activityObjects.Where(p => p.ActivityId.Equals(id)).SingleOrDefault(); if (activityObject != null) _activityObjects.Remove(activityObject); activityObject = new ActivityObject() { ActivityId = id, IsCounterSign = (bool)ucFlowSetting.activityProperty.chkGroupAudit.IsChecked ? true : false, RoleId = ucFlowSetting.activityProperty.cboRoles.SelectedItem == null ? "" : (ucFlowSetting.activityProperty.cboRoles.SelectedItem as StateType).StateCode, UserType = ucFlowSetting.activityProperty.cboUserType.SelectedItem == null ? "" : (ucFlowSetting.activityProperty.cboUserType.SelectedItem as UserType).TypeCode, IsSpecifyCompany = (bool)ucFlowSetting.activityProperty.cbOtherCompany.IsChecked ? true : false, CounterType = ucFlowSetting.activityProperty.cboRule.SelectedIndex.ToString(), CounterSignRoleList = ucFlowSetting.activityProperty.ActivityObjectData == null ? null : ucFlowSetting.activityProperty.ActivityObjectData.CounterSignRoleList, }; _activityObjects.Add(activityObject); }