示例#1
0
        public ModelInvokeResult <DictionaryItemPK> Create(DictionaryItem dictionaryItem)
        {
            ModelInvokeResult <DictionaryItemPK> result = new ModelInvokeResult <DictionaryItemPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                if (dictionaryItem.ItemId == "自动生成")
                {
                    dictionaryItem.ItemId = GlobalManager.getPK2(dictionaryItem.GetMappingTableName(), "ItemId", "UD");//user define
                }
                if (dictionaryItem.ParentId == "_")
                {
                    dictionaryItem.ParentId = null;
                }
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = dictionaryItem.GetCreateMethodName(), ParameterObject = dictionaryItem.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT
                });
                /***********************begin 自定义代码*******************/
                StringObjectDictionary dictionary = new
                {
                    DictionaryId = dictionaryItem.DictionaryId,
                    ItemId       = dictionaryItem.ItemId,
                    Action       = SqlExecuteType.INSERT.ToString().ToLower(),
                    OldParentId  = System.DBNull.Value
                }.ToStringObjectDictionary();
                dictionary.Add("ErrorCode", null);
                dictionary.Add("ErrorMessage", null);

                statements.Add(new IBatisNetBatchStatement {
                    StatementName = "SP_Sys_AdjustDictionaryItem", ParameterObject = dictionary, Type = SqlExecuteType.UPDATE
                });
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new DictionaryItemPK {
                    DictionaryId = dictionaryItem.DictionaryId, ItemId = dictionaryItem.ItemId
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }