Example #1
0
        private void ShowView()
        {
            try
            {
                int    driverId = ddl_Driver.SelectedValue.ToInt();
                string driverNo = ddl_Driver.Text.Trim();

                if (driverId != 0)
                {
                    long jobId = General.GetQueryable <Fleet_DriverQueueList>(c => c.DriverId == driverId && c.Status == true).OrderByDescending(c => c.Id).FirstOrDefault().DefaultIfEmpty().CurrentJobId.ToLong();

                    //if (jobId == 0)
                    //{

                    //    jobId= General.GetQueryable<Booking>(c => c.DriverId == driverId && c.AcceptedDateTime != null).OrderByDescending(c => c.AcceptedDateTime).FirstOrDefault().DefaultIfEmpty().Id;
                    //}
                    if (jobId != 0)
                    {
                        new Thread(delegate()
                        {
                            int loopCnt = 1;
                            while (loopCnt < 3)
                            {
                                bool success = General.ReCallBooking(jobId, driverId);

                                if (success)
                                {
                                    break;
                                }
                                else
                                {
                                    loopCnt++;
                                }
                            }
                        }).Start();

                        //new Thread(delegate()
                        //{
                        //    General.ReCallBooking(jobId, driverId);

                        //}).Start();

                        Thread.Sleep(500);


                        (Application.OpenForms.OfType <Form>().FirstOrDefault(c => c.Name == "frmBookingDashBoard") as frmBookingDashBoard).RefreshAllActiveData();
                        this.Close();

                        using (TaxiDataContext db = new TaxiDataContext())
                        {
                            db.stp_BookingLog(jobId, AppVars.LoginObj.UserName.ToStr(), "Job is Recovered from Driver (" + driverNo + ")");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
Example #2
0
        private void ReCallJob()
        {
            if (ddl_Driver.SelectedValue == null)
            {
                return;
            }
            try
            {
                int driverId = ddl_Driver.SelectedValue.ToInt();

                int    statusId = 0;
                long   jobId    = 0;
                string driverNO = string.Empty;
                using (TaxiDataContext db = new TaxiDataContext())
                {
                    Fleet_DriverQueueList objLogin = db.Fleet_DriverQueueLists.FirstOrDefault(c => c.Status == true && c.DriverId == driverId);

                    if (objLogin != null)
                    {
                        statusId = objLogin.DriverWorkStatusId.ToInt();
                        jobId    = objLogin.CurrentJobId.ToLong();
                        driverNO = objLogin.Fleet_Driver.DriverNo.ToStr();
                    }
                }


                if (jobId == 0)
                {
                    MessageBox.Show("No Current Job Found");
                    return;
                }
                else
                {
                    if (statusId == Enums.Driver_WORKINGSTATUS.NOTAVAILABLE || statusId == Enums.Driver_WORKINGSTATUS.SOONTOCLEAR)
                    {
                        MessageBox.Show("Job cannot be Re-Call as driver is on " + "POB or STC Status.");
                        return;
                    }
                }


                if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to Re-Call a Booking ? ", "", MessageBoxButtons.YesNo, RadMessageIcon.Question))
                {
                    new Thread(delegate()
                    {
                        int loopCnt  = 1;
                        bool success = false;
                        while (loopCnt < 3)
                        {
                            success = General.ReCallBooking(jobId, driverId);

                            if (success)
                            {
                                break;
                            }
                            else
                            {
                                loopCnt++;
                            }
                        }
                    }).Start();


                    using (TaxiDataContext dbX = new TaxiDataContext())
                    {
                        dbX.stp_BookingLog(jobId, AppVars.LoginObj.UserName.ToStr(), "Recall Job from Driver (" + driverNO + ")");
                    }

                    // new BroadcasterData().BroadCastToAll(RefreshTypes.REFRESH_DASHBOARD);
                }
            }
            catch
            {
            }
        }
        private void Save()
        {
            try
            {
                int      defaultAllocationLimit = AppVars.objPolicyConfiguration.AllocateDrvPreExistJobLimit.ToInt();
                int?     driverId          = ddl_Driver.SelectedValue.ToIntorNull();
                int?     oldDriverId       = null;
                string   oldDriverNo       = string.Empty;
                long     jobId             = 0;
                bool     cancelJob         = false;
                DateTime?pickupDateAndTime = ObjMaster.Current.PickupDateTime.ToDateTimeorNull();


                //if (driverId != null && defaultAllocationLimit>0 &&
                //    General.GetQueryable<Booking>(null).Count(c => c.DriverId == driverId && c.Id!=ObjMaster.Current.Id
                //         && (c.BookingStatusId==Enums.BOOKINGSTATUS.WAITING || c.BookingStatusId==Enums.BOOKINGSTATUS.PENDING)
                //         &&

                //         (
                //         (c.PickupDateTime.Value<=pickupDateAndTime
                //         && (c.PickupDateTime.Value >= pickupDateAndTime.Value.AddMinutes(-defaultAllocationLimit)) )

                //              || (c.PickupDateTime.Value >= pickupDateAndTime
                //         && (c.PickupDateTime.Value <= pickupDateAndTime.Value.AddMinutes(defaultAllocationLimit)))
                //         )


                //         ) > 0)
                //{

                //    if (DialogResult.No == MessageBox.Show("This driver already have a Job Allocated at this time "+
                //         Environment.NewLine + "Do you still want to Allocate it ? ", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                //    {
                //        return;

                //    }

                //}


                if (driverId != null)
                {
                    var ObjDriver = General.GetObject <Fleet_Driver>(c => c.Id == driverId);

                    if (ObjDriver != null)
                    {
                        allocateDrvNo = ObjDriver.DriverNo.ToStr().Trim();
                        if (ObjDriver.VehicleTypeId != null)
                        {
                            if (ObjMaster.Current.AttributeValues.ToStr().Trim().Length > 0)
                            {
                                string[] bookingAttrs  = ObjMaster.Current.AttributeValues.ToStr().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                string   drvAttributes = ObjDriver.AttributeValues.ToStr() + "," + ObjDriver.Fleet_VehicleType.AttributeValues;

                                int      totalAttr          = bookingAttrs.Count();
                                int      matchCnt           = 0;
                                string   unmatchedAttrValue = string.Empty;
                                string[] drvAttrsArr        = drvAttributes.ToStr().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                                foreach (var item in bookingAttrs)
                                {
                                    if (drvAttrsArr.Count(c => c.ToLower() == item.ToLower()) > 0)
                                    {
                                        matchCnt++;
                                    }
                                    else
                                    {
                                        unmatchedAttrValue += item + ",";
                                    }
                                }

                                if (matchCnt != totalAttr)
                                {
                                    if (unmatchedAttrValue.EndsWith(","))
                                    {
                                        unmatchedAttrValue = unmatchedAttrValue.Substring(0, unmatchedAttrValue.LastIndexOf(","));
                                    }

                                    MessageBox.Show(("Driver : " + ObjDriver.DriverNo + " doesn't have attributes (" + unmatchedAttrValue + ")"), "Warning");
                                    return;
                                }
                            }

                            if (AppVars.listUserRights.Count(c => c.functionId == "RESTRICT ON DESPATCH JOB TO INVALID VEHICLE DRIVER") > 0)
                            {
                                string vehAttributes = ObjMaster.Current.Fleet_VehicleType.DefaultIfEmpty().AttributeValues.ToStr().Trim();

                                if (vehAttributes.Length > 0)
                                {
                                    bool MatchedAttr = false;
                                    foreach (var item in vehAttributes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                                    {
                                        if (ObjDriver.VehicleTypeId.ToInt() == item.ToInt())
                                        {
                                            MatchedAttr = true;
                                            break;
                                        }
                                    }



                                    if (MatchedAttr == false)
                                    {
                                        MessageBox.Show("This Job is for " + ObjMaster.Current.Fleet_VehicleType.VehicleType.ToStr() + " Vehicle" + Environment.NewLine +
                                                        "and Driver no " + ObjDriver.DriverNo + " have " + ObjDriver.Fleet_VehicleType.VehicleType + ".");

                                        return;
                                    }
                                }
                                else
                                {
                                    if (ObjDriver.Fleet_VehicleType.NoofPassengers.ToInt() < ObjMaster.Current.Fleet_VehicleType.NoofPassengers.ToInt())
                                    {
                                        MessageBox.Show("This Job is for " + ObjMaster.Current.Fleet_VehicleType.VehicleType.ToStr() + " Vehicle" + Environment.NewLine +
                                                        "and Driver no " + ObjDriver.DriverNo + " have " + ObjDriver.Fleet_VehicleType.VehicleType + ".");


                                        return;
                                    }
                                }
                            }
                            else
                            {
                                if (ObjDriver.Fleet_VehicleType.NoofPassengers.ToInt() < ObjMaster.Current.Fleet_VehicleType.NoofPassengers.ToInt())
                                {
                                    if (DialogResult.No == MessageBox.Show("This Job is for " + ObjMaster.Current.Fleet_VehicleType.VehicleType.ToStr() + " Vehicle" + Environment.NewLine +
                                                                           "and Driver no " + ObjDriver.DriverNo + " have " + ObjDriver.Fleet_VehicleType.VehicleType + "." + Environment.NewLine
                                                                           + "Do you still want to Allocate this Job to that Driver " + ObjDriver.DriverNo + " ?", "Despatch", MessageBoxButtons.YesNo))
                                    {
                                        return;
                                    }
                                }
                            }
                        }
                    }

                    try
                    {
                        if ((driverId != null && ObjMaster.Current.DriverId == null) || (driverId != null && ObjMaster.Current.DriverId != null && driverId != ObjMaster.Current.DriverId))
                        {
                            if (IsDriverDocumentExpired(driverId.ToInt(), ObjDriver))
                            {
                                return;
                            }
                        }
                    }
                    catch
                    {
                    }
                }



                if (ObjMaster.Current != null)
                {
                    if (driverId != null || (ObjMaster.Current.DriverId != null && ObjMaster.Current.BookingStatusId.ToInt() == Enums.BOOKINGSTATUS.WAITING))
                    {
                        //if ((driverId != null && ObjMaster.Current.DriverId == null) || (driverId!=null && ObjMaster.Current.DriverId!=null && driverId!=ObjMaster.Current.DriverId))
                        //{

                        //   if  (IsDriverDocumentExpired(driverId.ToInt()))
                        //       return;

                        //}


                        if (driverId == null && ObjMaster.Current.DriverId != null)
                        {
                            oldDriverNo = ObjMaster.Current.Fleet_Driver.DriverNo.ToStr();
                        }


                        if (ObjMaster.Current.DriverId != null)
                        {
                            oldDriverId = ObjMaster.Current.DriverId;
                        }


                        ObjMaster.CheckDataValidation = false;

                        ObjMaster.Edit();

                        ObjMaster.Current.DriverId = driverId;

                        ObjMaster.Current.IsConfirmedDriver = driverId != null ? chkConfirmed.Checked:false;



                        if (ObjMaster.Current.BookingStatusId.ToInt() == Enums.BOOKINGSTATUS.NOTACCEPTED)
                        {
                            ObjMaster.Current.BookingStatusId = Enums.BOOKINGSTATUS.WAITING;
                        }



                        if (driverId == null || (oldDriverId != null && oldDriverId != driverId && ObjMaster.Current.BookingStatusId != Enums.BOOKINGSTATUS.WAITING))
                        {
                            ObjMaster.Current.BookingStatusId = Enums.BOOKINGSTATUS.WAITING;
                            cancelJob = true;
                        }


                        jobId          = ObjMaster.Current.Id;
                        allocatedJobId = jobId;

                        ObjMaster.CheckCustomerValidation = false;
                        ObjMaster.DisableUpdateReturnJob  = true;

                        ObjMaster.Save();


                        if (ObjMaster.Current.BookingTypeId.ToInt() == Enums.BOOKING_TYPES.THIRDPARTY && ObjMaster.Current.OnlineBookingId != null)
                        {
                            General.UpdateThirdPartyJobStatus(null, jobId, "allocated");
                        }

                        this.Close();


                        if (IsOpenFrom == 1)
                        {
                            RefreshTodayBookingsDashboard();
                        }
                        else
                        {
                            RefreshTodayAndPreBookingsDashboard();
                            //  AppVars.frmMDI.RefreshTodayAnPreDashboard();
                        }

                        string Msg = string.Empty;


                        if (driverId != null)
                        {
                            if (chkConfirmed.Checked)
                            {
                                Msg = "Job is Allocated and confirmed to Driver (" + ObjMaster.Current.Fleet_Driver.DriverNo.ToStr() + ")";
                            }
                            else
                            {
                                Msg = "Job is Allocated  to Driver (" + ObjMaster.Current.Fleet_Driver.DriverNo.ToStr() + ")";
                            }
                        }
                        else if (driverId == null && !string.IsNullOrEmpty(oldDriverNo))
                        {
                            Msg = "Job is De-Allocated from Driver (" + oldDriverNo + ")";
                        }

                        using (TaxiDataContext db = new TaxiDataContext())
                        {
                            db.stp_BookingLog(ObjMaster.Current.Id, AppVars.LoginObj.UserName.ToStr(), Msg);


                            if (cancelJob)
                            {
                                if (AppVars.objPolicyConfiguration.DespatchOfflineJobs.ToBool())
                                {
                                    db.stp_DeleteDrvOfflineJob(ObjMaster.Current.Id, oldDriverId);
                                }
                            }
                        }



                        if (cancelJob)
                        {
                            //For TCP Connection
                            if (AppVars.objPolicyConfiguration.IsListenAll.ToBool())
                            {
                                new Thread(delegate()
                                {
                                    General.SendMessageToPDA("request pda=" + oldDriverId + "=" + jobId + "=Cancelled Pre Job>>" + jobId + "=2");
                                }).Start();
                            }
                        }
                    }
                    else
                    {
                        ENUtils.ShowMessage("Required: Driver");
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #4
0
        private void NoShow()
        {
            try
            {
                if (ddl_Driver.SelectedValue == null)
                {
                    ENUtils.ShowMessage("Select any Driver");

                    return;
                }
                else
                {
                    int driverId = ddl_Driver.SelectedValue.ToInt();
                    var list     = from a in General.GetQueryable <Fleet_DriverQueueList>(c => c.Id > 0)
                                   where a.DriverId == driverId && a.Status == true && a.CurrentJobId != null
                                   select new
                    {
                        Id = a.Id,
                    };

                    string val = list.ToStr();

                    if (list.Count() != 0)
                    {
                        long jobId = 0;

                        using (TaxiDataContext db = new TaxiDataContext())
                        {
                            jobId = db.Fleet_DriverQueueLists.FirstOrDefault(c => c.Id == list.FirstOrDefault().Id).DefaultIfEmpty().CurrentJobId.ToLong();
                        }



                        if (jobId != 0)
                        {
                            string[] driverNo = (ddl_Driver.SelectedItem.Text).Split('-');

                            new Thread(delegate()
                            {
                                int loopCnt = 1;
                                while (loopCnt < 3)
                                {
                                    bool success = General.ReCallBookingWithStatus(jobId.ToLong(), driverId.ToInt(), Enums.BOOKINGSTATUS.NOPICKUP, Enums.Driver_WORKINGSTATUS.AVAILABLE);

                                    if (success)
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        loopCnt++;
                                    }
                                }
                            }).Start();

                            Thread.Sleep(500);


                            new BroadcasterData().BroadCastToAll(RefreshTypes.REFRESH_DASHBOARD);
                            // (Application.OpenForms.OfType<Form>().FirstOrDefault(c => c.Name == "frmBookingDashBoard") as frmBookingDashBoard).RefreshData();


                            using (TaxiDataContext db = new TaxiDataContext())
                            {
                                db.stp_BookingLog(jobId, AppVars.LoginObj.UserName.ToStr(), "Controller Pressed NO Pickup from Driver (" + driverNo[0] + ")");
                            }
                        }
                        else
                        {
                            MessageBox.Show("No Current Job Found");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }