예제 #1
0
 public ServicesManager(DataManager dataManager)
 {
     _dataManager          = dataManager;
     _depatrmentService    = new DepatrmentService(_dataManager);
     _firedService         = new FiredService(_dataManager);
     _positionService      = new PositionService(_dataManager);
     _rankService          = new RankService(_dataManager);
     _staffService         = new StaffService(_dataManager);
     _subDepartmentService = new SubDepartmentService(_dataManager);
     _decreeService        = new DecreeService(_dataManager);
 }
        public ActionResult Details(int id)
        {
            int OrgID = int.Parse(Request.Cookies["OrgID"].Value);
            OrganizationModel orgmodel = new OrganizationService().GetOrganizationByID(OrgID);

            ViewBag.Departments = orgmodel.Departments;

            SubDepartmentModel model = new SubDepartmentService().GetSubDepartmentDetails(id);

            return(View("Modify", model));
        }
예제 #3
0
        public ActionResult Upload(Document model, HttpPostedFileBase uploadFile)
        {
            // Verify that the user selected a file

            if (model != null && uploadFile != null && uploadFile.ContentLength > 0)
            {
                try
                {
                    int  UserID     = int.Parse(Request.Cookies["UserID"].Value);
                    bool authorized = Framework.Security.SecurityBase.IsUserRoleAuthorized(UserID, model.DepartmentID, model.SubDepartmentID, "Doc Upload");
                    if (!authorized)
                    {
                        throw new Exception("Access denied! You donot have permission to upload any document for the department/subdepartment.");
                    }
                    using (TransactionScope trans = new TransactionScope())
                    {
                        // extract only the fielname
                        var fileName = Path.GetFileName(uploadFile.FileName);

                        // Save file
                        model.FileType  = new FileInfo(fileName).Extension;
                        model.CreatedBy = Request.Cookies["UserEmail"].Value;
                        Document newDocinfo = new DocumentFacade().Save(model);

                        string rootpath = Server.MapPath("~/WorkSpaces/" + newDocinfo.PhysicalPath);

                        var path = Path.Combine(rootpath, model.DocumentName + model.FileType);
                        if (DocumentHelper.CreatePath(path))
                        {
                            // Save meta data
                            var    metadata_path = Path.Combine(Server.MapPath("~/WorkSpaces/" + newDocinfo.MetaDataPath), model.DocumentName + ".xml");
                            string metadata      = XmlHelper.Serialize(newDocinfo, newDocinfo.GetType());
                            System.IO.File.WriteAllText(metadata_path, metadata);
                            // Save document
                            uploadFile.SaveAs(path);
                            trans.Complete();
                        }
                    }
                    // build response message
                    var    dept     = new DepartmentService().GetDepartmentDetails(model.DepartmentID);
                    string deptName = dept.DepartmentName;

                    // build response message
                    string subDeptName = "";
                    if (model.SubDepartmentID > 0)
                    {
                        var subdept = new SubDepartmentService().GetSubDepartmentDetails(model.SubDepartmentID);
                        subDeptName = "/" + subdept.SubDepartmentName;
                    }

                    this.ShowMessage(Helpers.MessageType.Success, "New document for " + deptName + subDeptName + " created/revised successfully");
                    return(RedirectToAction("Index", "DocumentLibrary"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
            }

            // Rebuild data
            int OrgID = int.Parse(Request.Cookies["OrgID"].Value);
            List <DepartmentModel> depts = new OrganizationService().GetOrganizationByID(OrgID).Departments;

            ViewBag.Departments    = depts;
            ViewBag.SubDepartments = new List <SubDepartmentModel>();



            return(View(model));
        }