/// <summary>
        /// Export product shipping commands by using specific conditions
        /// </summary>
        /// <returns></returns>
        public async Task <ActionResult> ExportProductShippingCommands(ExportProductShippingCommandViewModel parameters)
        {
            try
            {
                if (parameters == null)
                {
                    parameters = new ExportProductShippingCommandViewModel();
                    TryValidateModel(parameters);
                }

                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                // Find results.
                ConfigurationService configurationService = new ConfigurationService();
                var data = new
                {
                    items = await _productShippingCommandDomain.FindProductShippingCommandsForPrinting(parameters.ShippingNo,
                                                                                                       parameters.ProductCode, parameters.lstPalletNo, parameters.ProductLotNo, parameters.ProductLotNo, parameters.Settings,
                                                                                                       parameters.ShelfNo),
                    page        = parameters.Settings.PageIndex,
                    shippingNo  = parameters.ShippingNo,
                    productCode = parameters.ProductCode,
                    productName = parameters.ProductName,
                    currentTime = DateTime.Now.ToString("dd-MM-yyyy HH:mm"),
                    companyName = configurationService.CompanyName,
                };

                // Template file location detect.
                var file = Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.ProductShippingCommand));

                //Read the template.
                var template = await _exportReportDomain.ReadTemplateFileAsync(file);

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

                return(Json(new
                {
                    render
                }));
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
Exemple #2
0
        public async Task <ActionResult> ExportPreProductRetrievalRecord(string from, string to)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                // Find the list of records
                string exportMaterialNameAbsolutePath = "";
                // check status

                var result =
                    await _ManagementReportDomain.SearchPreProductRetrievalRecord(from, to);

                // Export the template.
                if (result.FindPrintManagementReportItem.Count > 0)
                {
                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.PreProductRetrievalRecord));
                }
                else
                {
                    //Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.PreProductRetrievalRecordEmpty));
                }
                // Read the template.
                var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);


                var render = await _exportReportDomain.ExportToFlatFileAsync(result, template);

                var jsonResult = Json(new
                {
                    render
                }, "application/json");
                jsonResult.MaxJsonLength = int.MaxValue;

                return(jsonResult);
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
        public async Task <ActionResult> Print(MaterialReqListSearchViewModel model)
        {
            // Parameters are invalid.
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            string renderedData;

            // Base on what user selects, print the related.

            // Find the template absolute path.
            var exportPreProductAbsolutePath =
                Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.MaterialRequirementList));

            // Read the template.
            var masterListPreProductTemplate =
                await _exportReportDomain.ReadTemplateFileAsync(exportPreProductAbsolutePath);

            // Find all records.
            var result        = _materialRequirementListDomain.SearchCriteria(ConvertHelper.ConvertToDateTimeFull("01/" + model.DateSearch), null);
            var lstPreProduct = new
            {
                Data = new
                {
                    result.Data.data,
                    currentDate = DateTime.Now.ToString("dd/MM/yyyy"),
                    yearMonth   = model.DateSearch,
                    companyName = WebConfigurationManager.AppSettings["CompanyName"]
                }
            };

            // Render template
            renderedData =
                await _exportReportDomain.ExportToFlatFileAsync(lstPreProduct.Data,
                                                                masterListPreProductTemplate);

            return(Json(new
            {
                render = renderedData,
            }));
        }
