Example #1
0
 /// <summary>
 /// 更新文档图片集
 /// </summary>
 /// <param name="filesList"></param>
 public void UpdatImgFileList(List <BaseDocImgFile> filesList)
 {
     if (filesList == null)
     {
         filesList = new List <BaseDocImgFile>();
     }
     foreach (var item in filesList)
     {
         ValiDatas.valiData(item);
     }
     using (var db = new DefaultContainer()) {
         //删除原来的
         db.Database.ExecuteSqlCommand("delete from Db_BaseDocFileSet where Db_BaseDocId =@docId", new SqlParameter("@docId", this.Id));
         if (filesList.Count > 0)
         {
             List <Db_BaseDocFile> dbFiles = new List <Db_BaseDocFile>();
             foreach (var item in filesList)
             {
                 dbFiles.Add(new Db_BaseDocFile()
                 {
                     Caption      = item.Caption,
                     CreatedOn    = DateTime.Now,
                     Db_BaseDocId = this.Id,
                     Descript     = item.Descript,
                     Seq          = item.Seq,
                     FileId       = item.FileId,
                     Id           = Guid.NewGuid().ToString()
                 });
             }
             db.Db_BaseDocFileSet.AddRange(dbFiles);
             db.SaveChanges();
         }
     }
 }
Example #2
0
        /// <summary>
        /// 批量添加基础工单信息
        /// </summary>
        /// <param name="remarks"></param>
        /// <returns></returns>
        public static List <BaseWorkOrder> CreateBaseWorkOrders(List <string> remarks)
        {
            List <BaseWorkOrder> result = new List <BaseWorkOrder>();

            using (var db = new DefaultContainer()) {
                List <Db_BaseWorkOrder> dbRows = new List <Db_BaseWorkOrder>();
                foreach (var item in remarks)
                {
                    var newRow = new Db_BaseWorkOrder()
                    {
                        CreatedOn = DateTime.Now,
                        Id        = Guid.NewGuid().ToString(),
                        OrderType = (byte)WorkOrderType.无类型.GetHashCode(),
                        Remark    = item
                    };
                    dbRows.Add(newRow);
                    result.Add(new BaseWorkOrder(newRow));
                }
                if (dbRows.Count > 0)
                {
                    db.Db_BaseWorkOrderSet.AddRange(dbRows);
                    db.SaveChanges();
                }
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// 新增/编辑
        /// </summary>
        /// <param name="rows"></param>
        /// <returns></returns>
        public static List <WorkFlowRole> Edit(List <WorkFlowRole> rows)
        {
            List <WorkFlowRole> result = new List <WorkFlowRole>();

            foreach (var item in rows)
            {
                ValiDatas.valiData(item);
            }
            using (var db = new DefaultContainer()) {
                foreach (var item in rows)
                {
                    if (string.IsNullOrEmpty(item.Id))
                    {
                        Db_WorkFlowRole dbRole = new Db_WorkFlowRole()
                        {
                            CreatedOn = DateTime.Now,
                            Descript  = string.IsNullOrEmpty(item.Descript) ? null : item.Descript,
                            Id        = Guid.NewGuid().ToString(),
                            RoleName  = item.RoleName
                        };
                        db.Db_WorkFlowRoleSet.Add(dbRole);
                        result.Add(new WorkFlowRole(dbRole));
                    }
                    else
                    {
                        var row = db.Db_WorkFlowRoleSet.Single(p => p.Id == item.Id);
                        row.RoleName = item.RoleName;
                        row.Descript = item.Descript;
                        result.Add(new WorkFlowRole(row));
                    }
                }
                db.SaveChanges();
            }
            return(result);
        }
Example #4
0
        /// <summary>
        /// 编辑图文消息
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public DocPic EditDocPic(DocPicEditReqeust info)
        {
            ValiDatas.valiData(info);
            ValiCode(info.Code, info.Id);
            using (var db = new DefaultContainer()) {
                var row = db.Db_BaseDocSet.OfType <Db_DocPic>().Single(p => p.Id == this.Id);
                row.Caption  = info.Caption;
                row.Code     = info.Code;
                row.Content  = info.Content;
                row.Descript = info.Descript;

                //删除原来的分类
                db.Database.ExecuteSqlCommand("delete from Db_BaseDocTreeSet where Db_BaseDocId=@docId", new SqlParameter("@docId", this.Id));
                //新增分类
                if (info.TreeIds != null)
                {
                    if (info.TreeIds.Count > 0)
                    {
                        List <Db_BaseDocTree> dbTrees = new List <Db_BaseDocTree>();
                        foreach (var item in info.TreeIds)
                        {
                            dbTrees.Add(new Db_BaseDocTree()
                            {
                                Id           = Guid.NewGuid().ToString(),
                                Db_BaseDocId = this.Id,
                                TreeId       = item
                            });
                        }
                        db.Db_BaseDocTreeSet.AddRange(dbTrees);
                    }
                }
                db.SaveChanges();
                return(new DocPic(row));
            }
        }
Example #5
0
 /// <summary>
 /// 标记为删除
 /// </summary>
 public void SelDel()
 {
     using (var db = new DefaultContainer()) {
         var row = db.Db_BaseDocSet.Single(p => p.Id == this.Id);
         row.IsDeleted = true;
         db.SaveChanges();
     }
 }
Example #6
0
 /// <summary>
 /// 重设用户的登录密码 -- 使用配置文件中的初始登录密码
 /// </summary>
 public void resetPwd()
 {
     using (var db = new DefaultContainer()) {
         var dbuser = db.Db_BaseUserSet.OfType <Db_ManagerUser>().Single(p => p.Id == this.Id);
         dbuser.passWord = SysSetingsHelp.DefaultAdminPwd;
         db.SaveChanges();
     }
 }
Example #7
0
 /// <summary>
 /// 更新流程的工作流书签ID 保存为toStep.Id 用于下次流程启动时恢复到当前位置
 /// </summary>
 /// <param name="line">工作流关系线信息</param>
 protected void SetWorkFlowBookMark(WorkFlowDefLineDetail line)
 {
     using (var db = new DefaultContainer())
     {
         var row = db.Db_BaseWorkOrderSet.Single(p => p.Id == this.Id);
         row.WorkFlowBookMarkId = line.ToStep.Id;
         db.SaveChanges();
     }
 }
Example #8
0
 /// <summary>
 /// 保存审批状态
 /// </summary>
 public void SaveConfirm()
 {
     using (var db = new DefaultContainer()) {
         var row = db.Db_BaseWorkOrderTaskUserSet.Single(p => p.Id == this.Id);
         row.ConfirmTime = this.ConfirmTime;
         row.Remark      = this.Remark;
         row.IsConfirm   = this.IsConfirm;
         db.SaveChanges();
     }
 }
Example #9
0
 /// <summary>
 /// 设置工作流为完成状态
 /// </summary>
 protected void SetWorkFlowToEndStatus()
 {
     using (var db = new DefaultContainer())
     {
         var row = db.Db_BaseWorkOrderSet.Single(p => p.Id == this.Id);
         row.OrderStatus        = (byte)WorkOrderStatus.已完成.GetHashCode();
         row.WorkFlowBookMarkId = null;
         db.SaveChanges();
     }
 }
Example #10
0
 /// <summary>
 /// 切换禁用状态
 /// </summary>
 /// <returns></returns>
 public BaseDoc SetDisable()
 {
     using (var db = new DefaultContainer())
     {
         var row = db.Db_BaseDocSet.Single(p => p.Id == this.Id);
         row.IsDisabled = row.IsDisabled ? false : true;
         db.SaveChanges();
         return(new BaseDoc(row));
     }
 }
Example #11
0
 private void saveLastLoginInfo()
 {
     using (var db = new DefaultContainer())
     {
         var row = db.Db_BaseUserSet.Single(p => p.Id == this.Id);
         row.lastLoginIpAddress = this.lastLoginIpAddress;
         row.lastLoginTime      = this.lastLoginTime;
         db.SaveChanges();
     }
 }
Example #12
0
 /// <summary>
 /// 保存基本信息-姓名与手机号
 /// </summary>
 private void saveBaseInfo()
 {
     using (var db = new DefaultContainer())
     {
         var dbuser = db.Db_BaseUserSet.OfType <Db_ManagerUser>().Single(p => p.Id == this.Id);
         dbuser.fullName    = this.fullName;
         dbuser.mobilePhone = this.mobilePhone;
         db.SaveChanges();
     }
 }
Example #13
0
 /// <summary>
 /// 物理删除 工单
 /// </summary>
 public virtual void Del()
 {
     using (var db = new DefaultContainer()) {
         var row = db.Db_BaseWorkOrderSet.Single(p => p.Id == this.Id);
         db.Db_BaseWorkOrderApprovalHistorySet.RemoveRange(row.Db_BaseWorkOrderApprovalHistory);
         db.Db_BaseWorkOrderTaskUserSet.RemoveRange(row.Db_BaseWorkOrderTaskUser);
         db.Db_BaseWorkOrderSet.Remove(row);
         db.SaveChanges();
     }
 }
Example #14
0
        private Login AddNewLoginForCustomer(DefaultContainer context, Customer customer, string loginKeyValue)
        {
            var newLogin = new Login { Username = loginKeyValue, };

            context.AddToLogin(newLogin);
            context.SetLink(newLogin, "Customer", customer);
            context.AddLink(customer, "Logins", newLogin);
            context.SaveChanges();

            return newLogin;
        }
Example #15
0
 /// <summary>
 /// 编辑请假申请
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public LeaveInfo EditLeaveInfo(LeaveInfoEditRequest info)
 {
     using (var db = new DefaultContainer()) {
         var row = db.Db_BaseWorkOrderSet.OfType <Db_OA_Leave>().Single(p => p.Id == this.Id);
         row.BeginTime = info.BeginTime;
         row.EndTime   = info.EndTime;
         row.LeaveType = (byte)info.Type.GetHashCode();
         row.Descript  = info.Descript;
         db.SaveChanges();
         return(new LeaveInfo(row));
     }
 }
Example #16
0
        private Login AddNewLoginForCustomer(DefaultContainer context, Customer customer, string loginKeyValue)
        {
            var newLogin = new Login {
                Username = loginKeyValue,
            };

            context.AddToLogin(newLogin);
            context.SetLink(newLogin, "Customer", customer);
            context.AddLink(customer, "Logins", newLogin);
            context.SaveChanges();

            return(newLogin);
        }
Example #17
0
 /// <summary>
 /// 保存用户的禁用设置
 /// </summary>
 public void saveDisabled(bool isDisabled)
 {
     if (this.isDisabled == isDisabled)
     {
         throw new ValiDataException(string.Format("当前用户已是{0}状态,不能重复设置", this.isDisabled ? "已禁用" : "未禁用"));
     }
     this.isDisabled = isDisabled;
     using (var db = new DefaultContainer()) {
         var row = db.Db_BaseUserSet.Single(p => p.Id == this.Id);
         row.isDisabled = this.isDisabled;
         db.SaveChanges();
     }
 }
Example #18
0
 /// <summary>
 /// 修改用户的密码
 /// </summary>
 /// <param name="condtion"></param>
 public void changePwd(UserChangePwdRequst condtion)
 {
     ValiDatas.valiData(condtion);
     using (var db = new DefaultContainer()) {
         var dbuser = db.Db_BaseUserSet.OfType <Db_ManagerUser>().Single(p => p.Id == this.Id);
         if (dbuser.passWord.ToLower() != condtion.oldPwd.ToLower())
         {
             throw new ValiDataException("您提供的旧密码错误");
         }
         dbuser.passWord = condtion.newPwd;
         db.SaveChanges();
     }
 }
Example #19
0
 /// <summary>
 /// 删除(物理删除)包括从表
 /// </summary>
 /// <returns></returns>
 public WorkFlowRole Delete()
 {
     using (var db = new DefaultContainer()) {
         var row = db.Db_WorkFlowRoleSet.Single(p => p.Id == this.Id);
         db.Db_WorkFlowRoleSet.Remove(row);
         var descriptsRows = (from c in db.Db_WorkFlowRoleDescriptSet where c.WorkFlowRoleId == this.Id select c).ToList();
         if (descriptsRows.Count > 0)
         {
             db.Db_WorkFlowRoleDescriptSet.RemoveRange(descriptsRows);
         }
         db.SaveChanges();
     }
     return(this);
 }
Example #20
0
 /// <summary>
 /// 记录到审批历史记录
 /// </summary>
 /// <param name="line"></param>
 private void LogToApprovalHistory(WorkFlowDefLineDetail line)
 {
     using (var db = new DefaultContainer()) {
         var dbRow = new Db_BaseWorkOrderApprovalHistory()
         {
             CreatedOn          = DateTime.Now,
             Db_BaseWorkOrderId = this.Id,
             Id = Guid.NewGuid().ToString(),
             WorkFlowDefLineId = line.Id
         };
         db.Db_BaseWorkOrderApprovalHistorySet.Add(dbRow);
         db.SaveChanges();
     }
 }
Example #21
0
        /// <summary>
        /// 批量新增/编辑业务流程定义
        /// </summary>
        /// <param name="condtion"></param>
        public static List <WorkFlowDefinition> EditDefs(List <WorkFlowDefinition> condtion)
        {
            List <WorkFlowDefinition> result = new List <WorkFlowDefinition>();

            if (condtion != null)
            {
                if (condtion.Count > 0)
                {
                    foreach (var item in condtion)
                    {
                        ValiDatas.valiData(condtion);
                    }



                    using (var db = new DefaultContainer())
                    {
                        foreach (var item in condtion)
                        {
                            if (string.IsNullOrEmpty(item.Id))
                            {
                                //新增
                                Db_WorkFlowDefinition dbDef = new Db_WorkFlowDefinition()
                                {
                                    Id        = SysHelps.GetNewId(),
                                    Caption   = item.Caption,
                                    Descript  = string.IsNullOrEmpty(item.Descript)? null :item.Descript,
                                    CreatedOn = DateTime.Now
                                };
                                db.Db_WorkFlowDefinitionSet.Add(dbDef);
                                result.Add(new WorkFlowDefinition(dbDef));
                            }
                            else
                            {
                                //编辑
                                var dbDef = db.Db_WorkFlowDefinitionSet.Single(p => p.Id == item.Id);
                                dbDef.Caption  = item.Caption;
                                dbDef.Descript = item.Descript;
                                result.Add(new WorkFlowDefinition(dbDef));
                            }
                        }
                        db.SaveChanges();
                    }
                }
            }



            return(result);
        }
Example #22
0
 /// <summary>
 /// 保存到数据库 - 角色/会签 只有任务类型可以保存
 /// </summary>
 /// <returns></returns>
 public WorkFlowDefSetpDetail EditStepApprovalInfo(WorkFlowDefStep condtion)
 {
     if (this.type != WorkFlowStepType.task)
     {
         throw new ValiDataException("只有类型为任务的接口可以编辑该信息");
     }
     using (var db = new DefaultContainer())
     {
         var row = db.Db_WorkFlowDefBaseUnitSet.OfType <Db_WorkFlowDefStep>().Single(p => p.Id == this.Id);
         row.IsCountersign  = condtion.IsCountersign;
         row.WorkFlowRoleId = condtion.WorkFlowRoleId;
         db.SaveChanges();
         return(GetDetailInstance(condtion.Id));
     }
 }
Example #23
0
 /// <summary>
 /// 删除节点以及几点下的子节点(物理删除)
 /// </summary>
 public void DelBaseTree()
 {
     this.GetBaseTreeChilderns();
     IdList = new List <string>();
     IdList.Add(this.id);
     SetChildrenIdList();
     using (var db = new DefaultContainer()) {
         var rows = (from c in db.Db_BaseTreeSet.AsEnumerable() where IdList.Contains(c.Id) select c);
         if (rows.Count() > 0)
         {
             db.Db_BaseTreeSet.RemoveRange(rows);
             db.SaveChanges();
         }
     }
 }
Example #24
0
        /// <summary>
        /// 创建系统日志
        /// </summary>
        /// <param name="message">日志内容</param>
        /// <returns></returns>
        public static BaseLog create(string message)
        {
            Db_BaseLog newRow = new Db_BaseLog()
            {
                createdOn = DateTime.Now,
                logType   = (byte)BaseLogType.系统日志.GetHashCode(),
                message   = message
            };

            using (var db = new DefaultContainer()) {
                var newrow = db.Db_BaseLogSet.Add(newRow);
                db.SaveChanges();
                return(new BaseLog(newrow));
            }
        }
Example #25
0
        /// <summary>
        /// 创建基本文件信息
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static BaseFile CreateBaseFile(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ValiDataException("文件的存放路径不能为空,path is null");
            }

            string fileName;
            int    x = path.LastIndexOf("/");

            if (x > 0)
            {
                fileName = path.Substring(x + 1);
            }
            else
            {
                fileName = path;
            }
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ValiDataException(string.Format("路径:{0},格式不正确", path));
            }
            string exName = string.Empty;

            x = fileName.LastIndexOf(".");
            if (x > 0)
            {
                exName = fileName.Substring(x);
            }

            Db_BaseFile dbFile = new Db_BaseFile()
            {
                Id        = Guid.NewGuid().ToString(),
                CreatedOn = DateTime.Now,
                Path      = path,
                FileName  = fileName,
                ExName    = string.IsNullOrEmpty(exName) ? null : exName
            };

            using (var db = new DefaultContainer()) {
                db.Db_BaseFileSet.Add(dbFile);
                db.SaveChanges();
            }
            return(new BaseFile(dbFile));
        }
