Exemplo n.º 1
0
        public async Task <HttpResponseMessage> PostMaintenanceDeleteAlertUrl(DeleteMaintenanceAlertRequestModel model, string sessionId)
        {
            var cts  = new CancellationTokenSource();
            var task = RemoteRequestAsync(_dashboardApi.GetApi(Priority.UserInitiated).PostMaintenanceDeleteAlertUrl(model, sessionId, cts.Token));

            runningTasks.Add(task.Id, cts);

            return(await task);
        }
Exemplo n.º 2
0
        private async void RemoveAlertCommandRecieverAsync()
        {
            if (RemoveSelecetedMaintenance != null)
            {
                var neededTypes = RemoveMaintenanceCollection.Where(x => x.Id == RemoveSelecetedMaintenance.Id).Select(x => x.Id).FirstOrDefault();
                Loader.StartLoading();
                var model = new DeleteMaintenanceAlertRequestModel
                {
                    KegId  = KegId,
                    TypeId = neededTypes,
                };
                try
                {
                    var result = await _dashboardService.PostMaintenanceDeleteAlertUrlAsync(model, AppSettings.SessionId, Configuration.DeleteTypeMaintenanceAlert);

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

                        foreach (var item in result.AddMaintenanceAlertResponseModel)
                        {
                            var removedItem = RemoveMaintenanceCollection.Where(x => x.Id != item.MaintenanceType.Id).First();
                            if (removedItem != null)
                            {
                                RemoveMaintenanceCollection.Remove(removedItem);
                                MaintenanceCollection.Add(removedItem);
                            }
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
                finally
                {
                    Loader.StopLoading();
                    RemoveSelecetedMaintenance = null;
                }
            }
        }
Exemplo n.º 3
0
        public async Task <AddMaintenanceAlertModel> PostMaintenanceDeleteAlertUrlAsync(DeleteMaintenanceAlertRequestModel inModel, string sessionId, string RequestType)
        {
            AddMaintenanceAlertModel outModel = new AddMaintenanceAlertModel
            {
                Response = new KegIDResponse(),
                AddMaintenanceAlertResponseModel = new List <AddMaintenanceAlertResponseModel>()
            };

            try
            {
                string url     = string.Format(Configuration.PostMaintenanceDeleteAlertUrl, 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);
        }