Exemple #4
0
        public async Task <ActionResult> ExportKneadingCommands(PrintInputKneadingCommandViewModel item)
        {
            try
            {
                // Request parameters haven't been initialized.
                if (item == null)
                {
                    item = new PrintInputKneadingCommandViewModel();
                    TryValidateModel(item);
                }

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

                // Find the list of records
                var result =
                    await _inputOfKneadingCommandDomain.SearchRecordsForPrinting(item.PreProductCode, item.CommandNo);

                // Find the template file.
                var exportKneadingCommandAbsolutePath =
                    Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InputKneadingCommands));

                // Read the template.
                var template = await _exportReportDomain.ReadTemplateFileAsync(exportKneadingCommandAbsolutePath);

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

                return(Json(new
                {
                    render
                }));
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
Exemple #5
0
        public async Task <ActionResult> ExportConsumerMaterial(string yearmonth)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                // Find the list of records
                string exportMaterialNameAbsolutePath = "";
                // check status

                var result =
                    await _ProductCerfiticateConsumedListDomain.PrintConsumerCerfiticates(yearmonth);

                // Find the template file.
                exportMaterialNameAbsolutePath =
                    Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.ConsumerProduct));
                // Read the template.
                var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

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

                var jsonResult = Json(new
                {
                    render
                }, "application/json");
                jsonResult.MaxJsonLength = int.MaxValue;

                return(jsonResult);
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
Exemple #6
0
        public async Task <ActionResult> ExportExtPreProductName(string status)
        {
            try
            {
                // Request parameters are invalid.
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                // Find the list of records
                var exportExtPreProductNameAbsolutePath = "";
                var render = string.Empty;
                // check status
                if (status == "0")
                {
                    var printingNormalResult = new
                    {
                        normal      = await _inquiryByExternalPreProductNameDomain.SearchRecordsForPrintingNormal(),
                        companyName = _configurationService.CompanyName,
                        datetime    = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                    };
                    // Find the template file.
                    exportExtPreProductNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InquiryByExtPreProductNameNormal));
                    // Read the template.
                    var printingTemplateNormal = await _exportReportDomain.ReadTemplateFileAsync(exportExtPreProductNameAbsolutePath);

                    // Export the template.
                    render = await _exportReportDomain.ExportToFlatFileAsync(printingNormalResult, printingTemplateNormal);

                    return(Json(new
                    {
                        render
                    }));
                }
                else if (status == "1")
                {
                    var printingExternalResult = new
                    {
                        external    = await _inquiryByExternalPreProductNameDomain.SearchRecordsForPrintingExternal(),
                        companyName = _configurationService.CompanyName,
                        datetime    = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                    };
                    // Find the template file.
                    exportExtPreProductNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InquiryByExtPreProductNameExternal));
                    // Read the template.
                    var printingExternalTemplate = await _exportReportDomain.ReadTemplateFileAsync(exportExtPreProductNameAbsolutePath);

                    // Export the template.
                    render = await _exportReportDomain.ExportToFlatFileAsync(printingExternalResult, printingExternalTemplate);

                    return(Json(new
                    {
                        render
                    }));
                }
                var printingAllResult = new
                {
                    normal      = await _inquiryByExternalPreProductNameDomain.SearchRecordsForPrintingNormal(),
                    external    = await _inquiryByExternalPreProductNameDomain.SearchRecordsForPrintingExternal(),
                    companyName = _configurationService.CompanyName,
                    //datetime = DateTime.Today.ToString("g"),
                    datetime = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                };


//#if DEBUG

