コード例 #1
0
        public async Task <AddMaintenanceAlertModel> PostMaintenanceAlertAsync(AddMaintenanceAlertRequestModel inModel, string sessionId, string RequestType)
        {
            AddMaintenanceAlertModel outModel = new AddMaintenanceAlertModel
            {
                Response = new KegIDResponse(),
                AddMaintenanceAlertResponseModel = new List <AddMaintenanceAlertResponseModel>()
            };

            try
            {
                string url     = string.Format(Configuration.PostMaintenanceAlertUrl, sessionId);
                string content = JsonConvert.SerializeObject(inModel);
                var    value   = await App.kegIDClient.ExecuteServiceCall <KegIDResponse>(url, HttpMethodType.Send, content, RequestType : RequestType);

                var result = !string.IsNullOrEmpty(value.Response) ? App.kegIDClient.DeserializeObject <IList <AddMaintenanceAlertResponseModel> >(value.Response) : new List <AddMaintenanceAlertResponseModel>();

                foreach (var item in result)
                {
                    outModel.AddMaintenanceAlertResponseModel.Add(item);
                }

                outModel.Response.StatusCode = value.StatusCode;
            }
            catch (System.Exception)
            {
            }
            return(outModel);
        }
コード例 #2
0
        public async Task <HttpResponseMessage> PostMaintenanceAlert(AddMaintenanceAlertRequestModel model, string sessionId)
        {
            var cts  = new CancellationTokenSource();
            var task = RemoteRequestAsync(_dashboardApi.GetApi(Priority.UserInitiated).PostMaintenanceAlert(model, sessionId, cts.Token));

            runningTasks.Add(task.Id, cts);

            return(await task);
        }
コード例 #3
0
        private async void AddAlertCommandRecieverAsync()
        {
            if (SelectedMaintenance != null)
            {
                List <long> neededTypes = MaintenanceCollection.Where(x => x.Id == SelectedMaintenance.Id).Select(x => x.Id).ToList();
                var         model       = new AddMaintenanceAlertRequestModel
                {
                    AlertCc      = "",
                    DueDate      = SelectedMaintenance.DueDate,
                    KegId        = KegId,
                    Message      = SelectedMaintenance.Message,
                    NeededTypes  = neededTypes,
                    ReminderDays = 5
                };

                try
                {
                    Loader.StartLoading();
                    var result = await _dashboardService.PostMaintenanceAlertAsync(model, AppSettings.SessionId, Configuration.PostedMaintenanceAlert);

                    if (result.Response.StatusCode == System.Net.HttpStatusCode.OK.ToString())
                    {
                        await _dialogService.DisplayAlertAsync("Alert", "Alert adedd successfuly", "Ok");

                        foreach (var item in result.AddMaintenanceAlertResponseModel)
                        {
                            var removal = MaintenanceCollection.Where(x => x.Id == item.MaintenanceType.Id).FirstOrDefault();
                            if (removal != null)
                            {
                                MaintenanceCollection.Remove(removal);
                                RemoveMaintenanceCollection.Add(removal);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
                finally
                {
                    Loader.StopLoading();
                    SelectedMaintenance = null;
                }
            }
        }