private ActionResult ParseParam(string schemaCode, string mode)
        {
            ActionResult result = new ActionResult();

            this.SchemaCode = schemaCode;
            if (string.IsNullOrEmpty(SchemaCode))
            {
                this.Schema = null;
            }
            else
            {
                this.Schema = this.Engine.BizObjectManager.GetDraftSchema(SchemaCode);
            }

            if (this.Schema == null)
            {
                result.Success = false;
                result.Message = "TestBizObject.Msg0";
                return(result);
            }

            string s_Mode = mode;

            int.TryParse(s_Mode, out this.Mode);
            result.Success = true;
            return(result);
        }
        /// <summary>
        /// 对参数进行解析
        /// </summary>
        /// <param name="property">属性编码</param>
        /// <param name="code">属性模板编码</param>
        /// <param name="parentProperty">父属性</param>
        private void OnParseParam(string property, string code, string parentProperty)
        {
            this.SelectedProperty = HttpUtility.UrlDecode(property) ?? "";
            this.SchemaCode       = code;
            if (!string.IsNullOrEmpty(SchemaCode))
            {
                this.RootSchema = this.Engine.BizObjectManager.GetDraftSchema(SchemaCode);
                // 获得之前已经发布的
                string parentPropertyPath = HttpUtility.UrlDecode(parentProperty);//属性路径
                if (!string.IsNullOrEmpty(parentPropertyPath))
                {
                    //因为只有两级结构,如果路径的第一个节点不等于当前编辑的数据项,说明是编辑子对象里的数据项,当前模型是子对象的模型
                    string[] properties = parentPropertyPath.Split(new string[] { "\\" }, StringSplitOptions.RemoveEmptyEntries);
                    if (!this.SelectedProperty.Equals(properties[0], StringComparison.InvariantCultureIgnoreCase))
                    {
                        this.CurrentSchema = this.RootSchema.GetProperty(properties[0]).ChildSchema;
                        PublishedSchema    = (PublishedSchema != null && PublishedSchema.GetProperty(properties[0]) != null) ? PublishedSchema.GetProperty(properties[0]).ChildSchema : null;
                    }
                }

                if (this.CurrentSchema == null)//没有子对象,那么当前就是主对象
                {
                    this.CurrentSchema = this.RootSchema;
                }
                if (PublishedSchema == null)//还没发布
                {
                    this.CurrentPublishedPropertySchema = null;
                }
                else
                {
                    this.CurrentPublishedPropertySchema = PublishedSchema.GetProperty(this.SelectedProperty);
                }
            }
        }
示例#3
0
        /// <summary>
        /// 解析HttpRequest中的参数,如果InstanceParams为null,则直接返回,如果流程参数在InstanceParams已经存在该参数则不添加,否则将QueryString中的参数转化为流程参数,如果转换失败,则抛出异常
        /// </summary>
        /// <param name="Request"></param>
        /// <param name="Workflow"></param>
        /// <returns></returns>
        public static void ParseRequestParams(
            System.Web.HttpRequest Request,
            OThinker.H3.WorkflowTemplate.PublishedWorkflowTemplate Workflow,
            OThinker.H3.DataModel.BizObjectSchema Schema,
            System.Collections.Generic.Dictionary <string, object> instanceParams)
        {
            if (Request == null || Workflow == null || instanceParams == null)
            {
                return;
            }

            DataModel.PropertySchema[] items = Schema.Properties;
            if (items != null)
            {
                foreach (DataModel.PropertySchema item in items)
                {
                    object v    = null;
                    string urlV = Request.QueryString[item.Name];
                    if (!string.IsNullOrEmpty(urlV) &&
                        !instanceParams.ContainsKey(item.Name) &&
                        OThinker.Data.Convertor.Convert(urlV, item.RealType, ref v))
                    {
                        instanceParams.Add(item.Name, v);
                    }
                }
            }
        }
        private ActionResult ParseParam(string schemaCode, string associationName)
        {
            this.SchemaCode      = schemaCode;
            this.AssociationName = associationName;
            ActionResult result = new ActionResult();

            if (string.IsNullOrEmpty(this.SchemaCode))
            {
                this.Schema = null;
            }
            else
            {
                this.Schema = this.Engine.BizObjectManager.GetDraftSchema(this.SchemaCode);
            }
            if (this.Schema == null)
            {
                //业务对象模式不存在,或者已经被删除
                result.Message = "BizObjectSchemaAssociation.Msg0";
                result.Success = false;
                return(result);
            }
            if (!string.IsNullOrWhiteSpace(AssociationName))
            {
                this.Association = this.Schema.GetAssociation(AssociationName);
            }

            result.Success = true;
            return(result);
        }
示例#5
0
        /// <summary>
        /// 初始化参数
        /// </summary>
        /// <returns>初始化结果</returns>
        private ActionResult ParseParam(string schemaCode, string selectedMethod, string methodType)
        {
            this.MethodType     = methodType;
            this.SchemaCode     = schemaCode;
            this.SelectedMethod = selectedMethod;
            ActionResult result = new ActionResult();

            //数据模型和业务方法不能为空
            if (string.IsNullOrEmpty(SchemaCode) || string.IsNullOrWhiteSpace(this.SelectedMethod))
            {
                this.Schema    = null;
                result.Success = false;
            }
            else
            {
                this.Schema    = this.Engine.BizObjectManager.GetDraftSchema(SchemaCode);
                result.Success = true;
            }

            if (this.Schema == null)
            {
                result.Success = false;
                result.Message = "EditBizObjectSchemaMethod_Msg1";
            }
            //业务方法
            this.Method = this.Schema.GetMethod(this.SelectedMethod);
            return(result);
        }
示例#6
0
        public JsonResult SaveWorkflowPackage(WorkflowPackageViewModel model)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult(false);
                if (this.WorkflowLimit != 0)
                {
                    int workflowCount = this.Engine.Query.Count(OThinker.H3.WorkflowTemplate.WorkflowClause.TableName,
                                                                new string[] {
                        OThinker.H3.WorkflowTemplate.WorkflowClause.PropertyName_State + "=" + (int)OThinker.H3.WorkflowTemplate.WorkflowState.Active
                    });
                    if (workflowCount >= this.WorkflowLimit)
                    {
                        result.Success = false;
                        result.Message = "WorkflowPackage.OverLimit";
                        return Json(result, JsonRequestBehavior.AllowGet);
                    }
                }
                FunctionNodeType nodeType = string.IsNullOrWhiteSpace(model.ObjectType) ? FunctionNodeType.BizWorkflowPackage : (FunctionNodeType)Enum.Parse(typeof(FunctionNodeType), model.ObjectType);

                if (!Validator(nodeType, model, out result))
                {
                    return Json(result, JsonRequestBehavior.AllowGet);
                }

                if (nodeType == FunctionNodeType.BizWorkflowPackage) //流程包
                {
                    result = SavePackage(model);
                    return Json(result, JsonRequestBehavior.AllowGet);
                }
                else //流程
                {
                    string code = model.Code.Trim();
                    if (this.Engine.WorkflowManager.GetDraftTemplate(code) != null)
                    {
                        result.Success = false;
                        result.Message = "WorkflowPackage.Msg8";
                        return Json(result, JsonRequestBehavior.AllowGet);
                    }
                    int sortKey;
                    Int32.TryParse(model.SortKey, out sortKey);
                    OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetDraftSchema(model.Folder);

                    WorkflowTemplate.WorkflowClause wClause = new WorkflowTemplate.WorkflowClause(model.Folder, code, model.DisplayName, sortKey);
                    wClause.IsShared = schema.IsShared;
                    if (schema.IsQuotePacket)
                    {
                        //使用共享包的,用共享包的模型创建
                        wClause = new WorkflowTemplate.WorkflowClause(schema.BindPacket, code, model.DisplayName, sortKey);
                        //加自己的标识
                        wClause.OwnSchemaCode = schema.SchemaCode;
                    }
                    result.Success = this.Engine.WorkflowManager.AddClause(wClause);
                    result.Extend = model.ParentId;
                }

                return Json(result, JsonRequestBehavior.AllowGet);
            }));
        }
        /// <summary>
        /// 解析变量
        /// </summary>
        /// <param name="mapIndex">参数行号</param>
        /// <param name="schemaCode">数据模型编码</param>
        /// <param name="method">方法</param>
        /// <param name="methodType">绑定方法类型</param>
        /// <param name="paramName">参数名称</param>
        /// <param name="isParam">是否参数</param>
        /// <returns>解析结果</returns>
        private ActionResult ParseParam(string mapIndex, string schemaCode, string method, string methodType, string paramName, bool isParam)
        {
            string       code   = HttpUtility.UrlDecode(schemaCode);
            ActionResult result = new ActionResult();

            if (string.IsNullOrEmpty(code))
            {
                result.Success = false;
                result.Message = "EditBizObjectSchemaParamMap_Msg0";
                return(result);
            }
            else if (string.IsNullOrEmpty(mapIndex))
            {
                result.Success = false;
                result.Message = "msgGlobalString.SaveFirst";
                return(result);
            }
            this.Schema = this.Engine.BizObjectManager.GetDraftSchema(code);
            if (this.Schema == null)
            {
                result.Success = false;
                result.Message = "EditBizObjectSchemaParamMap_Msg0";
                //业务对象模式不存在,或者已经被删除
                return(result);
            }

            //验权
            //this.ValidateBiztreeNodeModify(BizTreeNodeType.BizObject, code);

            this.SelectedMethod = HttpUtility.UrlDecode(method);

            string strIndex = HttpUtility.UrlDecode(mapIndex);

            if (string.IsNullOrEmpty(strIndex))
            {
                this.SelectedMapIndex = -1;
            }
            else
            {
                this.SelectedMapIndex = int.Parse(strIndex);
            }
            this.IsParam   = isParam;
            this.ParamName = HttpUtility.UrlDecode(paramName);
            result.Success = true;
            return(result);
        }
        private List <Item> GetFilterMethods(string workflowID)
        {
            List <Item> list = new List <Item>();

            OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetDraftSchema(workflowID);
            if (schema != null)
            {
                foreach (OThinker.H3.DataModel.MethodGroupSchema method in schema.Methods)
                {
                    if (method.MethodType == H3.DataModel.MethodType.Filter)
                    {
                        list.Add(new Item(method.FullName, method.MethodName));
                    }
                }
            }
            return(list);
        }
        private List <Item> GetItemNames(ObjectSchemaAssociationViewModel model)
        {
            List <Item> list = new List <Item>();

            OThinker.H3.DataModel.BizObjectSchema associatedSchema = this.Engine.BizObjectManager.GetDraftSchema(model.WorkflowID);
            if (associatedSchema == null)
            {
                return(list);
            }
            OThinker.H3.DataModel.BizObjectAssociation asso = new DataModel.BizObjectAssociation(
                model.RelationName ?? "",
                model.DisplayName ?? "",
                (H3.DataModel.AssociationType)Enum.Parse(typeof(AssociationType), model.Type ?? ""),
                associatedSchema,
                model.FilterMethod ?? "");
            OThinker.H3.DataModel.DataMap[] maps = asso.Maps.ToArray();
            ServiceMethodMap[] methodMaps        = associatedSchema.GetMethod("GetList").MethodMaps;
            if (methodMaps != null && methodMaps.Length > 0)
            {
                DataMapCollection paramMaps  = associatedSchema.GetMethod("GetList").MethodMaps[0].ParamMaps;
                string[]          paramNames = paramMaps.GetParamNames();

                foreach (string propertyName in paramNames)
                {
                    DataMap map         = paramMaps.GetMap(propertyName);
                    string  mapProperty = map.MapTo;
                    if (!string.IsNullOrEmpty(mapProperty))
                    {
                        DataModel.PropertySchema item = associatedSchema.GetProperty(map.ItemName);
                        if (item != null)
                        {
                            list.Add(new Item(item.FullName, item.Name));
                        }
                    }
                }
            }
            else
            {
                foreach (OThinker.H3.DataModel.DataMap map in maps)
                {
                    DataModel.PropertySchema item = associatedSchema.GetProperty(map.ItemName);
                    list.Add(new Item(item.FullName, item.Name));
                }
            }
            return(list);
        }
