示例#1
0
        protected override void UpdateData(SrfRequest item, SrfRequestModelForm model)
        {
            var Dept = _department.GetById(model.DepartmentId);
            var Network = _network.GetById(model.NetworkId);
            int total_day = Extension.MonthDistance(model.SrfBegin, model.SrfEnd);
            item.SrfBegin = model.SrfBegin;
            item.SrfEnd = model.SrfEnd;
            item.DepartmentId = model.DepartmentId;
            item.DepartmentSubId = model.DepartmentSubId;
            item.CostCenterId = model.CostCenterId;
            item.AccountId = model.AccountId;
            item.NetworkId = model.NetworkId;
            item.Description = model.Description;
            item.ApproveSixId = model.ApproveSixId;
            item.ServicePackId = model.FormVacancy.ServicePackId;
            item.ServiceLevel = model.FormVacancy.OtLevel;
            item.IsHrms = model.FormVacancy.isHrms;
            item.IsManager = model.FormVacancy.isManager;
            item.Number = model.Number;
            item.Type = model.Type;
            item.ActivityId = model.ActivityId;
            item.ApproveStatusOne = model.ApproveStatusOne;
            item.ApproveStatusTwo = model.ApproveStatusTwo;
            item.ApproveStatusThree = model.ApproveStatusThree;
            item.ApproveStatusFour = model.ApproveStatusFour;
            item.ApproveStatusFive = model.ApproveStatusFive;
            item.ApproveStatusSix = model.ApproveStatusSix;
            item.isWorkstation = model.FormVacancy.isLaptop == 1 ? true : false;
            item.isCommunication = model.FormVacancy.isUsim;
            item.ProjectManagerId = Network.ProjectManagerId;
            item.ApproveOneId = model.ApproveOneId;
            item.Status = model.Status;

            if(model.ApproveTwoId!=0)
            {
                item.ApproveTwoId = model.ApproveTwoId;
            }

            if (model.ApproveThreeId!=0)
            {
                item.ApproveThreeId = model.ApproveThreeId;
            }

            if (model.ApproveFourId !=0)
            {
                item.ApproveFourId = model.ApproveFourId;
            }

            if (model.ApproveFiveId !=0)
            {
                item.ApproveFiveId = model.ApproveFiveId;
            }

            if (model.ApproveSixId!=0)
            {
                item.ApproveSixId = model.ApproveSixId;
            }


            var Esc = _escalation.GetAll().Where(x => x.SrfId.Equals(x.Id)).FirstOrDefault();
            if(Esc!=null)
            {
                Esc.ApproveStatusOne = model.ApproveStatusTwo;
                if(Dept.OperateOrNon == 1)
                {
                    Esc.ApproveStatusTwo = model.ApproveStatusTwo;
                }
                else
                {
                    Esc.ApproveStatusTwo = model.ApproveStatusThree;
                }
                Esc.ApproveStatusThree = model.ApproveStatusFive;
                Esc.ApproveStatusFour = model.ApproveStatusSix;
                _escalation.Update(Esc);
             
            }

            if (model.ExtendFrom!=null)
            {
                item.ExtendFrom = model.ExtendFrom;
                item.IsExtended = true;
            }
            else
            {
                item.ExtendFrom = null;
                item.IsExtended = false;
            }

            if (item.Type == SrfType.Extension)
            {
                item.AnnualLeave = item.AnnualLeave + (int)total_day;
            }
            else
            {
                item.AnnualLeave = (int)total_day;
            }

            if (Dept.OperateOrNon == 1)
            {
                // Send To Head Of Service Line
                item.ApproveFourId = null;
                item.ApproveTwoId = model.ApproveTwoId;
                item.ApproveThreeId = model.ApproveThreeId;
            }
            else
            {
                // Send To Non Head Operation
                item.ApproveTwoId = null;
                item.ApproveThreeId = null;
                item.ApproveFourId = model.ApproveFourId;
            }

           
                // Update Vacancy
            var Candidate = _candidate.GetById(item.CandidateId);
            if (Candidate != null)
            {
                var Vacancy = _vacancy.GetById(Candidate.VacancyId);
                var UppdateVacancy = Mapper.Map(model.FormVacancy, Vacancy);
                UppdateVacancy.AccountNameId = item.AccountId.Value;
                UppdateVacancy.CostCodeId = item.CostCenterId;
                UppdateVacancy.DepartmentId = item.DepartmentId;
                UppdateVacancy.DepartmentSubId = item.DepartmentSubId;
                UppdateVacancy.NetworkId = item.NetworkId;
                UppdateVacancy.ApproverOneId = item.ApproveOneId;
                UppdateVacancy.ServicePackId = model.FormVacancy.ServicePackId;
                UppdateVacancy.isLaptop = model.FormVacancy.isLaptop == 1 ? true : false;
                UppdateVacancy.isUsim = model.FormVacancy.isUsim;
                UppdateVacancy.isHrms = model.FormVacancy.isHrms;
                UppdateVacancy.isManager = model.FormVacancy.isManager;
                UppdateVacancy.OtLevel = model.FormVacancy.OtLevel;
                _vacancy.Update(UppdateVacancy);

               
               

                // Set SRF Status

                var UserProfile = _profileService.GetById(Candidate.AccountId);
                if (item.Status == SrfStatus.Done)
                {
                    UserProfile.IsBlacklist = false;
                    UserProfile.IsTerminate = false;
                    UserProfile.IsActive = true;
                    _profileService.Update(UserProfile);
                }

                if (item.Status == SrfStatus.Terminate)
                {
                    UserProfile.IsBlacklist = false;
                    UserProfile.IsTerminate = true;
                    UserProfile.IsActive = false;
                    _profileService.Update(UserProfile);
                }

                if (item.Status == SrfStatus.Blacklist)
                {
                    UserProfile.IsBlacklist = true;
                    UserProfile.IsTerminate = false;
                    UserProfile.IsActive = false;
                    _profileService.Update(UserProfile);
                }

                Candidate.AgencyId = model.AgencyId;
                _candidate.Update(Candidate);


                TempData["Success"] = "OK";
            }
        }
        public IActionResult Update(EscalationModelForm model)
        {
            if (ModelState.IsValid)
            {
                var srf = Service.GetById(model.SrfId);
                if (srf != null)
                {
                    var item      = _escalation.GetAll().Where(x => x.SrfId.Equals(model.SrfId)).FirstOrDefault();
                    var Dept      = _department.GetById(srf.DepartmentId);
                    int ProfileId = 0;
                    if (Dept.OperateOrNon == 1)
                    {
                        ProfileId = model.Srf.ApproveTwoId;
                    }
                    else
                    {
                        ProfileId = model.Srf.ApproveFourId;
                    }
                    item.OtLevel          = model.OtLevel;
                    item.IsWorkstation    = model.IsWorkstation;
                    item.IsCommnunication = model.IsCommnunication;
                    item.SparateValue     = model.SparateValue;
                    item.Note             = model.Note;
                    item.ServicePackId    = model.ServicePackId;

                    //nitip
                    item.CustomField1 = model.PackageTypeId?.ToString();
                    item.CustomField2 = model.ServicePackCategoryId?.ToString();

                    if (!string.IsNullOrWhiteSpace(model.Files))
                    {
                        var split = model.Files.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                        item.Files = JsonConvert.SerializeObject(split);
                    }

                    _escalation.Update(item);

                    // Update Srf General
                    srf.SrfBegin        = model.Srf.SrfBegin;
                    srf.SrfEnd          = model.Srf.SrfEnd;
                    srf.AnnualLeave     = Extension.MonthDistance(model.Srf.SrfBegin, model.Srf.SrfEnd);
                    srf.DepartmentId    = model.Srf.DepartmentId;
                    srf.DepartmentSubId = model.Srf.DepartmentSubId;
                    srf.CostCenterId    = model.Srf.CostCenterId;
                    srf.AccountId       = model.Srf.AccountId;
                    srf.NetworkId       = model.Srf.NetworkId;
                    srf.ApproveFiveId   = model.Srf.ApproveFiveId;
                    srf.ApproveSixId    = model.Srf.ApproveSixId;
                    srf.SpectValue      = model.SparateValue;
                    if (model.SparateValue > 0)
                    {
                        srf.RateType = RateType.SpecialRate;
                    }
                    else
                    {
                        srf.RateType = RateType.Normal;
                    }
                    //srf.RateType = RateType.SpecialRate;
                    Service.Update(srf);

                    // Update Vacancy
                    var Candidate = _candidate.GetById(srf.CandidateId);
                    if (Candidate != null)
                    {
                        var Vacancy = _vacancy.GetById(Candidate.VacancyId);
                        if (Vacancy != null)
                        {
                            Vacancy.AccountNameId   = srf.AccountId.Value;
                            Vacancy.CostCodeId      = srf.CostCenterId;
                            Vacancy.DepartmentId    = srf.DepartmentId;
                            Vacancy.DepartmentSubId = srf.DepartmentSubId;
                            Vacancy.NetworkId       = srf.NetworkId;
                            Vacancy.ApproverOneId   = srf.ApproveOneId;
                            Vacancy.ServicePackId   = srf.ServicePackId;
                            Vacancy.isLaptop        = srf.isWorkstation;
                            Vacancy.isUsim          = srf.isCommunication;
                            Vacancy.isHrms          = srf.IsHrms;
                            Vacancy.OtLevel         = model.OtLevel;
                            _vacancy.Update(Vacancy);
                        }
                    }
                }
            }
            TempData["Saved"] = "OK";
            return(RedirectToAction("Edit", "ContractorDataEscalation", new { id = model.SrfId }));
        }
