protected string GetConverterCommandParam( string actionName, RosterFiltersModel filters, int? sortBy, bool? sortDescending) { var localhostUrl = ConfigurationManager.AppSettings["localhost"]; string args = string.Format(@"{0}{1}{2}{3}{4}{5}{6}", filters.BeginDate.HasValue ? string.Format("beginDate={0}&", filters.BeginDate.Value.ToShortDateString()) : string.Empty, filters.EndDate.HasValue ? string.Format("endDate={0}&", filters.EndDate.Value.ToShortDateString()) : string.Empty, filters.DepartmentId, filters.StatusId.HasValue ? string.Format("statusId={0}&", filters.StatusId.Value) : string.Empty, !string.IsNullOrEmpty(filters.UserName) ? string.Format("userName={0}&", Server.UrlEncode(filters.UserName)) : string.Empty, sortBy.HasValue ? string.Format("sortBy={0}&", sortBy.Value) : string.Empty, sortDescending.HasValue ? string.Format("sortDescending={0}&", sortDescending.Value) : string.Empty ); if (!string.IsNullOrEmpty(args)) { args = args.Substring(0, args.Length - 1); } return !string.IsNullOrEmpty(localhostUrl) ? string.Format(@"{0}/{1}/{2}?{2}", localhostUrl, "Employment", actionName, args) : Url.Content(string.Format(@"{0}/{1}?{2}", "Employment", actionName, args)); }
public ActionResult Roster(RosterFiltersModel input, RosterModel roster, bool isApproveModified = false) { RosterModel model = EmploymentBl.GetRosterModel(input); /* string error = string.Empty; if (isApproveModified) { EmploymentBl.SaveApprovals(roster, out error); } */ return View(model); }
public ActionResult GetPrintRoster(RosterFiltersModel filters, int? sortBy, bool? sortDescending) { return GetListPrintForm("PrintRoster", filters, sortBy, sortDescending, true); }
public ActionResult PrintRoster(RosterFiltersModel filters, int? sortBy, bool? sortDescending) { IList<CandidateDto> model = EmploymentBl.GetPrintRosterModel(filters, sortBy, sortDescending); return View(model); }
public ActionResult GetListPrintForm( string actionName, RosterFiltersModel filters, int? sortBy, bool? sortDescending, bool isLandscape = false) { string filePath = null; try { var folderPath = ConfigurationManager.AppSettings["PresentationFolderPath"]; var fileName = string.Format("{0}.pdf", Guid.NewGuid()); folderPath = HttpContext.Server.MapPath(folderPath); if (!Directory.Exists(folderPath)) Directory.CreateDirectory(folderPath); filePath = Path.Combine(folderPath, fileName); var arguments = new StringBuilder(); var cookieName = FormsAuthentication.FormsCookieName; var authCookie = Request.Cookies[cookieName]; if (authCookie == null || authCookie.Value == null) throw new ArgumentException("Ошибка авторизации."); if (isLandscape) arguments.AppendFormat(" --orientation Landscape {0} --cookie {1} {2}", GetConverterCommandParam(actionName, filters, sortBy, sortDescending), cookieName, authCookie.Value); else arguments.AppendFormat("{0} --cookie {1} {2}", GetConverterCommandParam(actionName, filters, sortBy, sortDescending), cookieName, authCookie.Value); arguments.AppendFormat(" \"{0}\"", filePath); var serverSideProcess = new Process { StartInfo = { FileName = ConfigurationManager.AppSettings["PdfConverterCommandLineTemplate"], Arguments = arguments.ToString(), UseShellExecute = true, }, EnableRaisingEvents = true, }; serverSideProcess.Start(); serverSideProcess.WaitForExit(); return GetFile(Response, Request, Server, filePath, fileName, @"application/pdf", actionName + ".pdf"); } catch (Exception ex) { Log.Error("Exception on GetPrintForm", ex); throw; } finally { if (!string.IsNullOrEmpty(filePath) && System.IO.File.Exists(filePath)) { try { System.IO.File.Delete(filePath); } catch (Exception ex) { Log.Warn(string.Format("Exception on delete file {0}", filePath), ex); } } } }