Exemple #1
0
 private void LoadCases()
 {
     try
     {
         if (File.Exists(txtTSVFileLocation.Text.Trim()))
         {
             List <Dictionary <string, string> > parsedTable = BatchBL.ParseXSVFile(txtTSVFileLocation.Text);
             dgCases.Rows.Clear();
             foreach (var tableRow in parsedTable)
             { //Read each row of data
                 DataGridViewRow dr = new DataGridViewRow();
                 dr.Height = 30;
                 dr.CreateCells(dgCases);
                 dr.Cells[0].Value = tableRow["id"].ToString();
                 if (tableRow.ContainsKey("template"))
                 {
                     dr.Cells[1].Value = tableRow["template"].ToString();
                 }
                 if (tableRow.ContainsKey("case_number"))
                 {
                     dr.Cells[2].Value = tableRow["case_number"].ToString();
                 }
                 if (tableRow.ContainsKey("jurisdiction"))
                 {
                     dr.Cells[3].Value = tableRow["jurisdiction"].ToString();
                 }
                 dr.Cells[6].Value = "Preview";
                 dgCases.Rows.Add(dr);
             }
             dgCases.Refresh();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #2
0
        //Complete Filter
        public DataTable getBranchAcceptanceDataByFilter(DateTime date, Guid?revenueUnitId, string driver, Guid?batchId)
        {
            RevenueUnitBL      revenueunitservice = new RevenueUnitBL();
            BatchBL            batchservice       = new BatchBL();
            BranchAcceptanceBL branchAcceptanceBl = new BranchAcceptanceBL();
            ShipmentBL         shipmentService    = new ShipmentBL();
            BranchCorpOfficeBL bcoService         = new BranchCorpOfficeBL();

            //List<Shipment> shipments = shipmentService.FilterActive().Where(x => x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();
            List <Shipment> shipments = shipmentService.FilterActive().Where(x => x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.Booking.BookingStatus.BookingStatusName == "Picked-up" && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();
            // List<BranchAcceptance> branchAcceptance = branchAcceptanceBl.GetAll().Where(x => x.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.BatchID == batchId && x.Driver == driver).ToList();
            //List<BranchAcceptance> branchAcceptance = branchAcceptanceBl.GetAll().Where(x => x.Users.Employee.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.Users.Employee.AssignedToArea.RevenueUnitId == revenueUnitId && x.RecordStatus == 1 && x.BatchID == batchId && x.Driver == driver && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();

            List <BranchAcceptanceViewModel> list             = new List <BranchAcceptanceViewModel>();
            List <BranchAcceptance>          branchAcceptance = branchAcceptanceBl.FilterActive().
                                                                Where(
                x => x.RecordStatus == 1
                //&& ((x.Users.Employee.AssignedToArea.RevenueUnitId == revenueUnitId && x.Users.Employee.AssignedToArea.RevenueUnitId != Guid.Empty) || (x.Users.Employee.AssignedToArea.RevenueUnitId == x.Users.Employee.AssignedToArea.RevenueUnitId && revenueUnitId == Guid.Empty))
                && ((x.BatchID == batchId && x.BatchID != Guid.Empty) || (x.BatchID == x.BatchID && batchId == Guid.Empty)) &&
                ((x.Driver == driver && x.Driver != "All") || (x.Driver == x.Driver && driver == "All")) &&
                x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();

            string revenueunitname = "";
            string batchname       = "";
            string bcoName         = "";

            if (batchId != Guid.Empty)
            {
                batchname = batchservice.FilterActive().Find(x => x.BatchID == batchId).BatchName;
            }
            else
            {
                batchname = "All";
            }

            if (revenueUnitId != Guid.Empty)
            {
                revenueunitname = revenueunitservice.FilterActive().Find(x => x.RevenueUnitId == revenueUnitId).RevenueUnitName;
            }
            else
            {
                revenueunitname = "All";
            }

            bcoName = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName;

            list = Match(branchAcceptance, shipments).
                   FindAll
                       (x =>
                       ((x.Area == revenueunitname && x.Area != "N/A") || (x.Area == x.Area && revenueunitname == "All")) &&
                       ((x.Driver == driver && x.Driver != "N/A") || (x.Driver == x.Driver && driver == "All")) &&
                       ((x.Batch == batchname && x.Batch != "N/A") || (x.Batch == x.Batch && batchname == "All")) &&
                       ((x.BCO == bcoName && x.BCO != "N/A") || (x.BCO == x.BCO && bcoName == "")) &&
                       !x.Area.Contains("Walk-in"));

            //if (revenueUnitId != Guid.Empty && batchId !=Guid.Empty)
            //{
            //    batchname = batchservice.GetAll().Find(x => x.BatchID == batchId).BatchName;
            //    revenueunitname = revenueunitservice.GetAll().Find(x => x.RevenueUnitId == revenueUnitId).RevenueUnitName;
            //    list = Match(branchAcceptance, shipments).FindAll(x => x.Area == revenueunitname && x.Batch == batchname);
            //}
            //else if (revenueUnitId == Guid.Empty && batchId != Guid.Empty)
            //{
            //    batchname = batchservice.GetAll().Find(x => x.BatchID == batchId).BatchName;
            //    list = Match(branchAcceptance, shipments).FindAll(x => x.Batch == batchname && x.Area != "N/A");
            //}
            //else if (revenueUnitId != Guid.Empty && batchId == Guid.Empty)
            //{
            //    revenueunitname = revenueunitservice.GetAll().Find(x => x.RevenueUnitId == revenueUnitId).RevenueUnitName;
            //    list = Match(branchAcceptance, shipments).FindAll(x => x.Area == revenueunitname);
            //}
            //else
            //{
            //    bcoName = bcoService.GetAll().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName;
            //    list = Match(branchAcceptance, shipments).FindAll(x => x.BCO == bcoName && x.Area != "N/A");
            //    //list = Match(branchAcceptance, shipments);
            //}

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("No", typeof(string)));
            dt.Columns.Add(new DataColumn("Area/Branch", typeof(string)));
            dt.Columns.Add(new DataColumn("Driver", typeof(string)));
            dt.Columns.Add(new DataColumn("Checker", typeof(string)));
            dt.Columns.Add(new DataColumn("Plate #", typeof(string)));
            dt.Columns.Add(new DataColumn("Batch", typeof(string)));
            dt.Columns.Add(new DataColumn("AWB", typeof(string)));
            dt.Columns.Add(new DataColumn("Recieved(Qty)", typeof(string)));
            dt.Columns.Add(new DataColumn("Discrepancy(Qty)", typeof(string)));
            dt.Columns.Add(new DataColumn("Total Qty", typeof(string)));
            dt.Columns.Add(new DataColumn("BCO", typeof(string)));
            dt.Columns.Add(new DataColumn("BSO", typeof(string)));

            dt.Columns.Add(new DataColumn("ScannedBy", typeof(string)));
            dt.Columns.Add(new DataColumn("Remarks", typeof(string)));
            dt.Columns.Add(new DataColumn("Notes", typeof(string)));
            dt.BeginLoadData();
            int ctr = 1;

            foreach (BranchAcceptanceViewModel item in list)
            {
                DataRow row = dt.NewRow();
                row[0] = ctr++.ToString();
                row[1] = item.Area.ToString();
                row[2] = item.Driver.ToString();
                row[3] = item.Checker.ToString();
                row[4] = item.PlateNo.ToString();
                row[5] = item.Batch.ToString();
                row[6] = item.AirwayBillNo.ToString();
                row[7] = item.TotalRecieved.ToString();
                row[8] = item.TotalDiscrepency.ToString();
                row[9] = item.Total.ToString();

                row[10] = item.BCO;
                row[11] = item.BSO;
                row[12] = item.ScannedBy;
                row[13] = item.Remarks;
                row[14] = item.Notes;
                dt.Rows.Add(row);
            }
            dt.EndLoadData();

            return(dt);
        }
 private void refreshEnvelope_Click(object sender, EventArgs e)
 {
     refreshEnvelope.Enabled = false;
     BatchBL.refreshBatch(BatchId);
     refreshEnvelope.Enabled = true;
 }
Exemple #4
0
        private void dgCases_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex == -1)
                {
                    return;
                }
                int selectedIndex = dgCases.CurrentCell.RowIndex;
                int selectedCol   = dgCases.CurrentCell.ColumnIndex;

                var id = dgCases.Rows[selectedIndex].Cells[0].Value;


                string templatepath = Path.Combine(txtJsonTemplateLocation.Text, AppConstants.LoginState);

                List <Dictionary <string, string> > parsedTable = BatchBL.ParseXSVFile(txtTSVFileLocation.Text);

                Dictionary <string, string> templates = BatchBL.InitiTemplates(templatepath);

                foreach (var tableRow in parsedTable)
                {
                    //Read each row of data
                    if (id.Equals(tableRow["id"]))
                    {
                        tableRow.Add("batch_id", BatchId);

                        var line = string.Join(AppConstants.XSV_SEPERATOR, tableRow.Values);

                        String payload  = null;
                        string template = null;

                        if (tableRow.ContainsKey("template"))
                        {
                            template = tableRow["template"];
                        }

                        if (template != null && template.Trim().Length > 0)
                        {
                            if (templates.ContainsKey(template))
                            {
                                payload = templates[template];
                            }
                        }
                        else
                        {
                            if (!tableRow.ContainsKey("case_number") || tableRow["case_number"].ToString().Trim().Length == 0)
                            {
                                template = "NEW";
                            }
                            else
                            {
                                template = "EXISTING";
                            }

                            if (templates.ContainsKey(template))
                            {
                                payload = templates[template];
                            }
                        }

                        if (payload == null)
                        {
                            MessageBox.Show("Template: " + template + " Not Found");
                        }
                        else
                        {
                            foreach (KeyValuePair <string, string> entry in tableRow)
                            {
                                var value = entry.Value;
                                if (entry.Value.EndsWith(AppConstants.PDF_PATTERN))
                                {
                                    value = Path.GetFileName(value);
                                }
                                payload = payload.Replace("${" + entry.Key + "}", value);
                            }

                            frmPayload frmPayload = new frmPayload();
                            frmPayload.Payload = payload;
                            frmPayload.ShowDialog();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.LogError(ex);
            }
        }
Exemple #5
0
        private void BGBatchProcess_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                string templatepath = Path.Combine(txtJsonTemplateLocation.Text, AppConstants.LoginState);

                List <Dictionary <string, string> > parsedTable = BatchBL.ParseXSVFile(txtTSVFileLocation.Text);

                Dictionary <string, string> templates = BatchBL.InitiTemplates(templatepath);
                var results     = new List <dynamic>();
                int counter     = 0;
                int TotalRecord = parsedTable.Count;
                LogManager.Trace(String.Format("Add to batch process started  for batch {0}.", BatchId));
                foreach (var tableRow in parsedTable)
                {
                    if (BGBatchProcess.CancellationPending)
                    {
                        LogManager.Trace(String.Format("Add to batch process stopped by user for batch {0}.", BatchId));
                        e.Cancel = true;
                        break;
                    }
                    //Read each row of data
                    tableRow.Add("batch_id", BatchId);

                    var line = string.Join(AppConstants.XSV_SEPERATOR, tableRow.Values);

                    String payload  = null;
                    string template = null;
                    if (tableRow.ContainsKey("template"))
                    {
                        template = tableRow["template"];
                    }
                    if (template != null && template.Trim().Length > 0)
                    {
                        if (templates.ContainsKey(template))
                        {
                            payload = templates[template];
                        }
                    }
                    else
                    {
                        if (tableRow["case_number"].ToString().Trim().Length == 0)
                        {
                            template = "NEW";
                        }
                        else
                        {
                            template = "EXISTING";
                        }

                        if (templates.ContainsKey(template))
                        {
                            payload = templates[template];
                        }
                    }

                    //--------------------------------------------------------------------------------
                    var filepaths = new List <string>();

                    if (payload != null)
                    {
                        foreach (KeyValuePair <string, string> entry in tableRow)
                        {
                            var value = entry.Value;
                            if (entry.Value.EndsWith(AppConstants.PDF_PATTERN))
                            {
                                filepaths.Add(value);
                                value = Path.GetFileName(value);
                            }
                            payload = payload.Replace("${" + entry.Key + "}", value);
                        }
                    }

                    var id       = tableRow["id"];
                    int progress = (counter * 100) / TotalRecord;
                    BGBatchProcess.ReportProgress(progress, id + "-Started-" + "efile process started.");
                    try
                    {
                        if (payload == null)
                        {
                            throw new Exception("Template not found: " + template);
                        }
                        LogManager.Trace(String.Format("eFile for batch- {0} and  id {1} started ", BatchId, id));
                        dynamic response = AppConstants.ApiCaller.Efile(id, payload, filepaths); //It is important that you update your database immidiately here with response before doing other things
                        results.Add(response);
                        LogManager.Trace(String.Format("eFile for batch- {0} and id {1} completed ", BatchId, id));

                        BGBatchProcess.ReportProgress(progress, id + "-Completed-" + "eFile process completed");
                    }
                    catch (Exception ex)
                    {
                        BGBatchProcess.ReportProgress(progress, id + "-Failed-" + ex.Message);
                    }

                    counter++;
                }
                e.Result = results;
            }
            catch (Exception ex)
            {
                LogManager.LogError(ex);
            }
        }