コード例 #1
0
ファイル: LoadPage.xaml.cs プロジェクト: idogga/snc_manager
        // TODO Сделать разделение по приложениям
        Task LoadLimitation()
        {
            return(Task.Factory.StartNew(async() =>
            {
                try
                {
                    Logger.WriteLine("LoadLimitation : start");
                    Device.BeginInvokeOnMainThread(delegate
                    {
                        descriptionLabel.Text = "Загрузка ограничений";
                    });
                    string limit = "";

                    try
                    {
                        limit = MobileStaticVariables.WebUtils.SendSystemRequest("Limitations", "");
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteError(ex);
                        throw ex;
                    }
                    Logger.WriteLine("limit : " + limit);
                    if (limit == "")
                    {
                        throw new Exception("Не удалось получить limit");
                    }

                    Limitation deserialized = new Limitation();
                    if (limit != "")
                    {
                        deserialized = JsonConvert.DeserializeObject <Limitation>(limit);
                    }
                    deserialized.LoadLimitation();
                    isLimitationLoad = true;
                    Logger.WriteLine("LoadLimitation : end");
                }
                catch (Exception ex)
                {
                    Logger.WriteError(ex);
                    if (!_isDatabaseLoad)
                    {
                        if (needDisplayAlert)
                        {
                            needDisplayAlert = false;
                            await DisplayAlert("Внимание", "Не удалось подключиться", "Продолжить");
                        }
                        await LoadLimitation();
                    }
                }
            }));
        }