/// <summary> /// 创建一个新的流程实例 /// </summary> /// <param name="Engine">流程引擎</param> /// <param name="BizObjectId">业务对象ID</param> /// <param name="Workflow">流程模板</param> /// <param name="Schema">数据模型结构</param> /// <param name="InstanceId">流程实例ID</param> /// <param name="Originator">发起人</param> /// <param name="OriginatedGroup">发起人选择的身份,可以为空,如果为空,则表示不以任何组成员的身份发起流程</param> /// <param name="OriginatedPost">发起人所在的岗位,可以为空,如果为空,则表示不以任何岗位的身份发起流程</param> /// <param name="InstanceName">流程实例名称</param> /// <param name="OriginatingInstance">发起流程的事件接口</param> /// <param name="ParameterTable">发起流程的参数表</param> /// <param name="Request">HttpRequest</param> /// <param name="WorkItemId">工作任务ID</param> /// <param name="ErrorMessage">错误消息</param> /// <returns>返回创建流程是否成功</returns> public static bool OriginateInstance( IEngine Engine, string BizObjectId, WorkflowTemplate.PublishedWorkflowTemplate Workflow, DataModel.BizObjectSchema Schema, ref string InstanceId, string Originator, string OriginatedJob, string InstanceName, EventHandler <OriginateInstanceEventArgs> OriginatingInstance, Dictionary <string, object> ParameterTable, System.Web.HttpRequest Request, ref string WorkItemId, ref string ErrorMessage) { return(OriginateInstance( Engine, BizObjectId, Workflow, Schema, ref InstanceId, Originator, OriginatedJob, InstanceName, Instance.PriorityType.Normal, OriginatingInstance, ParameterTable, Request, ref WorkItemId, ref ErrorMessage, false)); }
/// <summary> /// 获取查询条件 /// </summary> /// <param name="Schema"></param> /// <param name="ListMethod"></param> /// <param name="Query"></param> /// <returns></returns> private OThinker.H3.BizBus.Filter.Filter GetFilter(DataModel.BizObjectSchema Schema, string ListMethod, DataModel.BizQuery Query) { // 构造查询条件 OThinker.H3.BizBus.Filter.Filter filter = new OThinker.H3.BizBus.Filter.Filter(); OThinker.H3.BizBus.Filter.And and = new OThinker.H3.BizBus.Filter.And(); filter.Matcher = and; ItemMatcher propertyMatcher = null; if (Query.QueryItems != null) { foreach (DataModel.BizQueryItem queryItem in Query.QueryItems) { // 增加系统参数条件 if (queryItem.FilterType == DataModel.FilterType.SystemParam) { propertyMatcher = new OThinker.H3.BizBus.Filter.ItemMatcher(queryItem.PropertyName, OThinker.Data.ComparisonOperatorType.Equal, SheetUtility.GetSystemParamValue(this.UserValidator, queryItem.SelectedValues)); and.Add(propertyMatcher); } else if (queryItem.Visible == OThinker.Data.BoolMatchValue.False) { and.Add(new ItemMatcher(queryItem.PropertyName, queryItem.FilterType == DataModel.FilterType.Contains ? OThinker.Data.ComparisonOperatorType.Contain : OThinker.Data.ComparisonOperatorType.Equal, queryItem.DefaultValue)); } } } return(filter); }
public JsonResult PublishBizObjectSchema(string schemaCode) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(); this.SchemaCode = schemaCode; if (!this.ParseParam()) { result.Success = false; result.Message = "EditBizObjectSchema.Msg0"; return Json(result, JsonRequestBehavior.AllowGet); } string message = null; if (!this.Engine.BizObjectManager.PublishSchema(this.Schema.SchemaCode, out message)) { result.Success = false; result.Message = "EditBizObjectSchema.PublishFailed"; result.Extend = message; } else { this.Schema = this.Engine.BizObjectManager.GetDraftSchema(this.Schema.SchemaCode); result.Success = true; result.Message = "EditBizObjectSchema.PublishedSuccess"; } return Json(result, JsonRequestBehavior.AllowGet); })); }
/// <summary> /// 输出数据模型 /// </summary> /// <param name="SchemaCode"></param> public JsonResult WriteSchema(string SchemaCode) { return(ExecuteFunctionRun(() => { DataModel.BizObjectSchema BizObject = this.Engine.BizObjectManager.GetDraftSchema(SchemaCode); if (BizObject != null && BizObject.Properties != null) { List <object> lstDataItems = new List <object>(); foreach (DataModel.PropertySchema Property in BizObject.Properties) { //不显示保留数据项 if (!DataModel.BizObjectSchema.IsReservedProperty(Property.Name)) { lstDataItems.Add(new { Text = Property.DisplayName, Value = Property.Name }); } } return Json(new { SchemaCode = SchemaCode, DataItems = lstDataItems.ToArray() }); } return Json(new { SchemaCode = "", DataItems = new {} }); })); }
private void ReadXmlFile(BizMasterDataImportViewModel model) { //从服务器加载 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(this.Session[model.XmlSessionName].ToString()); //根节点 XmlElement bizMasterData = xmlDoc.DocumentElement; //数据模型 XmlNodeList bizObjectSchemaNodes = bizMasterData.GetElementsByTagName("BizObjectSchema"); if (bizObjectSchemaNodes != null) { bizObjectSchema = Convertor.XmlToObject(typeof(BizObjectSchema), bizObjectSchemaNodes[0].OuterXml) as BizObjectSchema; } //主数据编码、名称 if (bizObjectSchema != null) { model.MasterDataCode = bizObjectSchema.SchemaCode; model.MasterDataName = bizObjectSchema.DisplayName; } //监听实例 XmlNodeList bizListenerPolicyNodes = bizMasterData.GetElementsByTagName("BizListenerPolicy"); if (bizListenerPolicyNodes != null && bizListenerPolicyNodes.Count > 0) { bizListenerPolicy = Convertor.XmlToObject(typeof(BizListenerPolicy), bizListenerPolicyNodes[0].OuterXml) as BizListenerPolicy; } //定时作业 XmlNodeList scheduleInvokerNodes = bizMasterData.GetElementsByTagName("ScheduleInvokers"); if (scheduleInvokerNodes != null && scheduleInvokerNodes.Count > 0) { scheduleInvokerList = new List <ScheduleInvoker>(); foreach (XmlNode scheduleInvoker in scheduleInvokerNodes[0].ChildNodes) { scheduleInvokerList.Add(Convertor.XmlToObject(typeof(ScheduleInvoker), scheduleInvoker.OuterXml) as ScheduleInvoker); } } //查询列表 XmlNodeList bizQueryNodes = bizMasterData.GetElementsByTagName("BizQueries"); if (bizQueryNodes != null && bizQueryNodes.Count > 0) { bizQueryList = new List <BizQuery>(); foreach (XmlNode query in bizQueryNodes[0].ChildNodes) { bizQueryList.Add(Convertor.XmlToObject(typeof(BizQuery), query.OuterXml) as BizQuery); } } }
/// <summary> /// 获取属性列表 /// </summary> /// <param name="properties">业务对象属性模式</param> /// <param name="publishedSchema">数据模型</param> /// <param name="parentPropertyPath">父级路径</param> /// <returns>数据模型属性列表</returns> private List <PropertySchemaViewModel> GetBizObjectChildren(DataModel.PropertySchema[] properties, DataModel.BizObjectSchema publishedSchema, string parentPropertyPath = "") { //排序 //properties = properties.OrderBy(p => p.Seq).ToArray(); List <PropertySchemaViewModel> list = new List <PropertySchemaViewModel>(); string parentProperty; DataModel.BizObjectSchema chirenSchema = null; DataModel.PropertySchema publishedProperty = null; foreach (DataModel.PropertySchema item in properties) { if (this.Schema.GetAssociation(item.Name) == null) { parentProperty = parentPropertyPath + "\\" + item.Name; //全局变量 var logicType = item.SourceType == SourceType.Metadata ? OThinker.H3.Data.DataLogicType.GlobalData : item.LogicType; PropertySchemaViewModel model = new PropertySchemaViewModel() { ParentProperty = parentProperty, ParentItemName = parentPropertyPath, ItemName = item.Name, LogicType = logicType.ToString(), LogicTypeName = Data.DataLogicTypeConvertor.ToLogicTypeName((Data.DataLogicType)logicType), ChildSchemaCode = item.ChildSchema == null ? null : item.ChildSchema.SchemaCode, DisplayName = string.Format("{0} [{1}]", item.DisplayName, item.Name), DefaultValue = item.DefaultValue == null ? null : item.DefaultValue.ToString(), Trackable = item.Trackable, Indexed = item.Indexed, Searchable = item.Searchable, Abstract = item.Abstract, IsReserved = DataModel.BizObjectSchema.IsReservedProperty(item.Name) }; //判断是否发布 publishedProperty = publishedSchema != null?publishedSchema.GetProperty(item.Name) : null; if (publishedProperty != null && publishedProperty.LogicType == item.LogicType) { model.IsPublished = true; chirenSchema = publishedSchema.GetProperty(item.Name).ChildSchema; } else { model.IsPublished = false; } if (item.ChildSchema != null && item.ChildSchema.Properties != null) { model.children = GetBizObjectChildren(item.ChildSchema.Properties, chirenSchema, parentProperty); } list.Add(model); } } return(list); }
/// <summary> /// 获取数据模型的列 /// </summary> /// <param name="Schema"></param> /// <returns></returns> private List <ReportSourceColumn> CreateColumnsBySchema(DataModel.BizObjectSchema Schema, string parentName = "") { List <ReportSourceColumn> ReportSourceColumns = new List <ReportSourceColumn>(); if (Schema.Properties != null) { for (int i = 0, j = Schema.Properties.Length; i < j; i++) { DataModel.PropertySchema p = Schema.Properties[i]; if (p.LogicType == Data.DataLogicType.Comment || p.LogicType == Data.DataLogicType.Attachment || p.LogicType == Data.DataLogicType.BizObject || p.LogicType == Data.DataLogicType.BoolArray || p.LogicType == Data.DataLogicType.ByteArray || p.LogicType == Data.DataLogicType.BizObjectArray ) { continue; } DataType DataType = DataType.String; switch (p.LogicType) { case DataLogicType.Decimal: case DataLogicType.Int: case DataLogicType.Double: case DataLogicType.Long: DataType = DataType.Numeric; break; case DataLogicType.DateTime: DataType = DataType.DateTime; break; default: DataType = DataType.String; break; } ReportSourceColumns.Add(new ReportSourceColumn() { ColumnCode = p.Name, ColumnName = p.Name, DisplayName = p.DisplayName, ReportSourceColumnType = ReportSourceColumnType.TableColumn, //DataRuleText = GetPropertySchemaRule(p), DataType = DataType, FunctionType = Function.Sum }); } } return(ReportSourceColumns); }
/// <summary> /// 从服务创建 /// </summary> /// <returns></returns> private H3.DataModel.BizObjectSchema FromDbTableAdapter(string code, string service) { H3.DataModel.BizObjectSchema schema = new DataModel.BizObjectSchema(DataModel.StorageType.PureServiceBased, code, false); // 获得服务定义 H3.DataModel.BizObjectSchemaUtility.CreateMethodMap(this.Engine.BizBus, schema, H3.DataModel.BizObjectSchema.MethodName_Create, H3.DataModel.MethodType.Normal, service, H3.BizBus.Declaration.DbTableAdapter_Method_Insert); H3.DataModel.BizObjectSchemaUtility.CreateMethodMap(this.Engine.BizBus, schema, H3.DataModel.BizObjectSchema.MethodName_Load, H3.DataModel.MethodType.Normal, service, H3.BizBus.Declaration.DbTableAdapter_Method_Load); H3.DataModel.BizObjectSchemaUtility.CreateMethodMap(this.Engine.BizBus, schema, H3.DataModel.BizObjectSchema.MethodName_Update, H3.DataModel.MethodType.Normal, service, H3.BizBus.Declaration.DbTableAdapter_Method_Update); H3.DataModel.BizObjectSchemaUtility.CreateMethodMap(this.Engine.BizBus, schema, H3.DataModel.BizObjectSchema.MethodName_Remove, H3.DataModel.MethodType.Normal, service, H3.BizBus.Declaration.DbTableAdapter_Method_Delete); H3.DataModel.BizObjectSchemaUtility.CreateMethodMap(this.Engine.BizBus, schema, H3.DataModel.BizObjectSchema.MethodName_GetList, H3.DataModel.MethodType.Filter, service, H3.BizBus.Declaration.DbTableAdapter_DefaultGetListName); return(schema); }
List <FormulaTreeNode> GetDataItems(string SchemaCode, string ParentID) { var RootNodeID = Guid.NewGuid().ToString(); FormulaTreeNode flowDataNode = new FormulaTreeNode() { ObjectID = RootNodeID, Text = "Designer.Designer_InstanceDataItem", Value = "", Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/folder_16.png", ParentID = ParentID }; List <FormulaTreeNode> lstDataItems = new List <FormulaTreeNode>(); lstDataItems.Add(flowDataNode); WorkflowClause clause = this.Engine.WorkflowManager.GetClause(SchemaCode); if (clause != null) { SchemaCode = clause.BizSchemaCode; } if (!string.IsNullOrEmpty(SchemaCode)) { DataModel.BizObjectSchema BizSchema = this.Engine.BizObjectManager.GetDraftSchema(SchemaCode); if (BizSchema != null) { if (BizSchema != null && BizSchema.Properties != null) { foreach (DataModel.PropertySchema Property in BizSchema.Properties) { //不显示保留数据项 if (!DataModel.BizObjectSchema.IsReservedProperty(Property.Name)) { lstDataItems.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), IsLeaf = true, ParentID = RootNodeID, Text = Property.DisplayName, Value = Property.Name }); ; } } } } } return(lstDataItems); }
/// <summary> /// 创建子对象 /// </summary> /// <param name="propertyName">属性名称</param> /// <returns>子对象</returns> private DataModel.BizObjectSchema CreateChildSchema(string propertyName) { DataModel.PropertySchema oldPropertySchema = this.CurrentSchema.GetProperty(this.SelectedProperty); H3.DataModel.BizObjectSchema childSchema = null; if (oldPropertySchema == null || (oldPropertySchema != null && oldPropertySchema.ChildSchema == null)) { childSchema = new DataModel.BizObjectSchema( this.CurrentSchema.StorageType == DataModel.StorageType.PureServiceBased ? DataModel.StorageType.PureServiceBased : DataModel.StorageType.DataList, propertyName, //this.txtChildSchemaCode.Text, false); } else { childSchema = oldPropertySchema.ChildSchema; childSchema.SchemaCode = propertyName; } return(childSchema); }
private bool ParseParam() { string code = SchemaCode; if (string.IsNullOrEmpty(code)) { this.Schema = null; } else { this.Schema = this.Engine.BizObjectManager.GetDraftSchema(code); } if (this.Schema == null) { return(false); //业务对象模式不存在,或者已经被删除 //this.ShowErrorMessage(this.PortalResource.GetString("EditBizObjectSchema_Msg0")); //this.CloseCurrentTabPage(); //Response.End(); } this.PublishedSchema = this.Engine.BizObjectManager.GetPublishedSchema(this.Schema.SchemaCode); return(true); }
/// <summary> /// 读取配置最原始的的列 /// </summary> /// <param name="ReportSource"></param> /// <returns></returns> private List <ReportSourceColumn> GetOriginalColumnDataBySetting(ReportSource ReportSource) { List <ReportSourceColumn> ReportSourceColumns = new List <ReportSourceColumn>(); if (ReportSource.ReportSourceType == ReportSourceType.H3System && !string.IsNullOrWhiteSpace(ReportSource.SchemaCode)) {//数据模型 DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(ReportSource.SchemaCode); if (schema != null) { ReportSourceColumns.AddRange(CreateColumnsBySchema(schema)); } } else {//业务数据配置 //BizDbConnectionConfig DBConfig = this.Engine.SettingManager.GetBizDbConnectionConfig(ReportSource.DbCode); Analytics.AnalyticalQuery Query = this.Engine.BPAQuery.GetAnalyticalQuery(this.Engine, ReportSource); if (null != Query) { ReportSourceColumns = Query.GetTableColumns(ReportSource.TableNameOrCommandText, ReportSource.DataSourceType); } } return(ReportSourceColumns); }
public JsonResult SaveMasterPackage(MasterPackageViewModel model) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(); if (string.IsNullOrWhiteSpace(model.Code)) { result.Success = false; result.Message = "EditBizObjectSchema.CodeNotNull"; return Json(result, JsonRequestBehavior.AllowGet); //this.ShowErrorMessage(this.PortalResource.GetString("BizOperation_CodeNotNull")); } H3.DataModel.BizObjectSchema schema = null; if (model.IsImport) { if (!string.IsNullOrEmpty(model.BizService)) { schema = this.FromDbTableAdapter(model.Code, model.BizService); schema.DisplayName = model.DisplayName ?? schema.SchemaCode; } } else { ////手工新建 //if (string.IsNullOrWhiteSpace(model.DisplayName)) //{ // result.Success = false; // result.Message = "EditBizObjectSchema.DisplayNameNotNull"; // return Json(result, JsonRequestBehavior.AllowGet); //} StorageType storageType = (StorageType)int.Parse(model.StorageType); schema = new DataModel.BizObjectSchema(storageType, model.Code.Trim(), storageType != StorageType.PureServiceBased); schema.DisplayName = model.DisplayName ?? schema.SchemaCode; } if (schema == null) { result.Success = false; result.Message = "msgGlobalString.CreateFailed"; return Json(result, JsonRequestBehavior.AllowGet); } //添加校验 if (schema.SchemaCode.Length > BizObjectSchema.MaxCodeLength) { result.Success = false; result.Message = "EditBizObjectSchema.Msg1"; result.Extend = BizObjectSchema.MaxCodeLength; return Json(result, JsonRequestBehavior.AllowGet); //this.ShowWarningMessage(this.PortalResource.GetString("BizObjectSchema_Mssg1") + BizObjectSchema.MaxCodeLength); } //校验编码规范 System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(BizObjectSchema.CodeRegex); if (!regex.IsMatch(schema.SchemaCode)) { result.Success = false; result.Message = "EditBizObjectSchemaProperty.Msg2"; return Json(result, JsonRequestBehavior.AllowGet); //this.ShowWarningMessage(this.PortalResource.GetString("BizObjectSchema_Mssg2")); } if (!this.Engine.BizObjectManager.AddDraftSchema(schema)) { //保存失败,可能是由于编码重复 result.Success = false; result.Message = "EditBizObjectSchema.Msg3"; return Json(result, JsonRequestBehavior.AllowGet); } else { // 添加成功,这里还是需要写入FuntionNode节点的,为了跟流程包里的数据模型节点区别 Acl.FunctionNode node = new Acl.FunctionNode (schema.SchemaCode, schema.DisplayName, "", "", FunctionNodeType.BizObject, model.ParentCode, 0 ); this.Engine.FunctionAclManager.AddFunctionNode(node); } result.Success = true; result.Message = "msgGlobalString.SaveSuccess"; result.Extend = model.ParentId; return Json(result, JsonRequestBehavior.AllowGet); })); }
/// <summary> /// 获取提示信息 /// </summary> /// <param name="SchemaCode"></param> /// <param name="RuleCode"></param> /// <returns></returns> public JsonResult GetFormulaTips(string SchemaCode, string RuleCode) { return(ExecuteFunctionRun(() => { FormulaTipViewModel model = new FormulaTipViewModel(); #region 参与者函数 List <object> lstParticipantFunctions = new List <object>(); foreach (OThinker.H3.Math.Function Function in OThinker.H3.Math.FunctionFactory.Create(this.Engine.Organization, this.Engine.BizBus)) { if (Function is OThinker.H3.Math.Function) { //ERROR:这两个函数名称不是Public所以不能访问,下行代码写死了函数名称 //以下两个函数不显示 if (Function.FunctionName == "OrgCodeToID" || Function.FunctionName == "OrgIDToCode") { continue; } OThinker.H3.Math.Parameter returns = Function.GetHelper().Return; //构造脚本 lstParticipantFunctions.Add(new { FunctionName = Function.FunctionName, Helper = ((OThinker.H3.Math.Function)Function).GetHelper(), ReturnType = returns == null ? null : returns.LogicTypes }); } } model.ParticipantFunctions = lstParticipantFunctions; #endregion #region 参数类型 // <Key,{Name,DisplayName}> Dictionary <string, object> LogicTypeDictionary = new Dictionary <string, object>(); foreach (Data.DataLogicType LogicType in Enum.GetValues(typeof(Data.DataLogicType))) { LogicTypeDictionary.Add(((int)LogicType).ToString(), new { Name = LogicType.ToString(), DisplayName = Data.DataLogicTypeConvertor.ToLogicTypeName(LogicType) }); } model.LogicTypes = LogicTypeDictionary; #endregion #region 规则环境 if (!string.IsNullOrWhiteSpace(RuleCode)) { OThinker.H3.BizBus.BizRule.BizRuleTable rule = this.Engine.BizBus.GetBizRule(RuleCode); List <object> lstRuleElement = new List <object>(); if (rule != null) { if (rule.DataElements != null) { foreach (OThinker.H3.BizBus.BizRule.BizRuleDataElement RuleElement in rule.DataElements) { //词汇表 lstRuleElement.Add(new { Name = RuleElement.ElementName, DisplayName = RuleElement.DisplayName, LogicType = RuleElement.LogicType }); } } } model.RuleElement = lstRuleElement; } #endregion #region 流程环境 if (!string.IsNullOrEmpty(SchemaCode)) { ////系统数据 List <FormulaTreeNode> listSystemDatas = GetSystemDataItemNode(""); ////获取所有节点的文本集合,供智能感知 List <string> lstNodeStrings = new List <string>(); AddTreeString(listSystemDatas, lstNodeStrings); model.InstanceVariables = lstNodeStrings; } #endregion #region 数据模型环境 if (!string.IsNullOrEmpty(SchemaCode)) { DataModel.BizObjectSchema BizSchema = this.Engine.BizObjectManager.GetDraftSchema(SchemaCode); if (BizSchema != null) { if (BizSchema != null && BizSchema.Properties != null) { List <object> lstDataItems = new List <object>(); foreach (DataModel.PropertySchema Property in BizSchema.Properties) { //不显示保留数据项 if (!DataModel.BizObjectSchema.IsReservedProperty(Property.Name)) { lstDataItems.Add(new { Name = Property.Name, DisplayName = Property.DisplayName, LogicType = Property.LogicType }); ; } } model.DataItems = lstDataItems; } } } #endregion return Json(model, JsonRequestBehavior.AllowGet); })); }
/// <summary> /// 获取联动规则的数据,数据源来自 BizBus /// </summary> protected void GetLinkageData() { string targetId = Request["TargetID"]; string schemaCode = Request["SchemaCode"]; string filterMethod = Request["FilterMethod"]; string queryCode = Request["QueryCode"]; string queryPropertyName = Request["QueryPropertyName"]; string queryPropertyValue = Request["QueryPropertyValue"]; string textDataField = Request["TextDataField"]; string valueDataField = Request["ValueDataField"]; // 获取查询对象 //BizQuery query = OThinker.H3.WorkSheet.AppUtility.Engine.BizBus.GetBizQuery(schemaCode, queryCode); DataModel.BizQuery query = AppUtility.Engine.BizObjectManager.GetBizQuery(queryCode); // 构造查询条件 OThinker.H3.BizBus.Filter.Filter filter = new BizBus.Filter.Filter(); OThinker.H3.BizBus.Filter.And and = new And(); filter.Matcher = and; ItemMatcher propertyMatcher = null; if (query.QueryItems != null) { string[] values = queryPropertyValue.Split(new string[] { "," }, StringSplitOptions.None); int i = 0; foreach (DataModel.BizQueryItem queryItem in query.QueryItems) { // 增加系统参数条件 if (queryItem.FilterType == DataModel.FilterType.SystemParam) { propertyMatcher = new OThinker.H3.BizBus.Filter.ItemMatcher(queryItem.PropertyName, OThinker.Data.ComparisonOperatorType.Equal, SheetUtility.GetSystemParamValue(UserValidatorFactory.CurrentUser, queryItem.SelectedValues)); and.Add(propertyMatcher); continue; } else if (values.Length > 1) { if (values.Length > i) { propertyMatcher = new OThinker.H3.BizBus.Filter.ItemMatcher(queryItem.PropertyName, queryItem.FilterType == DataModel.FilterType.Contains ? OThinker.Data.ComparisonOperatorType.Contain : OThinker.Data.ComparisonOperatorType.Equal, values[i]); and.Add(propertyMatcher); } } else if (queryItem.PropertyName == queryPropertyName) { propertyMatcher = new OThinker.H3.BizBus.Filter.ItemMatcher(queryPropertyName, queryItem.FilterType == DataModel.FilterType.Contains ? OThinker.Data.ComparisonOperatorType.Contain : OThinker.Data.ComparisonOperatorType.Equal, queryPropertyValue); and.Add(propertyMatcher); } i++; } } DataModel.BizObjectSchema schema = AppUtility.Engine.BizObjectManager.GetPublishedSchema(schemaCode); Dictionary <string, string> SelectItems = new Dictionary <string, string>(); if (schema != null) { // 调用查询获取数据源 //OThinker.H3.DataModel.BizObject[] objs = schema.GetList(OThinker.H3.WorkSheet.AppUtility.Engine.BizBus, // this.UserValidator.UserID, // filterMethod, // filter); DataModel.BizObject[] objs = schema.GetList( AppUtility.Engine.Organization, AppUtility.Engine.MetadataRepository, AppUtility.Engine.BizObjectManager, UserValidatorFactory.CurrentUser != null ? UserValidatorFactory.CurrentUser.UserID : string.Empty, filterMethod, filter); DataTable dtSource = DataModel.BizObjectUtility.ToTable(schema, objs); foreach (DataRow row in dtSource.Rows) { SelectItems.Add(row[valueDataField] + string.Empty, row[textDataField] + string.Empty); } } Response.Clear(); Response.Write(JSSerializer.Serialize(SelectItems)); Response.Buffer = true; }
/// <summary> /// 验证公式 /// </summary> /// <param name="Formula"></param> /// <param name="SchemaCode">流程模板编码</param> /// <param name="RuleCode"></param> /// <returns></returns> public JsonResult Validate(string Formula, string SchemaCode, string RuleCode) { return(ExecuteFunctionRun(() => { //校验结果 ActionResult result = new ActionResult(true, ""); Formula = Server.HtmlDecode(Formula); //错误项 string[] errorItems = null; //错误信息 List <string> Errors = new List <string>(); if (!string.IsNullOrEmpty(Formula)) { // 所有数据项的名称 Dictionary <string, string> formulaItemNames = new Dictionary <string, string>(); string formulaId = Guid.NewGuid().ToString(); formulaItemNames.Add(formulaId, Formula); //所有项名称:数据项、流程关键字 List <string> allItemNames = new List <string>(); //流程关键字 string[] words = OThinker.H3.Instance.Keywords.ParserFactory.GetKeywords(); allItemNames.AddRange(words); //业务模型数据项 //string SchemaCode = CurrentParams[ConstantString.Param_SchemaCode]; if (!string.IsNullOrEmpty(SchemaCode)) { DataModel.BizObjectSchema Schema = this.Engine.BizObjectManager.GetDraftSchema(SchemaCode); //如果一个流程包含有多个流程模板的时候,需要重新计算一下shcema if (Schema == null) { WorkflowTemplate.WorkflowClause clause = this.Engine.WorkflowManager.GetClause(SchemaCode); if (clause != null) { Schema = this.Engine.BizObjectManager.GetDraftSchema(clause.BizSchemaCode); } } if (Schema != null) { if (Schema.IsQuotePacket) { Schema = this.Engine.BizObjectManager.GetDraftSchema(Schema.BindPacket); } foreach (DataModel.PropertySchema item in Schema.Properties) { allItemNames.Add(item.Name); } } } //string RuleCode = CurrentContext.Request[ConstantString.Param_RuleCode]; // 业务规则数据项 if (!string.IsNullOrEmpty(RuleCode)) { OThinker.H3.BizBus.BizRule.BizRuleTable rule = this.Engine.BizBus.GetBizRule(RuleCode); if (rule != null) { if (rule.DataElements != null) { foreach (OThinker.H3.BizBus.BizRule.BizRuleDataElement RuleElement in rule.DataElements) { allItemNames.Add(RuleElement.ElementName); } } } } Function[] fs = FunctionFactory.Create(this.Engine.Organization, this.Engine.BizBus); Dictionary <string, Function> fDic = new Dictionary <string, Function>(); if (fs != null) { foreach (OThinker.H3.Math.Function f in fs) { fDic.Add(f.FunctionName, f); } } result.Success = FormulaParser.Validate(Formula, fDic, allItemNames, ref Errors); result.Message = string.Join(";", Errors); } return Json(result, JsonRequestBehavior.AllowGet); })); }
/// <summary> /// 输出流程模板包、流程模板 /// </summary> public JsonResult RegisterActivityTemplateConfigs(string WorkflowCode, int WorkflowVersion, string InstanceID) { return(ExecuteFunctionRun(() => { WorkflowCode = Server.UrlDecode(WorkflowCode); //解决WorkflowCode为汉字的情景 ActivityTemplateConfigsViewModel model = new ActivityTemplateConfigsViewModel(); if ((WorkflowCode == null || WorkflowCode == "") && WorkflowVersion == -1) { Instance.InstanceContext InstanceContext = this.Engine.InstanceManager.GetInstanceContext(InstanceID); if (InstanceContext != null) { WorkflowCode = InstanceContext.WorkflowCode; WorkflowVersion = InstanceContext.WorkflowVersion; model.InstanceContext = InstanceContext; model.ExceptionActivities = this.ExceptionActivities(InstanceID); } } #region 是否锁定 model.IsControlUsable = BizWorkflowPackageLockByID(WorkflowCode); #endregion #region 流程模板 WorkflowDocument WorkflowTemplate = null; if (WorkflowVersion == WorkflowDocument.NullWorkflowVersion) { WorkflowTemplate = this.Engine.WorkflowManager.GetDraftTemplate(WorkflowCode); } else { WorkflowTemplate = this.Engine.WorkflowManager.GetPublishedTemplate(WorkflowCode, WorkflowVersion); } #endregion #region 数据模型 //数据项 List <string> lstDataItems = new List <string>(); //所有属性 List <object> lstProperties = new List <object>(); //输出到前台的数据项 List <object> lstFrontDataItems = new List <object>(); //允许设置权限的数据项 List <string> lstPermissionDataItems = new List <string>(); //参与者数据项 List <string> lstUserDataItems = new List <string>(); //逻辑型数据项 List <string> lstBoolDataItems = new List <string>(); //业务方法名称列表 List <string> lstBizMethodNames = new List <string>(); List <object> lstAllDataItems = new List <object>();//系统数据项,+流程数据项,流程设计选择时使用 WorkflowClause Clause = this.Engine.WorkflowManager.GetClause(WorkflowCode); if (Clause != null && Clause.BizSchemaCode != null) { //ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "ClauseName", "var ClauseName=" + JSSerializer.Serialize(Clause.DisplayName + string.Empty) + ";", true); model.ClauseName = Clause.WorkflowName + string.Empty; //流程模板浏览页面地址 // ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "WorkflowViewUrl", "var WorkflowViewUrl=" + JSSerializer.Serialize(GetPortalRoot(this.Page) + ConstantString.PagePath_WorkflowDesigner) + ";", true); model.WorkflowViewUrl = PortalRoot + ConstantString.PagePath_WorkflowDesigner; DataModel.BizObjectSchema BizObject = this.Engine.BizObjectManager.GetDraftSchema(Clause.BizSchemaCode); if (BizObject != null) { //流程包 object Package = new { SchemaCode = BizObject.SchemaCode }; //ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "Package", "var Package=" + JSSerializer.Serialize(Package) + ";", true); model.Package = Package; #region 页标签 if (Clause != null) { string TabName = string.IsNullOrEmpty(Clause.WorkflowName) ? Clause.WorkflowCode : Clause.WorkflowName; if (WorkflowVersion != WorkflowDocument.NullWorkflowVersion) { TabName += "[" + WorkflowVersion + "]"; } else { TabName += "[设计]"; } //SetTabHeader(TabName);//前台执行 model.TabName = TabName; } #endregion List <object> lstBizMethods = new List <object>(); //可选的业务方法 if (BizObject.Methods != null) { foreach (var Method in BizObject.Methods) { if (!DataModel.BizObjectSchema.IsDefaultMethod(Method.MethodName) && Method.MethodType == DataModel.MethodType.Normal) { lstBizMethodNames.Add(Method.MethodName); lstBizMethods.Add(new { Text = Method.FullName, Value = Method.MethodName }); } } } model.BizMethods = lstBizMethods; //ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "BizMethods", "var BizMethods=" + JSSerializer.Serialize(lstBizMethods.ToArray()) + ";", true); #region 数据项、参与者、逻辑型数据项 //数据项、参与者、逻辑型数据项 if (BizObject.Properties != null) { List <Object> listNotifyCondition = new List <object>(); List <Object> listApprovalDataItem = new List <object>(); List <Object> listCommentDataItem = new List <object>(); listNotifyCondition.Add(new { Text = string.Empty, Value = string.Empty }); listApprovalDataItem.Add(new { Text = string.Empty, Value = string.Empty }); listCommentDataItem.Add(new { Text = string.Empty, Value = string.Empty }); foreach (DataModel.PropertySchema Property in BizObject.Properties) { //不显示保留数据项 if (!DataModel.BizObjectSchema.IsReservedProperty(Property.Name)) { lstDataItems.Add(Property.Name); lstProperties.Add(new { Text = Property.DisplayName, Value = Property.Name }); lstFrontDataItems.Add(new { Text = Property.DisplayName, Value = Property.Name, //标记子表标题行 ItemType = Property.LogicType == Data.DataLogicType.BizObjectArray ? "SubTableHeader" : string.Empty }); lstPermissionDataItems.Add(Property.Name); //通知条件 TODO // sltNotifyCondition.Items.Add(new ListItem(Property.DisplayName, Property.Name)); listNotifyCondition.Add(new { Text = Property.DisplayName, Value = Property.Name }); //子表 if ((Property.LogicType == Data.DataLogicType.BizObject || Property.LogicType == Data.DataLogicType.BizObjectArray) && Property.ChildSchema != null && Property.ChildSchema.Properties != null) { foreach (DataModel.PropertySchema ChildProperty in Property.ChildSchema.Properties) { if (!DataModel.BizObjectSchema.IsReservedProperty(ChildProperty.Name)) { lstFrontDataItems.Add(new { Text = Property.DisplayName + "." + ChildProperty.DisplayName, Value = Property.Name + "." + ChildProperty.Name }); lstPermissionDataItems.Add(Property.Name + "." + ChildProperty.Name); } } } //参与者 else if (Property.LogicType == Data.DataLogicType.SingleParticipant || Property.LogicType == Data.DataLogicType.MultiParticipant) { lstUserDataItems.Add(Property.Name); } //逻辑型 else if (Property.LogicType == Data.DataLogicType.Bool) { lstBoolDataItems.Add(Property.Name); //TODO listApprovalDataItem.Add(new { Text = Property.DisplayName, Value = Property.Name }); } //文本 else if (Property.LogicType == Data.DataLogicType.String) { listCommentDataItem.Add(new { Text = Property.DisplayName, Value = Property.Name }); } //else if (Property.LogicType == Data.DataLogicType.TimeSpan) // sltAllowedTime.Items.Add(new ListItem(Property.DisplayName, Property.Name)); } } model.NotifyCondition = listNotifyCondition; model.ApprovalDataItem = listApprovalDataItem; model.CommentDataItem = listCommentDataItem; } #endregion #region 关联对象权限 if (BizObject.Associations != null) { foreach (DataModel.BizObjectAssociation association in BizObject.Associations) { DataModel.BizObjectSchema AssociatedSchema = this.Engine.BizObjectManager.GetPublishedSchema(association.AssociatedSchemaCode); if (AssociatedSchema != null && AssociatedSchema.Properties != null) { lstFrontDataItems.Add(new { Text = association.DisplayName, Value = association.Name, //标记子表标题行 ItemType = "SubTableHeader" }); lstPermissionDataItems.Add(association.Name); foreach (DataModel.PropertySchema AssociatedChildProperty in AssociatedSchema.Properties) { if (!DataModel.BizObjectSchema.IsReservedProperty(AssociatedChildProperty.Name)) { lstFrontDataItems.Add(new { Text = association.DisplayName + "." + AssociatedChildProperty.DisplayName, Value = association.Name + "." + AssociatedChildProperty.Name }); lstPermissionDataItems.Add(association.Name + "." + AssociatedChildProperty.Name); } } } } } #endregion #region 可选表单 //TODO // sltSheetCodes.Items.Clear(); List <object> listSheetCodes = new List <object>(); Sheet.BizSheet[] Sheets = this.Engine.BizSheetManager.GetBizSheetBySchemaCode(Clause.BizSchemaCode); if (Sheets != null) { foreach (Sheet.BizSheet Sheet in Sheets) { listSheetCodes.Add(new { Text = Sheet.DisplayName + "[" + Sheet.SheetCode + "]", Value = Sheet.SheetCode }); } } model.SheetCodes = listSheetCodes; #endregion } } model.DataItems = lstFrontDataItems; #endregion //设置可选的数据项 TODO 前台处理 //SetDataItems(lstDataItems); #region 前置条件, Text前台需要解析多语言包 // TODO List <object> listEntryCondition = new List <object>(); listEntryCondition.Add(new { Text = "Designer.Designer_AnyOne", Value = (int)EntryConditionType.Any + string.Empty, Indext = 0 }); listEntryCondition.Add(new { Text = "Designer.Designer_All", Value = (int)EntryConditionType.All + string.Empty, Index = 1 }); model.EntryCondition = listEntryCondition; #endregion #region 步异步 List <object> listSync = new List <object>(); listSync.Add(new { Text = "Designer.Designer_Sync", Value = "true", Index = 0 }); listSync.Add(new { Text = "Designer.Designer_Async", Value = "false", Index = 1 }); model.SyncOrASync = listSync; #endregion #region 参与者策略 //TODO List <object> listParAbNormalPolicy = GetParAbnormalPolicy(); model.ParAbnormalPolicy = listParAbNormalPolicy; #endregion #region 发起者参与者策略 List <object> listOriginatorParAbnormalPolicy = GetOriginatorParAbnormalPolicy(); model.OriginatorParAbnormalPolicy = listOriginatorParAbnormalPolicy; #endregion #region 参与方式:单人/多人 //TODO List <object> listParticipantMode = new List <object>(); listParticipantMode.Add(new { Text = "Designer.Designer_Single", Value = (int)ActivityParticipateType.SingleParticipant + string.Empty, Index = 0 }); listParticipantMode.Add(new { Text = "Designer.Designer_Mulit", Value = (int)ActivityParticipateType.MultiParticipants + string.Empty, Index = 1 }); model.ParticipantMode = listParticipantMode; #endregion #region 可选参与方式:并行/串行 //TODO List <object> listParticipateMethod = new List <object>(); listParticipateMethod.Add(new { Text = "Designer.Designer_Parallel", Value = (int)ParticipateMethod.Parallel + string.Empty, Index = 0 }); listParticipateMethod.Add(new { Text = "Designer.Designer_Serial", Value = (int)ParticipateMethod.Serial + string.Empty, Index = 1 }); model.ParticipateMethod = listParticipateMethod; #endregion #region 提交时检查 //TODO List <object> listSubmittingValidation = new List <object>(); listSubmittingValidation.Add(new { Text = "Designer.Designer_NotCheck", Value = (int)SubmittingValidationType.None + string.Empty, Index = 0 }); listSubmittingValidation.Add(new { Text = "Designer.Designer_CheckParticipant", Value = (int)SubmittingValidationType.CheckNextParIsNull + string.Empty, Index = 1 }); model.SubmittingValidation = listSubmittingValidation; #endregion #region 子流程数据映射类型 List <object> lstMapTypes = new List <object>(); foreach (string WorkflowDataMapInOutType in Enum.GetNames(typeof(OThinker.H3.WorkflowTemplate.WorkflowDataMap.InOutType))) { //不需要使用InOutAppend if (WorkflowDataMapInOutType != OThinker.H3.WorkflowTemplate.WorkflowDataMap.InOutType.InOutAppend.ToString()) { lstMapTypes.Add(new { Text = WorkflowDataMapInOutType, Value = (int)Enum.Parse(typeof(OThinker.H3.WorkflowTemplate.WorkflowDataMap.InOutType), WorkflowDataMapInOutType) + string.Empty }); } } model.MapTypes = lstMapTypes; #endregion #region 表单锁 //TODO List <object> listLockLevel = new List <object>(); listLockLevel.Add(new { Text = "Designer.Designer_PopupManyPeople", Value = (int)LockLevel.Warning + string.Empty }); listLockLevel.Add(new { Text = "Designer.Designer_ProhibitOneTime", Value = (int)LockLevel.Mono + string.Empty }); listLockLevel.Add(new { Text = "Designer.Designer_CancelExclusive", Value = (int)LockLevel.CancelOthers + string.Empty }); model.LockLevel = listLockLevel; #endregion #region 锁策略 //TODO List <object> listLockPlicy = new List <object>(); listLockPlicy.Add(new { Text = "Designer.Designer_NotLock", Value = (int)LockPolicy.None + string.Empty }); listLockPlicy.Add(new { Text = "Designer.Designer_LockOpen", Value = (int)LockPolicy.Open + string.Empty }); listLockPlicy.Add(new { Text = "Designer.Designer_LockRequest", Value = (int)LockPolicy.Request + string.Empty }); model.LockPolicy = listLockPlicy; #endregion #region 超时策略 //TODO List <object> listOvertimePolicy = new List <object>(); listOvertimePolicy.Add(new { Text = "Designer.Designer_ExecuteStrategy", Value = (int)OvertimePolicy.None + string.Empty }); listOvertimePolicy.Add(new { Text = "Designer.Designer_Approval", Value = (int)OvertimePolicy.Approve + string.Empty }); //超时审批拒绝,暂时关闭 //listOvertimePolicy.Add(new { Text = "Designer.Designer_ApprovalVote", Value = (int)OvertimePolicy.Disapprove + string.Empty }); listOvertimePolicy.Add(new { Text = "Designer.Designer_AutoComplete", Value = (int)OvertimePolicy.Finish + string.Empty }); listOvertimePolicy.Add(new { Text = "Designer.Designer_RemindStrategy1", Value = (int)OvertimePolicy.Remind1 + string.Empty }); listOvertimePolicy.Add(new { Text = "Designer.Designer_RemindStrategy2", Value = (int)OvertimePolicy.Remind2 + string.Empty }); //超时策略3,4在消息设置中去除,关闭 //listOvertimePolicy.Add(new { Text = "Designer.Designer_RemindStrategy3", Value = (int)OvertimePolicy.Remind3 + string.Empty }); //listOvertimePolicy.Add(new { Text = "Designer.Designer_RemindStrategy4", Value = (int)OvertimePolicy.Remind4 + string.Empty }); model.OvertimePolicy = listOvertimePolicy; #endregion #region 数据项映射类型 List <object> lstDataDisposalTypes = new List <object>(); foreach (string DisposalTypeString in Enum.GetNames(typeof(DataDisposalType))) { lstDataDisposalTypes.Add(new { Text = DisposalTypeString, Value = (int)Enum.Parse(typeof(DataDisposalType), DisposalTypeString) + string.Empty }); } model.DataDisposalTypes = lstDataDisposalTypes; #endregion #region 初始化活动的数据权限 if (WorkflowVersion == WorkflowDocument.NullWorkflowVersion && WorkflowTemplate != null && WorkflowTemplate.Activities != null) {//流程模板编码\显示名称 Dictionary <string, string> dicWorkflowNames = new Dictionary <string, string>(); //整理数据项权限 foreach (Activity Activity in WorkflowTemplate.Activities) { if (Activity is ParticipativeActivity) { ParticipativeActivity ParticipativeActivity = (ParticipativeActivity)Activity; List <string> lstValidPermissionItemNames = new List <string>(); List <DataItemPermission> lstValidDataItemPermissions = new List <DataItemPermission>(); if (ParticipativeActivity.DataPermissions == null) { ParticipativeActivity.DataPermissions = lstValidDataItemPermissions.ToArray(); } if (ParticipativeActivity.DataPermissions != null) { foreach (DataItemPermission DataItemPermission in ParticipativeActivity.DataPermissions) { if (lstPermissionDataItems.Contains(DataItemPermission.ItemName)) { lstValidDataItemPermissions.Add(DataItemPermission); lstValidPermissionItemNames.Add(DataItemPermission.ItemName); } } } foreach (string ItemName in lstPermissionDataItems) { if (!lstValidPermissionItemNames.Contains(ItemName)) { lstValidDataItemPermissions.Add(new DataItemPermission() { ItemName = ItemName, Visible = true, MobileVisible = true }); lstValidPermissionItemNames.Add(ItemName); } } ParticipativeActivity.DataPermissions = lstValidDataItemPermissions.ToArray(); } //子流程:获取流程模板显示名称 else if (Activity is SubInstanceActivity) { string _SubWorkflowCode = ((SubInstanceActivity)Activity).WorkflowCode; if (!string.IsNullOrEmpty(_SubWorkflowCode) && !dicWorkflowNames.ContainsKey(_SubWorkflowCode.ToLower())) { WorkflowClause _SubClause = this.Engine.WorkflowManager.GetClause(_SubWorkflowCode); dicWorkflowNames.Add(_SubWorkflowCode.ToLower(), _SubClause == null ? _SubWorkflowCode : _SubClause.WorkflowName); } } } //流程模板编码\显示名称 model.WorkflowNames = dicWorkflowNames; } #endregion model.WorkflowTemplate = WorkflowTemplate; #region 数据项 model.DataItemsSelect = GetALLDataItems(WorkflowCode); #endregion return Json(model, JsonRequestBehavior.AllowGet); })); }
EditSimulationViewModel ShowDataItems(string workflowCode, DataModel.BizObjectSchema Schema, InstanceSimulation simulation, Dictionary <string, object> valueTable, EditSimulationViewModel model) { if (Schema == null || Schema.Properties == null) { return(model); } //<ItemName,Values> WorkflowTemplate.PublishedWorkflowTemplate tempalte = this.Engine.WorkflowManager.GetDefaultWorkflow(workflowCode); Dictionary <string, string[]> ExistItems = new Dictionary <string, string[]>(); Dictionary <string, bool> ActivityIgnore = new Dictionary <string, bool>(); if (valueTable != null) { foreach (string key in valueTable.Keys) { string[] values = new string[1]; values[0] = valueTable[key] + string.Empty; ExistItems.Add(key, values); } } else if (simulation != null && simulation.DataItems != null && simulation.DataItems.Length > 0) { foreach (InstanceSimulationDataItem item in simulation.DataItems) { if (!ExistItems.ContainsKey(item.ItemName)) { ExistItems.Add(item.ItemName, item.ItemValues); } if (!ActivityIgnore.ContainsKey(item.ItemName)) { ActivityIgnore.Add(item.ItemName, item.Ignore); } } } //可设置的类型 Data.DataLogicType[] SetableLogicTypes = new Data.DataLogicType[] { Data.DataLogicType.Bool, //Data.DataLogicType.Comment, Data.DataLogicType.DateTime, Data.DataLogicType.Decimal, Data.DataLogicType.Double, //Data.DataLogicType.Html, Data.DataLogicType.Int, Data.DataLogicType.Long, Data.DataLogicType.MultiParticipant, Data.DataLogicType.ShortString, Data.DataLogicType.SingleParticipant, Data.DataLogicType.String, Data.DataLogicType.TimeSpan//, //Data.DataLogicType.Xml }; List <string> UserIDs = new List <string>(); foreach (DataModel.PropertySchema p in Schema.Properties) { if (!DataModel.BizObjectSchema.IsReservedProperty(p.Name) && (p.LogicType == Data.DataLogicType.SingleParticipant || p.LogicType == Data.DataLogicType.MultiParticipant) && ExistItems.ContainsKey(p.Name) && ExistItems[p.Name] != null) { foreach (string id in ExistItems[p.Name]) { UserIDs.Add(id); } } } foreach (WorkflowTemplate.Activity activity in tempalte.Activities) { if (activity.ActivityType == WorkflowTemplate.ActivityType.Start || activity.ActivityType == WorkflowTemplate.ActivityType.End) { continue; } if (activity.ActivityCode == tempalte.StartActivityCode) { continue; } if (ExistItems.ContainsKey(activity.ActivityCode)) { foreach (string id in ExistItems[activity.ActivityCode]) { UserIDs.Add(id); } } } OThinker.Organization.Unit[] Units = this.Engine.Organization.GetUnits(UserIDs.ToArray()).ToArray(); //<UserID,UserName> Dictionary <string, string> DicUnits = new Dictionary <string, string>(); if (Units != null) { foreach (OThinker.Organization.Unit u in Units) { if (!DicUnits.ContainsKey(u.ObjectID)) { DicUnits.Add(u.ObjectID, u.Name); } } } List <object> lstDataItems = new List <object>(); foreach (DataModel.PropertySchema p in Schema.Properties) { if (DataModel.BizObjectSchema.IsReservedProperty(p.Name)) { continue; } if (!SetableLogicTypes.Contains(p.LogicType)) { continue; } string DisplayValueString = string.Empty; if (ExistItems.ContainsKey(p.Name) && ExistItems[p.Name] != null && ExistItems[p.Name].Length > 0) { if (p.LogicType == Data.DataLogicType.SingleParticipant || p.LogicType == Data.DataLogicType.MultiParticipant) { foreach (string _Value in ExistItems[p.Name]) { if (DicUnits.ContainsKey(_Value)) { DisplayValueString += DicUnits[_Value] + ";"; } else { DisplayValueString += ";"; } } } else { DisplayValueString = string.Join(";", ExistItems[p.Name]); } } lstDataItems.Add(new { ItemName = p.Name, ItemValues = ExistItems.ContainsKey(p.Name) ? ExistItems[p.Name] : null, DisplayValueString = DisplayValueString, LogicType = OThinker.H3.Data.DataLogicTypeConvertor.ToLogicTypeName(p.LogicType), Editable = SetableLogicTypes.Contains(p.LogicType) }); } List <object> lstActivitys = new List <object>(); foreach (WorkflowTemplate.Activity activity in tempalte.Activities) { if (activity.ActivityType == WorkflowTemplate.ActivityType.Start || activity.ActivityType == WorkflowTemplate.ActivityType.End) { continue; } if (activity.ActivityCode == tempalte.StartActivityCode) { continue; } string DisplayValueString = string.Empty; if (ExistItems.ContainsKey(activity.ActivityCode) && ExistItems[activity.ActivityCode] != null && ExistItems[activity.ActivityCode].Length > 0) { foreach (string _Value in ExistItems[activity.ActivityCode]) { if (DicUnits.ContainsKey(_Value)) { DisplayValueString += DicUnits[_Value] + ";"; } else { DisplayValueString += ";"; } } } lstActivitys.Add(new { WorkflowTemplate = workflowCode, ActivityCode = activity.ActivityCode, ActivityName = activity.DisplayName, Participants = ExistItems.ContainsKey(activity.ActivityCode) ? ExistItems[activity.ActivityCode] : null, DisplayValueString = DisplayValueString, Ignore = ActivityIgnore.ContainsKey(activity.ActivityCode) ? ActivityIgnore[activity.ActivityCode] : false, Editable = true }); } model.DataItems = CreateLigerUIGridData(lstDataItems.ToArray()); model.Activitys = CreateLigerUIGridData(lstActivitys.ToArray()); return(model); }
/// <summary> /// 创建公式编辑器左边树 /// </summary> /// <param name="functionID"></param> /// <param name="nodes"></param> /// <returns></returns> protected List <FormulaTreeNode> GetFormulaTree(string SchemaCode, string RuleCode) { List <FormulaTreeNode> treeNodeList = new List <FormulaTreeNode>(); #region 输入 string InputObjectID = Guid.NewGuid().ToString();//构造一个ObjectID FormulaTreeNode InputNode = new FormulaTreeNode() { ObjectID = InputObjectID, Text = "FormulaEditor.FormulaEditor_Input", //显示 Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/in.png", //图标 IsLeaf = true, LoadDataUrl = "", //加载数据,组织结构时使用 FormulaType = FormulaType.Input.ToString(), //判断类型 Value = "", //存储值,点击时传递该值 ParentID = "" }; treeNodeList.Add(InputNode); #endregion #region 常量 string BlockObjectID = Guid.NewGuid().ToString();//构造一个ObjectID FormulaTreeNode BlockNode = new FormulaTreeNode() { ObjectID = BlockObjectID, Text = "FormulaEditor.FormulaEditor_Constant", //显示 Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/folder_16.png", //图标 IsLeaf = false, LoadDataUrl = "", //加载数据,组织结构时使用 FormulaType = FormulaType.Input.ToString(), //判断类型 Value = "", //存储值,点击时传递该值 ParentID = "" }; treeNodeList.Add(BlockNode); List <string> BlockValus = new List <string>(); BlockValus.Add("True"); BlockValus.Add("False"); BlockValus.Add("null"); foreach (string block in BlockValus) { FormulaTreeNode constNode = new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), Text = block, //显示 Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/const.png", //图标 IsLeaf = true, LoadDataUrl = "", //加载数据,组织结构时使用 FormulaType = FormulaType.Block.ToString(), //判断类型 Value = block, //存储值,点击时传递该值 ParentID = BlockObjectID }; treeNodeList.Add(constNode); } #endregion #region 函数 var FunctionRootID = Guid.NewGuid().ToString(); FormulaTreeNode FunctionParentNode = new FormulaTreeNode() { ObjectID = FunctionRootID, Text = "FormulaEditor.FormulaEditor_Funciton", Value = "", ParentID = "", LoadDataUrl = "", IsLeaf = false, FormulaType = FormulaType.Function.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/folder_16.png" //图标 }; treeNodeList.Add(FunctionParentNode); #endregion #region 参与者函数 List <object> lstParticipantFunctions = new List <object>(); foreach (OThinker.H3.Math.Function Function in OThinker.H3.Math.FunctionFactory.Create(this.Engine.Organization, this.Engine.BizBus)) { if (Function is OThinker.H3.Math.Function) { //ERROR:这两个函数名称不是Public所以不能访问,下行代码写死了函数名称 //以下两个函数不显示 if (Function.FunctionName == "OrgCodeToID" || Function.FunctionName == "OrgIDToCode") { continue; } OThinker.H3.Math.Parameter returns = Function.GetHelper().Return; //构造脚本 lstParticipantFunctions.Add(new { FunctionName = Function.FunctionName, Helper = ((OThinker.H3.Math.Function)Function).GetHelper(), ReturnType = returns == null ? null : returns.LogicTypes }); //构造树节点 FormulaTreeNode FunctionNode = new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), Text = Function.FunctionName, Value = Function.FunctionName, ParentID = FunctionRootID, LoadDataUrl = "", IsLeaf = true, FormulaType = FormulaType.ParticipantFunction.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/pf.png" //图标 }; treeNodeList.Add(FunctionNode); } } #endregion #region 参数类型 // <Key,{Name,DisplayName}> Dictionary <string, object> LogicTypeDictionary = new Dictionary <string, object>(); foreach (Data.DataLogicType LogicType in Enum.GetValues(typeof(Data.DataLogicType))) { LogicTypeDictionary.Add(((int)LogicType).ToString(), new { Name = LogicType.ToString(), DisplayName = Data.DataLogicTypeConvertor.ToLogicTypeName(LogicType) }); } //TODO //ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "LogicTypes", "var LogicTypes=" + this.JSSerializer.Serialize(LogicTypeDictionary) + ";", true); #endregion #region 规则环境 if (!string.IsNullOrWhiteSpace(RuleCode)) { OThinker.H3.BizBus.BizRule.BizRuleTable rule = this.Engine.BizBus.GetBizRule(RuleCode); if (rule != null) { string RuleRootID = Guid.NewGuid().ToString(); bool isleaf = rule.DataElements == null; FormulaTreeNode RuleRootNode = new FormulaTreeNode() { ObjectID = RuleRootID, Text = "FormulaEditor.FormulaEditor_Vocabulary", Value = "", ParentID = "", LoadDataUrl = "", IsLeaf = isleaf, FormulaType = FormulaType.RuleElement.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/folder_16.png" //图标 }; treeNodeList.Add(RuleRootNode); if (rule.DataElements != null) { foreach (OThinker.H3.BizBus.BizRule.BizRuleDataElement RuleElement in rule.DataElements) { //词汇表 FormulaTreeNode RuleElementNode = new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), Text = RuleElement.DisplayName + "[" + RuleElement.ElementName + "]", Value = RuleElement.ElementName, ParentID = RuleRootID, LoadDataUrl = "", IsLeaf = true, FormulaType = FormulaType.RuleElement.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/di.png" //图标 }; treeNodeList.Add(RuleElementNode); } } } } #endregion #region 流程环境 if (!string.IsNullOrEmpty(SchemaCode)) { //系统数据 List <FormulaTreeNode> listSystemDatas = GetSystemDataItemNode(""); treeNodeList.AddRange(listSystemDatas); } #endregion #region 数据模型环境 if (!string.IsNullOrEmpty(SchemaCode)) { DataModel.BizObjectSchema BizSchema = this.Engine.BizObjectManager.GetDraftSchema(SchemaCode); //如果 BizShceMa为空,把SchemaCode 作为流程编码查询对应的SchemaCode然后再查询 if (BizSchema == null) { WorkflowTemplate.WorkflowClause clause = this.Engine.WorkflowManager.GetClause(SchemaCode); { if (clause != null) { BizSchema = this.Engine.BizObjectManager.GetDraftSchema(clause.BizSchemaCode); } } } if (BizSchema != null) { if (BizSchema.IsQuotePacket) { BizSchema = this.Engine.BizObjectManager.GetDraftSchema(BizSchema.BindPacket); } string SchemaRootID = Guid.NewGuid().ToString(); FormulaTreeNode SchemaRootNode = new FormulaTreeNode() { ObjectID = SchemaRootID, Text = "FormulaEditor.FormulaEditor_BusinessPorperty", Value = "", ParentID = "", LoadDataUrl = "", IsLeaf = false, FormulaType = FormulaType.BizObjectSchema.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/folder_16.png" //图标 }; if (BizSchema != null && BizSchema.Properties != null) { List <object> lstDataItems = new List <object>(); foreach (DataModel.PropertySchema Property in BizSchema.Properties) { //不显示保留数据项 if (!DataModel.BizObjectSchema.IsReservedProperty(Property.Name)) { lstDataItems.Add(new { Name = Property.Name, DisplayName = Property.DisplayName, LogicType = Property.LogicType }); TreeNode DataItemNode = new TreeNode(Property.FullName, Property.Name); DataItemNode.NavigateUrl = "javascript:FormulaSettings.InsertVariable('" + Property.Name + "')"; DataItemNode.ImageUrl = "../../WFRes/_Content/designer/image/formula/di.png"; FormulaTreeNode SchemaNode = new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), Text = Property.DisplayName + "[" + Property.Name + "]", Value = Property.Name, ParentID = SchemaRootID, LoadDataUrl = "", IsLeaf = true, FormulaType = FormulaType.BizObjectSchema.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/di.png" //图标 }; treeNodeList.Add(SchemaNode); } } if (lstDataItems.Count == 0) { SchemaRootNode.IsLeaf = true; } treeNodeList.Add(SchemaRootNode); //ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "FunctionNames", "var DataItems=" + this.JSSerializer.Serialize(lstDataItems) + ";", true); } } } #endregion #region 符号 string OperatorRootID = Guid.NewGuid().ToString(); FormulaTreeNode OperatorRootNode = new FormulaTreeNode() { ObjectID = OperatorRootID, Text = "FormulaEditor.FormulaEditor_Symbol", Value = "", ParentID = "", LoadDataUrl = "", IsLeaf = false, FormulaType = FormulaType.Operator.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/folder_16.png" //图标 }; treeNodeList.Add(OperatorRootNode); //加减乘除 treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Plus) + " +", Value = "+", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Minus) + " -", Value = "-", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Mul) + " *", Value = "*", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Div) + " /", Value = "/", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Set) + " =", Value = "=", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); //大小等于 treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Gr) + " >", Value = ">", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.GrEq) + " >=", Value = ">=", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Ls) + " <", Value = "<", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.LsEq) + " <=", Value = "<=", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Eq) + " ==", Value = "==", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.NtEq) + " !=", Value = "!=", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); //与或非 treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.And) + " &&", Value = "&&", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Or) + " ||", Value = "||", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Not) + " !", Value = "!", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); //左/右括号 treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.LeftPar) + " (", Value = "(", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.RightPar) + " )", Value = ")", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); #endregion #region 组织架构 var OrgRootID = this.Engine.Organization.RootUnit.ObjectID; FormulaTreeNode OrgRootNode = new FormulaTreeNode() { ObjectID = OrgRootID, Text = this.Engine.Organization.RootUnit.Name, Value = OrgRootID, ParentID = "", LoadDataUrl = this.PortalRoot + "/Formula/LoadTreeData?unitID=" + OrgRootID, IsLeaf = false, FormulaType = FormulaType.Organization.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/folder_16.png" //图标 }; treeNodeList.Add(OrgRootNode); ////选中事件,前台处理 //if (!string.IsNullOrEmpty(Company.Code)) // UserTree.NavigateUrl = "javascript:FormulaSettings.InsertUser(" + JSSerializer.Serialize(UserTree.Text) + "," + JSSerializer.Serialize(Company.Code) + ")"; //else // UserTree.NavigateUrl = "javascript:FormulaSettings.InsertUser(" + JSSerializer.Serialize(UserTree.Text) + ",'" + JSSerializer.Serialize(Company.ObjectID) + "')"; #endregion return(treeNodeList); }
/// <summary> /// 执行保存 /// </summary> /// <returns>是否保存成功</returns> private bool SaveBizObjectSchemaProperty(BizObjectSchemaPropertyViewModel model, out ActionResult actionResult) { actionResult = new ActionResult(); string propertyName = model.PropertyName; string displayName = string.IsNullOrWhiteSpace(model.DisplayName) ? propertyName : model.DisplayName; // 检查选中的参数 Data.DataLogicType logicType = (Data.DataLogicType)Enum.Parse(typeof(Data.DataLogicType), model.LogicType); object defaultValue;//默认值 if (model.DefaultValue == string.Empty) { defaultValue = null; } else if (!DataValidator(model, propertyName, logicType, out defaultValue, out actionResult)) {//数据校验 return(false); } // 校验编码规范 System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(BizObjectSchema.CodeRegex); if (!regex.IsMatch(propertyName)) { actionResult.Success = false; actionResult.Message = "EditBizObjectSchemaProperty.Msg2"; return(false); } DataModel.PropertySchema newItem = null; if (logicType == Data.DataLogicType.BizObject || logicType == Data.DataLogicType.BizObjectArray) { //业务对象或业务对象数组 H3.DataModel.BizObjectSchema childSchema = CreateChildSchema(model.PropertyName); newItem = new DataModel.PropertySchema( propertyName, displayName, logicType, childSchema); } else { PropertySerializeMethod method = PropertySerializeMethod.None; int maxLength = 0; if (!model.VirtualField) { DataLogicTypeConvertor.GetSerializeMethod(logicType, ref method, ref maxLength); if (logicType == DataLogicType.Attachment && this.RootSchema.SchemaCode != this.CurrentSchema.SchemaCode) { method = PropertySerializeMethod.Xml; } } SourceType sourceType = logicType == DataLogicType.GlobalData ? SourceType.Metadata : SourceType.Normal; newItem = new DataModel.PropertySchema( propertyName, sourceType, method, model.Global, model.Indexed, displayName, logicType == DataLogicType.GlobalData ? DataLogicType.ShortString : logicType, maxLength, defaultValue, model.Formula, string.Empty, //this.txtDisplayValueFormula.Text, // 显示值公式没有实际作用,已注释 model.RecordTrail, model.Searchable, false, // this.chkAbstract.Checked // 摘要没有实际作用,已注释 false ); } bool result = true; if (!string.IsNullOrEmpty(this.SelectedProperty)) {//更新 DataModel.PropertySchema oldPropertySchema = this.CurrentSchema.GetProperty(this.SelectedProperty); DataModel.BizObjectSchema published = this.Engine.BizObjectManager.GetPublishedSchema(this.RootSchema.SchemaCode); if (published != null && published.GetProperty(propertyName) != null && !Data.DataLogicTypeConvertor.CanConvert(oldPropertySchema.LogicType, newItem.LogicType)) { actionResult.Success = false; actionResult.Message = "EditBizObjectSchemaProperty.Msg1"; return(false); } result = this.CurrentSchema.UpdateProperty(this.SelectedProperty, newItem); } else { result = this.CurrentSchema.AddProperty(newItem); } if (!result) { // 保存失败 actionResult.Success = false; actionResult.Message = "EditBizObjectSchemaProperty.Msg9"; return(false); } // 保存 if (!this.Engine.BizObjectManager.UpdateDraftSchema(this.RootSchema)) { // 保存失败 actionResult.Success = false; actionResult.Message = "msgGlobalString.SaveFailed"; return(false); } return(true); }
/// <summary> /// 读取导入的XML文件 /// </summary> /// <param name="mapPath"></param> private void ReadXmlFile(WorkflowPackageImportViewModel model) { //从服务器加载 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(Session[model.XMLString].ToString()); XmlElement BizWorkflowPackage = xmlDoc.DocumentElement;//根节点 //流程包编码、名称 PackageCode = BizWorkflowPackage.GetElementsByTagName("PackageCode")[0].InnerXml; PackageName = BizWorkflowPackage.GetElementsByTagName("PackageName")[0].InnerXml; //流程包 XmlNodeList packageNodes = BizWorkflowPackage.GetElementsByTagName("FunctionNode"); if (packageNodes != null && packageNodes.Count > 0) { XmlNode openNewWindow = packageNodes[0].SelectSingleNode("OpenNewWindow"); if (openNewWindow != null) { openNewWindow.InnerText = openNewWindow.InnerText.ToLower(); } package = Convertor.XmlToObject(typeof(FunctionNode), packageNodes[0].OuterXml) as FunctionNode; package.ParentCode = model.ParentCode; } //数据模型 XmlNodeList bizObjectSchemaNodes = BizWorkflowPackage.GetElementsByTagName("BizObjectSchema"); if (bizObjectSchemaNodes != null && bizObjectSchemaNodes.Count > 0) { BizObjectSchema = (DataModel.BizObjectSchema)Convertor.XmlToObject(typeof(DataModel.BizObjectSchema), bizObjectSchemaNodes[0].OuterXml); //监听实例 XmlNodeList bizListenerPolicyNodes = BizWorkflowPackage.GetElementsByTagName("BizListenerPolicy"); if (bizListenerPolicyNodes != null && bizListenerPolicyNodes.Count > 0) { bizListenerPolicy = Convertor.XmlToObject(typeof(BizListenerPolicy), bizListenerPolicyNodes[0].OuterXml) as BizListenerPolicy; } //定时作业 XmlNodeList scheduleInvokerNodes = BizWorkflowPackage.GetElementsByTagName("ScheduleInvokers"); if (scheduleInvokerNodes != null && scheduleInvokerNodes.Count > 0) { scheduleInvokerList = new List <ScheduleInvoker>(); foreach (XmlNode scheduleInvoker in scheduleInvokerNodes[0].ChildNodes) { scheduleInvokerList.Add(Convertor.XmlToObject(typeof(ScheduleInvoker), scheduleInvoker.OuterXml) as ScheduleInvoker); } } //查询列表 XmlNodeList bizQueryNodes = BizWorkflowPackage.GetElementsByTagName("BizQueries"); if (bizQueryNodes != null && bizQueryNodes.Count > 0) { bizQueryList = new List <BizQuery>(); foreach (XmlNode query in bizQueryNodes[0].ChildNodes) { bizQueryList.Add(Convertor.XmlToObject(typeof(BizQuery), query.OuterXml) as BizQuery); } } } //流程表单 XmlNode SheetRoot = BizWorkflowPackage.GetElementsByTagName("BizSheets")[0]; XmlNodeList Sheets = ((XmlElement)SheetRoot).GetElementsByTagName("BizSheet"); BizSheets = new List <BizSheet>(); foreach (XmlNode node in Sheets) { BizSheet sheet = (BizSheet)Convertor.XmlToObject(typeof(BizSheet), node.OuterXml); if (sheet.SheetType == SheetType.DefaultSheet) {//清空默认表单 sheet.SheetAddress = string.Empty; } var BizSheetModel = (BizSheet)Convertor.XmlToObject(typeof(BizSheet), node.OuterXml); //处理旧版本的默认表单的发起时间绑定字段是OriginateDate 而新版本的是OriginateTime 做兼容处理 if (BizSheetModel.DesignModeContent != null) { BizSheetModel.DesignModeContent = BizSheetModel.DesignModeContent.Replace(@"OriginateDate", "OriginateTime"); } if (BizSheetModel.RuntimeContent != null) { BizSheetModel.RuntimeContent = BizSheetModel.RuntimeContent.Replace(@"OriginateDate", "OriginateTime"); } BizSheets.Add(BizSheetModel); } //流程模板 XmlNode TemplateRoot = BizWorkflowPackage.GetElementsByTagName("WorkflowTemplates")[0]; XmlNodeList Templates = ((XmlElement)TemplateRoot).GetElementsByTagName("WorkflowTemplate"); if (Templates.Count > 0) { WorkflowTemplates = new List <DraftWorkflowTemplate>(); foreach (XmlNode node in Templates) { DraftWorkflowTemplate draftWorkflowTemplate = new DraftWorkflowTemplate(((XmlElement)node).GetElementsByTagName("WorkflowDocument")[0].OuterXml); WorkflowNames.Add(draftWorkflowTemplate.WorkflowCode, ((XmlElement)node).GetElementsByTagName("WorkflowTemplateName")[0].InnerXml); WorkflowTemplates.Add(draftWorkflowTemplate); } //流程模拟 XmlNode SimulationRoot = BizWorkflowPackage.GetElementsByTagName("Simulations")[0]; XmlNodeList SimulationNodes = ((XmlElement)SimulationRoot).GetElementsByTagName("InstanceSimulation"); this.Simulations = new List <InstanceSimulation>(); foreach (XmlNode simulation in SimulationNodes) { this.Simulations.Add((InstanceSimulation)Convertor.XmlToObject(typeof(InstanceSimulation), simulation.OuterXml)); } XmlNodeList clauseNodes = BizWorkflowPackage.GetElementsByTagName("WorkflowClause"); if (clauseNodes != null && clauseNodes.Count > 0) { foreach (XmlNode clauseNode in clauseNodes) { this.clauses.Add((WorkflowClause)Convertor.XmlToObject(typeof(WorkflowClause), clauseNode.OuterXml)); } } } }
public JsonResult StartInstance(string paramString) { ActionResult result = new ActionResult(false, ""); Dictionary <string, string> dicParams = JsonConvert.DeserializeObject <Dictionary <string, string> >(paramString); string WorkflowCode = string.Empty, SchemaCode = string.Empty, InstanceName = string.Empty; int WorkflowVersion = WorkflowTemplate.WorkflowDocument.NullWorkflowVersion; bool IsMobile = false; string SheetCode = string.Empty; string LoginName = string.Empty; string MobileToken = string.Empty; string WechatCode = string.Empty; string EngineCode = string.Empty; Dictionary <string, string> dicOtherParams = new Dictionary <string, string>(); //读取URL参数 foreach (string key in dicParams.Keys) { if (key == Param_WorkflowCode) { WorkflowCode = dicParams[key]; continue; } if (key == Param_SchemaCode) { SchemaCode = dicParams[key]; continue; } if (key == Param_WorkflowVersion) { int.TryParse(dicParams[key], out WorkflowVersion); continue; } if (key == Param_IsMobile) { bool.TryParse(dicParams[key], out IsMobile); continue; } if (key == Param_SheetCode) { SheetCode = dicParams[key]; continue; } if (key == Param_InstanceName) { InstanceName = dicParams[key]; continue; } if (key.ToLower() == "loginname") { LoginName = dicParams[key]; continue; } if (key.ToLower() == "mobiletoken") { MobileToken = dicParams[key]; continue; } if (key.ToLower() == "code") { WechatCode = dicParams[key]; } if (key.ToLower() == "state") { EngineCode = dicParams[key]; } dicOtherParams.Add(key, dicParams[key]); } //TODO:微信不需要做单点登录 ////实现微信单点登录 //if (!string.IsNullOrEmpty(WechatCode) && !string.IsNullOrEmpty(EngineCode) // && System.Web.HttpContext.Current.Session[Sessions.GetUserValidator()] != null) //{ // IsMobile = true; // UserValidatorFactory.LoginAsWeChat(EngineCode, WechatCode); //} //APP打开表单验证 if (!string.IsNullOrEmpty(LoginName) && !string.IsNullOrEmpty(MobileToken) && this.UserValidator == null) { if (!SSOopenSheet(LoginName, MobileToken)) { result = new ActionResult(false, "登录超时!", null, ExceptionCode.NoAuthorize); return(Json(result, JsonRequestBehavior.AllowGet)); } } else if (this.UserValidator == null) { result = new ActionResult(false, "登录超时!", null, ExceptionCode.NoAuthorize); return(Json(result, JsonRequestBehavior.AllowGet)); } //计算 WorkflowCode if (WorkflowCode == string.Empty && !string.IsNullOrEmpty(SchemaCode)) { WorkflowClause[] clauses = this.Engine.WorkflowManager.GetClausesBySchemaCode(SchemaCode); if (clauses != null) { foreach (WorkflowClause clause in clauses) { if (clause.DefaultVersion > 0) { WorkflowCode = clause.WorkflowCode; } } } } //流程版本号 if (WorkflowVersion == WorkflowTemplate.WorkflowDocument.NullWorkflowVersion || WorkflowVersion == 0) { WorkflowVersion = this.Engine.WorkflowManager.GetWorkflowDefaultVersion(WorkflowCode); } //流程优先级 OThinker.H3.Instance.PriorityType Priority = OThinker.H3.Instance.PriorityType.Normal; if (dicParams.ContainsKey(Param_Priority)) { string strPriority = dicParams[Param_Priority]; Priority = (OThinker.H3.Instance.PriorityType)Enum.Parse(typeof(OThinker.H3.Instance.PriorityType), strPriority); } try { if (string.IsNullOrEmpty(WorkflowCode)) { result.Message = "StartInstance.StartInstance_Msg0"; return(Json(result, JsonRequestBehavior.AllowGet)); } // 获得工作流模板 PublishedWorkflowTemplate workflow = this.Engine.WorkflowManager.GetPublishedTemplate(WorkflowCode, WorkflowVersion); if (workflow == null) { result.Message = "StartInstance.StartInstance_Msg1"; return(Json(result, JsonRequestBehavior.AllowGet)); } DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(workflow.BizObjectSchemaCode); // 开始节点 ClientActivity startActivity = null; // 开始的表单 BizSheet startSheet = null; System.Text.StringBuilder instanceParamBuilder = new System.Text.StringBuilder(); if (dicOtherParams.Count > 0) { foreach (string key in dicOtherParams.Keys) { instanceParamBuilder.Append(string.Format("&{0}={1}", key, dicOtherParams[key])); } } startActivity = workflow.GetActivityByCode(workflow.StartActivityCode) as ClientActivity; if (!string.IsNullOrEmpty(SheetCode)) { startSheet = this.Engine.BizSheetManager.GetBizSheetByCode(SheetCode); } if (startSheet == null) { if (!string.IsNullOrEmpty(startActivity.SheetCode)) { startSheet = this.Engine.BizSheetManager.GetBizSheetByCode(startActivity.SheetCode); } else { BizSheet[] sheets = this.Engine.BizSheetManager.GetBizSheetBySchemaCode(workflow.BizObjectSchemaCode); if (sheets != null && sheets.Length > 0) { startSheet = sheets[0]; } } } if (workflow.StartWithSheet && startActivity != null && startSheet != null) { string url = this.GetSheetBaseUrl( SheetMode.Originate, IsMobile, startSheet); url = url + SheetEnviroment.Param_Mode + "=" + SheetMode.Originate + "&" + Param_WorkflowCode + "=" + System.Web.HttpUtility.UrlEncode(workflow.WorkflowCode) + "&" + Param_WorkflowVersion + "=" + workflow.WorkflowVersion + //(string.IsNullOrEmpty(SheetCode)?"":("&"+Param_SheetCode+"="+SheetCode))+ (instanceParamBuilder.Length == 0 ? string.Empty : ("&" + instanceParamBuilder.ToString())); //URL result.Message = url; } else { // 发起流程 string instanceId = Guid.NewGuid().ToString().ToLower(); string workItemId = null; string error = null; OThinker.H3.DataModel.BizObject bo = new DataModel.BizObject(this.UserValidator.Engine, schema, this.UserValidator.UserID); bo.Create(); if (!SheetUtility.OriginateInstance( this.Engine, bo.ObjectID, workflow, schema, ref instanceId, this.UserValidator.UserID, null, null, OThinker.H3.Instance.PriorityType.Unspecified, null, null, null, ref workItemId, ref error, false)) { result.Message = error; } string startInstanceUrl = this.GetInstanceUrl(instanceId, workItemId); startInstanceUrl += (instanceParamBuilder.Length == 0 ? null : ("&" + instanceParamBuilder.ToString())); result.Message = startInstanceUrl; } } catch (Exception ex) { result.Message = ex.Message; return(Json(result, JsonRequestBehavior.AllowGet)); } result.Success = true; return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 创建一个新的流程实例 /// </summary> /// <param name="Engine">引擎实例对象</param> /// <param name="BizObjectId">业务对象ID</param> /// <param name="Workflow">流程模板</param> /// <param name="Schema">数据模型结构</param> /// <param name="InstanceId">流程实例ID</param> /// <param name="Originator">发起人</param> /// <param name="OriginatedJob">发起人使用的角色</param> /// <param name="InstanceName">流程实例名称</param> /// <param name="Priority">紧急程度</param> /// <param name="OriginatingInstance">发起流程的事件接口</param> /// <param name="ParameterTable">发起流程的参数表</param> /// <param name="Request">HttpRequest</param> /// <param name="WorkItemId">返回工作任务ID</param> /// <param name="ErrorMessage">错误消息</param> /// <param name="FinishStartActivity">是否结束第一个活动</param> /// <returns>返回创建流程是否成功</returns> public static bool OriginateInstance( IEngine Engine, string BizObjectId, WorkflowTemplate.PublishedWorkflowTemplate Workflow, DataModel.BizObjectSchema Schema, ref string InstanceId, string Originator, string OriginatedJob, string InstanceName, Instance.PriorityType Priority, EventHandler <OriginateInstanceEventArgs> OriginatingInstance, Dictionary <string, object> ParameterTable, System.Web.HttpRequest Request, ref string WorkItemId, ref string ErrorMessage, bool FinishStartActivity) { if (Workflow == null) { ErrorMessage = Configs.Global.ResourceManager.GetString("SheetUtility_WorkflowNotExist"); return(false); } // 创建流程实例 InstanceId = AppUtility.Engine.InstanceManager.CreateInstance( BizObjectId, Workflow.WorkflowCode, Workflow.WorkflowVersion, InstanceId, InstanceName, Originator, OriginatedJob, false, Instance.InstanceContext.UnspecifiedID, null, Instance.Token.UnspecifiedID); // 设置紧急程度为普通 OThinker.H3.Messages.MessageEmergencyType emergency = Messages.MessageEmergencyType.Normal; // 如果是发起后需要用户填写表单的模式,则紧急程度为高 if (Workflow.StartWithSheet) { emergency = OThinker.H3.Messages.MessageEmergencyType.High; } // 解析流程参数 System.Collections.Generic.Dictionary <string, object> instanceParams = ParameterTable; if (instanceParams == null) { instanceParams = new Dictionary <string, object>(); } // Http Request Parameters ParseRequestParams(Request, Workflow, Schema, instanceParams); // 调用发起事件 OriginateInstanceEventArgs originateArgs = new OriginateInstanceEventArgs(InstanceId, instanceParams); if (OriginatingInstance != null) { OriginatingInstance(OriginatingInstance, originateArgs); } WorkItemId = Guid.NewGuid().ToString().ToLower(); // 启动流程的消息 OThinker.H3.Messages.StartInstanceMessage startInstanceMessage = new OThinker.H3.Messages.StartInstanceMessage( emergency, InstanceId, WorkItemId, originateArgs == null ? null : originateArgs.InstanceParameterTable.Count == 0 ? null : originateArgs.InstanceParameterTable, Priority, false, OThinker.H3.Instance.Token.UnspecifiedID, null); Engine.InstanceManager.SendMessage(startInstanceMessage); if (!Workflow.StartWithSheet) { // 返回工作项为空 WorkItemId = H3.WorkItem.WorkItem.NullWorkItemID; return(true); } // 查找新创建的工作项 string[] jobs = null; for (int triedTimes = 0; triedTimes < 30; triedTimes++) { System.Threading.Thread.Sleep(500); if (AppUtility.Engine.WorkItemManager.GetWorkItem(WorkItemId) != null) { WorkItem.WorkItem item = AppUtility.Engine.WorkItemManager.GetWorkItem(WorkItemId); jobs = new string[] { item.WorkItemID }; break; } } if (jobs == null || jobs.Length == 0) { ErrorMessage = Configs.Global.ResourceManager.GetString("SheetUtility_OriginateFailed"); WorkItemId = OThinker.H3.WorkItem.WorkItem.NullWorkItemID; return(false); } else { // 返回新创建的工作项 WorkItemId = jobs[0]; if (FinishStartActivity) { OThinker.H3.WorkItem.WorkItem item = Engine.WorkItemManager.GetWorkItem(WorkItemId); // 结束掉第一个活动 Engine.WorkItemManager.FinishWorkItem( WorkItemId, Originator, Request.Browser.IsMobileDevice ? WorkItem.AccessPoint.Mobile : WorkItem.AccessPoint.Web, OriginatedJob, OThinker.Data.BoolMatchValue.Unspecified, null, null, WorkItem.ActionEventType.Forward, WorkItem.WorkItem.UnspecifiedActionButtonType); OThinker.H3.Messages.AsyncEndMessage endMessage = new Messages.AsyncEndMessage( Messages.MessageEmergencyType.Normal, InstanceId, item.ActivityCode, item.TokenId, OThinker.Data.BoolMatchValue.Unspecified, false, OThinker.Data.BoolMatchValue.Unspecified, true, null); Engine.InstanceManager.SendMessage(endMessage); } return(true); } }
public JsonResult ImportSimulation(string SquenceNo, string WorkflowCode) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(false, ""); DataModel.BizObjectSchema Schema = null; OThinker.H3.WorkflowTemplate.WorkflowClause Clause = null; EditSimulationViewModel model = new EditSimulationViewModel(); model.WorkflowCode = WorkflowCode; if (!string.IsNullOrEmpty(WorkflowCode)) { Clause = this.Engine.WorkflowManager.GetClause(WorkflowCode); } if (Clause != null) { Schema = this.Engine.BizObjectManager.GetPublishedSchema(Clause.BizSchemaCode); } string[] conditions = null; string seqCondition = OThinker.H3.Instance.InstanceContext.TableName + "." + OThinker.H3.Instance.InstanceContext.PropertyName_SequenceNo + " ='" + SquenceNo + "'"; conditions = OThinker.Data.ArrayConvertor <string> .AddToArray(conditions, seqCondition); DataTable dt = this.Engine.Query.QueryInstance(conditions, 0, 1); if (dt != null && dt.Rows.Count > 0) { string InstanceId = dt.Rows[0][1] + string.Empty; InstanceContext context = this.Engine.InstanceManager.GetInstanceContext(InstanceId); if (context != null) { if (context.WorkflowCode == WorkflowCode) { InstanceData dataitems = new InstanceData(this.Engine, InstanceId, this.UserValidator.UserID); Dictionary <string, object> valuetable = dataitems.BizObject.ValueTable; OThinker.Organization.User Originator = this.Engine.Organization.GetUnit(context.Originator) as OThinker.Organization.User; if (Originator != null) { model.Originator = new { ObjectID = Originator.ObjectID, Name = Originator.Name }; } string[] workitemIds = this.Engine.Query.QueryWorkItems(InstanceId, -1, WorkItem.WorkItemType.Unspecified, WorkItem.WorkItemState.Unspecified, OThinker.Data.BoolMatchValue.Unspecified); if (workitemIds != null || workitemIds.Length > 0) { foreach (string workitemId in workitemIds) { WorkItem.WorkItem workItem = this.Engine.WorkItemManager.GetWorkItem(workitemId); if (!valuetable.ContainsKey(workItem.ActivityCode)) { valuetable.Add(workItem.ActivityCode, workItem.Participant); } } } model.WorkflowName = context.InstanceName; ShowDataItems(WorkflowCode, Schema, null, valuetable, model); } else { result.Message = "Simulation.EditSimulation_Mssg1"; return Json(result, JsonRequestBehavior.AllowGet); } } } else { result.Message = "Simulation.EditSimulation_Mssg2"; return Json(result, JsonRequestBehavior.AllowGet); } result.Success = true; result.Extend = model; result.Message = "msgGlobalString.ImportSucceed"; return Json(result, JsonRequestBehavior.AllowGet); })); }
public JsonResult LoadSimulation(string simulationID, string workflowCode) { return(ExecuteFunctionRun(() => { EditSimulationViewModel model = new EditSimulationViewModel(); ActionResult result = new ActionResult(true); DataModel.BizObjectSchema Schema = null; OThinker.H3.WorkflowTemplate.WorkflowClause Clause = null; InstanceSimulation Simulation = null; if (!string.IsNullOrEmpty(workflowCode)) { Clause = this.Engine.WorkflowManager.GetClause(workflowCode); } if (Clause != null) { Schema = this.Engine.BizObjectManager.GetPublishedSchema(Clause.BizSchemaCode); } if (Schema == null) { result.Success = false; result.Message = "EditBizObjectSchema.Msg0"; return Json(result, JsonRequestBehavior.AllowGet); } WorkflowTemplate.PublishedWorkflowTemplate tempalte = this.Engine.WorkflowManager.GetDefaultWorkflow(workflowCode); if (tempalte == null) { result.Success = false; result.Message = "StartInstance.StartInstance_Msg1"; return Json(result, JsonRequestBehavior.AllowGet); } if (string.IsNullOrEmpty(simulationID)) { model.WorkflowCode = workflowCode; model.WorkflowName = this.Engine.WorkflowManager.GetClauseDisplayName(workflowCode); ShowDataItems(workflowCode, Schema, null, null, model); } else { Simulation = this.Engine.SimulationManager.GetSimulation(simulationID); if (Simulation == null) { result.Success = false; result.Message = "Simulation.SimulationDetail_Mssg1"; return Json(result, JsonRequestBehavior.AllowGet); } else { if (Clause != null) { model.WorkflowName = Clause.WorkflowName + "[" + workflowCode + "]"; } model.UseCaseName = Simulation.InstanceName; model.Creator = JsonConvert.SerializeObject(Simulation.Originators); //DataItems ShowDataItems(workflowCode, Schema, Simulation, null, model); } } result.Extend = model; return Json(result, JsonRequestBehavior.AllowGet); })); }
/// <summary> /// 删除文件夹 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonResult DeleteFolder(string nodeId, string nodeCode, string objectType) { return(ExecuteFunctionRun(() => { nodeCode = HttpUtility.UrlDecode(nodeCode); string nodeType = objectType.ToString() ?? ""; ActionResult result = new ActionResult(true); //Node.ID 与Node.Code值相同 if (string.IsNullOrWhiteSpace(nodeType) || nodeType.ToLowerInvariant().Equals(FunctionNodeType.BizWorkflowPackage.ToString().ToLowerInvariant()) || nodeType.ToLowerInvariant().Equals(FunctionNodeType.BizFolder.ToString().ToLowerInvariant()) || nodeType.ToLowerInvariant().Equals(FunctionNodeType.BizWFFolder.ToString().ToLowerInvariant()) ) { FunctionNode node = this.Engine.FunctionAclManager.GetFunctionNode(nodeId); if (node.NodeType == FunctionNodeType.BizWorkflowPackage) { DeleteReportSourceAndTemplate(node.Code);//删除关联的报表模板和报表数据源模板 FunctionNode[] Fs = this.Engine.FunctionAclManager.GetFunctionNodes(); foreach (FunctionNode f in Fs) { if (!string.IsNullOrEmpty(f.Url)) { if (f.Url.IndexOf("SchemaCode") > -1) { string[] memebrs = f.Url.Split('&'); foreach (string schemastring in memebrs) { if (schemastring.IndexOf("SchemaCode") > -1) { string schemacode = schemastring.Replace("SchemaCode=", ""); if (node.Code == schemacode) { this.Engine.FunctionAclManager.RemoveFunctionNode(f.ObjectID, false); } } } } } } this.Engine.LogWriter.Write(string.Format("--------------------->删除节点{0},操作用户{1}", node.DisplayName, this.UserValidator.UserCode)); this.Engine.AppPackageManager.DeleteAppPackage(node); this.Engine.WorkflowConfigManager.DeleteFavoriteWorkflow(this.UserValidator.UserID, node.Code); } else if (node.NodeType == FunctionNodeType.ReportTemplateFolder) // 删除报表模板目录 { Analytics.Reporting.ReportTemplate[] reportTemplates = this.Engine.Analyzer.GetReportTemplateByFolderCode(node.Code); //存在报表模板不能直接删除 if (reportTemplates != null && reportTemplates.Length > 0) { result.Success = false; } else { result.Success = this.Engine.FunctionAclManager.RemoveFunctionNode(nodeId, false); } } else { if (node.NodeType == FunctionNodeType.RuleFolder) { //检测是否有子目录 FunctionNode[] Folders = this.Engine.FunctionAclManager.GetFunctionNodesByParentCode(nodeCode); BizService[] bizServices = this.Engine.BizBus.GetBizServicesByFolderCode(nodeCode); if ((Folders != null && Folders.Length > 0) || (bizServices != null && bizServices.Length > 0)) { result.Success = false; result.Message = "msgGlobalString.HasChildNotDelete"; return Json(result); } result.Success = this.Engine.FunctionAclManager.RemoveFunctionNode(nodeId, false); }//流程目录 else if (node.NodeType == FunctionNodeType.BizWFFolder) { //检测是否有子目录 FunctionNode[] Folders = this.Engine.FunctionAclManager.GetFunctionNodesByParentCode(nodeCode); DataModel.BizObjectSchema bizSchema = this.Engine.BizObjectManager.GetPublishedSchema(nodeCode); if ((Folders != null && Folders.Length > 0) || bizSchema != null) { result.Success = false; result.Message = "msgGlobalString.HasChildNotDelete"; return Json(result); } result.Success = this.Engine.FunctionAclManager.RemoveFunctionNode(nodeId, false); } else { result.Success = this.Engine.FunctionAclManager.RemoveFunctionNode(nodeId, false); } } } else { FunctionNodeType type = (FunctionNodeType)Enum.Parse(typeof(FunctionNodeType), nodeType); switch (type) { case FunctionNodeType.BizSheet: var sheet = this.Engine.BizSheetManager.GetBizSheetByCode(nodeCode); if (sheet.IsShared) { //共享流程包,只有主包可以删除共享表单 if (nodeId == sheet.ObjectID) { result.Success = this.Engine.BizSheetManager.DeleteBizSheet(nodeCode); } else { result.Success = false; } } else { result.Success = this.Engine.BizSheetManager.DeleteBizSheet(nodeCode); } break; case FunctionNodeType.BizWorkflow: this.Engine.WorkflowManager.RemoveClause(nodeCode); result.Success = true; break; } } if (result.Success) { result.Message = "ProcessFolder.Msg_DeleteSuccess"; } else { result.Message = "ProcessFolder.Msg_DeleteFailed"; //ajaxResult.ResultMsg = this.PortalResource.GetString("Msg_DeleteFailed") + ":" + this.PortalResource.GetString("AddProcessFolder_Mssg1"); } return Json(result); })); }