Example #26
0
 /// <summary>
 /// 执行工作流终止操作
 /// </summary>
 /// <returns></returns>
 protected BaseWorkOrder DoWorkFlowTermination(ICommunicationable user, string remark)
 {
     using (var db = new DefaultContainer())
     {
         var row = db.Db_BaseWorkOrderSet.Single(p => p.Id == this.Id);
         row.OrderStatus        = (byte)WorkOrderStatus.已终止.GetHashCode();
         row.WorkFlowBookMarkId = null;
         var tu = row.Db_BaseWorkOrderTaskUser.FirstOrDefault(p => p.UserId == user.getIdString());
         if (tu != null)
         {
             tu.IsConfirm   = true;
             tu.ConfirmTime = DateTime.Now;
             tu.Remark      = remark;
         }
         db.SaveChanges();
         return(new BaseWorkOrder(row));
     }
 }
Example #27
0
 /// <summary>
 /// 更新数据库的信息 可更新【姓名,手机与角色】
 /// </summary>
 private void save()
 {
     using (var db = new DefaultContainer()) {
         var dbuser = db.Db_BaseUserSet.OfType <Db_ManagerUser>().Single(p => p.Id == this.Id);
         db.Db_BaseUserRoleSet.RemoveRange(dbuser.Db_BaseUserRole);
         dbuser.fullName    = this.fullName;
         dbuser.mobilePhone = this.mobilePhone;
         foreach (var role in this.rolesList)
         {
             dbuser.Db_BaseUserRole.Add(new Db_BaseUserRole()
             {
                 Id       = Guid.NewGuid().ToString(),
                 roleName = role
             });
         }
         db.SaveChanges();
     }
 }
