private void TrackDriver()
        {
            try
            {
                if (Application.OpenForms.Cast <Form>().Where(c => c.Name.Equals("rptJobRouthPathGoogle")).Count() > 0)
                {
                    try
                    {
                        Application.OpenForms.Cast <Form>().FirstOrDefault(c => c.Name.Equals("rptJobRouthPathGoogle")).Close();
                    }
                    catch
                    {
                    }
                }



                if (File.Exists(Application.StartupPath + "\\Booking\\TreasureBooking.exe"))
                {
                    ClsDataTransfer polObj = new ClsDataTransfer();

                    foreach (System.Reflection.PropertyInfo item in AppVars.objPolicyConfiguration.GetType().GetProperties())
                    {
                        try
                        {
                            if (polObj.GetType().GetProperty(item.Name) != null)
                            {
                                polObj.GetType().GetProperty(item.Name).SetValue(polObj, item.GetValue(AppVars.objPolicyConfiguration, null), null);
                            }
                        }
                        catch
                        {
                        }
                    }


                    polObj.DataString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToStr().Replace(" ", "**");
                    string  pol = Newtonsoft.Json.JsonConvert.SerializeObject(polObj, Newtonsoft.Json.Formatting.Indented).Replace(" ", "~").Replace(Environment.NewLine, "").Replace("\"", "*");
                    string  s   = "XXX";
                    Process pp  = new Process();
                    pp.StartInfo.FileName   = Application.StartupPath + "\\Booking\\TreasureBooking.exe";
                    pp.StartInfo.Arguments  = s + " " + pol + " " + Newtonsoft.Json.JsonConvert.SerializeObject(AppVars.LoginObj, Newtonsoft.Json.Formatting.Indented).Replace(" ", "").Replace(Environment.NewLine, "").Replace("\"", "*") + " " + Newtonsoft.Json.JsonConvert.SerializeObject(AppVars.keyLocations, Newtonsoft.Json.Formatting.Indented).Replace(" ", "").Replace(Environment.NewLine, "").Replace("\"", "*") + " " + Newtonsoft.Json.JsonConvert.SerializeObject(AppVars.zonesList, Newtonsoft.Json.Formatting.Indented).Replace(" ", "").Replace(Environment.NewLine, "").Replace("\"", "*");
                    pp.StartInfo.Arguments += " " + "rptJobRouthPathGoogle" + " " + this.JobId + " " + "true" + " " + this.DriverId;
                    pp.Start();
                    Thread.Sleep(500);
                    //   pp.WaitForExit();
                }
                else
                {
                    rptJobRouthPathGoogle rpt = new rptJobRouthPathGoogle(this.JobId > 0 ? new TaxiDataContext().Bookings.FirstOrDefault(c => c.Id == this.JobId) : null, true, this.DriverId);
                    rpt.ShowDialog();
                    rpt.Dispose();

                    GC.Collect();
                }
            }
            catch
            {
            }
        }
        private void TrackDriver()
        {
            try
            {
                if (string.IsNullOrEmpty(AppVars.objPolicyConfiguration.ListenerIP.ToStr()))
                {
                    ENUtils.ShowMessage("Server IP is not configured in Settings.");
                    return;
                }

                string driverNo = ddl_Driver.SelectedValue.ToStr().Trim();
                if (string.IsNullOrEmpty(driverNo))
                {
                    return;
                }



                DisposeTimer();

                // Thread smsThread = new Thread(delegate()
                // {
                //     new BroadcasterData().BroadCastToPort("**track driver=" + driverNo+"="+Environment.MachineName,3530);
                //     //if (this.IsDisposed == false)
                //     //{
                //     //    SendMessage("request tracking=" + driverNo);
                //     //}
                // });


                // smsThread.Start();



                //System.Threading.Thread.Sleep(1000);
                int driverId = 0;


                using (Taxi_Model.TaxiDataContext db = new Taxi_Model.TaxiDataContext())
                {
                    driverId = db.Fleet_Drivers.FirstOrDefault(c => c.DriverNo == driverNo && c.IsActive == true).DefaultIfEmpty().Id;
                    if (driverId > 0)
                    {
                        long jobId = db.Fleet_DriverQueueLists.FirstOrDefault(c => c.Status == true && c.DriverId == driverId).DefaultIfEmpty().CurrentJobId.ToLong();


                        if (System.IO.File.Exists(Application.StartupPath + "\\TreasureBooking.exe"))
                        {
                            ClsDataTransfer polObj = new ClsDataTransfer();

                            foreach (System.Reflection.PropertyInfo item in AppVars.objPolicyConfiguration.GetType().GetProperties())
                            {
                                try
                                {
                                    if (polObj.GetType().GetProperty(item.Name) != null)
                                    {
                                        polObj.GetType().GetProperty(item.Name).SetValue(polObj, item.GetValue(AppVars.objPolicyConfiguration, null), null);
                                    }
                                }
                                catch
                                {
                                }
                            }


                            polObj.DataString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToStr().Replace(" ", "**");
                            string  pol = Newtonsoft.Json.JsonConvert.SerializeObject(polObj, Newtonsoft.Json.Formatting.Indented).Replace(" ", "~").Replace(Environment.NewLine, "").Replace("\"", "*");
                            string  s   = "XXX";
                            Process pp  = new Process();
                            pp.StartInfo.FileName   = Application.StartupPath + "\\TreasureBooking.exe";
                            pp.StartInfo.Arguments  = s + " " + pol + " " + Newtonsoft.Json.JsonConvert.SerializeObject(AppVars.LoginObj, Newtonsoft.Json.Formatting.Indented).Replace(" ", "").Replace(Environment.NewLine, "").Replace("\"", "*") + " " + Newtonsoft.Json.JsonConvert.SerializeObject(AppVars.keyLocations, Newtonsoft.Json.Formatting.Indented).Replace(" ", "").Replace(Environment.NewLine, "").Replace("\"", "*") + " " + Newtonsoft.Json.JsonConvert.SerializeObject(AppVars.zonesList, Newtonsoft.Json.Formatting.Indented).Replace(" ", "").Replace(Environment.NewLine, "").Replace("\"", "*");
                            pp.StartInfo.Arguments += " " + "rptJobRouthPathGoogle" + " " + jobId + " " + "true" + " " + driverId;
                            pp.Start();
                            Thread.Sleep(500);
                            //   pp.WaitForExit();
                        }
                        else
                        {
                            rptJobRouthPathGoogle rpt = new rptJobRouthPathGoogle(jobId > 0 ? db.Bookings.First(c => c.Id == jobId) : null, true, driverId);
                            rpt.Show();
                        }
                    }
                }
                //rpt.Dispose();



                this.Close();
            }
            catch (Exception ex)
            {
                //   ENUtils.ShowMessage(ex.Message);
            }
        }
Esempio n. 3
0
        private void TrackDriver()
        {
            if (ddl_Driver.SelectedValue == null)
            {
                ENUtils.ShowMessage("Select any Driver");
            }

            try
            {
                int driverId = ddl_Driver.SelectedValue.ToInt();

                using (TaxiDataContext db = new TaxiDataContext())
                {
                    var objLogin = db.Fleet_DriverQueueLists.FirstOrDefault(c => c.Status == true && c.DriverId == driverId);

                    if (objLogin == null)
                    {
                        ENUtils.ShowMessage("Driver is not Login");
                    }
                    else
                    {
                        long jobId = objLogin.CurrentJobId.ToLong();

                        if (File.Exists(Application.StartupPath + "\\Booking\\TreasureBooking.exe"))
                        {
                            ClsDataTransfer polObj = new ClsDataTransfer();

                            foreach (System.Reflection.PropertyInfo item in AppVars.objPolicyConfiguration.GetType().GetProperties())
                            {
                                try
                                {
                                    if (polObj.GetType().GetProperty(item.Name) != null)
                                    {
                                        polObj.GetType().GetProperty(item.Name).SetValue(polObj, item.GetValue(AppVars.objPolicyConfiguration, null), null);
                                    }
                                }
                                catch
                                {
                                }
                            }


                            polObj.DataString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToStr().Replace(" ", "**");
                            string  pol = Newtonsoft.Json.JsonConvert.SerializeObject(polObj, Newtonsoft.Json.Formatting.Indented).Replace(" ", "~").Replace(Environment.NewLine, "").Replace("\"", "*");
                            string  s   = "XXX";
                            Process pp  = new Process();
                            pp.StartInfo.FileName   = Application.StartupPath + "\\Booking\\TreasureBooking.exe";
                            pp.StartInfo.Arguments  = s + " " + pol + " " + Newtonsoft.Json.JsonConvert.SerializeObject(AppVars.LoginObj, Newtonsoft.Json.Formatting.Indented).Replace(" ", "").Replace(Environment.NewLine, "").Replace("\"", "*") + " " + Newtonsoft.Json.JsonConvert.SerializeObject(AppVars.keyLocations, Newtonsoft.Json.Formatting.Indented).Replace(" ", "").Replace(Environment.NewLine, "").Replace("\"", "*") + " " + Newtonsoft.Json.JsonConvert.SerializeObject(AppVars.zonesList, Newtonsoft.Json.Formatting.Indented).Replace(" ", "").Replace(Environment.NewLine, "").Replace("\"", "*");
                            pp.StartInfo.Arguments += " " + "rptJobRouthPathGoogle" + " " + jobId + " " + "true" + " " + driverId;
                            pp.Start();
                            Thread.Sleep(500);
                            //   pp.WaitForExit();
                        }
                        else
                        {
                            rptJobRouthPathGoogle rpt = new rptJobRouthPathGoogle(jobId > 0 ? db.Bookings.FirstOrDefault(c => c.Id == jobId) : null, true, driverId);
                            rpt.ShowDialog();
                            rpt.Dispose();

                            GC.Collect();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }