private async void ToggleRun()
 {
     IsRunning = !IsRunning;
     ToggleBtn.SetLabel(IsRunning ? "Stop" : "Run");
     if (IsRunning)
     {
         await PeriodsList.RefreshAll();
     }
 }
Beispiel #2
0
 private void PopulatePeriodsList()
 {
     if (Game.Game.Periods == 2)
     {
         PeriodsList.Add("1");
         PeriodsList.Add("2");
     }
     else
     {
         PeriodsList.Add("1");
         PeriodsList.Add("2");
         PeriodsList.Add("3");
         PeriodsList.Add("4");
     }
 }
Beispiel #3
0
        public virtual ActionResult InternshipsPeriodsList()
        {
            var archivesList  = _archivesService.GetArchives();
            var periodsListVm = new PeriodsList
            {
                periodsList = new List <ViewModels.Archives.Index>()
            };

            foreach (var archive in archivesList)
            {
                var periodVm = Mapper.Map <ViewModels.Archives.Index>(archive);

                periodsListVm.periodsList.Add(periodVm);
            }

            return(View(MVC.Coordinator.Views.ViewNames.PeriodsList, periodsListVm));
        }
        /// <summary>
        /// метод нахождения периодов в Excel файле субподрядчика
        /// </summary>
        /// <param name="path"></param>
        public List <Period> FindPeriodList(object[,] array, int index)
        {
            if (this.array == null)
            {
                this.array = array;
                Cell leftTop = findLeftTopCell();
                leftTop.Row--;
                while (array[leftTop.Row - 1, leftTop.Column] == null)
                {
                    leftTop.Row--;
                }
                for (int i = leftTop.Row; i < array.Length / array.GetLength(1); i++)
                {
                    bool swt = false;
                    for (int j = 1; j <= array.GetLength(1); j++)
                    {
                        DateTime date = findDate(array[i, j]);
                        if (date.Year != 2)
                        {
                            leftTop.Row    = i;
                            leftTop.Column = j;
                            swt            = true;
                            break;
                        }
                    }
                    if (swt)
                    {
                        break;
                    }
                }
                DateTime lastDate = new DateTime();
                for (int i = leftTop.Column; i < array.GetLength(1); i++)
                {
                    DateTime newDate = findDate(array[leftTop.Row, i]);
                    if (newDate.Year != 2)
                    {
                        PeriodsList.Add(newDate);
                        ColumnsPeriodsList.Add(i);
                        lastDate = newDate;
                    }
                    else if (!topCell(leftTop.Row, i))
                    {
                        PeriodsList.Add(lastDate);
                        ColumnsPeriodsList.Add(i);
                    }
                }
                SupplementYears(PeriodsList);
            }

            for (int i = 1, j = 0; i < PeriodsList.Count; i++, j++)
            {
                if (PeriodsList[i].Month == PeriodsList[i - 1].Month)
                {
                    DeletedIndexes.Add(i - 1);
                    PeriodsList.RemoveAt(i - 1);
                    i--;
                }
            }

            FindExcelTitleSubcontr finder = new FindExcelTitleSubcontr();
            int            line           = CellOf(finder.FindTitle(array, index).Title).Row;
            List <decimal> moneys         = new List <decimal>();
            decimal        sum            = 0;

            for (int i = 0; i < ColumnsPeriodsList.Count; i++)
            {
                if (DeletedIndexes.Exists(x => x == i))
                {
                    if (array[line, ColumnsPeriodsList[i]] != null)
                    {
                        sum += decimal.Parse(array[line, ColumnsPeriodsList[i]].ToString());
                    }
                    DeletedIndexes.Remove(i);
                    ColumnsPeriodsList.RemoveAt(i);
                    i--;
                }
                else
                {
                    if (array[line, ColumnsPeriodsList[i]] != null)
                    {
                        moneys.Add(sum + decimal.Parse(array[line, ColumnsPeriodsList[i]].ToString()));
                    }
                    else
                    {
                        moneys.Add(sum);
                    }
                    sum = 0;
                }
            }

            List <Period> result = new List <Period>();

            for (int i = 0; i < PeriodsList.Count; i++)
            {
                Period newPeriod = new Period()
                {
                    Date  = PeriodsList[i],
                    Money = moneys[i]
                };
                result.Add(newPeriod);
            }

            return(result);
        }
        /// <summary>
        /// метод нахождения периодов в Excel файле субподрядчика
        /// </summary>
        /// <param name="path"></param>
        public List <Period> FindPeriodList(Excel.Application TempImportExcel, int index)
        {
            if (PeriodsList == null)
            {
                if (this.TempImportExcel == null)
                {
                    this.TempImportExcel = TempImportExcel;
                }
                Excel.Range startRange = findLeftTopCell();
                CountingLine   = startRange.Row;
                CountingColumn = startRange.Column;

                int CountingPeriodLine = CountingLine - 1;
                int CountingMoneyLine  = CountingPeriodLine + 2;

                while (TempImportExcel.Cells[CountingMoneyLine + 1, CountingColumn].Text != "1")
                {
                    CountingMoneyLine++;
                }

                CreatePeriodList();

                for (int i = 1; i < PeriodsList.Count; i++)
                {
                    if (PeriodsList[i].Year == PeriodsList[i - 1].Year &&
                        PeriodsList[i].Month == PeriodsList[i - 1].Month)
                    {
                        PeriodsList.RemoveAt(i - 1);
                        DeletedIndexes.Add(i - 1);
                        i--;
                    }
                }
            }

            List <decimal?> moneyList = new List <decimal?>();

            int newLineIndex = findIndexLine(index);

            for (int i = ColumnsPeriodsList.First(); i <= ColumnsPeriodsList.Last(); i++)
            {
                if (ColumnsPeriodsList.Contains(i))
                {
                    if (TempImportExcel.Cells[newLineIndex, i].Value != null)
                    {
                        moneyList.Add((decimal)TempImportExcel.Cells[newLineIndex, i].Value);
                    }
                    else
                    {
                        moneyList.Add(0);
                    }
                }
            }

            List <int> tempList = new List <int>();

            tempList.AddRange(DeletedIndexes);
            for (int i = 1; i < moneyList.Count; i++)
            {
                if (tempList.Contains(i - 1))
                {
                    moneyList[i] += moneyList[i - 1];
                    moneyList.RemoveAt(i - 1);
                    tempList.Remove(i - 1);
                    i--;
                }
            }

            List <Period> result = new List <Period>();

            for (int i = 0; i < moneyList.Count; i++)
            {
                result.Add(new Period {
                    Date = PeriodsList[i], Money = moneyList[i]
                });
            }

            return(result);
        }