Example #28
0
        /// <summary>
        /// 执行工作流提交
        /// </summary>
        /// <param name="defId">工作流定义的ID</param>
        /// <param name="user">提交工作流的用户</param>
        protected virtual void DoWorkFlowBegin(string defId, ICommunicationable user)
        {
            this.WorkFlowDefinitionId = defId;

            if (!DoWorkFlowBeginBefore(defId, user))
            {
                throw new ValiDataException("当前工作流无法启动");
            }

            var defInfo = WorkFlowDefinition.GetInstance(defId);

            //获取启动步骤
            defInfo.SetUnits();//获取流程信息
            var beginStep = defInfo.GetBegin();

            if (beginStep == null)
            {
                throw new ValiDataException(string.Format("工作流[{0}]没有起点,无法启动", defInfo.Caption));
            }

            //修改工单状态
            using (var db = new DefaultContainer())
            {
                var row = db.Db_BaseWorkOrderSet.Single(p => p.Id == this.Id);
                row.WorkFlowDefinitionId = defId;
                row.OrderStatus          = (byte)WorkOrderStatus.执行中.GetHashCode();
                db.SaveChanges();
            }

            //记录到日志
            UserLog.create(string.Format("启动工作流,执行流程[{0}]", defInfo.Caption), "工作流", user, this);

            //执行
            //获取下一步
            var nextList = beginStep.GetNextLineDetails();

            if (nextList.Count > 0)
            {
                DoWorkFlowConfim(nextList.First());
            }

            DoWorkFlowBeginAfter(defId, user);
        }
