Пример #1
0
        public ActionResult UploadDoc(TManager.Models.ViewModels.AttachedFileVM uploadhelper)
        {
            if (ModelState.IsValid)
            {
                if (uploadhelper.AttachedFile != null && uploadhelper.AttachedFile.ContentLength > 0)
                {
                    var    realFileName  = System.IO.Path.GetFileName(uploadhelper.AttachedFile.FileName);
                    var    filePath      = Server.MapPath("~/App_Data/UploadedDoc");
                    var    fileName      = DateTime.Now.Ticks + System.IO.Path.GetExtension(uploadhelper.AttachedFile.FileName);
                    string savedFileName = System.IO.Path.Combine(filePath, fileName);
                    uploadhelper.AttachedFile.SaveAs(savedFileName);
                    // init object here
                    var evd = new TempDoc();
                    evd.FileName       = realFileName;
                    evd.FileSystemName = fileName;
                    evd.ContentType    = uploadhelper.AttachedFile.ContentType;
                    evd.FileExtension  = Path.GetExtension(fileName);
                    // for now
                    evd.Description = uploadhelper.FDescription;
                    // evd.WorkFlowName = "Vendor Registration";
                    evd.FileStatus = 1;
                    unitOfWork.Repository <TempDoc>().Insert(evd);
                    unitOfWork.Save();
                    // we shall send back the id for this file
                    return(Json(new { ID = evd.TempID, R = true, FileName = evd.FileName, FileSystemName = evd.FileSystemName, Description = evd.Description, DLink = Url.Action("DownloadTemp", "Home", new { id = evd.TempID }) }));
                }
            }

            return(Json(new { R = false }));
        }
Пример #2
0
 public ActionResult DeleteTempDoc(string id)
 {
     if (!(string.IsNullOrEmpty(id)))
     {
         int     delID    = int.Parse(id);
         TempDoc doc      = unitOfWork.Repository <TempDoc>().GetByID(delID);
         string  fullPath = Request.MapPath("~/App_Data/UploadedDoc/" + doc.FileName);
         if (System.IO.File.Exists(fullPath))
         {
             System.IO.File.Delete(fullPath);
         }
         unitOfWork.Repository <TempDoc>().Delete(doc);
         unitOfWork.Save();
         return(Json(new { msg = "Document Remove successfully", D = true }));
     }
     return(Json(new { msg = "error in removing doc", D = false }));
 }
