public ActionResult Delete()
        {
            var Department_ID = Request.Params["Department_ID"];

            if (Const.IsNullOrEmpty(Department_ID))
            {
                return Json(new { success = false, message = "Department_ID 参数错误。" }, JsonRequestBehavior.AllowGet);
            }

            var id = Convert.ToInt64(Department_ID);

            if (id == 1)
            {
                return Json(new { success = false, message = "默认部门不能删除。" }, JsonRequestBehavior.AllowGet);
            }

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                var items = data.DepartmentDTO.Where(u => u.ID == id).ToList();
                if (items.Count > 0)
                {
                    var entity = items.First();
                    data.DepartmentDTO.DeleteOnSubmit(entity);
                    data.SubmitChanges();
                }
            }

            return Json(new { success = true, message = string.Empty }, JsonRequestBehavior.AllowGet);
        }
        public ActionResult Create(ProjectStageDTO entity)
        {
            var errors = "B000";
            string message = string.Empty;

            if (Const.IsNullOrEmpty(entity.Name))
            {
                errors = "B001";
                message = "项目阶段名称不能为空。";
            }

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                if (data.ProjectStageDTO.Where(u => u.Name == entity.Name).Count() > 0)
                {
                    errors = "B002";
                    message = "项目阶段已经存在。";
                }

                if (errors == "B000")
                {
                    data.ProjectStageDTO.InsertOnSubmit(entity);
                    data.SubmitChanges();
                }
            }

            return Json(new { success = (errors == "B000"), errors = errors, message = message }, JsonRequestBehavior.AllowGet);
        }
        public ActionResult Authorize()
        {
            string roleCode = Request.Params["roleCode"];
            string resourceCodes = Request.Params["resourceCodes"];

            //if (roleCode == "Administrator")
            //{
            //    return Json(new { success = false, message = "系统管理员不允许修改。" }, JsonRequestBehavior.AllowGet);
            //}

            if (Const.IsNullOrEmpty(roleCode))
            {
                return Json(new { success = false, message = "参数错误。" }, JsonRequestBehavior.AllowGet);
            }

            if (resourceCodes == null) resourceCodes = "";

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                var items = data.PermissionDTO.Where(u => u.Role_Code == roleCode).ToList();
                data.PermissionDTO.DeleteAllOnSubmit(items);

                string[] splits = resourceCodes.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var s in splits)
                {
                    data.PermissionDTO.InsertOnSubmit(new PermissionDTO() { Role_Code = roleCode, Resource_Code = s });
                }

                data.SubmitChanges();
            }

            return Json(new { success = true, message = string.Empty }, JsonRequestBehavior.AllowGet);
        }
Esempio n. 4
0
        public ActionResult Create(RoleDTO entity)
        {
            int errors = 0;
            string message = string.Empty;

            if (Const.IsNullOrEmpty(entity.Name))
            {
                errors++;
                message = "角色名称不能为空。<br/>";
            }

            if (Const.IsNullOrEmpty(entity.Code))
            {
                errors++;
                message = "角色编码不能为空。<br/>";
            }

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                if (data.RoleDTO.Where(u => u.Code == entity.Code).Count() > 0)
                {
                    errors++;
                    message = entity + " 角色已经存在。<br/>";
                }

                if (errors == 0)
                {
                    data.RoleDTO.InsertOnSubmit(entity);
                    data.SubmitChanges();
                }
            }

            return Json(new { success = (errors == 0), message = message }, JsonRequestBehavior.AllowGet);
        }
Esempio n. 5
0
        public ActionResult Delete()
        {
            var code = Request.Params["code"];

            if (Const.IsNullOrEmpty(code))
            {
                return Json(new { success = false, message = "code 参数错误。" }, JsonRequestBehavior.AllowGet);
            }

            if (code == "Administrator")
            {
                return Json(new { success = false, message = "系统管理员不能修改。<br/>" }, JsonRequestBehavior.AllowGet);
            }

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                var count = data.UserDTO.Where(u => u.Role_Code == code).Count();

                if (count > 0)
                {
                    return Json(new { success = false, message = "用户正在使用这个角色,请用户换角色再删除。" }, JsonRequestBehavior.AllowGet);
                }

                data.ExecuteCommand("DELETE FROM T_ROLE WHERE CODE=@p0", code);
            }

            return Json(new { success = true, message = string.Empty }, JsonRequestBehavior.AllowGet);
        }
