Пример #1
0
 /// <summary>
 ///     Print the list of input commands.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public ActionResult Export()
 {
     try
     {
         var model = new PrintProductCertificationViewModel
         {
             StartDate = DateTime.Now.ToString("dd/MM/yyyy"),
             EndDate   = DateTime.Now.ToString("dd/MM/yyyy")
                         //IsCreate = true
                         //F39_Status = Constants.Status.Yet.ToString(),
                         //F39_KndEptBgnDate = DateTime.Now.ToString("MM/yyyy")
         };
         //if (!string.IsNullOrEmpty(prodCode) && !string.IsNullOrEmpty(prePdtLotNo) &&
         //    !string.IsNullOrEmpty(productFlg))
         //{
         //    var entity = _prodCerDomain.GetById(prodCode, prePdtLotNo, productFlg);
         //    if (entity != null)
         //    {
         //        model = Mapper.Map<ProductCertificationViewModel>(entity);
         //        //model.F39_Status = Enum.GetName(typeof(Constants.Status), ConvertHelper.ToInteger(model.F39_Status));
         //        model.IsCreate = false;
         //    }
         //}
         return(PartialView("_PartialPrintProductCertification", model));
     }
     catch (Exception exception)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
     }
 }
Пример #2
0
        public async Task <ActionResult> ExportDetail(PrintProductCertificationViewModel item)
        {
            try
            {
                // Request parameters haven't been initialized.
                if (item == null)
                {
                    item = new PrintProductCertificationViewModel();
                    TryValidateModel(item);
                }

                // Request parameters are invalid.
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                string file = null;

                switch (item.PrintProductCertificationStatus)
                {
                case Constants.PrintProductCertificationStatus.Certificated:
                    file = Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.StockCertified));
                    break;

                case Constants.PrintProductCertificationStatus.OutOfSpec:
                    file = Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.StockListOutOfSpec));
                    break;

                default:
                    file = Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.StockListUncertificated));
                    break;
                }

                var data = new
                {
                    items = await _prodCerDomain.FindProductCertificationsForPrinting(item.PrintProductCertificationStatus, ConvertHelper.ConvertToDateTimeFull(item.StartDate), ConvertHelper.ConvertToDateTimeFull(item.EndDate)),
                    //  page = item.Settings.PageIndex.ToString("###"),
                    company     = WebConfigurationManager.AppSettings["CompanyName"], // TODO: Move to web.config
                    currentDate = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                };

                if (data.items != null)
                {
                    var template = await _exportReportDomain.ReadTemplateFileAsync(file);

                    // Export the template.
                    var render = await _exportReportDomain.ExportToFlatFileAsync(data, template);

                    return(Json(new
                    {
                        render
                    }));
                }
                else
                {
                    return(Json(new { Success = false, Message = ProductManagementResources.MSG1 }));
                }

                // Read the template.
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }