コード例 #1
0
        // GET: /<controller>/
        public IActionResult Index()
        {
            var user = _userHelper.GetUser(User);

            var roles = _userManager
                        .GetRolesAsync(user)
                        .Result
                        .ToList();

            if (User.IsInRole("Contractor"))
            {
                var srf            = _userHelper.GetCurrentSrfByLogin(User);
                var ContractorInfo = _candidate.GetById(srf.CandidateId);
                var Vacancy        = _vacancy.GetById(ContractorInfo.VacancyId);
                ViewBag.Srf            = srf;
                ViewBag.ContractorInfo = ContractorInfo;
                ViewBag.Departement    = _department.GetById(srf.DepartmentId);
                ViewBag.DepartmentSub  = _departmentSub.GetById(srf.DepartmentSubId);
                ViewBag.LineManager    = _userHelper.GetUserProfile(srf.ApproveOneId.Value);
                ViewBag.ProjectManager = _userHelper.GetUserProfile(srf.ProjectManagerId);
                ViewBag.SSOW           = _ssow.GetById(Vacancy.ServicePackId);
                if (ContractorInfo.HomeBaseId.HasValue)
                {
                    ViewBag.HomeBase = _city.GetById(ContractorInfo.HomeBaseId).Name;
                }
                else
                {
                    ViewBag.HomeBase = "-";
                }
            }
            else
            {
                ViewBag.Srf            = null;
                ViewBag.ContractorInfo = null;
                ViewBag.Departement    = null;
                ViewBag.DepartmentSub  = null;
                ViewBag.LineManager    = null;
            }


            ViewBag.ModelForm   = _mapper.Map <UpdateProfileForm>(user);
            ViewBag.CurretRoles = roles;
            return(View(_mapper.Map <ApplicationUserViewModel>(user)));
        }
コード例 #2
0
        public string CurrentTemplate()
        {
            string   sWebRootFolder = _environment.WebRootPath;
            string   sFileName      = @"report/TRCP_TEMPLATE.xlsx";
            string   URL            = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, sFileName);
            FileInfo file           = new FileInfo(Path.Combine(sWebRootFolder, sFileName));

            if (file.Exists)
            {
                file.Delete();
                file = new FileInfo(Path.Combine(sWebRootFolder, sFileName));
            }
            using (ExcelPackage package = new ExcelPackage(file))
            {
                ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Sheet1");
                int            i         = 0;
                int            index     = 1;
                worksheet.Cells[index, i += 1].Value = "Organization / Sub Organization";
                worksheet.Cells[index, i += 1].Value = "TRCP Approved";
                worksheet.Cells[index, i += 1].Value = "TRCP Forecast";
                worksheet.Cells[index, i += 1].Value = "Date SRF";

                for (int i_temp = 1; i_temp <= i; i_temp++)
                {
                    worksheet.Cells[index, i_temp].Style.Font.Bold        = true;
                    worksheet.Cells[index, i_temp].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                    worksheet.Cells[index, i_temp].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.FromArgb(79, 129, 189));
                    worksheet.Cells[index, i_temp].Style.Font.Color.SetColor(System.Drawing.Color.White);
                }


                index += 1;
                var Data = Service.GetAll().ToList();
                if (Data != null)
                {
                    foreach (var row in Data)
                    {
                        if (row.DepartmentId.HasValue && row.DepartmentSubId == null)
                        {
                            var Temp = _dept.GetById(row.DepartmentId);
                            worksheet.Cells[index, 1].Value = Temp.Name;
                        }
                        else
                        {
                            var Temp = _deptSub.GetById(row.DepartmentSubId);
                            worksheet.Cells[index, 1].Value = Temp.SubName;
                        }
                        worksheet.Cells[index, 2].Value = row.Approved;
                        worksheet.Cells[index, 3].Value = row.Forecast;
                        if (row.DateSrf.HasValue)
                        {
                            worksheet.Cells[index, 4].Value = row.DateSrf.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
                        }
                        else
                        {
                            worksheet.Cells[index, 4].Value = "";
                        }
                        index++;
                    }
                }
                worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
                package.Save();
            }
            return(URL);
        }