Esempio n. 6
0
        public ActionResult Delete()
        {
            var loginID = Request.Params["Login_ID"];

            if(Const.IsNullOrEmpty(loginID)) {
                return Json(new { success = false, message = "Login_ID 参数错误。" }, JsonRequestBehavior.AllowGet);
            }

            if (loginID == "Admin")
            {
                return Json(new { success = false, message = "Admin 帐号不能删除。" }, JsonRequestBehavior.AllowGet);
            }

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                var items = data.UserDTO.Where(u => u.Login_ID == loginID).ToList();
                if (items.Count > 0)
                {
                    var entity = items.First();
                    data.UserDTO.DeleteOnSubmit(entity);
                    data.SubmitChanges();
                }
            }

            return Json(new { success = true, message = string.Empty }, JsonRequestBehavior.AllowGet);
        }
        public ActionResult List()
        {
            List<ResourceDTO> items = null;

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                items = data.ResourceDTO.ToList();
            }

            return Json(items, JsonRequestBehavior.AllowGet);
        }
Esempio n. 8
0
        public ActionResult List()
        {
            var status = Request.Params["status"];
            int startIndex = Convert.ToInt32(Request.Params["start"]);
            int maxResults = Convert.ToInt32(Request.Params["limit"]);

            List<AuditDTO> items;
            var count = 0;
            using (DataClassesDataContext data = new DataClassesDataContext())
            {

                var q = from s in data.AuditDTO select s;

                var identity = User.Identity.Name;
                if (Const.IsNullOrEmpty(status)) status = "0"; // 默认查询等待审核

                IQueryable<AuditDTO> query = (from e in data.AuditDTO select e).Where(t => t.Status == Convert.ToInt32(status) && t.Audit_User_ID == identity).OrderByDescending(t => t.Apply_Date);
                count = query.Count();
                items = query.Skip(startIndex).Take(maxResults).ToList();
            }

            items.ForEach(SetUsername);

            var result = new
            {
                count = count,
                items = items.Select(t => new
                {
                    ID = t.ID,
                    Project_Code = t.Project_Code,
                    Project_Name = t.Project_Name,
                    Project_Stage = t.Project_Stage,
                    Project_Subject = t.Project_Subject,
                    Barcode = t.Barcode,
                    Diagram_Name = t.Diagram_Name,
                    Login_ID = t.Login_ID,
                    Username = t.Username,
                    File_Name = t.File_Name,
                    Reason = t.Reason,
                    Status = t.Status,
                    Audit_Date = t.Audit_Date.HasValue ? t.Audit_Date.ToString() : null,
                    Apply_Date = t.Apply_Date.HasValue ? t.Apply_Date.ToString() : null,
                    StatusDescription = Const.GetStatusDesc(t.Status)
                }).ToList()
            };

            return Json(result, "text/html", JsonRequestBehavior.AllowGet);
        }
Esempio n. 9
0
        public ActionResult Index()
        {
            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                UserDTO currentUser = data.UserDTO
                         .Where(u => u.Login_ID == this.User.Identity.Name)
                         .Single();

                string sql = "SELECT b.* FROM dbo.T_PERMISSION a left join dbo.T_RESOURCE b on a.Resource_Code=b.Code WHERE a.Role_Code='" + currentUser.Role_Code + "' ORDER BY b.Sort ASC";
                var items = data.ExecuteQuery<ResourceDTO>(sql).ToList();

                ViewData["authorities"] = items;
            }

            return View();
        }
Esempio n. 10
0
        public ActionResult HasPermissions()
        {
            string roleCode = Request.Params["roleCode"];

            if (Const.IsNullOrEmpty(roleCode))
            {
                return View();
            }
            else
            {
                using (DataClassesDataContext data = new DataClassesDataContext())
                {
                    var items = data.PermissionDTO.Where(u => u.Role_Code == roleCode).ToList();

                    return Json(items, JsonRequestBehavior.AllowGet);
                }
            }
        }
