Exemplo n.º 1
0
        public ActionResult StatementRestDays(string sid, DateTime? dateStart, int? daysCount, string cause)
        {
            var data = new StatementRestFewDays();
            data.SidEmployee = sid;
            data.DateStart = dateStart.Value;
            data.DaysCount = daysCount.Value;
            data.Cause = cause;
            data.Configure();

            return View("Statement", data);
        }
Exemplo n.º 2
0
        public ActionResult StatementRestFewDays(StatementRestFewDays data)
        {
            try
            {
                data.Configure();
            }
            catch (Exception ex)
            {
                TempData["ServerError"] = ex.Message;
                return View("StatementFewDays", data);
            }
            HtmlToPdf converter = new HtmlToPdf();

            string url = Url.Action("StatementRestDays", new{sid=data.SidEmployee, dateStart=data.DateStart, daysCount=data.DaysCount, cause=data.Cause});
            var leftPartUrl = String.Format("{0}://{1}:{2}", Request.RequestContext.HttpContext.Request.Url.Scheme, Request.RequestContext.HttpContext.Request.Url.Host, Request.RequestContext.HttpContext.Request.Url.Port);
            url = String.Format("{1}{0}", url, leftPartUrl);
            PdfDocument doc = converter.ConvertUrl(url);
            MemoryStream stream = new MemoryStream();
            doc.Save(stream);
            return File(stream.ToArray(), "application/pdf");
        }
Exemplo n.º 3
0
 public ActionResult StatementRestFewDays(StatementRestFewDays data)
 {
     try
     {
         data.Configure();
     }
     catch (Exception ex)
     {
         TempData["ServerError"] = ex.Message;
         return View("StatementFewDays", data);
     }
     HtmlToPdf converter = new HtmlToPdf();
     var statementPrint = new StatementPrint
     {
         IdStatementType = 2,
         EmployeeSid = data.SidEmployee,
         DateBegin = data.DateStart,
         DateEnd = data.DateStart.AddDays(data.DaysCount),
         DurationDays = data.DaysCount,
         Cause = data.Cause,
         IdDepartment = data.Employee.Department.Id,
         IdOrganization = data.Employee.Organization.Id,
         Confirmed = false
     };
     ResponseMessage rm;
     if (statementPrint.Save(out rm))
         statementPrint.Id = rm.Id;
     string url = Url.Action("StatementRestDays", new{sid=data.SidEmployee, dateStart=data.DateStart, daysCount=data.DaysCount, cause=data.Cause, id=statementPrint.Id});
     var leftPartUrl = String.Format("{0}://{1}:{2}", Request.RequestContext.HttpContext.Request.Url.Scheme, Request.RequestContext.HttpContext.Request.Url.Host, Request.RequestContext.HttpContext.Request.Url.Port);
     url = String.Format("{1}{0}", url, leftPartUrl);
     PdfDocument doc = converter.ConvertUrl(url);
     MemoryStream stream = new MemoryStream();
     doc.Save(stream);
     return File(stream.ToArray(), "application/pdf");
 }