Example #29
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="c">错误类型</param>
        /// <param name="message">消息</param>
        /// <param name="stackTrace">堆栈信息</param>
        /// <returns></returns>
        public static ExceptionLog create(HttpStatusCode c, string message, string stackTrace)
        {
            Db_ExceptionLog log = new Db_ExceptionLog()
            {
                code       = c.GetHashCode().ToString(),
                codeString = c.ToString(),
                createdOn  = DateTime.Now,
                message    = message,
                logType    = (byte)BaseLogType.异常日志.GetHashCode(),
                stackTrace = stackTrace
            };

            using (var db = new DefaultContainer())
            {
                db.Db_BaseLogSet.Add(log);
                db.SaveChanges();
                return(new ExceptionLog(log));
            }
        }
Example #30
0
        /// <summary>
        /// 编辑树的节点
        /// </summary>
        /// <param name="condtion"></param>
        /// <returns></returns>
        public BaseTree EditBaseTree(BaseTreeAttr condtion)
        {
            ValiDatas.valiData(condtion);
            var r = CheckCode(condtion.Code, this.id);

            if (r > 0)
            {
                throw new ValiDataException(string.Format("code [{0}] 已存在,保存失败", condtion.Code));
            }

            using (var db = new DefaultContainer()) {
                var row = db.Db_BaseTreeSet.Single(p => p.Id == this.id);
                row.Code     = condtion.Code;
                row.Name     = condtion.text;
                row.ParentId = string.IsNullOrEmpty(condtion.ParentId) ? null : condtion.ParentId;
                row.Seq      = condtion.Seq;
                db.SaveChanges();
                return(BaseTree.GetBaseTreeById(this.id));
            }
        }
Example #31
0
 /// <summary>
 /// 更新角色的用户信息
 /// </summary>
 /// <param name="userIds"></param>
 public void UpdataDescriptUsers(List <string> userIds)
 {
     using (var db = new DefaultContainer()) {
         //先清空在新增
         var delRows = (from c in db.Db_WorkFlowRoleDescriptSet where c.WorkFlowRoleId == this.Id select c);
         db.Db_WorkFlowRoleDescriptSet.RemoveRange(delRows);
         List <Db_WorkFlowRoleDescript> newRows = new List <Db_WorkFlowRoleDescript>();
         foreach (var item in userIds)
         {
             newRows.Add(new Db_WorkFlowRoleDescript()
             {
                 CreatedOn      = DateTime.Now,
                 UserId         = item,
                 WorkFlowRoleId = this.Id
             });
         }
         db.Db_WorkFlowRoleDescriptSet.AddRange(newRows);
         db.SaveChanges();
     }
 }