Esempio n. 11
0
        public ActionResult Agree()
        {
            string[] items = Request.Params["items"].Split(new char[]{';'}, StringSplitOptions.RemoveEmptyEntries);

            using(DataClassesDataContext data = new DataClassesDataContext())
            {
                var entities = data.AuditDTO.Where(u => items.Contains(u.ID.ToString())).ToList();

                foreach (var entity in entities)
                {
                    entity.Status = 1;
                    entity.Audit_Date = DateTime.Now;
                }

                data.SubmitChanges();
            }

            return Json(new {success=true, message=string.Empty}, JsonRequestBehavior.AllowGet);
        }
        public ActionResult Delete()
        {
            var id = Request.Params["ID"];

            var errors = "B000";
            var message = "操作成功";

            if (!Const.IsNullOrEmpty(id))
            {
                using (DataClassesDataContext data = new DataClassesDataContext())
                {
                    var items = data.ProjectStageDTO.Where(t => t.ID == Convert.ToInt32(id)).ToList();
                    if (items.Count > 0)
                    {
                        var entity = items.First();

                        var profiles = data.ProfileDTO.Where(t => t.Project_Stage == entity.Name).Count();

                        if (profiles > 0)
                        {
                            errors = "B001";
                            message = "该项目阶段已包含文档, 不允删除";
                        }
                        else
                        {

                            data.ProjectStageDTO.DeleteOnSubmit(entity);
                            data.SubmitChanges();
                        }
                    }
                }
            }

            var retval = new
            {
                success = (errors == "B000"),
                errors = errors,
                message = message
            };

            return Json(retval, "text/html", JsonRequestBehavior.AllowGet);
        }
Esempio n. 13
0
        public ActionResult Create(ProjectDTO entity)
        {
            if (Const.IsNullOrEmpty(entity.Project_Code) && Const.IsNullOrEmpty(entity.Project_Name))
            {
                return Json(new
                {
                    success = false,
                    errors = "E001",
                    message = "项目编码、项目名称不允许空值。"
                }, "text/html", JsonRequestBehavior.AllowGet);
            }

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                if (data.ProjectDTO.Where(u => u.Project_Code == entity.Project_Code).Count() > 0)
                {
                    return Json(new
                    {
                        success = false,
                        errors = "E002",
                        message = "项目编码已经存在。"
                    }, "text/html", JsonRequestBehavior.AllowGet);
                }

                var directory = ConfigurationManager.AppSettings["Repository"];
                directory += entity.Project_Code;
                Const.Direcotry(directory);

                entity.Project_Date = Const.StripSubfix(entity.Project_Code);
                data.ProjectDTO.InsertOnSubmit(entity);
                data.SubmitChanges();
            }

            return Json(new
            {
                success = true,
                errors = "B000",
                message = "操作已成功。"
            }, "text/html", JsonRequestBehavior.AllowGet);
        }
Esempio n. 14
0
        public ActionResult Create(UserDTO entity)
        {
            int errors = 0;
            string message = string.Empty;

            if (Const.IsNullOrEmpty(entity.Login_ID))
            {
                errors++;
                message = "帐号名不能为空。<br/>";
            }

            if (Const.IsNullOrEmpty(entity.Username))
            {
                errors++;
                message = "用户名不能为空。<br/>";
            }

            if (Const.IsNullOrEmpty(entity.Role_Code)) entity.Role_Code = "Guest";

            if (entity.Department_ID <= 0) entity.Department_ID = 1;

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                if (data.UserDTO.Where(u => u.Login_ID == entity.Login_ID).Count() > 0)
                {
                    errors++;
                    message = entity.Login_ID + " 帐号已经存在。<br/>";
                }

                if (errors == 0)
                {
                    entity.Password = "******";
                    data.UserDTO.InsertOnSubmit(entity);
                    data.SubmitChanges();
                }
            }

            return Json(new {success = (errors == 0), message = message}, JsonRequestBehavior.AllowGet);
        }
