コード例 #1
0
        //public ActionResult ISR110_GetRptDeliveryConfirmData(string strSlipNo)
        //{
        //    strSlipNo = "401029201112043";
        //    IReportHandler reportHandler = ServiceContainer.GetService<IReportHandler>() as IReportHandler;
        //    List<RPTDeliveryConfirmDo> rptList = reportHandler.GetRptDeliveryConfirmData(strSlipNo);

        //    IDocumentHandler dochandler = ServiceContainer.GetService<IDocumentHandler>() as IDocumentHandler;
        //    List<tbm_DocumentTemplate> dLst = dochandler.GetDocumentTemplateByDocumentCode(DocumentCode.C_DOCUMENT_CODE_DELIVERY_CONFIRMATION_AND_WARRANTY);

        //    ReportDocument rptH = new ReportDocument();

        //    string path = ReportUtil.GetReportPath("Reports/ISR110_DeliveryConfirmData.rpt", Server.MapPath("/"));

        //    rptH.Load(path);

        //    List<RPTDeliveryConfirmDo> lst = new List<RPTDeliveryConfirmDo>();
        //    int i = 0;
        //    foreach (RPTDeliveryConfirmDo rptDataRow in rptList)
        //    {
        //        lst.Add(rptDataRow);
        //        if (dLst.Count > 0)
        //        {
        //            lst[i].DocumentNameEN = dLst[0].DocumentNameEN;
        //            lst[i].DocumentVersion = dLst[0].DocumentVersion;
        //        }
        //        i++;
        //    }
        //    rptH.SetDataSource(lst);
        //    rptH.Subreports["Page1"].SetDataSource(lst);
        //    rptH.Subreports["Page2"].SetDataSource(lst);
        //    Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        //    rptH.Close();

        //    return File(stream, "application/pdf");
        //}
        #endregion

        public ActionResult GenerateInstallationSlipDocBySlipNo()
        {
            ObjectResultData             res         = new ObjectResultData();
            ICommonHandler               comHandler  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            IInstallationDocumentHandler docHand     = ServiceContainer.GetService <IInstallationDocumentHandler>() as IInstallationDocumentHandler;
            IInstallationHandler         installHand = ServiceContainer.GetService <IInstallationHandler>() as IInstallationHandler;

            try
            {
                //using (TransactionScope scope = new TransactionScope())
                //{
                List <tbt_InstallationSlip> installList  = installHand.GetTbt_InstallationSlip(null);
                List <tbt_DocumentList>     documentList = comHandler.GetTbt_DocumentList(null, null, null);

                installList = (from t in installList
                               where //(
                                     //t.SlipStatus == "01"
                                     //|| t.SlipStatus == "02"
                                     //|| t.SlipStatus == "03"
                                     //|| t.SlipStatus == "04"
                                     //|| t.SlipStatus == "06")
                                     //&& t.SlipIssueFlag == true
                                     //&& t.CreateDate >= new DateTime(2013,7,24,12,20,0)
                               t.CreateBy == "INITIAL" &&
                               documentList.Any(d => (d.DocumentNo == t.SlipNo))
                               select t).ToList <tbt_InstallationSlip>();

                foreach (tbt_InstallationSlip data in installList)
                {
                    tbt_InstallationSlip dataSlip = installHand.GetTbt_InstallationSlipData(data.SlipNo);

                    //if (dataSlip != null
                    //        && dataSlip.SlipStatus != SlipStatus.C_SLIP_STATUS_NO_NEED_TO_STOCK_OUT
                    //        && dataSlip.SlipStatus != SlipStatus.C_SLIP_STATUS_NOT_STOCK_OUT //Modify by Jutarat A. on 07022013
                    //        && dataSlip.SlipStatus != SlipStatus.C_SLIP_STATUS_PARTIAL_STOCK_OUT //Add by Jutarat A. on 17062013
                    //        && dataSlip.SlipStatus != SlipStatus.C_SLIP_STATUS_STOCK_OUT) //Add by Jutarat A. on 24062013
                    //{
                    //    return Json(res);
                    //}

                    if (dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_NEW || dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_CHANGEPLAN_NEW)
                    {
                        //6.1.1.	Call		InstallationDocumentHandler.CreateISR010
                        //Parameter	doTbt_InstallationSlip.SlipNo
                        //Return		fsPDFFileISR010
                        docHand.CreateInstallationReport(dataSlip.SlipNo, DocumentCode.C_DOCUMENT_CODE_NEW_INSTALL_SLIP_RENTAL);
                    }

                    if (dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_CHANGE_WIRING ||
                        dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_CHANGEPLAN_AFTER_NEW ||
                        dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_MAINTENANCE_EXCHANGE ||
                        dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_MOVE ||
                        dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_PERIODICAL_MAINTENANCE ||
                        dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_REMOVE_DURING_STOP_PARTIAL ||
                        dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_REMOVE_DURING_STOP_REMOVE_ALL ||
                        dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_CHANGE_WIRING ||
                        dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_MAINTENANCE_EXCHANGE ||
                        dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_MOVE ||
                        dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_PARTIAL_REMOVE
                        )
                    {
                        //6.2.1.	Call		InstallationDocumentHandler.CreateISR020
                        //Parameter	doTbt_InstallationSlip.SlipNo
                        //Return		fsPDFFileISR020
                        docHand.CreateInstallationReport(dataSlip.SlipNo, DocumentCode.C_DOCUMENT_CODE_CHANGE_INSTALL_SLIP);
                    }
                    if (dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_REMOVE_ALL ||
                        dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_REMOVE_ALL)
                    {
                        //6.3.1.	Call		InstallationDocumentHandler.CreateISR030
                        //Parameter	doTbt_InstallationSlip.SlipNo
                        //Return		fsPDFFileISR030
                        docHand.CreateInstallationReport(dataSlip.SlipNo, DocumentCode.C_DOCUMENT_CODE_REMOVAL_INSTALL_SLIP);
                    }
                    if (dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_NEW ||
                        dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_ADD)
                    {
                        //6.4.1.	Call		InstallationDocumentHandler.CreateISR040
                        //Parameter	doTbt_InstallationSlip.SlipNo
                        //Return		fsPDFFileISR040
                        docHand.CreateInstallationReport(dataSlip.SlipNo, DocumentCode.C_DOCUMENT_CODE_NEW_INSTALL_SLIP_SALE);
                    }

                    if (dataSlip != null && dataSlip.SlipIssueFlag != FlagType.C_FLAG_ON)
                    {
                        dataSlip.SlipIssueFlag = FlagType.C_FLAG_ON;
                        int updatedRpw = installHand.UpdateTbt_InstallationSlip(dataSlip);
                    }
                }

                //    scope.Complete();
                //    res.ResultData = "Process Complete.";
                //}

                res.ResultData = "Process Complete.";
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
コード例 #2
0
        public doBatchProcessResult WorkProcess(string strUserId, DateTime dtBatchDate)
        {
            IBatchProcessHandler         batchHand = ServiceContainer.GetService <IBatchProcessHandler>() as IBatchProcessHandler;
            IInstallationDocumentHandler insHand   = ServiceContainer.GetService <IInstallationDocumentHandler>() as IInstallationDocumentHandler;
            int failed = 0;
            int total  = 0;

            try
            {
                CommonUtil.SetTransDataForJobScheduler(strUserId, dtBatchDate);

                List <tbt_InstallationReprint> lstSlipNo = insHand.GetTbt_InstallationReprint();
                total = lstSlipNo.Count;
                foreach (tbt_InstallationReprint slip in lstSlipNo)
                {
                    try
                    {
                        if (slip.DocumentCode == DocumentCode.C_DOCUMENT_CODE_NEW_INSTALL_SLIP_RENTAL ||
                            slip.DocumentCode == DocumentCode.C_DOCUMENT_CODE_CHANGE_INSTALL_SLIP ||
                            slip.DocumentCode == DocumentCode.C_DOCUMENT_CODE_REMOVAL_INSTALL_SLIP ||
                            slip.DocumentCode == DocumentCode.C_DOCUMENT_CODE_NEW_INSTALL_SLIP_SALE)
                        {
                            Stream tmp = insHand.CreateInstallationReport(slip.SlipNo, slip.DocumentCode);

                            if (tmp != null)
                            {
                                batchHand.InsertTbt_BatchLog(dtBatchDate, "99", string.Format("Reprint installation report completed: {0}: {1} {2}", slip.Id, slip.DocumentCode, slip.SlipNo), false, strUserId);
                                tmp.Close();
                            }
                            else
                            {
                                batchHand.InsertTbt_BatchLog(dtBatchDate, "99", string.Format("Reprint installation report completed without file: {0}: {1} {2}", slip.Id, slip.DocumentCode, slip.SlipNo), true, strUserId);
                                failed++;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        batchHand.InsertTbt_BatchLog(dtBatchDate, "99", string.Format("Reprint installation report error: {0}: {1} {2} - {3} {4} {5}", slip.Id, slip.DocumentCode, slip.SlipNo, ex.Message, ex.ToString(), ex.StackTrace), true, strUserId);
                        failed++;
                    }
                }
            }
            catch (Exception ex)
            {
                batchHand.InsertTbt_BatchLog(dtBatchDate, "99", string.Format("Reprint installation report error: {0} {1} {2}", ex.Message, ex.ToString(), ex.StackTrace), true, strUserId);
                failed = total = 0;
            }

            return(new doBatchProcessResult()
            {
                Result = FlagType.C_FLAG_ON,
                BatchStatus = (failed == 0 ? BatchStatus.C_BATCH_STATUS_SUCCEEDED : BatchStatus.C_BATCH_STATUS_FAILED),
                Total = total,
                Complete = total - failed,
                Failed = failed,
                ErrorMessage = null,
                BatchUser = strUserId,
                BatchDate = dtBatchDate
            });
        }