Пример #3
0
        public ActionResult AddProject(ProjectReg preg)
        {
            var           insertProject  = new ProjectReg();
            List <string> arr            = new List <string>();
            string        tid            = null;
            int           CompID         = 0;
            var           additionalFile = false;

            try
            {
                insertProject.ProjectName     = preg.ProjectName;
                insertProject.Priority        = preg.Priority;
                insertProject.ProjectManager  = preg.ProjectManager;
                insertProject.DeptResponsible = preg.DeptResponsible;
                insertProject.LeadDeveloper   = preg.LeadDeveloper;

                var otherDev = preg.multiSelectLob.Split(','); //string.Join(",", preg.multiSelectLob.ToArray()).Split(',');
                foreach (var o in otherDev.ToList())
                {
                    var od = unitOfWork.Repository <Team>().Get(f => f.Fullname == o);
                    if (od.Count() > 0) //.FirstOrDefault().TeamID;
                    {
                        tid = od.FirstOrDefault().TeamID.ToString();

                        arr.Add(tid);
                        od = null;
                    }
                }
                CompID = int.Parse(preg.CompanyID);
                var com = unitOfWork.Repository <Company>().GetByID(CompID);
                insertProject.OtherDeveloper  = string.Join(",", arr.ToArray());
                insertProject.NumberOfUsers   = preg.NumberOfUsers;
                insertProject.oDeveloper      = preg.oDeveloper;
                insertProject.oProjectManager = preg.oProjectManager;
                insertProject.CompanyID       = preg.CompanyID;
                insertProject.CompanyName     = com.CompanyName;
                insertProject.BusinessNeed    = preg.BusinessNeed;
                insertProject.BizContact      = com.ContactPerson;
                insertProject.DateRecieved    = DateTime.Now;

                // insertProject.RegisteredBy
                insertProject.ProjectRemark    = preg.ProjectRemark;
                insertProject.ProjectStatus    = preg.ProjectStatus;
                insertProject.ProjectTaskType  = preg.ProjectTaskType;
                insertProject.ProjectObjective = preg.ProjectObjective;
                insertProject.ProjectStatus    = TManager.Models.Consts.ApprovalConsts.PENDING;
                bool hasv = unitOfWork.Repository <ProjectReg>().Get().Any(a => a.ProjectName == insertProject.ProjectName);
                if (hasv == false)
                {
                    unitOfWork.Repository <ProjectReg>().Insert(insertProject);
                    unitOfWork.Save();
                    var       docs = unitOfWork.Repository <TempDoc>().Get().Where(d => d.Description == insertProject.ProjectName && d.FileStatus == 1);
                    UploadDoc doc  = new UploadDoc();
                    if (docs != null && docs.ToList().Count != 0)
                    {
                        foreach (var f in docs)
                        {
                            doc.FileName       = f.FileName;
                            doc.FileSystemName = f.FileSystemName;
                            doc.Description    = f.Description;
                            doc.ProjectID      = insertProject.ProjectRegisterID;
                            doc.ContentType    = f.ContentType;
                            unitOfWork.Repository <UploadDoc>().Insert(doc);
                            unitOfWork.Save();
                        }

                        // we have to set the file status to 2 to differentiate the ones taken from tempDoc to vendorDoc tables
                        foreach (var t in docs)
                        {
                            TempDoc td = unitOfWork.Repository <TempDoc>().GetByID(t.TempID);
                            td.FileStatus = 2;
                            td.ProjectID  = insertProject.ProjectRegisterID;
                            unitOfWork.Repository <TempDoc>().Update(td);
                        }
                        unitOfWork.Save();
                    }
                }
                return(RedirectToAction("Projects"));
            }

            catch (DbEntityValidationException e)
            {
                ViewBag.Error = e.StackTrace;
                foreach (var eve in e.EntityValidationErrors)
                {
                    ViewBag.Error += eve.Entry.Entity.GetType().Name + ", " + eve.Entry.State;
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        ViewBag.Error += ve.PropertyName + " :: " + ve.ErrorMessage;
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
            }
            // set notification for approval
            //    string TargetMsg = PCMS_v1.Models.Consts.Message.RequesterLp1VendorMsg(insertVendor.VendorName, newaction.ActionID, BasePath());
            //    string subject = "#" + insertVendor.VendorID + " / " + insertVendor.VendorType + "/" + insertVendor.VendorName + " Registration Approval";
            //    var lp1Data = unitOfWork.Repository<ConsolStaffData>().Get(e => e.POSITION_NBR == RequesterData.ReportsTo).FirstOrDefault();
            //    // initiator's message
            //    string initiatorMsg = PCMS_v1.Models.Consts.Message.initiatorMsg(insertVendor);
            //    //insertVendor.RequesterLp1Data.FullName = lp1Data.FULL_NAME;
            //    insertVendor.RequesterData = DataHelper.GetRequesterInfo(unitOfWork, insertVendor.VendorRequester);
            //    insertVendor.RequesterData.FullName = RequesterData.LastName + " " + RequesterData.OtherNames;
            //    insertVendor.RequesterData.EmailAddress = RequesterData.EmailAddress;
            //    string TargetMail = lp1Data.EMAIL_ADDR;
            //    // we can fire mail to both requester and initiator
            //      SendEmail(TargetMsg, TargetMail, subject, newaction.ActionID, newaction, PCMS_v1.Models.Consts.ProcessAndFlowName.VENDOR_PROCESS);
            //    SendEmail(initiatorMsg, RequesterData.EmailAddress, subject, newaction.ActionID, newaction, PCMS_v1.Models.Consts.ProcessAndFlowName.VENDOR_PROCESS);
            //    // NotifyNextActor(insertVendor, insertVendor.RequesterLp1, insertVendor.RequesterLp1, PCMS_v1.Models.Consts.ActorRole.REQUESTER_LP1, "ReviewVendor", PCMS_v1.Models.Consts.ActorRole.VENDOR_PROCESS, sequenceNumber, insertVendor.VendorID, targetMsg, initiatorMsg, insertVendor.RequesterLp1Data.EmailAddress, insertVendor.RequesterData.EmailAddress);

            //TempData["CssClass"] = "success";
            //TempData["Notify"] = "Vendor" + insertVendor.VendorName + " created successfully !";

            var company = unitOfWork.Repository <Company>().Get().OrderBy(o => o.CompanyName);

            var LeadDev    = unitOfWork.Repository <Team>().Get();
            var projectMgr = unitOfWork.Repository <Team>().Get(e => e.Role == TManager.Models.Consts.ActorRole.PROJECT_MANAGER);

            ViewBag.LeadDeveloper  = new SelectList(LeadDev, "TeamID", "Fullname");
            ViewBag.ProjectManager = new SelectList(projectMgr, "TeamID", "Fullname");
            ViewBag.CompanyID      = new SelectList(company, "CompanyID", "CompanyName");
            return(View());
        }