|
@@ -23,10 +23,14 @@ namespace comal.timesheets
|
|
|
{
|
|
|
public delegate void MainPageNotificationsChanged();
|
|
|
public delegate void RefreshScreen();
|
|
|
+ public delegate void RequestUserInputForTask(Guid taskID);
|
|
|
+ public delegate void TaskTitleChanged(string title);
|
|
|
public static class MainPageUtils
|
|
|
{
|
|
|
public static event MainPageNotificationsChanged OnMainPageNotificationsChanged;
|
|
|
public static event RefreshScreen OnRefreshScreen;
|
|
|
+ public static event RequestUserInputForTask OnRequestUserInput;
|
|
|
+ public static event TaskTitleChanged OnTaskTitleChanged;
|
|
|
|
|
|
public static Assignment CurrentAssignment = null;
|
|
|
public static JobShell Job = new JobShell();
|
|
@@ -40,6 +44,7 @@ namespace comal.timesheets
|
|
|
public static bool firstLoad = true;
|
|
|
public static bool recentlyAskedToUpdate = true;
|
|
|
public static int updateCounter;
|
|
|
+ public static Kanban CurrentTask = null;
|
|
|
|
|
|
public static void Init()
|
|
|
{
|
|
@@ -58,7 +63,7 @@ namespace comal.timesheets
|
|
|
App.Data.DataRefreshed += () => { OnRefreshScreen?.Invoke(); };
|
|
|
}
|
|
|
catch { }
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
private static void InitData()
|
|
|
{
|
|
@@ -106,6 +111,7 @@ namespace comal.timesheets
|
|
|
SearchForNewNotifications();
|
|
|
}
|
|
|
|
|
|
+ #region Assignments
|
|
|
public static Assignment CheckCurrentAssignment()
|
|
|
{
|
|
|
Thread.Sleep(5000);
|
|
@@ -169,33 +175,62 @@ namespace comal.timesheets
|
|
|
Job.Name = job.Name;
|
|
|
Job.OnJobIDChanged += OnJobIDChanged;
|
|
|
}
|
|
|
+ if (CurrentAssignment.Task.ID != Guid.Empty)
|
|
|
+ {
|
|
|
+ var task = new Client<Kanban>().Query(new Filter<Kanban>(x => x.ID).IsEqualTo(CurrentAssignment.Task.ID)).Rows.FirstOrDefault().ToObject<Kanban>();
|
|
|
+ OnTaskTitleChanged?.Invoke(task.Title);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static void OnJobIDChanged(Guid jobid)
|
|
|
{
|
|
|
if (CurrentAssignment == null)
|
|
|
- CreateNewAssignment(jobid);
|
|
|
+ CreateNewAssignment(jobid, Guid.Empty);
|
|
|
|
|
|
else
|
|
|
{
|
|
|
SaveCurrentAssignment("PRS Mobile main screen - saving assignment on job change", true);
|
|
|
- CreateNewAssignment(jobid);
|
|
|
+ CreateNewAssignment(jobid, Guid.Empty);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void CreateNewAssignment(Guid jobid)
|
|
|
+ public static void CreateNewAssignment(Guid jobid, Guid taskID)
|
|
|
{
|
|
|
CurrentAssignment = new Assignment { Date = DateTime.Now.Date };
|
|
|
CurrentAssignment.EmployeeLink.ID = GlobalVariables.EmpID;
|
|
|
- CurrentAssignment.JobLink.ID = jobid;
|
|
|
+
|
|
|
CurrentAssignment.Actual.Start = RoundToNearestInterval(DateTime.Now, new TimeSpan(0, 5, 0)).TimeOfDay;
|
|
|
CurrentAssignment.Booked.Start = CurrentAssignment.Actual.Start;
|
|
|
CurrentAssignment.Booked.Finish = RoundToNearestInterval(DateTime.Now, new TimeSpan(0, 5, 0)).TimeOfDay.Add(new TimeSpan(0, 5, 0));
|
|
|
+
|
|
|
+ if (jobid != Guid.Empty)
|
|
|
+ AddJobDetails(jobid);
|
|
|
+
|
|
|
+ if (taskID != Guid.Empty)
|
|
|
+ AddTaskDetails(taskID);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void AddJobDetails(Guid jobid)
|
|
|
+ {
|
|
|
+ CurrentAssignment.JobLink.ID = jobid;
|
|
|
var job = new Client<Job>().Query(new Filter<Job>(x => x.ID).IsEqualTo(jobid)).Rows.FirstOrDefault().ToObject<Job>();
|
|
|
CurrentAssignment.Title = "Clocking on to job " + job.Name + " (" + job.JobNumber + ") on PRS Mobile";
|
|
|
+ OnTaskTitleChanged?.Invoke("Task");
|
|
|
new Client<Assignment>().Save(CurrentAssignment, "Changed job on mobile - creating new assignment");
|
|
|
}
|
|
|
|
|
|
+ private static void AddTaskDetails(Guid taskID)
|
|
|
+ {
|
|
|
+ CurrentAssignment.Task.ID = taskID;
|
|
|
+ var task = new Client<Kanban>().Query(new Filter<Kanban>(x => x.ID).IsEqualTo(taskID)).Rows.FirstOrDefault().ToObject<Kanban>();
|
|
|
+ CurrentAssignment.Title = "Clocking on to task " + task.Title + " on PRS Mobile";
|
|
|
+ OnTaskTitleChanged?.Invoke(task.Title);
|
|
|
+ if (!string.IsNullOrWhiteSpace(task.JobLink.JobNumber))
|
|
|
+ Job.JobNumber = task.JobLink.JobNumber;
|
|
|
+ new Client<Assignment>().Save(CurrentAssignment, "Changed task on mobile - creating new assignment");
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
#region Notifications
|
|
|
|
|
|
public static Page DetermineCorrectPage(Plugin.LocalNotification.EventArgs.NotificationActionEventArgs e)
|
|
@@ -321,6 +356,7 @@ namespace comal.timesheets
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+ #region Location / Bluetooth
|
|
|
private static void LocationFound(LocationServices sender)
|
|
|
{
|
|
|
//if (bSharedDevice)
|
|
@@ -472,5 +508,39 @@ namespace comal.timesheets
|
|
|
}
|
|
|
catch { }
|
|
|
}
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ public static Dictionary<Guid, string> GetTasks()
|
|
|
+ {
|
|
|
+ Dictionary<Guid, string> dict = new Dictionary<Guid, string>();
|
|
|
+
|
|
|
+ CoreTable table = new Client<Kanban>().Query(
|
|
|
+ new Filter<Kanban>(x => x.EmployeeLink.ID).IsEqualTo(GlobalVariables.EmpID)
|
|
|
+ .And(x => x.Category).IsNotEqualTo("Complete"),
|
|
|
+ new Columns<Kanban>(x => x.ID, x => x.Title)
|
|
|
+ );
|
|
|
+ foreach (CoreRow row in table.Rows)
|
|
|
+ {
|
|
|
+ dict.Add
|
|
|
+ (
|
|
|
+ row.Get<Kanban, Guid>(x => x.ID),
|
|
|
+ row.Get<Kanban, string>(x => x.Title)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return dict;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void OnTaskSelected(Guid ID, string title)
|
|
|
+ {
|
|
|
+ if (CurrentAssignment != null)
|
|
|
+ OnRequestUserInput?.Invoke(ID);
|
|
|
+ else
|
|
|
+ CreateNewAssignment(Guid.Empty, ID);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void ChangeAssignmentTask(Guid taskID)
|
|
|
+ {
|
|
|
+ AddTaskDetails(taskID);
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
+}
|