//                var externals = printingAllResult.external;
//                var normals = printingAllResult.normal;
//#endif
                // Find the template file.
                exportExtPreProductNameAbsolutePath =
                    Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InquiryByExtPreProductNameAll));

                // Read the template.
                var printingAllResultTemplate = await _exportReportDomain.ReadTemplateFileAsync(exportExtPreProductNameAbsolutePath);

                // Export the template.
                render = await _exportReportDomain.ExportToFlatFileAsync(printingAllResult, printingAllResultTemplate);

                return(Json(new
                {
                    render
                }));
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
        public async Task <ActionResult> Print(MasterListSearchViewModel masterListSearchViewModel)
        {
            try
            {
                var companyName = WebConfigurationManager.AppSettings["CompanyName"];
                // Parameter hasn't been initialized.
                if (masterListSearchViewModel == null)
                {
                    masterListSearchViewModel = new MasterListSearchViewModel();
                    TryValidateModel(masterListSearchViewModel);
                }

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

                string renderedData;

                // Base on what user selects, print the related.
                switch (masterListSearchViewModel.SearchBy)
                {
                case 1:

                    // Find the template absolute path.
                    var exportPreProductAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.MasterListPreProduct));

                    // Read the template.
                    var masterListPreProductTemplate =
                        await _exportReportDomain.ReadTemplateFileAsync(exportPreProductAbsolutePath);

                    // Find all records.
                    var preProducts = _preProductDomain.MaterialListPrint(masterListSearchViewModel.MasterCode);

//#if DEBUG
//                        preProducts.Data.data = preProducts.Data.data.Take(10);
//#endif
                    var lstPreProduct = new
                    {
                        Data = new
                        {
                            preProducts.Data.data,
                            currentDate = DateTime.Now.ToString("dd/MM/yyyy HH:mm"),
                            companyName
                        }
                    };
                    // Render template
                    renderedData =
                        await
                        _exportReportDomain.ExportToFlatFileAsync(lstPreProduct.Data,
                                                                  masterListPreProductTemplate);

                    break;

                case 2:
                    // Find the template absolute path.
                    var exportProductAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.MasterListProduct));

                    // Read the template.
                    var masterListProductTemplate =
                        await _exportReportDomain.ReadTemplateFileAsync(exportProductAbsolutePath);

                    // Find all records.
                    var products = _productDomain.SearchPrint(masterListSearchViewModel.MasterCode, null);

                    var lstproduct = new
                    {
                        Data = new
                        {
                            products.Data.data,
                            currentDate = DateTime.Now.ToString("dd/MM/yyyy HH:mm"),
                            companyName
                        }
                    };
                    // Render template
                    renderedData =
                        await
                        _exportReportDomain.ExportToFlatFileAsync(lstproduct.Data,
                                                                  masterListProductTemplate);

                    break;

                default:
                    // Find the template absolute path.
                    var exportMaterialAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.MasterListMaterial));

                    // Read the template.
                    var masterListMaterialTemplate =
                        await _exportReportDomain.ReadTemplateFileAsync(exportMaterialAbsolutePath);



                    // Find all records.
                    var materials = _materialDomain.SearchCriteria(masterListSearchViewModel.MasterCode, null);
                    //   materials.Data.data = materials.Data.data.ToList();

                    var material = new
                    {
                        Data = new
                        {
                            materials.Data.data,
                            currentDate = DateTime.Now.ToString("dd/MM/yyyy HH:mm"),
                            companyName
                        }
                    };
                    // Render template
                    renderedData =
                        await
                        _exportReportDomain.ExportToFlatFileAsync(material.Data,
                                                                  masterListMaterialTemplate);

                    break;
                }

                var jsonResult = Json(new
                {
                    render = renderedData,
                });
                jsonResult.MaxJsonLength = int.MaxValue;
                return(jsonResult);
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
Exemple #8
0
        public async Task <ActionResult> ExportMaterialName(string status)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                // Find the list of records
                string exportMaterialNameAbsolutePath = "";
                //DateTime saveUtcNow = DateTime.UtcNow;

                // check status
                if (status == "0")
                {
                    var result = new
                    {
                        normal      = await _inquiryByMaterialNameDomain.SearchRecordsForPrinting(),
                        companyName = _configurationService.CompanyName,
                        datetime    = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                    };

                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InquiryByMaterialNameNormal));
                    // Read the template.
                    var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

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

                    return(Json(new
                    {
                        render
                    }));
                }
                else if (status == "1")
                {
                    var result = new
                    {
                        external    = await _inquiryByMaterialNameDomain.SearchRecordsForPrintingBailment(),
                        companyName = _configurationService.CompanyName,
                        datetime    = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                    };

                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InquiryByMaterialNameBailment));
                    // Read the template.
                    var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

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

                    return(Json(new
                    {
                        render
                    }));
                }
                else
                {
                    var printingAllResult = new
                    {
                        normal      = await _inquiryByMaterialNameDomain.SearchRecordsForPrinting(),
                        external    = await _inquiryByMaterialNameDomain.SearchRecordsForPrintingBailment(),
                        companyName = _configurationService.CompanyName,
                        datetime    = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                    };
                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InquiryByMaterialNameAll));
                    // Read the template.
                    var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

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

                    return(Json(new
                    {
                        render
                    }));
                }
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
Exemple #9
0
        public async Task <ActionResult> ExportMaterialName(string status)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                // Find the list of records
                string exportMaterialNameAbsolutePath = "";
                // check status
                if (status == "0")
                {
                    var result =
                        await _MaterialStockDomain.SearchRecordsForPrinting(status);

                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.ReportByMaterialNameNormal));
                    // Read the template.
                    var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

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

                    return(Json(new
                    {
                        render
                    }));
                }
                else if (status == "1")
                {
                    var result =
                        await _MaterialStockDomain.SearchRecordsForPrinting(status);

                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.ReportByMaterialNameBailment));
                    // Read the template.
                    var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

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

                    return(Json(new
                    {
                        render
                    }));
                }
                else
                {
                    var result =
                        await _MaterialStockDomain.SearchRecordsForPrintingAll();

                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.ReportByMaterialNameAll));
                    // Read the template.
                    var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

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

                    return(Json(new
                    {
                        render
                    }));
                }
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }