Exemplo n.º 1
0
        private void SetVisibleTotalInSelected()
        {
            ulong totalByte = 0;

            foreach (RowBase item in _selectedBases)
            {
                totalByte += item.SizeByte;
            }

            string total = new DirFile().GetSizeFormat(totalByte);

            txtTotalByteSelected.Text = totalByte.ToString();
            txtTotalSelected.Text     = total;

            grSelectedTotal.Visibility = _selectedBases.Count > 1 ? Visibility.Visible : Visibility.Hidden;
        }
Exemplo n.º 2
0
        private void SetValuePeriod()
        {
            DateTime maxValueDate = DateTime.MinValue;
            DateTime minValueDate = DateTime.MaxValue;

            DirFile dirFile = new DirFile();

            for (int i = 0; i < _listBases.Count(); i++)
            {
                RowBase currentElement = _listBases.ElementAt(i);
                maxValueDate = dirFile.CompareDateMinus(maxValueDate, currentElement.DateCreate);
                maxValueDate = dirFile.CompareDateMinus(maxValueDate, currentElement.DateEdit);
                minValueDate = dirFile.CompareDatePlus(minValueDate, currentElement.DateCreate);
                minValueDate = dirFile.CompareDatePlus(minValueDate, currentElement.DateEdit);
            }

            datePBegin.SelectedDate = minValueDate;
            datePEnd.SelectedDate   = maxValueDate;
        }
Exemplo n.º 3
0
        private void ReadCachePath(ref IEnumerable <RowBase> list, ref ulong totalByte, ref string total, List <RowBase> listCache, string path, TypeCache typeCache)
        {
            try
            {
                DirectoryInfo[] dirCache = new DirectoryInfo(path).GetDirectories();

                foreach (DirectoryInfo dir in dirCache)
                {
                    string nameDir = dir.Name;

                    if (nameDir.Count(f => f == '-') == 4)
                    {
                        RowBase rowBase = listCache.FirstOrDefault(f => f.ID == nameDir);

                        if (rowBase == null)
                        {
                            rowBase = new RowBase()
                            {
                                Name       = _nameRowIsNotList,
                                ID         = nameDir,
                                DateCreate = DateTime.MaxValue
                            };
                            listCache.Add(rowBase);
                        }

                        DirFile dirFile = new DirFile(dir.FullName);

                        ulong sizeByte = dirFile.GetDirSize();
                        Tuple <DateTime, DateTime> dateCreateEdit = dirFile.GetDateCreateEdited();

                        rowBase.DateCreate = dirFile.CompareDatePlus(rowBase.DateCreate, dateCreateEdit.Item1);
                        rowBase.DateEdit   = dirFile.CompareDateMinus(rowBase.DateEdit, dateCreateEdit.Item2);

                        string size = new DirFile().GetSizeFormat(sizeByte);

                        if (typeCache == TypeCache.Local)
                        {
                            rowBase.PathCacheLocal = dir.FullName;
                            rowBase.SizeLocal      = size;
                        }
                        else if (typeCache == TypeCache.AppData)
                        {
                            rowBase.PathCacheAppData = dir.FullName;
                            rowBase.SizeAppData      = size;
                        }

                        rowBase.SizeByte += sizeByte;

                        totalByte += sizeByte;
                    }
                }

                RemoveIncorrectRows(listCache);

                total = new DirFile().GetSizeFormat(totalByte);

                listCache.Sort();

                list = listCache;
            }
            catch (DirectoryNotFoundException)
            {
                Dialog.ShowMessage($"Не удалось получить данные с каталога: \n{path}\nКаталог кеша не существует.");
            }
            catch (UnauthorizedAccessException)
            {
                Dialog.ShowMessage($"Нет доступа к каталогу кеша: \n{path}");
            }
            catch (Exception ex)
            {
                Dialog.ShowMessage("Произошла непредвиденная ошибка.");
                Dialog.ShowMessage(ex.Message);
            }
        }