Beispiel #1
0
        public async Task <OneTimeTasks> InsertTaskAsync(OneTimeTasks task, bool isUserPerformed = false)
        {
            await _insertTaskSemaphoreSlim.WaitAsync();

            try
            {
                UserEntity userEntity = await _userModel.GetUserDetailsAsync();

                task.CreatedUser = userEntity.Id;

                int tId = await _taskModel.InsertTaskAsync(task, isUserPerformed);

                task = await _taskModel.GetTaskByIdAsync(tId);

                IList <OneTimeTasks> tasks = OneTimeTasks.ToList();
                tasks.Add(task);

                OneTimeTasks = tasks;
                CurrentUser  = userEntity;

                return(task);
            }
            catch (Exception k)
            {
                applicationErrorLog.ErrorLog("Task", "Insert one time task", k.ToString());
                return(task);
            }
            finally
            {
                _insertTaskSemaphoreSlim.Release();
            }
        }
Beispiel #2
0
        private void SplashScreenForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            ShowForm();
            SetUserRegistrationPanelVisible(false);

            _applicationService.ReleaseResourcesToExit
            (
                SetProgressStatusText,
                () => e.Cancel = true,
                () =>
            {
                RunOnMainThread(() =>
                {
                    applicationErrorLog.ErrorLog("End", "Ending Application", "--------");
                    Application.Exit();
                });
            }
            );
        }
Beispiel #3
0
        /// <summary>
        /// Execute Query Async
        /// </summary>
        /// <typeparam name="T">Type of list need to returned</typeparam>
        /// <param name="query">Query</param>
        /// <param name="readerFunc">Reader function</param>
        /// <param name="parameters">Optional. Parameters</param>
        /// <param name="isNeedTransactionBlock">Optional. IsNeedTransactionBlock default false</param>
        /// <returns>List of T</returns>
        public static async Task <IEnumerable <T> > ExecuteQueryAsync <T>(string query, Func <SQLiteDataReader, T> readerFunc, IEnumerable <KeyValuePair <string, object> > parameters = null, bool isNeedTransactionBlock = false)
        {
            IList <T> items = new List <T>();

            await Task.Run(() =>
            {
                using (SQLiteConnection conn = GetConnection)
                {
                    using (SQLiteCommand cmd = new SQLiteCommand(conn))
                    {
                        cmd.CommandText = query;
                        if (parameters != null && parameters.Count() > 0)
                        {
                            foreach (KeyValuePair <string, object> parameter in parameters)
                            {
                                cmd.Parameters.AddWithValue(parameter.Key, parameter.Value);
                            }
                        }
                        cmd.Prepare();


                        lock (readWriteLock)
                        {
                            conn.Open();
                            SQLiteTransaction transaction = null;
                            try
                            {
                                if (isNeedTransactionBlock)
                                {
                                    transaction = conn.BeginTransaction();
                                }

                                using (SQLiteDataReader reader = cmd.ExecuteReader())
                                {
                                    while (reader.Read())
                                    {
                                        items.Add(readerFunc(reader));
                                    }
                                }

                                transaction?.Commit();
                            }
                            catch
                            {
                                transaction?.Rollback();
                                applicationErrorLog.ErrorLog("Database", "DB Transaction", "DB Transaction Main queries Error");
                                throw;
                            }
                            finally
                            {
                                conn.Close();
                            }
                        }
                    }
                }
            });

            return(items);
        }
Beispiel #4
0
        private void SetTaskEntity(OneTimeTasks onetimetaskEntity = null)
        {
            try
            {
                _onetimetaskEntity = onetimetaskEntity ?? new OneTimeTasks()
                {
                    Duration        = 0D,
                    ReferenceNumber = "",
                    Comments        = "",
                };

                if (_onetimetaskEntity.Id == 0)
                {
                    referenceNumberPanel.Visible = false;
                }
                else
                {
                    referenceNumberPanel.Visible = true;
                    referenceNumberTextBox.Text  = _onetimetaskEntity.ReferenceNumber;
                }

                durationErrorLabel.Text        = "";
                amountNumericUpDown.Text       = _onetimetaskEntity.Duration.ToString();
                taskTypeComboBox.SelectedIndex = _onetimetaskEntity.Type;
                remarksTextBox.Text            = _onetimetaskEntity.Comments;
                dateTimePickerEffective.Value  = _onetimetaskEntity.Effectivedate;
                remarksTextBox.Text            = _onetimetaskEntity.Comments;
                remarksErrorLabel.Text         = "";
                comboBoxType.Enabled           = false;
                dateTimePickerForm.Enabled     = true;
            }
            catch (Exception k)
            {
                applicationErrorLog.ErrorLog("Task", "setting one time tasks to UI", k.ToString());
            }
        }
Beispiel #5
0
 private void MainScreenForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     applicationErrorLog.ErrorLog("End", "Ending Application", "--------");
     Application.Exit();
 }