示例#3
0
文件: EnableSrf.cs 项目: feblaw/ebast
        private void Upload()
        {
            var AllUser       = _userProfile.GetAll().ToList();
            var AllVacancy    = _vacancy.GetAll().ToList();
            var AllCandidate  = _candidate.GetAll().ToList();
            var AllEscalation = _escalation.GetAll().ToList();

            foreach (var row in AllUser)
            {
                String IdNumber = null;
                if (!string.IsNullOrEmpty(row.IdNumber))
                {
                    if (row.IdNumber.Length > 16)
                    {
                        IdNumber = row.IdNumber.Substring(0, 16);
                    }
                    else
                    {
                        IdNumber = row.IdNumber;
                    }
                }
                else
                {
                    Random random = new Random();
                    IdNumber = random.Next(0, 16).ToString();
                }

                var Pro = _userProfile.GetById(row.Id);

                // Upload User Profile
                if (!String.IsNullOrEmpty(row.Photo))
                {
                    var File = System.IO.File.Exists(Source + "/" + row.Photo);
                    if (File == true)
                    {
                        String   src    = Upload("temp", row.Photo);
                        FileInfo info   = new FileInfo(Source + "/" + row.Photo);
                        var      result = new Attachment()
                        {
                            Name     = info.Name,
                            FileType = info.Extension,
                            Type     = Attachment.FILE_TYPE_UPLOAD,
                            Path     = src,
                            Size     = info.Length / 1024
                        };
                        string output = JsonConvert.SerializeObject(result);
                        Pro.Photo = output;
                    }
                }


                Pro.IdNumber = IdNumber;
                _userProfile.Update(Pro);
            }



            // Vacancy

            foreach (var row in AllVacancy)
            {
                List <string> files = new List <string>();
                var           vac   = _vacancy.GetById(row.Id);

                if (!String.IsNullOrEmpty(row.Files))
                {
                    var attach = row.Files.Split(',');
                    if (attach != null)
                    {
                        foreach (var a in attach)
                        {
                            var File = System.IO.File.Exists(Source + "/" + a);
                            if (File == true)
                            {
                                String src = Upload("vacancy", a);
                                files.Add(src);
                            }
                        }
                    }
                }

                if (files != null)
                {
                    vac.Files = JsonConvert.SerializeObject(files);
                    _vacancy.Update(vac);
                }
            }


            // Candidate
            foreach (var row in AllCandidate)
            {
                List <string> files = new List <string>();
                var           can   = _candidate.GetById(row.Id);

                if (!String.IsNullOrEmpty(row.Attachments))
                {
                    var attach = row.Attachments.Split(',');
                    if (attach != null)
                    {
                        foreach (var a in attach)
                        {
                            var File = System.IO.File.Exists(Source + "/" + a);
                            if (File == true)
                            {
                                String src = Upload("candidate", a);
                                files.Add(src);
                            }
                        }
                    }
                }

                if (files != null)
                {
                    can.Attachments = JsonConvert.SerializeObject(files);
                    _candidate.Update(can);
                }
            }


            //Srf Escalation
            foreach (var row in AllEscalation)
            {
                List <string> files = new List <string>();
                var           esc   = _escalation.GetById(row.Id);

                if (!String.IsNullOrEmpty(row.Files))
                {
                    var attach = row.Files.Split(',');
                    if (attach != null)
                    {
                        foreach (var a in attach)
                        {
                            var File = System.IO.File.Exists(Source + "/" + a);
                            if (File == true)
                            {
                                String src = Upload("escalation", a);
                                files.Add(src);
                            }
                        }
                    }
                }

                if (files != null)
                {
                    esc.Files = JsonConvert.SerializeObject(files);
                    _escalation.Update(esc);
                }
            }
        }