Пример #1
0
 private void ScheduleUserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     Console.WriteLine(e.NewValue);
     if (AppMAnager.CurrentUser() != null)
     {
         prepared = true;
         refreshGrid();
     }
 }
Пример #2
0
        //private bool contentChanged;

        public PRegistroCopias()
        {
            InitializeComponent();

            //combo puntos de copia
            if (!AppMAnager.CurrentUser().is_admin)
            {
                _spPuntoCopia.Visibility = Visibility.Hidden;
            }
            else
            {
                List <copia_puntos> puntosList = DBManager.PuntoCopyRepo.List;
                cbxPuntoCopia.Items.Add("- TODOS - ");
                foreach (copia_puntos cp in puntosList)
                {
                    cbxPuntoCopia.Items.Add(cp);
                }
            }

            //combo categorias
            List <string> categs = DBManager.RegistroCopiasRepo.ListDistinctCategValues();

            cbxCategoria.Items.Add("- TODAS -");
            foreach (string categ in categs)
            {
                cbxCategoria.Items.Add(categ);
            }

            DateTime now = DateTime.Now;
            DateTime ini = now.Date + new TimeSpan(0, 0, 0);

            _datePickerIni.SelectedDate = ini;
            DateTime end = now.Date + new TimeSpan(11, 59, 0);

            _datePickerEnd.SelectedDate = end;

            prepared = false;
            //contentChanged = true;

            this.IsVisibleChanged += ScheduleUserControl_IsVisibleChanged;
        }
Пример #3
0
        /** COPIAR LISTA SELECCIONADA */
        private void BtnCopy_Click(object sender, RoutedEventArgs e)
        {
            string realValue = tbReal.Text.Replace(" ", "");

            while (realValue.StartsWith("0"))
            {
                realValue = realValue.Substring(1);
            }

            if (string.IsNullOrWhiteSpace(realValue) || double.Parse(realValue) <= 0)
            {
                AppMAnager.SetLabel_Error(lCostoReal, "Real:");
                AppMAnager.SetErrorTextBox(tbReal);
                MessageBox.Show("El costo real debe ser mayor que 0");
                return;
            }

            string destination = AppMAnager.showFolderBrowser("");

            if (Directory.Exists(destination))
            {
                string root      = Directory.GetDirectoryRoot(destination);
                long   freespace = new DriveInfo(root).AvailableFreeSpace;

                List <MediaFile_Basic_Info> mf_list = new List <MediaFile_Basic_Info>();
                MediaFile_Basic_Info        MFBI;
                foreach (StackPanel sp in _listSeleccion.Items)
                {
                    MFBI = (MediaFile_Basic_Info)sp.Tag;
                    mf_list.Add(MFBI);
                    //copySize += MFBI.getTotalSize();
                }

                if (freespace < listCopySize)
                {
                    double free = Math.Round(StorageConverter.Convert(Differential.ByteToGiga, freespace, StorageBase.BASE2), 2);
                    double need = Math.Round(StorageConverter.Convert(Differential.ByteToGiga, listCopySize, StorageBase.BASE2), 2);
                    MessageBox.Show("No hay espacio suficiente en el dispositivo seleccionado" + "\n" +
                                    "Necesario: " + need + "Gb       Disponible: " + free + "Gb");
                }
                else
                {
                    if (_copySplitter.Visibility == Visibility.Hidden)
                    {
                        _copysRow.Height         = new GridLength(100);
                        _copySplitter.Visibility = Visibility.Visible;
                    }

                    //  ProgressInfo pinfo = new ProgressInfo();
                    // int pos = _copysContainer.Children.Add(pinfo);  //Uso la posicion del componente para enlazarlo con el BackgroundMediaCopy
                    // pinfo.Tag = pos;

                    double montoReal = 0;
                    if (!string.IsNullOrEmpty(realValue))
                    {
                        montoReal = double.Parse(realValue);
                    }

                    copia c = new copia
                    {
                        user_id        = AppMAnager.CurrentUser().id,
                        punto_copia_id = AppMAnager.CurrentPuntoCopia().id,
                        codigo         = DBManager.CopiasRepo.NextSerie().ToString(),
                        tipo_pago_id   = tpagoId,
                        fecha          = DateTime.Now,
                        monto_sistema  = costoLista,
                        monto_real     = montoReal
                    };
                    copia the_copy = DBManager.CopiasRepo.Add(c);

                    if (the_copy != null)
                    {
                        BackgroundMediaFileCopy copier = new BackgroundMediaFileCopy(the_copy.id);
                        ProgressInfo            pinfo  = new ProgressInfo(copier);
                        _copysContainer.Children.Add(pinfo);
                        copier.StartCopyWorker(mf_list, destination, pinfo);
                        AppMAnager.RUNNING_COPYS_COUNT++;

                        //ClearPageSelection(true);
                        // AppMAnager.thread_copys.Add(pos, copier);

                        _listSeleccion.Items.Clear();
                        btnCopy.IsEnabled = false;

                        restartCostInfo();
                    }
                }
            }
        }
