|
@@ -47,7 +47,6 @@ namespace comal.timesheets
|
|
|
|
|
|
LoadCacheLists();
|
|
|
|
|
|
- //if (GlobalVariables.EmpID == Guid.Parse("40f6ccd9-5272-4b1a-99bf-de7542205aac"))
|
|
|
RunCustomScript();
|
|
|
}
|
|
|
catch (Exception e) { }
|
|
@@ -1172,19 +1171,12 @@ namespace comal.timesheets
|
|
|
GlobalVariables.ProductsLoaded = false;
|
|
|
GlobalVariables.JobsLoaded = false;
|
|
|
GlobalVariables.GetXamarinWidth();
|
|
|
+
|
|
|
CacheLoader.LoadJobs();
|
|
|
LoadEmployeeShells();
|
|
|
-
|
|
|
- //spread out loading
|
|
|
- Task.Run(() =>
|
|
|
- {
|
|
|
- Thread.Sleep(1000);
|
|
|
-
|
|
|
- LoadCompanyDevices();
|
|
|
- LoadBlueToothAddresses();
|
|
|
- Thread.Sleep(1000);
|
|
|
- LoadProducts();
|
|
|
- });
|
|
|
+ LoadCompanyDevices();
|
|
|
+ LoadBlueToothAddresses();
|
|
|
+ LoadProducts();
|
|
|
|
|
|
//LoadHRToDos(); to be uncommented when ready for roll out
|
|
|
}
|
|
@@ -1196,13 +1188,9 @@ namespace comal.timesheets
|
|
|
if (!string.IsNullOrWhiteSpace(MainPageUtils.deviceName) && MainPageUtils.deviceName != "unknown")
|
|
|
{
|
|
|
List<Equipment> companyDevices = new List<Equipment>();
|
|
|
- CoreTable table = new Client<Equipment>().Query
|
|
|
- (
|
|
|
- new Filter<Equipment>(x => x.GroupLink.Code).IsEqualTo("DEVICE"),
|
|
|
- new Columns<Equipment>(
|
|
|
- x => x.TrackerLink.DeviceID
|
|
|
- )
|
|
|
- );
|
|
|
+ CoreTable table = DoEquipmentQuery();
|
|
|
+ while (table == null)
|
|
|
+ table = DoEquipmentQuery();
|
|
|
if (table.Rows.Any())
|
|
|
{
|
|
|
foreach (CoreRow row in table.Rows)
|
|
@@ -1218,81 +1206,142 @@ namespace comal.timesheets
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private CoreTable DoEquipmentQuery()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return new Client<Equipment>().Query
|
|
|
+ (
|
|
|
+ new Filter<Equipment>(x => x.GroupLink.Code).IsEqualTo("DEVICE"),
|
|
|
+ new Columns<Equipment>(
|
|
|
+ x => x.TrackerLink.DeviceID
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ var log = new MobileLogging(LogType.Query, "DoEquipmentQuery()", ex.Message + ex.StackTrace, "CacheLoader");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void LoadEmployeeShells()
|
|
|
{
|
|
|
Task.Run(() =>
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- List<EmployeeShell> employeeShells = new List<EmployeeShell>();
|
|
|
- List<EmployeeShell> teamEmployeeShells = new List<EmployeeShell>();
|
|
|
-
|
|
|
- MultiQuery query = new MultiQuery();
|
|
|
+ AddEmployees();
|
|
|
+ AddTeams();
|
|
|
+ AddTeamEmployees();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ var log = new MobileLogging(LogType.Query, "LoadEmployeeShells()", ex.Message + ex.StackTrace, this.GetType().Name);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- query.Add<Employee>(
|
|
|
- LookupFactory.DefineFilter<Employee>(),
|
|
|
- new Columns<Employee>(x => x.ID)
|
|
|
- .Add(x => x.Code)
|
|
|
- .Add(x => x.Name),
|
|
|
- LookupFactory.DefineSort<Employee>()
|
|
|
- );
|
|
|
+ private void AddEmployees()
|
|
|
+ {
|
|
|
+ List<EmployeeShell> employeeShells = new List<EmployeeShell>();
|
|
|
+ CoreTable emps = DoEmployeeQuery();
|
|
|
+ while (emps == null)
|
|
|
+ emps = DoEmployeeQuery();
|
|
|
|
|
|
- query.Add<Team>(
|
|
|
- LookupFactory.DefineFilter<Team>(),
|
|
|
- new Columns<Team>(x => x.Name),
|
|
|
- new SortOrder<Team>(x => x.Name)
|
|
|
- );
|
|
|
-
|
|
|
- query.Add<EmployeeTeam>(
|
|
|
- LookupFactory.DefineFilter<EmployeeTeam>(),
|
|
|
- new Columns<EmployeeTeam>(x => x.EmployeeLink.ID)
|
|
|
- .Add(x => x.EmployeeLink.Code)
|
|
|
- .Add(x => x.EmployeeLink.Name)
|
|
|
- .Add(x => x.TeamLink.Name),
|
|
|
- new SortOrder<EmployeeTeam>(x => x.EmployeeLink.Name)
|
|
|
- );
|
|
|
-
|
|
|
- query.Query();
|
|
|
-
|
|
|
- CoreTable emps = query.Get<Employee>();
|
|
|
- foreach (var row in emps.Rows)
|
|
|
+ foreach (var row in emps.Rows)
|
|
|
+ {
|
|
|
+ employeeShells.Add(
|
|
|
+ new EmployeeShell()
|
|
|
{
|
|
|
- employeeShells.Add(
|
|
|
- new EmployeeShell()
|
|
|
- {
|
|
|
- ID = row.Get<Employee, Guid>(x => x.ID),
|
|
|
- Code = row.Get<Employee, String>(x => x.Code),
|
|
|
- Name = row.Get<Employee, String>(x => x.Name),
|
|
|
- TeamName = "All Staff"
|
|
|
- }
|
|
|
- );
|
|
|
+ ID = row.Get<Employee, Guid>(x => x.ID),
|
|
|
+ Code = row.Get<Employee, String>(x => x.Code),
|
|
|
+ Name = row.Get<Employee, String>(x => x.Name),
|
|
|
+ TeamName = "All Staff"
|
|
|
}
|
|
|
+ );
|
|
|
+ }
|
|
|
+ GlobalVariables.EmployeeShells = employeeShells;
|
|
|
+ }
|
|
|
|
|
|
- GlobalVariables.TeamNames = query.Get<Team>().Rows.Select(r => r.Get<Team, String>(c => c.Name)).ToList();
|
|
|
+ private void AddTeamEmployees()
|
|
|
+ {
|
|
|
+ List<EmployeeShell> teamEmployeeShells = new List<EmployeeShell>();
|
|
|
+ CoreTable members = DoEmployeeTeamQuery();
|
|
|
+ while (members == null)
|
|
|
+ members = DoEmployeeTeamQuery();
|
|
|
|
|
|
- CoreTable members = query.Get<EmployeeTeam>();
|
|
|
- foreach (var row in members.Rows)
|
|
|
+ foreach (var row in members.Rows)
|
|
|
+ {
|
|
|
+ teamEmployeeShells.Add(
|
|
|
+ new EmployeeShell()
|
|
|
{
|
|
|
- teamEmployeeShells.Add(
|
|
|
- new EmployeeShell()
|
|
|
- {
|
|
|
- ID = row.Get<EmployeeTeam, Guid>(x => x.EmployeeLink.ID),
|
|
|
- Code = row.Get<EmployeeTeam, String>(x => x.EmployeeLink.Code),
|
|
|
- Name = row.Get<EmployeeTeam, String>(x => x.EmployeeLink.Name),
|
|
|
- TeamName = row.Get<EmployeeTeam, String>(x => x.TeamLink.Name)
|
|
|
- }
|
|
|
- );
|
|
|
+ ID = row.Get<EmployeeTeam, Guid>(x => x.EmployeeLink.ID),
|
|
|
+ Code = row.Get<EmployeeTeam, String>(x => x.EmployeeLink.Code),
|
|
|
+ Name = row.Get<EmployeeTeam, String>(x => x.EmployeeLink.Name),
|
|
|
+ TeamName = row.Get<EmployeeTeam, String>(x => x.TeamLink.Name)
|
|
|
}
|
|
|
+ );
|
|
|
+ }
|
|
|
+ GlobalVariables.TeamEmployeeShells = teamEmployeeShells;
|
|
|
+ }
|
|
|
|
|
|
- GlobalVariables.EmployeeShells = employeeShells;
|
|
|
- GlobalVariables.TeamEmployeeShells = teamEmployeeShells;
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- var log = new MobileLogging(LogType.Query, "LoadEmployeeShells()", ex.Message + ex.StackTrace, this.GetType().Name);
|
|
|
- }
|
|
|
- });
|
|
|
+ private void AddTeams()
|
|
|
+ {
|
|
|
+ var teamsTable = DoTeamsQuery();
|
|
|
+ while (teamsTable == null)
|
|
|
+ teamsTable = DoTeamsQuery();
|
|
|
|
|
|
+ GlobalVariables.TeamNames = teamsTable.Rows.Select(r => r.Get<Team, String>(c => c.Name)).ToList();
|
|
|
+ }
|
|
|
+
|
|
|
+ private CoreTable DoEmployeeQuery()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return new Client<Employee>().Query(
|
|
|
+ LookupFactory.DefineFilter<Employee>(),
|
|
|
+ new Columns<Employee>(x => x.ID, x => x.Code, x => x.Name),
|
|
|
+ LookupFactory.DefineSort<Employee>());
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ var log = new MobileLogging(LogType.Query, "DoEmployeeQuery()", ex.Message + ex.StackTrace, this.GetType().Name);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private CoreTable DoTeamsQuery()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return new Client<Team>().Query(LookupFactory.DefineFilter<Team>(),
|
|
|
+ new Columns<Team>(x => x.Name),
|
|
|
+ new SortOrder<Team>(x => x.Name));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ var log = new MobileLogging(LogType.Query, "DoTeamsQuery()", ex.Message + ex.StackTrace, this.GetType().Name);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private CoreTable DoEmployeeTeamQuery()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return new Client<EmployeeTeam>().Query(LookupFactory.DefineFilter<EmployeeTeam>(),
|
|
|
+ new Columns<EmployeeTeam>(x => x.EmployeeLink.ID)
|
|
|
+ .Add(x => x.EmployeeLink.Code)
|
|
|
+ .Add(x => x.EmployeeLink.Name)
|
|
|
+ .Add(x => x.TeamLink.Name),
|
|
|
+ new SortOrder<EmployeeTeam>(x => x.EmployeeLink.Name));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ var log = new MobileLogging(LogType.Query, "DoTeamsQuery()", ex.Message + ex.StackTrace, this.GetType().Name);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private async void LoadHRToDos()
|
|
@@ -1330,39 +1379,40 @@ namespace comal.timesheets
|
|
|
|
|
|
private void LoadProducts()
|
|
|
{
|
|
|
- try
|
|
|
+ Task.Run(() =>
|
|
|
{
|
|
|
- Task.Run(() =>
|
|
|
- {
|
|
|
- ProductsLoader productsLoader = new ProductsLoader();
|
|
|
- });
|
|
|
- }
|
|
|
- catch { }
|
|
|
+ ProductsLoader productsLoader = new ProductsLoader();
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
private async void LoadBlueToothAddresses()
|
|
|
{
|
|
|
- try
|
|
|
+ Task.Run(() =>
|
|
|
{
|
|
|
- //if (bSharedDevice)
|
|
|
- // return;
|
|
|
- await Task.Run(() =>
|
|
|
+ GlobalVariables.GPSTrackerCache = new List<GPSTracker>();
|
|
|
+ CoreTable table = QueryGPSTrackers();
|
|
|
+ while (table == null)
|
|
|
+ table = QueryGPSTrackers();
|
|
|
+ foreach (CoreRow row in table.Rows)
|
|
|
{
|
|
|
- GlobalVariables.GPSTrackerCache = new List<GPSTracker>();
|
|
|
- CoreTable table = new Client<GPSTracker>().Query(new Filter<GPSTracker>(x => x.Type.Description).Contains("Kontakt"));
|
|
|
- foreach (CoreRow row in table.Rows)
|
|
|
- {
|
|
|
- GPSTracker tracker = row.ToObject<GPSTracker>();
|
|
|
- GlobalVariables.GPSTrackerCache.Add(tracker);
|
|
|
- App.Bluetooth.KnownBlueToothMACAddresses.Add(tracker.DeviceID);
|
|
|
- }
|
|
|
- });
|
|
|
+ GPSTracker tracker = row.ToObject<GPSTracker>();
|
|
|
+ GlobalVariables.GPSTrackerCache.Add(tracker);
|
|
|
+ App.Bluetooth.KnownBlueToothMACAddresses.Add(tracker.DeviceID);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private CoreTable QueryGPSTrackers()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return new Client<GPSTracker>().Query(new Filter<GPSTracker>(x => x.Type.Description).Contains("Kontakt"));
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- var log = new MobileLogging(LogType.Query, "LoadBlueToothAddresses()", ex.Message + ex.StackTrace, this.GetType().Name);
|
|
|
+ var log = new MobileLogging(LogType.Query, "QueryGPSTrackers()", ex.Message + ex.StackTrace, this.GetType().Name);
|
|
|
+ return null;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
#endregion
|
|
|
#endregion
|