/// <summary>
        /// 更新实体对象
        /// </summary>
        /// <param name="item">实体对象</param>
        public void UpdateRow(EntityInfoWithAttrValueListItem item)
        {
            var session = SessionFactory.CreateSession();

            try
            {
                session.BeginTrans();

                //更新主表记录
                var entityInfo = QuickRepository.GetById <EntityInfoEntity>(item.EntityInfo.ID);
                entityInfo.LastUpdatedDatetime = System.DateTime.Now;
                entityInfo.LastUpdatedUserID   = item.EntityInfo.LastUpdatedUserID;
                entityInfo.LastUpdatedUserName = item.EntityInfo.LastUpdatedUserName;

                QuickRepository.Update <EntityInfoEntity>(session.Connection, entityInfo, session.Transaction);

                //更新扩展属性表记录
                var eavManager = new EntityAttrValueManager();
                eavManager.UpdateItem(session.Connection, item.EntityAttrValueList, session.Transaction);

                session.Commit();
            }
            catch (System.Exception ex)
            {
                session.Rollback();
                throw;
            }
            finally
            {
                session.Dispose();
            }
        }
Beispiel #2
0
        public ResponseResult UpdateEntityRow(EntityInfoWithAttrValueListItem eav)
        {
            var result = ResponseResult.Default();

            try
            {
                var entityInfo = eav.EntityInfo;
                if (entityInfo.ID == 0)
                {
                    var newID = FBDataService.InsertRow(eav);
                    result = ResponseResult.Success(newID);
                }
                else if (entityInfo.ID > 0)
                {
                    FBDataService.UpdateRow(eav);
                    result = ResponseResult.Success();
                }
            }
            catch (System.Exception ex)
            {
                result = ResponseResult.Error(
                    string.Format("保存实体及其扩展属性失败, 错误:{0}", ex.Message)
                    );
            }
            return(result);
        }
        /// <summary>
        /// 整合插入实体数据
        /// </summary>
        /// <param name="item">实体对象</param>
        /// <returns>新实体的实例ID</returns>
        public int InsertRow(EntityInfoWithAttrValueListItem item)
        {
            int newEntityInfoID = 0;
            var session         = SessionFactory.CreateSession();

            try
            {
                session.BeginTrans();

                //保存实体基本信息
                var entityInfo = item.EntityInfo;
                entityInfo.CreatedDatetime     = System.DateTime.Now;
                entityInfo.LastUpdatedDatetime = System.DateTime.Now;
                newEntityInfoID = QuickRepository.Insert <EntityInfoEntity>(session.Connection, entityInfo, session.Transaction);

                //保存实体扩展属性
                foreach (var v in item.EntityAttrValueList)
                {
                    v.EntityInfoID = newEntityInfoID;
                }

                var attrValueList = item.EntityAttrValueList;
                var eavManager    = new EntityAttrValueManager();
                eavManager.InsertBatch(session.Connection, attrValueList, session.Transaction);

                session.Commit();
            }
            catch (System.Exception ex)
            {
                session.Rollback();
                throw;
            }
            finally
            {
                session.Dispose();
            }
            return(newEntityInfoID);
        }
Beispiel #4
0
        public ResponseResult <EntityInfoEntity> InsertEntityRowFlow(dynamic eav)
        {
            var result = ResponseResult <EntityInfoEntity> .Default();

            try
            {
                //先保存表单
                EntityInfoWithAttrValueListItem entityAttrValueItem = JsonConvert.DeserializeObject <EntityInfoWithAttrValueListItem>(
                    eav.EntityInfoWithAttrValueListItem.ToString());
                int newID      = FBDataService.InsertRow(entityAttrValueItem);
                var entityInfo = new EntityInfoEntity();
                entityInfo.ID = newID;

                var wfAppRunner = JsonConvert.DeserializeObject <WfAppRunner>(eav.WfAppRunner.ToString());
                wfAppRunner.AppInstanceID = newID.ToString();
                WfAppInteropService wfService = new WfAppInteropService();
                WfExecutedResult    wfResult  = wfService.StartProcess(wfAppRunner);

                //返回结果
                if (wfResult.Status == WfExecutedStatus.Success)
                {
                    result = ResponseResult <EntityInfoEntity> .Success(entityInfo, "表单数据已经保存,流程已经启动!");
                }
                else
                {
                    result = ResponseResult <EntityInfoEntity> .Error(wfResult.Message);
                }
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <EntityInfoEntity> .Error(
                    string.Format("保存实体及其扩展属性失败, 错误:{0}", ex.Message)
                    );
            }
            return(result);
        }