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() { 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); } }