示例#10
0
        /// <summary>
        /// 保存表单数据
        /// </summary>
        /// <param name="workItem"></param>
        /// <param name="user"></param>
        /// <param name="boolMatchValue"></param>
        /// <param name="paramValues"></param>
        private void SaveBizObject(OThinker.H3.WorkItem.WorkItem workItem, OThinker.Organization.User user, OThinker.Data.BoolMatchValue boolMatchValue, List <DataItemParam> paramValues)
        {
            InstanceContext InstanceContext = this.Engine.InstanceManager.GetInstanceContext(workItem.InstanceId);
            string          bizObjectId     = InstanceContext == null ? string.Empty : InstanceContext.BizObjectId;

            OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(InstanceContext.BizObjectSchemaCode);
            OThinker.H3.DataModel.BizObject       bo     = new OThinker.H3.DataModel.BizObject(this.Engine, schema, workItem.Participant);
            bo.ObjectID = bizObjectId;
            bo.Load();

            // 设置数据项的值
            foreach (DataItemParam param in paramValues)
            {
                OThinker.H3.DataModel.PropertySchema property = schema.GetProperty(param.ItemName);
                if (property.LogicType == DataLogicType.Comment)
                {// 审核意见
                    CommentParam comment = JSSerializer.Deserialize <CommentParam>(param.ItemValue + string.Empty);
                    this.Engine.BizObjectManager.AddComment(new Comment()
                    {
                        BizObjectId         = bo.ObjectID,
                        BizObjectSchemaCode = schema.SchemaCode,
                        InstanceId          = workItem.InstanceId,
                        TokenId             = workItem.TokenId,
                        Approval            = boolMatchValue,
                        Activity            = workItem.ActivityCode,
                        DataField           = property.Name,
                        UserID      = user.ObjectID,
                        SignatureId = comment.SignatureId,
                        Text        = comment.Text
                    });
                }
                else
                {
                    new BPM().SetItemValue(bo, property, param.ItemValue);
                }
            }

            bo.Update();
        }
        /// <summary>
        /// 启动H3流程实例(包含子表)
        /// </summary>
        /// <typeparam name="T">实体类-泛型</typeparam>
        /// <param name="workflowCode">流程模板编码</param>
        /// <param name="userCode">启动流程的用户编码</param>
        /// <param name="finishStart">是否结束第一个活动</param>
        /// <param name="EntityParamValues">流程实例启动初始化数据项实体类集合</param>
        /// <returns></returns>
        private BPMServiceResult startWorkflowByEntityTrinsJson(
            string workflowCode,
            string userCode,
            bool finishStart,
            object EntityParamValues)
        {
            string workItemID, keyItem, errorMessage;

            workItemID = keyItem = errorMessage = string.Empty;
            BPMServiceResult result;

            try
            {
                // 获取模板
                OThinker.H3.WorkflowTemplate.PublishedWorkflowTemplateHeader workflowTemplate = GetWorkflowTemplate(workflowCode);
                if (workflowTemplate == null)
                {
                    result = new BPMServiceResult(false, "流程启动失败,流程模板不存在,模板编码:" + workflowCode + "。");
                    return(result);
                }
                // 查找流程发起人
                //OThinker.Organization.User user = OThinker.H3.Controllers.AppUtility.Engine.Organization.GetUserByCode(userCode) as OThinker.Organization.User;
                string user = "******";// GetUserIDByCode(userCode);  //"18f923a7-5a5e-426d-94ae-a55ad1a4b239"; //
                if (user == null)
                {
                    result = new BPMServiceResult(false, "流程启动失败,用户{" + userCode + "}不存在。");
                    return(result);
                }

                OThinker.H3.DataModel.BizObjectSchema schema = OThinker.H3.Controllers.AppUtility.Engine.BizObjectManager.GetPublishedSchema(workflowTemplate.BizObjectSchemaCode);
                OThinker.H3.DataModel.BizObject       bo     = new OThinker.H3.DataModel.BizObject(
                    OThinker.H3.Controllers.AppUtility.Engine.Organization,
                    OThinker.H3.Controllers.AppUtility.Engine.MetadataRepository,
                    OThinker.H3.Controllers.AppUtility.Engine.BizObjectManager,
                    OThinker.H3.Controllers.AppUtility.Engine.BizBus,
                    schema,
                    OThinker.Organization.User.AdministratorID,
                    OThinker.Organization.OrganizationUnit.DefaultRootID);

                if (EntityParamValues != null)
                {
                    Newtonsoft.Json.Linq.JObject jObject = Newtonsoft.Json.Linq.JObject.Parse(EntityParamValues.ToString());
                    foreach (KeyValuePair <string, Newtonsoft.Json.Linq.JToken> jo in jObject)
                    {
                        //如果字段是GTAttachment则是附件
                        if (bo.Schema.ContainsField(jo.Key))
                        {
                            if (bo.Schema.GetLogicType(jo.Key) == OThinker.H3.Data.DataLogicType.Comment)
                            {
                                continue;
                            }
                            //判断是否子表
                            else if (bo.Schema.GetLogicType(jo.Key) != OThinker.H3.Data.DataLogicType.BizObjectArray)
                            {
                                //给对象赋值
                                bo[jo.Key] = jo.Value;
                            }
                            else
                            {
                                List <object> list = JSSerializer.Deserialize <List <object> >(Newtonsoft.Json.JsonConvert.SerializeObject(jo.Value) as string);
                                //获取子表的属性
                                BizObjectSchema childSchema = schema.GetProperty(jo.Key).ChildSchema;
                                BizObject[]     bizObjects  = new BizObject[list.Count];
                                int             i           = 0;
                                foreach (object objT in list)
                                {
                                    bizObjects[i] = new BizObject(OThinker.H3.Controllers.AppUtility.Engine, childSchema, userCode);
                                    foreach (KeyValuePair <string, object> t in (dynamic)objT)
                                    {
                                        if (childSchema.ContainsField(t.Key))
                                        {
                                            //给对象赋值
                                            bizObjects[i][t.Key] = t.Value;
                                            continue;
                                        }
                                    }
                                    i++;
                                }
                                //子表回写给流程子表
                                bo[jo.Key] = bizObjects;
                            }
                        }
                    }
                }
                bo.Create();

                // 创建流程实例
                string InstanceId = OThinker.H3.Controllers.AppUtility.Engine.InstanceManager.CreateInstance(
                    bo.ObjectID,
                    workflowTemplate.WorkflowCode,
                    workflowTemplate.WorkflowVersion,
                    null,
                    null,
                    user,
                    null,
                    false,
                    OThinker.H3.Instance.InstanceContext.UnspecifiedID,
                    null,
                    OThinker.H3.Instance.Token.UnspecifiedID);

                // 设置紧急程度为普通
                OThinker.H3.Messages.MessageEmergencyType emergency = OThinker.H3.Messages.MessageEmergencyType.Normal;
                // 这里也可以在启动流程的时候赋值
                Dictionary <string, object> paramTables = new Dictionary <string, object>();

                // 启动流程的消息
                OThinker.H3.Messages.StartInstanceMessage startInstanceMessage
                    = new OThinker.H3.Messages.StartInstanceMessage(
                          emergency,
                          InstanceId,
                          workItemID,
                          paramTables,
                          OThinker.H3.Instance.PriorityType.Normal,
                          true,
                          null,
                          false,
                          OThinker.H3.Instance.Token.UnspecifiedID,
                          null);
                OThinker.H3.Controllers.AppUtility.Engine.InstanceManager.SendMessage(startInstanceMessage);
                result = new BPMServiceResult(true, InstanceId, workItemID, "流程实例启动成功!", "");
            }
            catch (Exception ex)
            {
                result = new BPMServiceResult(false, "流程实例启动失败!错误:" + ex + string.Empty);
            }
            return(result);
        }
        /// <summary>
        /// 启动H3流程实例
        /// </summary>
        /// <param name="workflowCode">流程模板编码</param>
        /// <param name="userCode">启动流程的用户编码</param>
        /// <param name="finishStart">是否结束第一个活动</param>
        /// <param name="paramValues">流程实例启动初始化数据项集合</param>
        /// <returns></returns>
        public BPMServiceResult StartWorkflow(string workflowCode, string userCode, bool finishStart, List <DataItemParam> paramValues)
        {
            //ValidateSoapHeader();
            BPMServiceResult result = new BPMServiceResult();

            try
            {
                // 获取模板
                OThinker.H3.WorkflowTemplate.PublishedWorkflowTemplateHeader workflowTemplate = GetWorkflowTemplate(workflowCode);
                if (workflowTemplate == null)
                {
                    return(new BPMServiceResult(false, "流程启动失败,流程模板不存在,模板编码:" + workflowCode + "。"));
                }
                // 查找流程发起人
                //OThinker.Organization.User user = Engine.Organization.GetUnitByCode(userCode) as Organization.User;
                string user = "******";// GetUserIDByCode(userCode);
                if (user == null)
                {
                    return(new BPMServiceResult(false, "流程启动失败,用户{" + userCode + "}不存在。"));
                }
                OThinker.H3.DataModel.BizObjectSchema schema = Engine.BizObjectManager.GetPublishedSchema(workflowTemplate.BizObjectSchemaCode);
                OThinker.H3.DataModel.BizObject       bo     = new OThinker.H3.DataModel.BizObject(Engine.Organization, Engine.MetadataRepository, Engine.BizObjectManager, null, schema, user);
                if (paramValues != null)
                {
                    // 这里可以在创建流程的时候赋值
                    foreach (DataItemParam param in paramValues)
                    {
                        if (bo.Schema.GetProperty(param.ItemName).LogicType == OThinker.H3.Data.DataLogicType.BizObjectArray)
                        {
                            var t = new List <OThinker.H3.DataModel.BizObject>();
                            foreach (List <DataItemParam> list in (IEnumerable)param.ItemValue)
                            {
                                var m = new OThinker.H3.DataModel.BizObject(Engine.Organization, Engine.MetadataRepository, Engine.BizObjectManager, null, schema.Fields.FirstOrDefault(x => x.ChildSchemaCode == param.ItemName).Schema, user);
                                foreach (DataItemParam item in list)
                                {
                                    if (m.Schema.ContainsField(item.ItemName))
                                    {
                                        m[item.ItemName] = item.ItemValue;
                                    }
                                }
                                t.Add(m);
                            }
                            bo[param.ItemName] = t.ToArray();
                        }
                        else if (bo.Schema.ContainsField(param.ItemName))
                        {
                            bo[param.ItemName] = param.ItemValue;
                        }
                    }
                }
                bo.Create();
                // 创建流程实例
                //string InstanceId = this.Engine.InstanceManager.CreateInstance(
                //    bo.ObjectID,
                //    workflowTemplate.WorkflowCode,
                //    workflowTemplate.WorkflowVersion,
                //    null,
                //    null,
                //    user,
                //    null, // 以组的身份发起
                //    null, // 以岗位的身份发起
                //    false, //
                //    OThinker.H3.Instance.InstanceContext.UnspecifiedID,
                //    null,
                //    OThinker.H3.Instance.Token.UnspecifiedID);
                string InstanceId = this.Engine.InstanceManager.CreateInstanceByDefault(
                    bo.ObjectID, workflowTemplate.WorkflowCode, null, user);
                // 设置紧急程度为普通
                OThinker.H3.Messages.MessageEmergencyType emergency = OThinker.H3.Messages.MessageEmergencyType.Normal;
                // 这里也可以在启动流程的时候赋值
                Dictionary <string, object> paramTables = new Dictionary <string, object>();
                // 启动流程的消息
                OThinker.H3.Messages.StartInstanceMessage startInstanceMessage =
                    new OThinker.H3.Messages.StartInstanceMessage(emergency, InstanceId, null, paramTables,
                                                                  OThinker.H3.Instance.PriorityType.Normal, true, null, false, OThinker.H3.Instance.Token.UnspecifiedID, null);
                Engine.InstanceManager.SendMessage(startInstanceMessage);
                result = new BPMServiceResult(true, InstanceId, null, "流程实例启动成功!", "");
            }
            catch (Exception ex)
            {
                result = new BPMServiceResult(false, "流程实例启动失败!错误:" + ex.Message);
            }
            return(result);
        }
        /// <summary>
        /// 保存关联对象信息
        /// </summary>
        /// <param name="model">关联对象信息</param>
        /// <returns>是否成功</returns>
        public JsonResult SaveAssociation(ObjectSchemaAssociationViewModel model)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult();
                result = ParseParam(model.SchemaCode, model.RelationName);
                if (!result.Success)
                {
                    return Json(result, JsonRequestBehavior.AllowGet);
                }

                OThinker.H3.DataModel.BizObjectSchema schema = null;
                if (string.IsNullOrEmpty(model.WorkflowID) ||
                    string.IsNullOrEmpty(model.RelationName) ||
                    (schema = this.Engine.BizObjectManager.GetDraftSchema(model.WorkflowID)) == null)
                {
                    //输入的名称或者要关联的业务对象模式不正确
                    result.Message = "BizObjectSchemaAssociation.Msg1";
                    result.Success = false;
                    return Json(result, JsonRequestBehavior.AllowGet);
                }
                //if(){}
                if (this.Association == null)
                {
                    this.Association = new DataModel.BizObjectAssociation(
                        model.RelationName,
                        model.DisplayName,
                        (H3.DataModel.AssociationType)Enum.Parse(typeof(AssociationType), model.Type),
                        schema,
                        model.FilterMethod);
                }
                OThinker.H3.DataModel.DataMap[] maps = this.Association.Maps.ToArray();
                if (maps != null)
                {
                    List <AssociationDataMap> propertys = null;
                    if (!string.IsNullOrEmpty(model.PropertyMap))
                    {
                        propertys = JsonConvert.DeserializeObject <AssociationDataMap[]>((model.PropertyMap)).ToList();
                    }
                    if (propertys == null)
                    {
                        propertys = new List <AssociationDataMap>();
                    }
                    if (propertys.Count == 0)
                    {
                        propertys.Add(new AssociationDataMap()
                        {
                            ItemName = model.ItemName,
                            MapTo = model.MapTo,
                            MapType = model.MapType
                        });
                    }
                    foreach (OThinker.H3.DataModel.DataMap map in maps)
                    {
                        // 影射关系
                        AssociationDataMap property = propertys == null ? null : propertys.Where(p => p.ItemName == map.ItemName).FirstOrDefault();
                        if (property == null)
                        {
                            map.MapType = H3.DataModel.DataMapType.None;
                        }
                        else
                        {
                            map.MapTo = property.MapTo;
                            map.MapType = (OThinker.H3.DataModel.DataMapType)Enum.Parse(typeof(OThinker.H3.DataModel.DataMapType), property.MapType);
                        }
                    }
                }
                if (string.IsNullOrWhiteSpace(model.ObjectID))
                {
                    //添加
                    if (!this.Schema.AddAssociation(this.Association))
                    {
                        //添加失败
                        result.Message = "BizObjectSchemaAssociation.Msg2";
                        result.Success = false;
                        return Json(result, JsonRequestBehavior.AllowGet);
                    }
                }
                //更新
                if (!this.Engine.BizObjectManager.UpdateDraftSchema(this.Schema))
                {
                    //保存业务对象模式失败
                    result.Message = "BizObjectSchemaAssociation.Msg3";
                    result.Success = false;
                    return Json(result, JsonRequestBehavior.AllowGet);
                }
                result.Success = true;
                return Json(result, JsonRequestBehavior.AllowGet);
            }));
        }