예제 #1
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();
                    }
                }
            }
        }
예제 #2
0
 private void UpdateListSize(long size)
 {
     listCopySize  += size;
     lCopySize.Text = "[" + Math.Round(StorageConverter.Convert(Differential.ByteToGiga, listCopySize, StorageBase.BASE2), 2) + " Gb]";
 }
 private double getSizeGb()
 {
     return(StorageConverter.Convert(Differential.ByteToGiga, peso, StorageBase.BASE2));
 }