Esempio n. 15
0
        public ActionResult Delete()
        {
            var id = Request.Params["ID"];

            if (!Const.IsNullOrEmpty(id))
            {
                using (DataClassesDataContext data = new DataClassesDataContext())
                {
                    var items = data.ProjectDTO.Where(t => t.ID == Convert.ToInt32(id)).ToList();
                    if (items.Count > 0)
                    {
                        var entity = items.First();
                        data.ProjectDTO.DeleteOnSubmit(entity);
                        data.SubmitChanges();

                        var filepath = ConfigurationManager.AppSettings["Repository"] + entity.Project_Code;
                        System.IO.Directory.Delete(filepath);
                    }
                }
            }

            return Json(new { success = true });
        }
Esempio n. 16
0
        public ActionResult Update(ProfileTemporaryDTO update)
        {
            if (Const.IsNullOrEmpty(update.Project_Code))
            {
                return Json(new
                {
                    success = false,
                    errors = "B001",
                    message = "项目编码必须填写."
                }, "text/html", JsonRequestBehavior.AllowGet);
            }

            if (Const.IsNullOrEmpty(update.Project_Code))
            {
                return Json(new
                {
                    success = false,
                    errors = "B002",
                    message = "项目名称必须填写."
                }, "text/html", JsonRequestBehavior.AllowGet);
            }

            if (Const.IsNullOrEmpty(update.Project_Stage))
            {
                return Json(new
                {
                    success = false,
                    errors = "B003",
                    message = "项目阶段必须填写."
                }, "text/html", JsonRequestBehavior.AllowGet);
            }

            if (Const.IsNullOrEmpty(update.Project_Subject))
            {
                return Json(new
                {
                    success = false,
                    errors = "B004",
                    message = "项目专业必须填写."
                }, "text/html", JsonRequestBehavior.AllowGet);
            }

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                List<ProfileTemporaryDTO> items = data.ProfileTemporaryDTO
                    .Where(u => u.Barcode == update.Barcode)
                    .ToList();

                if (items.Count > 0)
                {
                    ProfileTemporaryDTO entity = items.First();

                    entity.Diagram_Name = update.Diagram_Name;
                    entity.Diagram_Code = update.Diagram_Code;
                    entity.Diagram_Version = update.Diagram_Version;
                    entity.Diagram_Scale = update.Diagram_Scale;

                    entity.Project_Code = update.Project_Code;
                    entity.Project_Name = update.Project_Name;
                    entity.Project_Stage = update.Project_Stage.Replace(" ", "");
                    entity.Project_Subject = update.Project_Subject.Replace(" ", "");
                    entity.Project_Date = Const.StripSubfix(update.Project_Code);

                    entity.Business_Owner = update.Business_Owner;
                    entity.File_Name = update.File_Name;
                    data.SubmitChanges();
                }
                else
                {
                    return Json(new
                    {
                        success = true,
                        errors = "B008",
                        message = "无预备归档记录."
                    }, "text/html", JsonRequestBehavior.AllowGet);
                }
            }

            return Json(new
            {
                success = true,
                errors = "B000",
                message = "操作已成功."
            }, "text/html", JsonRequestBehavior.AllowGet);
        }
Esempio n. 17
0
        public ActionResult Update(RoleDTO entity)
        {
            if (entity.Code == "Administrator")
            {
                return Json(new { success = false, message = "系统管理员不能修改。<br/>" }, JsonRequestBehavior.AllowGet);
            }

            int errors = 0;
            string message = string.Empty;

            if (Const.IsNullOrEmpty(entity.Name))
            {
                errors++;
                message = "角色名称不能为空。<br/>";
            }

            if (Const.IsNullOrEmpty(entity.Code))
            {
                errors++;
                message = "角色编码不能为空。<br/>";
            }

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                var items = data.RoleDTO.Where(u => u.Code == entity.Code)
                    .ToList();

                if (items.Count == 0)
                {
                    errors++;
                    message = entity.Name + " 角色不存在。<br/>";
                }

                if (errors == 0)
                {
                    var e = items.First();

                    e.Name = entity.Name;
                    e.Description = entity.Description;

                    data.SubmitChanges();
                }
            }

            return Json(new { success = (errors == 0), message = message }, JsonRequestBehavior.AllowGet);
        }
        public ActionResult List()
        {
            List<ProjectStageDTO> items;

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                items = data.ProjectStageDTO.OrderBy(t => t.Name).ToList();
            }

            return Json(items, JsonRequestBehavior.AllowGet);
        }
