/// <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);
                }
            }
        }
Exemplo n.º 2
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();
        }
 public JsonResult GetBizObjectSchemaProperty(string schemaCode, string property, string parentProperty, string isPublished)
 {
     return(ExecuteFunctionRun(() =>
     {
         //解析参数
         OnParseParam(property, schemaCode, parentProperty);
         ActionResult result = new ActionResult();
         if (this.CurrentSchema == null)
         {
             result.Success = false;
             result.Message = "EditBizObjectSchemaMethod.Msg1";
             return Json(result, JsonRequestBehavior.AllowGet);
         }
         BizObjectSchemaPropertyViewModel model;
         if (string.IsNullOrEmpty(SelectedProperty))//新增
         {
             var logicTypes = GetLogicTypes();
             var globals = GetGlobals();
             model = new BizObjectSchemaPropertyViewModel()
             {
                 SchemaCode = schemaCode,
                 Property = property,
                 ParentProperty = parentProperty,
                 LogicType = logicTypes.FirstOrDefault() != null ? logicTypes.FirstOrDefault().Value.ToString() : "",
                 Global = globals.FirstOrDefault() != null ? globals.FirstOrDefault().Value.ToString() : "",
                 VirtualField = false
             };
             result.Extend = new
             {
                 LogicTypes = logicTypes,
                 Globals = globals,
                 SchemProperty = model,
             };
         }
         else
         {//编辑
             OThinker.H3.DataModel.PropertySchema item = this.CurrentSchema.GetProperty(this.SelectedProperty);
             //全局变量
             var logicType = item.SourceType == SourceType.Metadata ? OThinker.H3.Data.DataLogicType.GlobalData : item.LogicType;
             model = new BizObjectSchemaPropertyViewModel()
             {
                 SchemaCode = schemaCode,
                 Property = property,
                 ParentProperty = parentProperty,
                 PropertyName = item.Name,
                 DisplayName = item.DisplayName,
                 DefaultValue = item.DefaultValue != null ? item.DefaultValue.ToString() : "",
                 Formula = item.Formula,
                 LogicType = logicType.ToString(),
                 Indexed = item.Indexed,
                 VirtualField = item.SerializeMethod == OThinker.Data.Database.Serialization.PropertySerializeMethod.None,
                 RecordTrail = item.Trackable,
                 Searchable = item.Searchable,
                 Global = item.MetadataItemName,
                 IsPublished = Convert.ToBoolean(isPublished)
             };
             result.Extend = new
             {
                 LogicTypes = GetLogicTypes(),
                 Globals = GetGlobals(),
                 SchemProperty = model,
                 IsCodeEdit = this.PublishedSchema != null && this.PublishedSchema.ContainsField(item.Name)
             };
         }
         result.Success = true;
         return Json(result.Extend, JsonRequestBehavior.AllowGet);
     }));
 }