Пример #4
0
        private async void refreshGrid()
        {
            ShowLoader();

            //Filtros

            /*DateTime fdesde = new DateTime();
             * if (_datePickerIni.SelectedDate != null)
             *  fdesde = (DateTime)_datePickerIni.SelectedDate;*/

            DateTime fdesde = (DateTime)_datePickerIni.SelectedDate;

            fdesde = fdesde.Date + new TimeSpan(0, 0, 0);
            DateTime fhasta = (DateTime)_datePickerEnd.SelectedDate;

            fhasta = fhasta.Date + new TimeSpan(23, 59, 0);

            int ptoCopiaId = -1;
            int user_id    = -1;

            if (!AppMAnager.CurrentUser().is_admin)
            {
                ptoCopiaId = AppMAnager.CurrentUser().copia_puntos.FirstOrDefault().id;
                user_id    = AppMAnager.CurrentUser().id;
            }
            else
            if (cbxPuntoCopia.SelectedIndex > 0)
            {
                ptoCopiaId = ((copia_puntos)cbxPuntoCopia.SelectedItem).id;
            }

            string categoria = "";

            if (cbxCategoria.SelectedIndex > 0)
            {
                categoria = cbxCategoria.SelectedItem.ToString();
            }

            List <registro_copias> list = await DBManager.RegistroCopiasRepo.FindAsync(fdesde, fhasta, ptoCopiaId, categoria, user_id);

            _dataGrid.ItemsSource = list;
            _ltotalFiles.Text     = list.Count.ToString();

            await Task.Run(() =>
            {
                double totalSize = 0;
                foreach (registro_copias rc in list)
                {
                    Thread.Sleep(2);
                    totalSize += rc.Size;
                }

                _lPesoTotal.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
                                              (Action)(() =>
                {
                    _lPesoTotal.Text = Math.Round(totalSize, 2).ToString() + " Gb";
                }));
            });

            /*Task.Run(() =>
             *  DBManager.RegistroCopiasRepo.FindAsync(fdesde, fhasta, ptoCopiaId, categoria, user_id).ContinueWith(
             *      task => {
             *          List<registro_copias> list = task.Result;
             *
             *          _dataGrid.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
             *              (Action)(() =>
             *              {
             *                  _dataGrid.ItemsSource = list;
             *              }));
             *
             *          _ltotalFiles.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
             *              (Action)(() =>
             *              {
             *                  _ltotalFiles.Text = list.Count.ToString();
             *              }));
             *
             *          double totalSize = 0;
             *          foreach (registro_copias rc in list)
             *          {
             *              Thread.Sleep(500);
             *              totalSize += rc.Size;
             *          }
             *
             *          _lPesoTotal.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
             *              (Action)(() =>
             *              {
             *                  _lPesoTotal.Text = Math.Round(totalSize, 2).ToString() + " Gb";
             *              }));
             *      }).Wait()
             * );*/

            HideLoader();
        }