Esempio n. 19
0
 public void Add(string name)
 {
     using (DataClassesDataContext data = new DataClassesDataContext())
     {
         data.ProjectSubjectDTO.InsertOnSubmit(new ProjectSubjectDTO() { Name = name });
         data.SubmitChanges();
     }
 }
Esempio n. 20
0
 public bool IsExists(string name)
 {
     bool retval = false;
     using (DataClassesDataContext data = new DataClassesDataContext())
     {
         retval = data.ProjectSubjectDTO.Where(t => t.Name == name).Count() > 0;
     }
     return retval;
 }
Esempio n. 21
0
        public ActionResult Update(DepartmentDTO entity)
        {
            try
            {
                if (entity.ID == 1)
                {
                    return Json(new { success = false, message = "默认部门不能修改。<br/>" }, JsonRequestBehavior.AllowGet);
                }

                int errors = 0;
                string message = string.Empty;

                if (Const.IsNullOrEmpty(entity.Name))
                {
                    errors++;
                    message = "部门名称不能为空。<br/>";
                }

                using (DataClassesDataContext data = new DataClassesDataContext())
                {
                    var items = data.DepartmentDTO.Where(u => u.ID == entity.ID)
                        .ToList();

                    if (items.Count == 0)
                    {
                        errors++;
                        message = entity.Name + " 部门不存在。<br/>";
                    }

                    if (errors == 0)
                    {
                        var e = items.First();

                        e.Name = entity.Name;
                        e.Description = entity.Description;

                        data.SubmitChanges();
                    }
                }

                return Json(new { success = (errors == 0), message = message }, JsonRequestBehavior.AllowGet);
            }
            catch
            {
                return View();
            }
        }
Esempio n. 22
0
        public int Archive(string barcode, bool archiveOption)
        {
            int retval = 0;
            var repository = ConfigurationManager.AppSettings["Repository"];
            var temporary = ConfigurationManager.AppSettings["Temporary"];

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                var items = data.ProfileTemporaryDTO.Where(u => u.Barcode == barcode).ToList();

                if (items.Count > 0)
                {
                    ProfileTemporaryDTO e = items.First();

                    try
                    {
                        string source = temporary + e.File_Name;

                        string directory = e.Project_Code + @"\" + e.Project_Stage + @"\" + e.Project_Subject + @"\";
                        string dest = repository + directory;

                        Const.Direcotry(dest);
                        e.File_Name = e.Barcode + '@' + e.File_Name; // 替换文件名, 使文件唯一存储在磁盘
                        dest += e.File_Name;

                        File.Copy(source, dest, true);
                        var extension = Const.GetExtension(dest);
                        if (extension.ToLower() == ".dwg")
                        {
                            // 转换PDF文件
                            var pdfFileName = Const.RemoveExtension(dest) + ".pdf";
                            DwgDirectXManager.Instance.ConvertToPDF(new InputOutputParam()
                            {
                                dwgFileName = dest,
                                pdfFileName = pdfFileName
                            });
                        }

                        retval = 1;
                    }
                    catch (FileNotFoundException)
                    {
                        retval = 2;
                    }
                    catch (DirectoryNotFoundException)
                    {
                        retval = 3;
                    }
                    catch (NotSupportedException)
                    {
                        retval = 4;
                    }
                    catch (IOException)
                    {
                        retval = 5;
                    }

                    if (retval == 1)
                    {
                        data.ProfileDTO.InsertOnSubmit(new ProfileDTO()
                        {
                            Barcode = e.Barcode,
                            Project_Code = e.Project_Code,
                            Project_Stage = e.Project_Stage,
                            Project_Name = e.Project_Name,
                            Project_Subject = e.Project_Subject,
                            Diagram_Name = e.Diagram_Name,
                            Diagram_Code = e.Diagram_Code,
                            Diagram_Version = e.Diagram_Version,
                            Diagram_Scale = e.Diagram_Scale,
                            File_Name = e.File_Name,
                            Created_Date = DateTime.Now,
                            Plotter = e.Plotter
                        });

                        data.ProfileTemporaryDTO.DeleteOnSubmit(e);
                        data.SubmitChanges();
                    }
                }
            }

            return retval;
        }
