Exemple #1
0
        /// <summary>
        /// Получение реестра документов.
        /// </summary>
        public DataTable GetData()
        {
            DataTable dataTable = new DataTable();

            using (Connection = new SqlConnection(stringConnection))
            {
                try
                {
                    Connection.Open();
                    SqlCommand command = new SqlCommand("GetDocuments", Connection)
                    {
                        // вызываем хп
                        CommandType = CommandType.StoredProcedure
                    };
                    SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
                    dataAdapter.Fill(dataTable);
                    // кидаем событие об успешной загрузке данных.
                    DataDownloaded?.Invoke(this, EventArgs.Empty);
                }
                catch (SqlException ex)
                {
                    Console.Error.WriteLine(ex.Message);
                }
                finally
                {
                    Connection.Close();
                }
                return(dataTable);
            }
        }
    private IEnumerator SendGetRequest(string url)
    {
        var request = UnityWebRequest.Get(url);

        yield return(request.SendWebRequest());

        if (!request.isHttpError && !request.isNetworkError)
        {
            DataDownloaded?.Invoke(request.downloadHandler.text);
        }
        else
        {
            Debug.LogErrorFormat("error request [{0}, {1}]", url, request.error);
            Debug.Log(null);
        }
        request.Dispose();
    }
Exemple #3
0
        private Task Synchronize(CancellationToken cancelToken)
        {
            return(Task.Run(async() =>
            {
                try
                {
                    _isRunning = true;
                    while (!cancelToken.IsCancellationRequested)
                    {
                        try
                        {
                            if (ShouldSave)
                            {
                                var data = MainBudget.Instance.ActualBudgetData;
                                _dataSynchroTime = await _cloudStorage.UploadData(data);
                                ShouldSave = false;
                            }
                            else
                            {
                                var cloudFileModifiedDate = await _cloudStorage.GetCloudFileModifiedTime();

                                if (cloudFileModifiedDate > _dataSynchroTime)
                                {
                                    var downloadData = await _cloudStorage.DownloadData();
                                    _dataSynchroTime = cloudFileModifiedDate;
                                    DataDownloaded?.Invoke(this, downloadData);
                                }
                            }
                        }
                        catch (Exception exc)
                        {
                            var msg = exc.Message;
                        }
                        await Task.Delay(SYNC_DELAY);
                    }
                }
                catch (Exception exc)
                {
                    var msg = exc.Message;
                }
                finally
                {
                    _isRunning = false;
                }
            }));
        }
Exemple #4
0
 private void OnDataDownloaded(object sender, BudgetData data)
 {
     DataDownloaded.Invoke(this, data);
 }
 protected virtual void OnDataDownloaded()
 {
     DataDownloaded?.Invoke(this, EventArgs.Empty);
 }