private async void Reload()
        {
            looper.Show(this);
            await Keeper.Refresh();

            source.DataSource  = Keeper.Items;
            dgItems.DataSource = source;
            source.ResetBindings(false);
            looper.Hide();
            page = 1;
        }
Beispiel #2
0
        public async Task LoadProcessActions()
        {
            try
            {
                List <Task <List <dynamic> > > tasks = new List <Task <List <dynamic> > >();

                await ActionTypes.Refresh();

                int year = DateTime.Now.Year;
                int week = DateTime.Now.IsoWeekOfYear();

                foreach (var at in ActionTypes.Items)
                {
                    if (at.ActionsApplicable == true)
                    {
                        //let's get its stats
                        Task <List <dynamic> > getAtStats = Task.Run(() => ProcessActionKeeper.GetProcessActionStats(year, week, DivisionType, at.ActionTypeId));
                        tasks.Add(getAtStats);
                    }
                }
                if (tasks.Any())
                {
                    var results = await Task.WhenAll(tasks);


                    foreach (var r in results)
                    {
                        chartSeries.Add(r);
                    }
                    //string s = chartSeries.FirstOrDefault().FirstOrDefault().Weekday;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Wystąpił problem przy pobieraniu statystyk wykonania czynności w listach kontrolnych", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private async void FormLoaded(object sender, EventArgs e)
        {
            Looper = new frmLooper(this);
            Looper.Show(this);
            var PlaceRefreshTask         = Task.Run(() => Places.Refresh(null, 'a'));
            var StartingUsersRefreshTask = Task.Run(() => StartingUsers.Refresh(null, 'a'));
            var LoadActionTypesTask      = Task.Run(() => ActionTypes.Refresh());
            var LoadAbandonReasonsTask   = Task.Run(() => AbandonReasons.Refresh());
            await Task.WhenAll(PlaceRefreshTask, StartingUsersRefreshTask, LoadActionTypesTask, LoadAbandonReasonsTask);

            FinishingUsers.Items  = new List <User>(StartingUsers.Items);
            AssignableUsers.Items = new List <User>(StartingUsers.Items);
            _this.Handlings       = new HandlingsKeeper();
            _this.Logs            = new LogsKeeper();
            _this.PartUsages      = new PartUsageKeeper();
            _this.ProcessActions  = new ProcessActionsKeeper();
            //await ActionTypes.Refresh();
            if (mode == 1)
            {
                cmbActionType.DataSource = ActionTypes.Items.Where(i => i.ShowInPlanning == true).ToList();
                txtPlannedStart.Enabled  = true;
                txtPlannedFinish.Enabled = true;
                txtPlannedStart.Value    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 6, 0, 0);
                txtPlannedFinish.Value   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 14, 0, 0);
            }
            else
            {
                cmbActionType.DataSource = ActionTypes.Items;
                if (_this.PlannedStart == null)
                {
                    txtPlannedStart.CustomFormat  = " ";
                    txtPlannedFinish.CustomFormat = " ";
                    txtPlannedStart.Enabled       = false;
                    txtPlannedFinish.Enabled      = false;
                }
                else
                {
                    txtPlannedStart.Value = (DateTime)_this.PlannedStart;
                    if (_this.PlannedFinish != null)
                    {
                        txtPlannedFinish.Value = (DateTime)_this.PlannedFinish;
                    }
                }
                if (_this.Status == "Planowany")
                {
                    txtPlannedStart.Enabled  = true;
                    txtPlannedFinish.Enabled = true;
                }
                else
                {
                    txtPlannedStart.Enabled  = false;
                    txtPlannedFinish.Enabled = false;
                }
                txtComment.Text = _this.Comment;
                LoadHistory();
                var loadActionsTask        = Task.Run(() => LoadActions());
                var loadProcessAssingsTask = Task.Run(() => assignedUsersHandler.LoadProcessAssigns());
                var loadUsedPartsTask      = Task.Run(() => LoadParts());

                await Task.WhenAll(loadActionsTask, loadProcessAssingsTask, loadUsedPartsTask);

                lblAssignedUsers.Text = assignedUsersHandler.AssignedUserNames;
            }
            cmbStartedBy.DataSource  = StartingUsers.Items;
            cmbFinishedBy.DataSource = FinishingUsers.Items;
            new AutoCompleteBehavior <Place>(this.cmbPlace, Places.Items);
            cmbStartedBy.DisplayMember  = "FullName";
            cmbStartedBy.ValueMember    = "UserId";
            cmbFinishedBy.DisplayMember = "FullName";
            cmbFinishedBy.ValueMember   = "UserId";
            cmbActionType.DisplayMember = "Name";
            cmbActionType.ValueMember   = "ActionTypeId";
            cmbPlace.DisplayMember      = "Name";
            cmbPlace.ValueMember        = "PlaceId";
            cmbActionType.SelectedIndex = cmbActionType.FindStringExact(_this.ActionTypeName);
            cmbPlace.SelectedIndex      = cmbPlace.FindStringExact(_this.PlaceName);
            cmbStartedBy.SelectedIndex  = cmbStartedBy.FindStringExact(_this.StartedByName);
            cmbFinishedBy.SelectedIndex = cmbFinishedBy.FindStringExact(_this.FinishedByName);
            cmbStatus.SelectedIndex     = cmbStatus.FindStringExact(_this.Status);
            if (_this.StartedOn != null)
            {
                LoadHandlings();

                txtStartedOn.Value = (DateTime)_this.StartedOn;
            }
            if (_this.FinishedOn != null)
            {
                txtFinishedOn.Value = (DateTime)_this.FinishedOn;
            }

            ChangeLook();
            if (_this.Status == "Zakończony" || _this.Status == "Zrealizowany")
            {
                try
                {
                    Wait4Reactivation();
                }
                catch (Exception ex)
                {
                }
            }
            files.Initialize();
            Looper.Hide();
        }