Ejemplo n.º 1
0
        /// <summary>
        /// Adds the converters to container.
        /// </summary>
        /// <param name="services">The services.</param>
        private static void AddConverters(this IServiceCollection services)
        {
            StorageConverter storageConverter = new StorageConverter();

            services.AddSingleton <ITypeConverter <DataContracts.Storage, Storage> >(storageConverter);
            services.AddSingleton <ITypeConverter <Storage, DataContracts.Storage> >(storageConverter);
            services.AddSingleton <ITypeConverter <DataContracts.Catalog, Storage> >(storageConverter);
            services.AddSingleton <ITypeConverter <Storage, DataContracts.Catalog> >(storageConverter);
            services.AddSingleton <ITypeConverter <DataContracts.CatalogDocument, Storage> >(storageConverter);
            services.AddSingleton <ITypeConverter <Storage, DataContracts.CatalogDocument> >(storageConverter);

            CatalogConverter catalogConverter = new CatalogConverter();

            services.AddSingleton <ITypeConverter <DataContracts.Catalog, Catalog> >(catalogConverter);
            services.AddSingleton <ITypeConverter <Catalog, DataContracts.Catalog> >(catalogConverter);
            services.AddSingleton <ITypeConverter <DataContracts.CatalogDocument, Catalog> >(catalogConverter);
            services.AddSingleton <ITypeConverter <Catalog, DataContracts.CatalogDocument> >(catalogConverter);

            CatalogEntryConverter catalogEntryConverter = new CatalogEntryConverter();

            services.AddSingleton <ITypeConverter <DataContracts.File, CatalogEntry> >(catalogEntryConverter);
            services.AddSingleton <ITypeConverter <CatalogEntry, DataContracts.File> >(catalogEntryConverter);
            services.AddSingleton <ITypeConverter <DataContracts.FileDocument, CatalogEntry> >(catalogEntryConverter);
            services.AddSingleton <ITypeConverter <CatalogEntry, DataContracts.FileDocument> >(catalogEntryConverter);

            ServiceResultConverter serviceResultConverter = new ServiceResultConverter();

            services.AddSingleton <ITypeConverter <ValidationResult, ServiceResult> >(serviceResultConverter);

            StorageViewModelConverter storageViewModelConverter = new StorageViewModelConverter();

            services.AddSingleton <ITypeConverter <Storage, StorageViewModel> >(storageViewModelConverter);
            services.AddSingleton <ITypeConverter <StorageViewModel, Storage> >(storageViewModelConverter);

            CatalogViewModelConverter catalogViewModelConverter = new CatalogViewModelConverter();

            services.AddSingleton <ITypeConverter <Catalog, CatalogViewModel> >(catalogViewModelConverter);
            services.AddSingleton <ITypeConverter <CatalogViewModel, Catalog> >(catalogViewModelConverter);

            services.AddSingleton <ITypeConverter <CatalogEntry, DataViewModel>, DataViewModelConverter>();
            services.AddSingleton <ITypeConverter <DataViewModel, CatalogEntry>, DataViewModelConverter>();

            services.AddSingleton <ITypeConverter <CatalogEntry, FileViewModel>, FileViewModelConverter>();
            services.AddSingleton <ITypeConverter <FileViewModel, CatalogEntry>, FileViewModelConverter>();

            services.AddSingleton <IMapper, Mapper>();
        }
Ejemplo n.º 2
0
 private void UpdateListSize(long size)
 {
     listCopySize  += size;
     lCopySize.Text = "[" + Math.Round(StorageConverter.Convert(Differential.ByteToGiga, listCopySize, StorageBase.BASE2), 2) + " Gb]";
 }
Ejemplo n.º 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();
                    }
                }
            }
        }
 private double getSizeGb()
 {
     return(StorageConverter.Convert(Differential.ByteToGiga, peso, StorageBase.BASE2));
 }