Exemplo n.º 1
0
        private VMessage GetNextFlow(SysUser user, int?prevFlowID)
        {
            VMessage result = new VMessage();

            // 根据当前用户角色获取审核流程类型

            var flowType = BasicDataCache.listVacationAuditFlowTypes.FirstOrDefault(type => type.UsedRoleIDs.ToIntList().Contains(user.RoleID));

            if (flowType == null)
            {
                result.AddItem("您所属的角色尚未设置审核流程,请联系管理员!");
                return(result);
            }

            if (prevFlowID.HasValue)
            {
                var prevFlow = BasicDataCache.listVacationAuditFlows.SingleOrDefault(flow => flow.ID == prevFlowID.Value);
                if (prevFlow == null)
                {
                    LogHelper.Log("流程缺失", string.Format("flow_id:{0}缺失", prevFlowID.Value));

                    result.AddItem("数据错误,请联系管理员!");
                    return(result);
                }

                var nextFlow = BasicDataCache.listVacationAuditFlows.Where(flow => flow.TypeID == prevFlow.TypeID)
                               .OrderBy(flow => flow.Sort).FirstOrDefault(flow => flow.Sort > prevFlow.Sort);

                result.Entity = nextFlow;
            }
            else
            {
                int minSort = BasicDataCache.listVacationAuditFlows.Where(flow => flow.TypeID == flowType.ID).Min(flow => flow.Sort);

                var firstFlow = BasicDataCache.listVacationAuditFlows.Where(flow => flow.TypeID == flowType.ID)
                                .SingleOrDefault(flow => flow.Sort == minSort);
                if (firstFlow == null)
                {
                    result.AddItem("您所属的角色尚未设置审核流程,请联系管理员!");
                    return(result);
                }

                result.Entity = firstFlow;
            }

            return(result);
        }
Exemplo n.º 2
0
        public static VMessage Login(string userName, string password)
        {
            var result = new VMessage();

            var user = SysUser.SingleOrDefault("where user_name=@0 and password=@1", userName, password);

            if (user == null)
            {
                result.AddItem("用户名或密码错误!");
            }
            else
            {
                result.Entity = user;
            }

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <param name="file">HttpPostedFile</param>
        /// <param name="saveDir">保存的目录</param>
        /// <param name="saveFileName">保存的文件名,默认为:yyyyMMddhhmmssfff</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">file</exception>
        public static VMessage UploadFile(HttpPostedFileBase file, string saveDir, string saveFileName = null)
        {
            //HttpPostedFile file = HttpContext.Current.Request.Files["Filedata"];

            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (string.IsNullOrEmpty(saveDir))
            {
                throw new ArgumentNullException("saveDir");
            }

            VMessage result = new VMessage();

            if (!Directory.Exists(saveDir))
            {
                Directory.CreateDirectory(saveDir);
            }

            string ext = System.IO.Path.GetExtension(file.FileName);

            if (string.IsNullOrEmpty(saveFileName))
            {
                saveFileName = DateTime.Now.ToString("yyyyMMddhhmmssfff") + ext;
            }

            //判断文件格式是否是禁传格式
            List <string> ignoreExtensions = UploadSettings.Instance.Ignore.Extensions;

            if (ignoreExtensions.Contains(ext, new IgnoreCaseEqualityComparer()))
            {
                result.AddItem("上传格式不正确");
            }
            else
            {
                string saveFilePath = Path.Combine(saveDir, saveFileName);   //绝对路径

                file.SaveAs(saveFilePath);

                result.Entity = saveFileName;
            }

            return(result);
        }