Пример #1
0
        /// <summary>
        /// user register
        /// </summary>
        /// <param name="account"></param>
        public void Register(UserAccountEntity account)
        {
            //verify input validation
            var result     = ResponseResult.Default();
            var userEntity = QuickRepository.GetDefaultByName <UserAccountEntity>("LoginName", account.LoginName);

            if (userEntity != null)
            {
                throw new ApplicationException("用户名已经被占用,请重新存在!");
            }
            else if (string.IsNullOrEmpty(account.Password) || account.Password.Length < 6)
            {
                throw new ApplicationException("密码不能为空,或者长度不能小于6位!");
            }

            //create
            try
            {
                QuickRepository.Insert <UserAccountEntity>(account);
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Пример #2
0
        /// <summary>
        /// 同步订单
        /// </summary>
        /// <param name="entity"></param>
        public ProductOrderEntity SyncOrder(IDbConnection conn, IDbTransaction trans)
        {
            var entity = new ProductOrderEntity();
            var rnd    = new Random();

            entity.OrderCode   = string.Format("TB{0}", rnd.Next(100000, 999999).ToString());
            entity.Status      = (short)ProductOrderStatusEnum.Ready;
            entity.ProductName = pruducttype[rnd.Next(1, 7) - 1];
            entity.Quantity    = rnd.Next(1, 10);
            entity.UnitPrice   = 1000;
            entity.TotalPrice  = entity.Quantity * entity.UnitPrice;

            var a = rnd.Next(1, 10) - 1;

            entity.CustomerName = customertype[a];
            entity.Address      = addresstype[a];

            entity.Mobile      = rnd.Next(100000, 999999).ToString();
            entity.Remark      = shoptype[rnd.Next(1, 6) - 1];
            entity.CreatedTime = System.DateTime.Now;

            QuickRepository.Insert <ProductOrderEntity>(conn, entity, trans);

            return(entity);
        }
Пример #3
0
        /// <summary>
        /// 写业务流程记录日志信息
        /// </summary>
        /// <param name="session"></param>
        /// <param name="runner"></param>
        /// <param name="activityName"></param>
        /// <param name="appInstanceID"></param>
        /// <param name="appInstanceCode"></param>
        /// <param name="remark"></param>
        private void Write(IDbSession session, WfAppRunner runner, string activityName,
                           string appInstanceID, string appInstanceCode = null, string remark = null)
        {
            //"派单", entity.ID.ToString(), entity.OrderCode, "完成派单")
            var flow = new AppFlowEntity();

            flow.AppInstanceID   = appInstanceID;
            flow.AppInstanceCode = appInstanceCode;
            flow.AppName         = runner.AppName;
            flow.ActivityName    = activityName;
            flow.ChangedTime     = System.DateTime.Now;
            flow.ChangedUserID   = runner.UserID;
            flow.ChangedUserName = runner.UserName;
            flow.Remark          = remark;

            QuickRepository.Insert <AppFlowEntity>(session.Connection, flow, session.Transaction);
        }
Пример #4
0
 /// <summary>
 /// insert login record
 /// </summary>
 /// <param name="log"></param>
 /// <returns></returns>
 public void Login(UserLogEntity log)
 {
     try
     {
         var entity = new UserLogEntity();
         entity.UserID      = log.UserID;
         entity.LoginName   = log.LoginName;
         entity.LoginTime   = System.DateTime.Now;
         entity.LogoutTime  = null;
         entity.SessionGUID = log.SessionGUID;
         entity.IPAddress   = log.IPAddress;
         QuickRepository.Insert <UserLogEntity>(entity);
     }
     catch (System.Exception)
     {
         throw;
     }
 }
Пример #5
0
 /// <summary>
 /// save resource
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public ResourceEntity SaveResource(ResourceEntity entity)
 {
     try
     {
         if (entity.ID > 0)
         {
             QuickRepository.Update <ResourceEntity>(entity);
         }
         else
         {
             var newID = QuickRepository.Insert <ResourceEntity>(entity);
             entity.ID = newID;
         }
         return(entity);
     }
     catch (System.Exception ex)
     {
         //NLogWriter.Error("删除资源数据,并且删除相关联的表中数据失败!", ex);
         throw;
     }
 }
Пример #6
0
        public void Submit(HrsLeaveEntity entity)
        {
            var runner = WfAppRunner;

            var session = SessionFactory.CreateSession();

            try
            {
                session.BeginTrans();
                entity.CreatedDateTime = System.DateTime.Now;
                entity.ToDate          = entity.FromDate.AddDays(Decimal.ToDouble(entity.Days));
                var appInstanceID = QuickRepository.Insert <HrsLeaveEntity>(session.Connection, entity, session.Transaction);

                //保存流程中关于业务信息的关联信息
                runner.AppInstanceID   = appInstanceID.ToString();
                runner.AppInstanceCode = string.Format("A4L-{0}", appInstanceID.ToString());

                var wfService = new WorkflowService();
                var wfResult  = wfService.StartProcess(session.Connection, runner, session.Transaction);
                if (wfResult.Status == WfExecutedStatus.Success)
                {
                    session.Commit();
                }
                else
                {
                    session.Rollback();
                    throw new ApplicationException(wfResult.Message);
                }
            }
            catch (System.Exception ex)
            {
                session.Rollback();
                throw;
            }
            finally
            {
                session.Dispose();
            }
        }
Пример #7
0
 /// <summary>
 /// add user into role
 /// </summary>
 /// <param name="entity"></param>
 public void AddRoleUser(RoleUserEntity entity)
 {
     QuickRepository.Insert <RoleUserEntity>(entity);
 }