Example #1
0
 private void AddImageFiles(ImageAddFiles obj)
 {
     if (obj.GuidKey == this._INSTANCE_KEY)
     {
         EventAggregator.Instance().Publish <ImageArticoloAddFiles>(
             new ImageArticoloAddFiles(this.EditItem,
                                       obj.Files, this._controllerImmagini));
     }
 }
Example #2
0
        private void AddImageFiles(ImageAddFiles obj)
        {
            if (obj.GuidKey == this._INSTANCE_KEY)
            {
                if (!SettingDocumentiPagamentiValidator.CheckFolderPdfPagamenti())
                {
                    return;
                }

                var folderPagamenti = SettingDocumentiPagamentiValidator.ReadSetting().CartellaReteDocumentiPagamenti;

                using (var saveManager = new SaveEntityManager())
                {
                    var repo = saveManager.UnitOfWork.PagamentoDocumentiRepository;
                    foreach (var item in obj.Files)
                    {
                        var filePdf = item;

                        var info     = new FileInfo(filePdf);
                        var nomeFile = info.Name;
                        var dir      = Path.Combine(folderPagamenti, this._IDPagamentoMaster.ToString());
                        if (!Directory.Exists(dir))
                        {
                            Directory.CreateDirectory(dir);
                        }
                        File.Copy(filePdf, Path.Combine(dir, nomeFile));

                        repo.Add(new PagamentoDocumenti()
                        {
                            IDPagamentoMaster = this._IDPagamentoMaster,
                            FileName          = nomeFile,
                            Ordine            = 0,
                            PathFile          = Path.Combine(this._IDPagamentoMaster.ToString(), nomeFile),
                        });
                    }

                    saveManager.SaveEntity("Immagini aggiunte correttamente");

                    EventAggregator.Instance().Publish <ImageListUpdate>(new ImageListUpdate());
                }
            }
        }