Exemplo n.º 1
0
        public ModelInvokeResult <DictionaryItemPK> Update(string strDictionaryId, string strItemId, DictionaryItem dictionaryItem)
        {
            ModelInvokeResult <DictionaryItemPK> result = new ModelInvokeResult <DictionaryItemPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                string _DictionaryId = strDictionaryId;
                dictionaryItem.DictionaryId = _DictionaryId;
                string _ItemId = strItemId;
                dictionaryItem.ItemId = _ItemId;
                if (dictionaryItem.ParentId == "_")
                {
                    dictionaryItem.ParentId = null;
                }
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = dictionaryItem.GetUpdateMethodName(), ParameterObject = dictionaryItem.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                });
                /***********************begin 自定义代码*******************/
                var dictionaryItemOld = BuilderFactory.DefaultBulder().Load <DictionaryItem, DictionaryItemPK>(new DictionaryItemPK {
                    DictionaryId = strDictionaryId, ItemId = strItemId
                });
                StringObjectDictionary dictionary = new
                {
                    DictionaryId = dictionaryItem.DictionaryId,
                    ItemId       = dictionaryItem.ItemId,
                    Action       = SqlExecuteType.UPDATE.ToString().ToLower(),
                    OldParentId  = dictionaryItemOld.ParentId
                }.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 = _DictionaryId, ItemId = _ItemId
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }