private void Disconnect() { SitesVM.StopMonitorRegister(); GraphVM.StopMonitorInstrument(); GraphVM.StopMonitorTemp(); comm.DestoryClient(); }
private void Connect() { if (!comm.CreatClient()) { MessageBox.Show("Init USB Fail"); return; } DateTime time = DateTime.Now; Task.Run(() => SitesVM.MonitorRegister(30 * 1000)); Task.Run(() => GraphVM.MonitorInstrument(30 * 1000, time)); //Task.Run(() => GraphVM.MonitorTemp(30 + 1000, time)); }
public List <SitesVM> GetSiteDataList(Int64 SiteId) { List <SitesVM> loSiteList = new List <SitesVM>(); SitesDL sd = new SitesDL(); DataTable dt = sd.GetSiteData("ById", SiteId.ToString()); if (dt.Rows.Count > 0) { SitesVM loSite; foreach (DataRow dr in dt.Rows) { loSite = new SitesVM(); loSite.SiteId = cnvtr.Int64(dr["SiteId"].ToString()); loSite.SiteCode = dr["SiteCode"].ToString(); loSite.Latitude = Convert.ToDouble(dr["Latitude"]); loSite.Longitude = Convert.ToDouble(dr["Longitude"]); loSite.SubmittedOn = Convert.ToDateTime(dr["SubmittedOn"]); if (dr["ScheduledOn"] != DBNull.Value) { loSite.ScheduledOn = Convert.ToDateTime(dr["ScheduledOn"]); } if (dr["AssignedOn"] != DBNull.Value) { loSite.AssignedOn = Convert.ToDateTime(dr["AssignedOn"]); } if (dr["CompletedOn"] != DBNull.Value) { loSite.CompletedOn = Convert.ToDateTime(dr["CompletedOn"]); } loSite.Status = dr["Status"].ToString(); loSite.Market = dr["Market"].ToString(); loSite.Region = dr["Region"].ToString(); loSite.NetworkMode = dr["NetworkMode"].ToString(); loSite.Band = dr["Band"].ToString(); loSite.Carrier = dr["Carrier"].ToString(); if (dt.Columns.Contains("CityId")) { loSite.CityId = (!string.IsNullOrEmpty(dr["CityId"].ToString()))? Convert.ToInt64(dr["CityId"].ToString()):0; } loSiteList.Add(loSite); } } return(loSiteList); }
public DashboardVM GetProjectDashboardVM(string ParentFilter, string ChildFilter, DateTime fromDate, DateTime toDate, DataTable dtCiteies, string Panel1Option, Int64 Panel1Value, string Panel2Option, Int64 Panel2Value, Int64 UserId, string CountryId, string Client, string Scopes, string Markets) { try { DashboardDL db = new DashboardDL(); DataSet ds = db.GetProjectDashboardData(ParentFilter, ChildFilter, fromDate, toDate, dtCiteies, Panel1Option, Panel1Value, Panel2Option, Panel2Value, UserId, CountryId, Client, Scopes, Markets); DashboardVM vm = new DashboardVM(); DataTable DashboardData = ds.Tables[0]; DataTable dtSiteWO = ds.Tables[1]; DashboardStatusVM SiteStatuses = new DashboardStatusVM(); SiteStatuses.TotalSites = Convert.ToInt32(DashboardData.Rows[0]["TotalSites"] is DBNull ? 0 : DashboardData.Rows[0]["TotalSites"]); SiteStatuses.PendingSites = Convert.ToInt32(DashboardData.Rows[0]["PendingSites"] is DBNull ? 0 : DashboardData.Rows[0]["PendingSites"]); SiteStatuses.InProcessSites = Convert.ToInt32(DashboardData.Rows[0]["InProcessSites"] is DBNull ? 0 : DashboardData.Rows[0]["InProcessSites"]); SiteStatuses.CompletedSites = Convert.ToInt32(DashboardData.Rows[0]["CompletedSites"] is DBNull ? 0 : DashboardData.Rows[0]["CompletedSites"]); SiteStatuses.DriveCompleted = Convert.ToInt32(DashboardData.Rows[0]["DriveCompletedSites"] is DBNull ? 0 : DashboardData.Rows[0]["DriveCompletedSites"]); SiteStatuses.PendingWithIssues = Convert.ToInt32(DashboardData.Rows[0]["PendingWithIssuesSites"] is DBNull ? 0 : DashboardData.Rows[0]["PendingWithIssuesSites"]); SiteStatuses.InProgress = Convert.ToInt32(DashboardData.Rows[0]["InProgress"] is DBNull ? 0 : DashboardData.Rows[0]["InProgress"]); SiteStatuses.ReportSubmitted = Convert.ToInt32(DashboardData.Rows[0]["ReportSubmitted"] is DBNull ? 0 : DashboardData.Rows[0]["ReportSubmitted"]); vm.SiteStatuses = SiteStatuses; if (dtSiteWO != null && dtSiteWO.Rows.Count > 0) { for (int i = 0; i < dtSiteWO.Rows.Count; i++) { SitesVM sv = new SitesVM(); sv.SubmittedOn = Convert.ToDateTime(dtSiteWO.Rows[i]["Date"].ToString()); sv.SiteCount = int.Parse(dtSiteWO.Rows[i]["SiteCount"].ToString()); vm.lstSiteWO.Add(sv); } } return(vm); } catch (Exception ex) { throw ex; } }
public SiteReportVM GetSiteReportSummary(Int64 SiteId) { SiteReportVM SiteReportvm = new SiteReportVM(); try { DataSet ds = sd.GetSiteTestSummary(SiteId); DataTable dtTestSummary = ds.Tables[0]; DataTable dtConfigurationSettigs = ds.Tables[1]; DataTable dtPlots = ds.Tables[2]; List <DataRow> drSite = dtTestSummary.Select("SiteId='" + SiteId + "'").Distinct().ToList(); SitesVM loSite = new SitesVM(); #region SitesVM loSite.SiteId = cnvtr.Int64(drSite[0]["SiteId"].ToString()); loSite.SiteCode = drSite[0]["Site"] is DBNull ? "" : drSite[0]["Site"].ToString(); loSite.Region = drSite[0]["Region"] is DBNull ? "" : drSite[0]["Region"].ToString(); loSite.Market = drSite[0]["City"] is DBNull ? "" : drSite[0]["City"].ToString(); loSite.Latitude = cnvtr.Double(drSite[0]["Latitude"].ToString()); loSite.Longitude = cnvtr.Double(drSite[0]["Longitude"].ToString()); loSite.ScheduledOn = drSite[0]["ScheduledOn"] is DBNull?Convert.ToDateTime("11/15/2016 00:00") : Convert.ToDateTime(drSite[0]["ScheduledOn"].ToString()); loSite.SubmittedOn = drSite[0]["SubmittedOn"] is DBNull?Convert.ToDateTime("11/15/2016 00:00") : Convert.ToDateTime(drSite[0]["SubmittedOn"].ToString()); loSite.CompletedOn = drSite[0]["CompletedOn"] is DBNull?Convert.ToDateTime("11/15/2016 00:00") : Convert.ToDateTime(drSite[0]["CompletedOn"].ToString()); loSite.ClientLogo = drSite[0]["ClientLogo"] is DBNull ? "" : drSite[0]["ClientLogo"].ToString(); loSite.VendorLogo = drSite[0]["VendorLogo"] is DBNull ? "" : drSite[0]["VendorLogo"].ToString(); #endregion DataView viewBands = new DataView(dtTestSummary); DataTable dtBands = viewBands.ToTable(true, "BandId", "Band", "NetworkMode", "Carrier", "Scope"); #region lstBands List <BandVM> lstBands = new List <BandVM>(); BandVM loBand; foreach (DataRow drBand in dtBands.Rows) { loBand = new BandVM(); loBand.BandId = drBand["BandId"] is DBNull ? 0 : Convert.ToInt32(drBand["BandId"]); loBand.BandName = drBand["Band"] is DBNull ? "" : Convert.ToString(drBand["Band"]); loBand.NetworkMode = drBand["NetworkMode"] is DBNull ? "" : Convert.ToString(drBand["NetworkMode"]); loBand.Carrier = drBand["Carrier"] is DBNull ? "" : Convert.ToString(drBand["Carrier"]); loBand.Scope = drBand["Scope"] is DBNull ? "" : Convert.ToString(drBand["Scope"]); DataView viewSectors = new DataView(dtTestSummary, "BandId = '" + loBand.BandId + "'", "SectorId", DataViewRowState.CurrentRows); DataTable dtSectors = viewBands.ToTable(true); #region TestResult And lstsectors List <SectorsVM> lstsectors = new List <SectorsVM>(); SectorsVM loSector; TestResultVm TestResult; foreach (DataRow drSector in dtSectors.Rows) { loSector = new SectorsVM(); loSector.SectorCode = drSector["Sector"] is DBNull ? "" : Convert.ToString(drSector["Sector"]); loSector.PCI = drSector["PciId"] is DBNull ? 0 : Convert.ToInt32(drSector["PciId"]); loSector.Azimuth = drSector["Azimuth"] is DBNull ? (float)0 : (float)Convert.ToDouble(drSector["Azimuth"]); loSector.BeamWidth = drSector["BeamWidth"] is DBNull ? (float)0 : (float)Convert.ToDouble(drSector["BeamWidth"]); TestResult = new TestResultVm(); TestResult.DownlinkAvgResult = cnvtr.Double(drSector["DownlinkAvgResult"].ToString()); TestResult.DownlinkMaxResult = cnvtr.Double(drSector["DownlinkMaxResult"].ToString()); TestResult.DownlinkMinResult = cnvtr.Double(drSector["DownlinkMinResult"].ToString()); TestResult.DownlinkRate = drSector["DownlinkRate"] is DBNull ? "" : Convert.ToString(drSector["DownlinkRate"]); if (!string.IsNullOrEmpty(drSector["DownlinkStatus"].ToString())) { TestResult.DownlinkStatus = Convert.ToBoolean(drSector["DownlinkStatus"]); } if (!string.IsNullOrEmpty(drSector["FtpStatus"].ToString())) { TestResult.FtpStatus = cnvtr.Bool(drSector["FtpStatus"].ToString()); } TestResult.GsmRssi = cnvtr.Int32(drSector["GsmRssi"].ToString()); TestResult.GsmRxQual = cnvtr.Int32(drSector["GsmRxQual"].ToString()); TestResult.LatencyRate = drSector["LatencyRate"] is DBNull ? "" : Convert.ToString(drSector["LatencyRate"]); TestResult.LteCqi = cnvtr.Double(drSector["LteCqi"].ToString()); TestResult.LteRsnr = cnvtr.Int32(drSector["LteRsnr"].ToString()); TestResult.LteRsrp = cnvtr.Int32(drSector["LteRsrp"].ToString()); TestResult.LteRsrq = cnvtr.Int32(drSector["LteRsrq"].ToString()); TestResult.LteRssi = cnvtr.Int32(drSector["LteRssi"].ToString()); TestResult.PciId = drSector["DownlinkAvgResult"] is DBNull ? "" : Convert.ToString(drSector["PciId"]); TestResult.PingAverageResult = cnvtr.Double(drSector["PingAverageResult"].ToString()); TestResult.PingHost = drSector["PingHost"] is DBNull ? "" : Convert.ToString(drSector["PingHost"]); TestResult.PingIterations = drSector["PingIterations"] is DBNull ? "" : Convert.ToString(drSector["PingIterations"]); TestResult.PingMaxResult = drSector["PingMaxResult"] is DBNull ? "" : Convert.ToString(drSector["PingMaxResult"]); TestResult.PingMinResult = cnvtr.Double(drSector["PingMinResult"].ToString()); if (!string.IsNullOrEmpty(drSector["PingStatus"].ToString())) { TestResult.PingStatus = cnvtr.Bool(drSector["PingStatus"].ToString()); } TestResult.UplinkMinResult = cnvtr.Double(drSector["UplinkMinResult"].ToString()); TestResult.UplinkRate = cnvtr.Double(drSector["UplinkRate"].ToString()); TestResult.WcdmaEcio = cnvtr.Double(drSector["WcdmaEcio"].ToString()); TestResult.WcdmaRscp = cnvtr.Int32(drSector["WcdmaRscp"].ToString()); TestResult.WcdmaRssi = cnvtr.Int32(drSector["WcdmaRssi"].ToString()); if (!string.IsNullOrEmpty(drSector["Ccwhandoverstatus"].ToString())) { TestResult.Ccwhandoverstatus = cnvtr.Bool(drSector["Ccwhandoverstatus"].ToString()); } if (!string.IsNullOrEmpty(drSector["ConnectionSetupStatus"].ToString())) { TestResult.ConnectionSetupStatus = cnvtr.Bool(drSector["ConnectionSetupStatus"].ToString()); TestResult.MoStatus = cnvtr.Bool(drSector["MoStatus"].ToString()); } TestResult.ConnectionSetupTime = drSector["ConnectionSetupTime"] is DBNull ? "" : Convert.ToString(drSector["ConnectionSetupTime"]); if (!string.IsNullOrEmpty(drSector["CwHandoverStatus"].ToString())) { TestResult.CwHandoverStatus = cnvtr.Bool(drSector["CwHandoverStatus"].ToString()); } TestResult.FtpDownlinkFile = drSector["FtpDownlinkFile"] is DBNull ? "" : Convert.ToString(drSector["FtpDownlinkFile"]); TestResult.FtpServerIp = drSector["FtpServerIp"] is DBNull ? "" : Convert.ToString(drSector["FtpServerIp"]); TestResult.FtpServerPath = drSector["FtpServerPath"] is DBNull ? "" : Convert.ToString(drSector["FtpServerPath"]); TestResult.FtpServerPort = drSector["FtpServerPort"] is DBNull ? "" : Convert.ToString(drSector["FtpServerPort"]); TestResult.MoMtCallDuration = drSector["MoMtCallDuration"] is DBNull ? "" : Convert.ToString(drSector["MoMtCallDuration"]); TestResult.MoMtCallNo = drSector["MoMtCallNo"] is DBNull ? "" : Convert.ToString(drSector["MoMtCallNo"]); if (!string.IsNullOrEmpty(drSector["MoStatus"].ToString())) { TestResult.MoStatus = cnvtr.Bool(drSector["MoStatus"].ToString()); } if (!string.IsNullOrEmpty(drSector["MtStatus"].ToString())) { TestResult.MtStatus = cnvtr.Bool(drSector["MtStatus"].ToString()); } TestResult.UplinkAvgResult = cnvtr.Double(drSector["UplinkAvgResult"].ToString()); TestResult.UplinkMaxResult = cnvtr.Double(drSector["UplinkMaxResult"].ToString()); if (!string.IsNullOrEmpty(drSector["UplinkStatus"].ToString())) { TestResult.UplinkStatus = cnvtr.Bool(drSector["UplinkStatus"].ToString()); } TestResult.VMoMtCallDuration = drSector["VMoMtCallDuration"] is DBNull ? "" : Convert.ToString(drSector["VMoMtCallDuration"]); TestResult.VMoMtCallno = drSector["VMoMtCallno"] is DBNull ? "" : Convert.ToString(drSector["VMoMtCallno"]); if (!string.IsNullOrEmpty(drSector["VMoStatus"].ToString())) { TestResult.VMoStatus = cnvtr.Bool(drSector["VMoStatus"].ToString()); } if (!string.IsNullOrEmpty(drSector["VMtStatus"].ToString())) { TestResult.VMtStatus = cnvtr.Bool(drSector["VMtStatus"].ToString()); } TestResult.StationaryTestFilePath = drSector["StationaryTestFilePath"] is DBNull ? "" : Convert.ToString(drSector["StationaryTestFilePath"]); TestResult.CwTestFilePath = drSector["CwTestFilePath"] is DBNull ? "" : Convert.ToString(drSector["CwTestFilePath"]); TestResult.CcwTestFilePath = drSector["CcwTestFilePath"] is DBNull ? "" : Convert.ToString(drSector["CcwTestFilePath"]); TestResult.OoklaDownLinkResult = cnvtr.Double(drSector["OoklaDownlinkResult"].ToString()); TestResult.OoklaUplinkResult = cnvtr.Double(drSector["OoklaUplinkResult"].ToString()); TestResult.Latitude = drSector["Latitude"] is DBNull ? "" : Convert.ToString(drSector["Latitude"]); TestResult.Longitude = drSector["Longitude"] is DBNull ? "" : Convert.ToString(drSector["Longitude"]); TestResult.TestLatitude = cnvtr.Double(drSector["TestLatitude"].ToString()); TestResult.TestLongitude = cnvtr.Double(drSector["TestLongitude"].ToString()); TestResult.Band = drSector["Band"].ToString(); TestResult.IRATHandover = cnvtr.Bool(drSector["IRATHandover"].ToString()); loSector.TestResult = TestResult; lstsectors.Add(loSector); } loBand.Sectors = lstsectors; #endregion DataView vSectors = new DataView(dtTestSummary, "SiteId = '" + loSite.SiteId + "'", "SectorId", DataViewRowState.CurrentRows); DataTable tblSectors = vSectors.ToTable(true); DataView viewPlots = new DataView(dtPlots); DataTable dtPlot = viewPlots.ToTable(true); #region SiteReportPlotVM List <SiteReportPlotVM> lstPlots = new List <SiteReportPlotVM>(); SiteReportPlotVM plot; foreach (DataRow drPlot in dtPlot.Rows) { plot = new SiteReportPlotVM(); plot.Latitude = Convert.ToDouble(drPlot["Latitude"] is DBNull ? 0 : drPlot["Latitude"]); plot.Longitude = Convert.ToDouble(drPlot["Longitude"] is DBNull ? 0 : drPlot["Longitude"]); plot.PCI = drPlot["PciId"] is DBNull ? "" : drPlot["PciId"].ToString(); plot.MarkerImagePath = "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0e/Ski_trail_rating_symbol-green_circle.svg/768px-Ski_trail_rating_symbol-green_circle.svg.png"; plot.siteLatitude = drSite[0]["Latitude"] is DBNull ? 0 : Convert.ToDouble(drSite[0]["Latitude"].ToString()); plot.siteLongitude = drSite[0]["Longitude"] is DBNull ? 0 : Convert.ToDouble(drSite[0]["Longitude"].ToString()); plot.IsHandover = Convert.ToBoolean(drPlot["IsHandover"].ToString()); ColorCollection cc = new ColorCollection(); #region LTE Color DataRow[] drows = tblSectors.Select("PciId=" + "'" + plot.PCI + "'"); if (drows.Count() > 0) { int SelectedIndex = tblSectors.Rows.IndexOf(drows[0]); plot.plotColor = cc.LTE_PciId(SelectedIndex); } if (loBand.NetworkMode.ToString() == "LTE") { int LteRsrp = drPlot["LteRsrp"] is DBNull ? 0 : Convert.ToInt32(drPlot["LteRsrp"]); plot.rsrpColor = cc.LTERsrp(LteRsrp); int LteRsrq = drPlot["LteRsrq"] is DBNull ? 0 : Convert.ToInt32(drPlot["LteRsrq"]); plot.rsrqColor = cc.LTERsrq(LteRsrq); int Ltesinr = drPlot["LteRsnr"] is DBNull ? 0 : Convert.ToInt32(drPlot["LteRsnr"]); plot.rsnrColor = cc.LTEsinr(Ltesinr); } #endregion #region WCDMA Color if (loBand.NetworkMode.ToString() == "WCDMA") { int WcdmaEcio = drPlot["WcdmaEcio"] is DBNull ? 0 : Convert.ToInt32(drPlot["WcdmaEcio"]); plot.rsrpColor = cc.WCDMAEcio(WcdmaEcio); } #endregion #region GSM Color if (loBand.NetworkMode.ToString() == "GSM") { int GsmRssi = drPlot["GsmRssi"] is DBNull ? 0 : Convert.ToInt32(drPlot["GsmRssi"]); plot.rsrpColor = cc.GsmRssi(GsmRssi); } #endregion lstPlots.Add(plot); } #endregion loBand.PciPlot = lstPlots; lstBands.Add(loBand); } #endregion loSite.Bands = lstBands; DataView view = new DataView(dtConfigurationSettigs); DataTable distinctValues = view.ToTable(true, "TestCateoryId", "TestCategory"); List <TestCategoryVM> lstTestCategories = new List <TestCategoryVM>(); TestCategoryVM cat; foreach (DataRow dr in distinctValues.Rows) { cat = new TestCategoryVM(); cat.TestCategoryId = cnvtr.Int64(dr["TestCateoryId"].ToString()); cat.TestCategoryName = dr["TestCategory"] is DBNull ? "" : dr["TestCategory"].ToString(); DataView v = new DataView(dtConfigurationSettigs, "TestCateoryId = '" + cat.TestCategoryId + "'", "TestTypeId", DataViewRowState.CurrentRows); DataTable dtTypes = v.ToTable(true, "TestTypeId", "TestType"); List <TestTypeVM> lstTestTypes = new List <TestTypeVM>(); TestTypeVM type; foreach (DataRow drtype in dtTypes.Rows) { type = new TestTypeVM(); type.TestTypeName = drtype["TestType"] is DBNull ? "" : drtype["TestType"].ToString(); type.TestTypeId = cnvtr.Int64(drtype["TestTypeId"].ToString()); DataView vkpis = new DataView(dtConfigurationSettigs, "TestTypeId = '" + type.TestTypeId + "'", "TestTypeId", DataViewRowState.CurrentRows); DataTable dtKpi = vkpis.ToTable(true, "Kpi", "KpiValue"); List <TestKpiVM> lstKpi = new List <TestKpiVM>(); TestKpiVM kpi; foreach (DataRow drkpi in dtKpi.Rows) { kpi = new TestKpiVM(); kpi.KpiName = drkpi["Kpi"] is DBNull ? "" : drkpi["Kpi"].ToString(); kpi.KpiValue = drkpi["KpiValue"] is DBNull ? "" : drkpi["KpiValue"].ToString(); lstKpi.Add(kpi); } type.TestKpi = lstKpi; lstTestTypes.Add(type); } cat.TestTypes = lstTestTypes; lstTestCategories.Add(cat); } SiteReportvm.Site = loSite; SiteReportvm.TestCategories = lstTestCategories; } catch (Exception) { // throw; } return(SiteReportvm); }
public SitesVM GetSiteDataSingle(Int64 SiteId) { SitesDL sd = new SitesDL(); DataTable dt = sd.GetSiteData("ById", SiteId.ToString()); if (dt.Rows.Count > 0) { SitesVM loSite = new SitesVM(); loSite.SiteId = cnvtr.Int64(dt.Rows[0]["SiteId"].ToString()); loSite.SiteCode = dt.Rows[0]["SiteCode"].ToString(); loSite.Latitude = Convert.ToDouble(dt.Rows[0]["Latitude"]); loSite.Longitude = Convert.ToDouble(dt.Rows[0]["Longitude"]); loSite.SubmittedOn = Convert.ToDateTime(dt.Rows[0]["SubmittedOn"]); if (dt.Rows[0]["ScheduledOn"] != DBNull.Value) { loSite.ScheduledOn = Convert.ToDateTime(dt.Rows[0]["ScheduledOn"]); } if (dt.Rows[0]["AssignedOn"] != DBNull.Value) { loSite.AssignedOn = Convert.ToDateTime(dt.Rows[0]["AssignedOn"]); } if (dt.Rows[0]["CompletedOn"] != DBNull.Value) { loSite.CompletedOn = Convert.ToDateTime(dt.Rows[0]["CompletedOn"]); } loSite.Status = dt.Rows[0]["Status"].ToString(); loSite.Market = dt.Rows[0]["Market"].ToString(); loSite.Region = dt.Rows[0]["Region"].ToString(); loSite.NetworkMode = dt.Rows[0]["NetworkMode"].ToString(); loSite.Band = dt.Rows[0]["Band"].ToString(); loSite.Carrier = dt.Rows[0]["Carrier"].ToString(); if (dt.Columns.Contains("ClientId")) { loSite.ClientId = (!string.IsNullOrEmpty(dt.Rows[0]["ClientId"].ToString()))?Convert.ToInt64(dt.Rows[0]["ClientId"].ToString()):0; } if (dt.Columns.Contains("CityId")) { loSite.CityId = (!string.IsNullOrEmpty(dt.Rows[0]["CityId"].ToString())) ? Convert.ToInt64(dt.Rows[0]["CityId"].ToString()) : 0; } if (dt.Columns.Contains("ScopeId")) { loSite.ScopeId = (!string.IsNullOrEmpty(dt.Rows[0]["ScopeId"].ToString())) ? Convert.ToInt64(dt.Rows[0]["ScopeId"].ToString()) : 0; } if (dt.Columns.Contains("Scope")) { loSite.Scope = dt.Rows[0]["Scope"].ToString(); } return(loSite); } return(null); }
public List <SitesVM> GetSitesFromTable(DataTable TotalSites) { DirectoryHandler dh = new DirectoryHandler(); List <SitesVM> lstSites = new List <SitesVM>(); string ApplicationPath = System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Substring(8); string AppPath = ApplicationPath.Remove(ApplicationPath.Length - 24); string Profile = ApplicationPath.Remove(ApplicationPath.Length - 24); if (TotalSites.Rows.Count > 0) { SitesVM loSite; for (int i = 0; i < TotalSites.Rows.Count; i++) { loSite = new SitesVM(); loSite.SiteId = Convert.ToInt64(TotalSites.Rows[i]["SiteId"]); loSite.SiteCode = TotalSites.Rows[i]["SiteCode"].ToString(); loSite.ClusterId = TotalSites.Rows[i]["ClusterId"].ToString(); if (TotalSites.Columns.Contains("Scope")) { loSite.Scope = TotalSites.Rows[i]["Scope"].ToString(); } if (TotalSites.Columns.Contains("ScopeId")) { loSite.ScopeId = Convert.ToInt64(TotalSites.Rows[i]["ScopeId"].ToString()); } loSite.Latitude = (!string.IsNullOrEmpty(TotalSites.Rows[i]["Latitude"].ToString())) ? Convert.ToDouble(TotalSites.Rows[i]["Latitude"]) : 0; loSite.Longitude = (!string.IsNullOrEmpty(TotalSites.Rows[i]["Longitude"].ToString())) ? Convert.ToDouble(TotalSites.Rows[i]["Longitude"]) : 0; loSite.Tester = TotalSites.Rows[i]["Tester"] == DBNull.Value ? "" : TotalSites.Rows[i]["Tester"].ToString(); loSite.TesterId = (TotalSites.Columns.Contains("TesterId")) ? TotalSites.Rows[i]["TesterId"] == DBNull.Value ? 0 : Convert.ToInt32(TotalSites.Rows[i]["TesterId"]) : 0; if (!string.IsNullOrEmpty(TotalSites.Rows[i]["SubmittedOn"].ToString())) { loSite.SubmittedOn = Convert.ToDateTime(TotalSites.Rows[i]["SubmittedOn"]); } if (!string.IsNullOrEmpty(TotalSites.Rows[i]["ReceivedOn"].ToString())) { loSite.ReceivedOn = Convert.ToDateTime(TotalSites.Rows[i]["ReceivedOn"]); } loSite.WoRefNo = TotalSites.Rows[i]["WoRefNo"].ToString(); if (TotalSites.Rows[i]["AssignedOn"] != DBNull.Value) { loSite.AssignedOn = Convert.ToDateTime(TotalSites.Rows[i]["AssignedOn"]); } if (TotalSites.Rows[i]["CompletedOn"] != DBNull.Value) { loSite.CompletedOn = Convert.ToDateTime(TotalSites.Rows[i]["CompletedOn"]); } // break point if (TotalSites.Columns.Contains("DriveCompletedOn")) { if (TotalSites.Rows[i]["DriveCompletedOn"] != DBNull.Value) { loSite.DriveCompletedOn = Convert.ToDateTime(TotalSites.Rows[i]["DriveCompletedOn"]); } } if (TotalSites.Rows[i]["ScheduledOn"] != DBNull.Value) { loSite.ScheduledOn = Convert.ToDateTime(TotalSites.Rows[i]["ScheduledOn"]); } string TesterPicture = TotalSites.Rows[i]["Status"].ToString(); loSite.Status = TotalSites.Rows[i]["Status"].ToString(); loSite.StatusName = TotalSites.Rows[i]["StatusName"].ToString(); loSite.StatusKeyCode = TotalSites.Rows[i]["StatusKeyCode"].ToString(); if (TotalSites.Columns.Contains("IsDownloaded") && !string.IsNullOrEmpty(TotalSites.Rows[i]["IsDownloaded"].ToString())) { loSite.IsDownloaded = Convert.ToBoolean(TotalSites.Rows[i]["IsDownloaded"].ToString()); } if (TotalSites.Columns.Contains("ReportSubmittedOn") && !string.IsNullOrEmpty(TotalSites.Rows[i]["ReportSubmittedOn"].ToString())) { loSite.ReportSubmittedOn = Convert.ToDateTime(TotalSites.Rows[i]["ReportSubmittedOn"].ToString()); } //ReportSubmittedOn loSite.Market = TotalSites.Rows[i]["Market"].ToString(); loSite.Region = TotalSites.Rows[i]["Region"].ToString(); loSite.Client = TotalSites.Rows[i]["ClientName"].ToString(); if (TotalSites.Columns.Contains("ClientPrefix") && !string.IsNullOrEmpty(TotalSites.Rows[i]["ClientPrefix"].ToString())) { loSite.ClientPrefix = TotalSites.Rows[i]["ClientPrefix"].ToString(); } if (TotalSites.Columns.Contains("IsActive") && !string.IsNullOrEmpty(TotalSites.Rows[i]["IsActive"].ToString())) { loSite.IsActive = Convert.ToBoolean(TotalSites.Rows[i]["IsActive"].ToString()); } // loSite.ZIndex = 1; string cnt = string.Empty; if (loSite.StatusKeyCode == "N/A") { Profile = "/Content/Images/Profile/home-" + loSite.TesterId + ".png"; // string NewProfilePath = ProfilePath + Profile; if (dh.FileExist(AppPath + Profile)) { loSite.MarkerImagePath = Profile; } else { loSite.MarkerImagePath = "/Content/Images/Profile/home-default.png"; } cnt = "<b>Tester: </b> " + loSite.Tester + "</br>"; } else { if (loSite.StatusKeyCode == "PENDING_SCHEDULED") { loSite.MarkerImagePath = "/Content/Images/Common/PENDING_SCHEDULED.png";//"http://maps.google.com/mapfiles/ms/icons/yellow-dot.png"; loSite.MarkerTitle = "PENDING_SCHEDULED"; } else if (loSite.StatusKeyCode == "COMPLETED") { loSite.MarkerImagePath = "/Content/Images/Common/COMPLETED_MARKER.png";// "http://maps.google.com/mapfiles/ms/icons/green-dot.png"; loSite.MarkerTitle = "COMPLETED"; } else if (loSite.StatusKeyCode == "IN_PROGRESS") { loSite.MarkerImagePath = "/Content/Images/Common/IN_PROGRESS_MARKER.png"; loSite.MarkerTitle = "IN_PROGRESS"; } else if (loSite.StatusKeyCode == "REPORT_SUBMITTED") { loSite.MarkerImagePath = "/Content/Images/Common/REPORT_SUBMITTED_MARKER.png";// "http://maps.google.com/mapfiles/ms/icons/green-dot.png"; loSite.MarkerTitle = "REPORT_SUBMITTED"; } else if (loSite.StatusKeyCode == "DRIVE_COMPLETED") { loSite.MarkerImagePath = "/Content/Images/Common/DRIVE_COMPLETED_MARKER.png";// "http://maps.google.com/mapfiles/ms/icons/green-dot.png"; loSite.MarkerTitle = "DRIVE_COMPLETED"; } else if (loSite.StatusKeyCode == "PENDING_WITH_ISSUE") { loSite.MarkerImagePath = "/Content/Images/Common/PENDING_WITH_ISSUE_MARKER.png"; //"http://maps.google.com/mapfiles/ms/icons/red-dot.png"; loSite.MarkerTitle = "PENDING_WITH_ISSUE"; } else if (loSite.StatusKeyCode == "SCHEDULED") { loSite.MarkerImagePath = "/Content/Images/Common/SCHEDULED_MARKER.png"; loSite.MarkerTitle = "SCHEDULED"; if (!string.IsNullOrEmpty(TotalSites.Rows[i]["TesterPicture"].ToString())) { string imgUrl = TotalSites.Rows[i]["TesterPicture"].ToString().Replace("u-", "thumb-"); if (imgUrl == "/Content/Images/Profile/Default.svg") { loSite.MarkerImagePath = "/Content/Images/Profile/defaultThumb.jpg"; } else { loSite.MarkerImagePath = imgUrl; } } } else { loSite.MarkerImagePath = "http://maps.google.com/mapfiles/ms/icons/yellow-dot.png"; loSite.MarkerTitle = loSite.SiteCode; } //cnt = "<div>" + "<b>Site Code: </b> " + loSite.SiteCode + "</br>" + "<b>Region: </b>" + loSite.Region + "</br>" + "<b>Market: </b> " + loSite.Market + "</br>" + "<b>Tester: </b> " + loSite.Tester + "</br>"; //cnt = (loSite.SubmittedOn.ToString("MM/dd/yyyy HH:mm") != "01/01/0001 00:00") ? cnt + "<b>Submitted: </b> " + loSite.SubmittedOn.ToString("MM/dd/yyyy HH:mm") + "</br>" : cnt + "<b>Submitted: </b> " + loSite.ScheduledOn.ToString("MM/dd/yyyy HH:mm") + "</br>"; //if (loSite.ScheduledOn.ToString("MM/dd/yyyy HH:mm") != "01/01/0001 00:00") //{ // cnt = cnt + "<b>Scheduled: </b> " + loSite.ScheduledOn.ToString("MM/dd/yyyy HH:mm") + "</br>"; //} //else //{ // cnt = cnt + "<b>Scheduled: </b> " + "</br>"; //} //if (loSite.CompletedOn.ToString("MM/dd/yyyy HH:mm") != "01/01/0001 00:00") //{ // cnt = cnt + "<b>Completed: </b> " + loSite.CompletedOn.ToString("MM/dd/yyyy HH:mm") + "</br>"; //} //else //{ // cnt = cnt + "<b>Completed: </b> " + "</br>"; //} //cnt = cnt + "</div>"; //--------------------------------------------- cnt = "<div>" + "<b>Site Code: </b> " + loSite.SiteCode + "</br>" + "<b>Site Status: </b> " + loSite.StatusName + "</br>" + "<b>Site Type: </b> " + loSite.SiteType + "</br>" + "<b>Scope: </b> " + loSite.Scope + "</br>" + "<b>Region: </b>" + loSite.Region + "</br>" + "<b>Market: </b> " + loSite.Market + "</br>" + "<b>Tester: </b> " + loSite.Tester + "</br>"; /*Received Date Start*/ if (loSite.ReceivedOn.ToString("MM/dd/yyyy HH:mm") != "01/01/0001 00:00") { cnt = cnt + "<b>Received: </b> " + loSite.ReceivedOn.ToString("MM/dd/yyyy HH:mm") + "</br>"; } else { cnt = cnt + "<b>Received: </b> " + "</br>"; } /*Received Date End*/ cnt = (loSite.SubmittedOn.ToString("MM/dd/yyyy HH:mm") != "01/01/0001 00:00") ? cnt + "<b>Submitted: </b> " + loSite.SubmittedOn.ToString("MM/dd/yyyy HH:mm") + "</br>" : cnt + "<b>Submitted: </b> " + loSite.ScheduledOn.ToString("MM/dd/yyyy HH:mm") + "</br>"; if (loSite.ScheduledOn.ToString("MM/dd/yyyy HH:mm") != "01/01/0001 00:00") { cnt = cnt + "<b>Scheduled: </b> " + loSite.ScheduledOn.ToString("MM/dd/yyyy HH:mm") + "</br>"; } else { cnt = cnt + "<b>Scheduled: </b> " + "</br>"; } var cd = loSite.DriveCompletedOn.ToString("MM/dd/yyyy HH:mm"); /*Drive Completed Date Start*/ if (loSite.DriveCompletedOn.ToString("MM/dd/yyyy HH:mm") != "01/01/0001 00:00") { cnt = cnt + "<b>Drive Completed: </b> " + loSite.DriveCompletedOn.ToString("MM/dd/yyyy HH:mm") + "</br>"; } else { cnt = cnt + "<b>Drive Completed: </b> " + "</br>"; } /*Drive Completed Date End*/ /*Report Submitted Date Start*/ if (loSite.ReportSubmittedOn.ToString("MM/dd/yyyy HH:mm") != "01/01/0001 00:00") { cnt = cnt + "<b>Report Submitted: </b> " + loSite.ReportSubmittedOn.ToString("MM/dd/yyyy HH:mm") + "</br>"; } else { cnt = cnt + "<b>Report Submitted: </b> " + "</br>"; } /*Report Submitted Date End*/ if (loSite.CompletedOn.ToString("MM/dd/yyyy HH:mm") != "01/01/0001 00:00") { cnt = cnt + "<b>Completed: </b> " + loSite.CompletedOn.ToString("MM/dd/yyyy HH:mm") + "</br>"; } else { cnt = cnt + "<b>Completed: </b> " + "</br>"; } cnt = cnt + "</div>"; } loSite.InfoWindowContent = cnt; lstSites.Add(loSite); } } return(lstSites); }