Esempio n. 23
0
        public List<ProjectDTO> List()
        {
            List<ProjectDTO> items = null;

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                items = data.ProjectDTO.ToList();
            }

            return items;
        }
Esempio n. 24
0
        public ActionResult List()
        {
            ActionResult retval = null;
            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                retval = Json(data.RoleDTO.ToList(), JsonRequestBehavior.AllowGet);
            }

            return retval;
        }
Esempio n. 25
0
        public ActionResult List()
        {
            string str = Request.Params["items"];

            List<ProfileTemporaryDTO> items = new List<ProfileTemporaryDTO>();

            if (Const.NotEmpty(str))
            {
                using (DataClassesDataContext data = new DataClassesDataContext())
                {
                    var splits = str.Split(new char[]{';'}, StringSplitOptions.RemoveEmptyEntries);
                    var results = (from e in data.ProfileTemporaryDTO select e).Where(t => splits.Contains(t.Barcode)).ToList();
                    items.AddRange(results);
                }
            }

            return Json(items.Select(u => new
            {
                Barcode = u.Barcode,
                Project_Code = u.Project_Code,
                Project_Stage = u.Project_Stage.Replace(" ", ""),
                Project_Name = u.Project_Name,
                Project_Subject = u.Project_Subject.Replace(" ", ""),
                File_Name = u.File_Name,
                Diagram_Code = u.Diagram_Code,
                Diagram_Name = u.Diagram_Name,
                Diagram_Version = u.Diagram_Version,
                Diagram_Scale = u.Diagram_Scale,
                Created_Date = u.Created_Date.ToString("yyyy-MM-dd"),
                Plotter = u.Plotter
            }), JsonRequestBehavior.AllowGet);
        }
Esempio n. 26
0
        public ActionResult List()
        {
            ActionResult retval = null;
            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                string sql = "SELECT A.Login_ID, A.Username, A.Department_ID, A.Role_Code, B.Name AS Department_Name, C.Code AS Role_Code, C.Name AS Role_Name FROM dbo.T_USER A LEFT JOIN dbo.T_DEPARTMENT B ON A.DEPARTMENT_ID=B.ID LEFT JOIN dbo.T_ROLE C ON A.ROLE_CODE=C.CODE ORDER BY A.Login_ID ASC";
                var items = data.ExecuteQuery<UserModel>(sql).ToList();
                retval = Json(items, JsonRequestBehavior.AllowGet);
            }

            return retval;
        }
Esempio n. 27
0
        public ProfileTemporaryDTO GetProfileTemporary(string barcode)
        {
            ProfileTemporaryDTO retval = null;
            using (DataClassesDataContext context = new DataClassesDataContext())
            {
                var items = context.ProfileTemporaryDTO.Where(c => c.Barcode == barcode).ToList();
                if (items.Count > 0)
                {
                    retval = items.First();
                }
            }

            return retval;
        }
Esempio n. 28
0
        public ActionResult Update(UserDTO entity)
        {
            try
            {
                if (entity.Login_ID == "Admin")
                {
                    return Json(new { success = false, message = "Admin 帐号不能修改。<br/>" }, JsonRequestBehavior.AllowGet);
                }

                int errors = 0;
                string message = string.Empty;

                if (Const.IsNullOrEmpty(entity.Login_ID))
                {
                    errors++;
                    message = "帐号不能为空。<br/>";
                }

                if (Const.IsNullOrEmpty(entity.Username))
                {
                    errors++;
                    message = "用户名不能为空。<br/>";
                }

                if (Const.IsNullOrEmpty(entity.Role_Code)) entity.Role_Code = "Guest";

                if (entity.Department_ID <= 0) entity.Department_ID = 1;

                using (DataClassesDataContext data = new DataClassesDataContext())
                {
                    var items = data.UserDTO.Where(u => u.Login_ID == entity.Login_ID)
                        .ToList();

                    if (items.Count == 0)
                    {
                        errors++;
                        message = entity.Login_ID + " 帐号不存在。<br/>";
                    }

                    if (errors == 0)
                    {
                        var e = items.First();

                        e.Login_ID = entity.Login_ID;
                        e.Department_ID = entity.Department_ID;
                        e.Role_Code = entity.Role_Code;
                        e.Username = entity.Username;

                        data.SubmitChanges();
                    }
                }

                return Json(new { success = (errors == 0), message = message }, JsonRequestBehavior.AllowGet);
            }
            catch
            {
                return View();
            }
        }
Esempio n. 29
0
        public ActionResult Execute()
        {
            var barcode = Request.Params["barcode"];
            var handler = Request.Params["handler"];
            var archiveOption = Request.Params["archiveOption"];

            if (Const.IsNullOrEmpty(barcode))
            {
                var result = new { errors = "E001", message = "条形码不能为空。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

            ProfileTemporaryDTO entity = ProfileTemporaryService.GetProfileTemporary(barcode);

            if (entity == null)
            {
                var result = new { errors = "B001", message = "无预备归档记录。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

            if (BarcodeService.IsExists(barcode))
            {
                var result = new { errors = "B002", message = "条形码已存在。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

            if (Const.IsNullOrEmpty(entity.Project_Code))
            {
                var result = new { errors = "B003", message = "项目编码不能为空。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

            if (Const.IsNullOrEmpty(entity.Project_Name))
            {
                var result = new { errors = "B004", message = "项目名称不能为空。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

            if (handler == "B008")
            {
                using (DataClassesDataContext data = new DataClassesDataContext())
                {
                    var newEntity = new ProjectDTO()
                    {
                        Project_Code = entity.Project_Code,
                        Project_Name = entity.Project_Name,
                        Project_Date = Const.StripSubfix(entity.Project_Code),
                        Business_Owner = entity.Business_Owner
                    };
                    data.ProjectDTO.InsertOnSubmit(newEntity);
                    data.SubmitChanges();
                }
            }

            if (Const.IsNullOrEmpty(entity.Project_Stage))
            {
                var result = new { errors = "B005", message = "项目阶段不能为空。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

            if (Const.IsNullOrEmpty(entity.Project_Subject))
            {
                var result = new { errors = "B006", message = "项目专业不能为空。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

            if (Const.IsNullOrEmpty(entity.File_Name))
            {
                var result = new { errors = "B007", message = "文件名不能为空。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

            if (!ProjectService.IsExists(entity.Project_Code))
            {
                var result = new { errors = "B008", message = "项目编码不存在。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

            if (!ProjectStageService.IsExists(entity.Project_Stage.Replace(" ", "")))
            {
                var result = new { errors = "B009", message = "项目阶段不存在。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

            if (!ProjectSubjectService.IsExists(entity.Project_Subject.Replace(" ", "")))
            {
                var result = new { errors = "B010", message = "项目专业不存在。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

            int status = ProfileTemporaryService.Archive(barcode, false);

            if (status == 2)
            {
                var result = new { errors = "B011", message = "试图访问磁盘上不存在的文件失败。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }
            else if (status == 3)
            {
                var result = new { errors = "B012", message = "当找不到文件或目录。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }
            else if (status == 4)
            {
                var result = new { errors = "B013", message = "当调用的方法不受支持,或试图读取、查找<br/>或写入不支持调用功能的流。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }
            else if (status == 5)
            {
                var result = new { errors = "B014", message = "发生 I/O 错误。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

            return Json(new {errors = "B000", message = "已成功。"}, JsonRequestBehavior.AllowGet);
        }
Esempio n. 30
0
        public ProjectDTO Get(string projectCode)
        {
            ProjectDTO retval = null;

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                var items = data.ProjectDTO.Where(t => t.Project_Code == projectCode).ToList();
                if (items.Count > 0)
                {
                    retval = items.First();
                }
            }

            return retval;
        }