コード例 #1
0
        private void LoadBreakDetails(BreakTable currentBreak)
        {
            BreakCount++;
            BreakTitle           = "Break " + BreakCount.ToString() + " of " + BreakTotalCount.ToString();
            StartTimeBreakPicker = DateTime.Parse(currentBreak.StartDate).TimeOfDay;
            EndTimeBreakPicker   = DateTime.Parse(currentBreak.EndDate).TimeOfDay;

            StartBreakLocation = currentBreak.StartLocation.Substring(currentBreak.StartLocation.LastIndexOf(',') + 1);
            EndBreakLocation   = currentBreak.EndLocation.Substring(currentBreak.EndLocation.LastIndexOf(',') + 1);
        }
コード例 #2
0
        internal async Task <int> QueryBreak(bool breakStarted, BreakTable breakTable)
        {
            string url;
            string contentType = Constants.CONTENT_TYPE;
            string json;
            HttpResponseMessage response;

            if (!breakStarted)
            {
                url = GetBaseUrl() + Constants.REST_URL_ADDBREAKSTART;

                BreakStartModel breakModel = new BreakStartModel()
                {
                    shiftId            = breakTable.ServerShiftKey,
                    startBreakDateTime = breakTable.StartDate,
                    startBreakLocation = breakTable.StartLocation,
                    startNote          = breakTable.StartNote
                };
                json = JsonConvert.SerializeObject(breakModel);
            }
            else
            {
                url = GetBaseUrl() + Constants.REST_URL_ADDBREAKEND;

                BreakEndModel breakModel = new BreakEndModel()
                {
                    id = breakTable.ServerId,
                    stopBreakDateTime = breakTable.EndDate,
                    stopBreakLocation = breakTable.EndLocation,
                    endNote           = breakTable.EndNote
                };
                json = JsonConvert.SerializeObject(breakModel);
            }

            HttpContent content = new StringContent(json, Encoding.UTF8, contentType);

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("Authorization", accessToken);
                try
                {
                    response = await client.PostAsync(url, content);
                }
                catch
                {
                    return(-1);
                }
            }

            if (response.IsSuccessStatusCode)
            {
                QueryBreakResponse result = JsonConvert.DeserializeObject <QueryBreakResponse>(response.Content.ReadAsStringAsync().Result);

                if (result.Success)
                {
                    if (result.Result > 0)
                    {
                        return(result.Result);
                    }
                    else
                    {
                        return(-2);
                    }
                }
                else
                {
                    return(-2);
                }
            }
            else
            {
                return(-1);
            }
        }
コード例 #3
0
        private void Add()
        {
            if (Instruction == "Break")
            {
                if (!CheckValidHuboEntry(HuboStart))
                {
                    return;
                }

                if (!CheckValidHuboEntry(HuboEnd))
                {
                    return;
                }

                BreakTable breakAdd = new BreakTable()
                {
                    StartDate     = BreakStart.ToString(Resource.DateFormat),
                    EndDate       = BreakEnd.ToString(Resource.DateFormat),
                    StartLocation = LocationStart,
                    EndLocation   = LocationEnd
                };
                MessagingCenter.Send(this, "Break_Added", breakAdd);
            }
            else if (Instruction == "Note")
            {
                NoteTable note = new NoteTable()
                {
                    Date = NoteTime.ToString(Resource.DateFormat),
                    Note = NoteDetail
                };
                MessagingCenter.Send(this, "Note_Added", note);
            }
            else if (Instruction == "Drive Shift")
            {
                if (!CheckValidHuboEntry(HuboStart))
                {
                    return;
                }

                if (!CheckValidHuboEntry(HuboEnd))
                {
                    return;
                }

                List <VehicleTable> vehicleKey = new List <VehicleTable>();
                vehicleKey = GetVehicles();

                DriveTable drive = new DriveTable()
                {
                    StartDate     = DriveStartTime.ToString(Resource.DateFormat),
                    EndDate       = DriveEndTime.ToString(Resource.DateFormat),
                    StartHubo     = int.Parse(HuboStart),
                    EndHubo       = int.Parse(HuboEnd),
                    ActiveVehicle = false,
                    VehicleKey    = vehicleKey[SelectedVehicle].Key
                };
                MessagingCenter.Send(this, "Drive_Added", drive);
            }

            Navigation.PopModalAsync();
        }