Exemple #1
0
        public bool RunGenerateReport()
        {
            log.DebugFormat("RunGenerateReport() - Start");
            bool result = true;

            try
            {
                for (int i = 0; i < dtProject.Rows.Count; i++)
                {
                    log.DebugFormat("RunGenerateReport() - Process {0}/{1} for Project {2}", i + 1, dtProject.Rows.Count, dtProject.Rows[i]["projectcode"].ToString());

                    string projectcode = dtProject.Rows[i]["projectcode"].ToString();

                    if (!CheckIsProjectInAllowed(projectcode))
                    {
                        log.DebugFormat("RunGenerateReport() - Process {0}/{1} Stopped because Project {2} is in exception.", i + 1, dtProject.Rows.Count, dtProject.Rows[i]["projectcode"].ToString());
                        continue;
                    }

                    string   sCluster = GetClusterFormattedString(projectcode);
                    DateTime asofDate = DateTime.Now;

                    if (string.IsNullOrEmpty(sCluster))
                    {
                        log.DebugFormat("RunGenerateReport() - Process {0}/{1} Failed. Cannot found Cluster for Project {2} ", i + 1, dtProject.Rows.Count, dtProject.Rows[i]["projectcode"].ToString());
                        continue;
                    }


                    int batchid = clsSalesSummary.GenerateSalesSummary(projectcode, sCluster, asofDate, "System Generated");

                    if (batchid != null)
                    {
                        log.DebugFormat("RunGenerateReport() - Process {0}/{1} for Project {2}. BatchID : {3}", i + 1, dtProject.Rows.Count, dtProject.Rows[i]["projectcode"].ToString(), batchid);

                        //update collection
                        initDTFinal_CollectionDetail();
                        _DTFinal_CollectionDetail = clsSalesSummary.GenerateScheduleCollection(projectcode, sCluster);
                        _DTFinal_CollectionDetail.Columns.Add("BatchID", System.Type.GetType("System.Int32"), batchid.ToString());
                        _DTFinal_CollectionDetail.Columns["BatchID"].SetOrdinal(0);

                        clsSalesSummary.InsertScheduleCollectionDetail(_DTFinal_CollectionDetail);


                        //update paidcomm
                        NewCommWS.NewComm_Services1 NewCommWS = new LKReportingSystem.NewCommWS.NewComm_Services1();
                        NewCommWS.Timeout = 600000;
                        decimal PaidComm   = 0;
                        decimal UnpaidComm = 0;
                        log.DebugFormat("NewComm Web Service Invoked.. Parameter sent: projectcode={0}", projectcode);
                        PaidComm   = NewCommWS.getCommPaid(projectcode);
                        UnpaidComm = NewCommWS.getCommUnprocessed(projectcode);


                        BudgetMktWS.WS_BudgetMarketing BudgetMktWS = new LKReportingSystem.BudgetMktWS.WS_BudgetMarketing();
                        BudgetMktWS.Timeout = 600000;

                        //update budgetmkt
                        decimal BudgetMKTExpense = 0;
                        log.DebugFormat("BudgetMkt Web Service [getBudgetMktActualExpense] Method Invoked.. Parameter sent: projectcode={0}", projectcode);
                        BudgetMKTExpense = BudgetMktWS.getBudgetMktActualExpense(projectcode);

                        //insert budgetmkt detail
                        initDTFinal_MktExpenseDetail();

                        log.DebugFormat("BudgetMkt Web Service [getBudgetMktActualExpenseDetail] Method Invoked.. Parameter sent: projectcode={0}", projectcode);
                        _DTFinal_MktExpenseDetail = Helper.ConvertXMLToDataset(BudgetMktWS.getBudgetMktActualExpenseDetail(projectcode)).Tables[0];
                        _DTFinal_MktExpenseDetail.Columns.Add("BatchID", System.Type.GetType("System.Int32"), batchid.ToString());
                        _DTFinal_MktExpenseDetail.Columns["BatchID"].SetOrdinal(0);

                        clsSalesSummary.InsertActualBudgetMktDetail(_DTFinal_MktExpenseDetail);


                        //actual Cost Contract
                        CostContractWS.WS_CostAndContract CostContractWS = new LKReportingSystem.CostContractWS.WS_CostAndContract();
                        CostContractWS.Timeout = 600000;
                        log.DebugFormat("CostContract Web Service [RetrieveProjectMapping] Method Invoked.. Parameter sent: projectcode={0}", projectcode);

                        initDT_CostContractProjectMapping();

                        if (CostContractWS.RetrieveProjectMapping(projectcode).Tables.Count != 0)
                        {
                            _DT_CostContractProjectMapping = CostContractWS.RetrieveProjectMapping(projectcode).Tables[0];

                            processActualConstructionCost(_DT_CostContractProjectMapping, batchid, asofDate);

                            clsSalesSummary.UpdateActualCost(_DT_CostContractProjectMapping, "System Generated");

                            clsSalesSummary.InsertActualCostContractDetail(_DTFinal_CostContractDetail);
                        }

                        clsSalesSummary.UpdateProjectByWsValue(batchid, PaidComm, UnpaidComm, BudgetMKTExpense);
                    }
                    else
                    {
                        log.DebugFormat("RunGenerateReport() - Failed to generate BatchId for project {0} and cluster {1}", projectcode, sCluster);
                    }
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("RunGenerateReport() - {0}", ex.Message);
                result = false;
            }

            log.DebugFormat("RunGenerateReport() - End");
            return(result);
        }
Exemple #2
0
        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            try
            {
                string projectcode = ddlProject.SelectedValue.ToString();
                string clustercode = "";

                foreach (ListItem item in lbxCluster.Items)
                {
                    if (item.Selected)
                    {
                        clustercode += item.Value.ToString() + ",";
                    }
                }


                DateTime asofdate = DateTime.ParseExact(txtAsOfDate.Text + " " + DateTime.Now.ToString("hh:mm:ss"), "dd/MM/yyyy hh:mm:ss", System.Globalization.CultureInfo.InvariantCulture);

                int batchid = clsSalesSummary.GenerateSalesSummary(projectcode, clustercode, asofdate, "System Generated");

                if (batchid != null)
                {
                    //update collection
                    initDTFinal_CollectionDetail();
                    _DTFinal_CollectionDetail = clsSalesSummary.GenerateScheduleCollection(projectcode, clustercode);

                    _DTFinal_CollectionDetail.Columns.Add("BatchID", System.Type.GetType("System.Int32"), batchid.ToString());
                    _DTFinal_CollectionDetail.Columns["BatchID"].SetOrdinal(0);

                    clsSalesSummary.InsertScheduleCollectionDetail(_DTFinal_CollectionDetail);


                    //update paidcomm
                    NewCommWS.NewComm_Services1 NewCommWS = new LKReportingSystem.NewCommWS.NewComm_Services1();
                    NewCommWS.Timeout = 600000;
                    decimal PaidComm   = 0;
                    decimal UnpaidComm = 0;
                    log.DebugFormat("NewComm Web Service Invoked.. Parameter sent: projectcode={0}", projectcode);
                    PaidComm   = NewCommWS.getCommPaid(projectcode);
                    UnpaidComm = NewCommWS.getCommUnprocessed(projectcode);

                    BudgetMktWS.WS_BudgetMarketing BudgetMktWS = new LKReportingSystem.BudgetMktWS.WS_BudgetMarketing();
                    BudgetMktWS.Timeout = 600000;

                    //update budgetmkt
                    decimal BudgetMKTExpense = 0;
                    log.DebugFormat("BudgetMkt Web Service [getBudgetMktActualExpense] Method Invoked.. Parameter sent: projectcode={0}", projectcode);
                    BudgetMKTExpense = BudgetMktWS.getBudgetMktActualExpense(projectcode);

                    //insert budgetmkt detail
                    //initDTFinal_MktExpenseDetail();

                    //log.DebugFormat("BudgetMkt Web Service [getBudgetMktActualExpenseDetail] Method Invoked.. Parameter sent: projectcode={0}", projectcode);

                    //_DTFinal_MktExpenseDetail = Helper.ConvertXMLToDataset(BudgetMktWS.getBudgetMktActualExpenseDetail(projectcode)).Tables[0];

                    //_DTFinal_MktExpenseDetail.Columns.Add("BatchID", System.Type.GetType("System.Int32"), batchid.ToString());
                    //_DTFinal_MktExpenseDetail.Columns["BatchID"].SetOrdinal(0);

                    //clsSalesSummary.InsertActualBudgetMktDetail(_DTFinal_MktExpenseDetail);



                    //actual Cost Contract
                    CostContractWS.WS_CostAndContract CostContractWS = new LKReportingSystem.CostContractWS.WS_CostAndContract();
                    CostContractWS.Timeout = 600000;
                    log.DebugFormat("CostContract Web Service [RetrieveProjectMapping] Method Invoked.. Parameter sent: projectcode={0}", projectcode);

                    initDT_CostContractProjectMapping();

                    if (CostContractWS.RetrieveProjectMapping(projectcode).Tables.Count != 0)
                    {
                        _DT_CostContractProjectMapping = CostContractWS.RetrieveProjectMapping(projectcode).Tables[0];

                        processActualConstructionCost(_DT_CostContractProjectMapping, batchid, asofdate);

                        clsSalesSummary.UpdateActualCost(_DT_CostContractProjectMapping, "System Generated");

                        clsSalesSummary.InsertActualCostContractDetail(_DTFinal_CostContractDetail);
                    }



                    clsSalesSummary.UpdateProjectByWsValue(batchid, PaidComm, UnpaidComm, BudgetMKTExpense);

                    BindDataSalesSummaryHistory();
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "BootboxAlert('Failed when Generate Sales Summary Report');", true);
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("btnGenerate_Click() ERROR: {0}.", ex.Message);
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "BootboxAlert('There is an error: " + ex.Message.Replace("'", "\\'") + "');", true);
            }
        }