コード例 #1
0
ファイル: Ping.cs プロジェクト: rotparmna/sydtrucking-payroll
        public async Task <bool> SendAsync()
        {
            bool ok = false;

            _updateMessage.Enable(false);
            _updateMessage.UpdateMessageConnection("Validating connection to database!");

            await _context.ValidateConnectionAsync().ContinueWith((x) =>
            {
                if (x.IsCompleted && !x.IsFaulted && !x.IsCanceled)
                {
                    ok = x.Result;
                    _updateMessage.UpdateMessageConnection(x.Result ?
                                                           "Correct connection to database!" :
                                                           "Incorrect connection to database!");
                    _updateMessage.Enable(x.Result);
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());

            return(ok);
        }
コード例 #2
0
        public async Task DoAsync()
        {
            _updateMessage.Enable(false);
            _updateMessage.UpdateMessageConnection("Initiating basic data.");
            if (_context.CountCollections == 0)
            {
                await _context.Roles.InsertOneAsync(new model.Role()
                {
                    Name = "Administrator"
                });

                await _context.Roles.InsertOneAsync(new model.Role()
                {
                    Name = "Basic1"
                });

                await _context.Roles.InsertOneAsync(new model.Role()
                {
                    Name = "Basic2"
                });

                model.User admin = new model.User()
                {
                    Username = "******",
                    Password = "******",
                    IsActive = true,
                    Fullname = "admin",
                };
                admin.Roles.AddRange(_context.Roles.Find(FilterDefinition <model.Role> .Empty).ToList());
                await _context.Users.InsertOneAsync(admin);

                await _context.Configurations.InsertOneAsync(new model.Configuration()
                {
                    Smtp = new model.Smtp()
                    {
                        Email     = "*****@*****.**",
                        EnableSsl = true,
                        Password  = "******",
                        Port      = 587,
                        Server    = "smtp.gmail.com"
                    },
                    Payroll = new model.PayrollConfiguration()
                    {
                        DaysWeek               = 6,
                        DaysWeekPayment        = 7,
                        FactorRateOvertimeHour = 1.5,
                        RegularHour            = 40,
                        TotalHoursPaying       = 120
                    },
                    PayrollLeaseCompany = new model.PayrollLeaseCompanyConfiguration()
                    {
                        LastThreeFridayPayrollLeaseCompany = -21,
                        PercentLeaseFeeValue   = 0.2,
                        PercentWorkerCompValue = 0.1599
                    },
                    Message = new model.MessageConfiguration()
                    {
                        ValidationRequiredFieldMessage = "The {0} is required.",
                        AtLeastOneTruckMustBeSelected  = "At least one truck must be selected."
                    }
                });

                _updateMessage.UpdateMessageConnection("Data started.");
            }
            else
            {
                _updateMessage.UpdateMessageConnection(string.Empty);
            }

            _updateMessage.Enable(true);
        }