private string GetAttachmentDestinationFilename() { //nome del file NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); FileInfo a = p.CretateUncFileFinfo(hyperLinkEdit2.Text); return(a.Name); }
private void DoMove(string foldername, string filename, bool move, bool overwrite) { NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); p.CopyLocalFileToUncFolder(hyperLinkEdit2.EditValue.ToString(), foldername, filename, overwrite); //if (move) ////File.Move(hyperLinkEdit2.EditValue.ToString(), fileName); //else // File.Copy(hyperLinkEdit2.EditValue.ToString(), fileName, overwrite); }
private string GetAttachmentDestinationName() { //destinazione string m_destination = hyperLinkEdit1.EditValue.ToString(); //nome del file NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); FileInfo a = p.CretateUncFileFinfo(hyperLinkEdit2.Text); string m_FileRegistry = a.Name; return(System.IO.Path.Combine(m_destination, m_FileRegistry)); }
public void SetAttachment(string filename) { NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); FileInfo f = p.CretateUncFileFinfo(filename); if (f == null) { throw new ArgumentException("file non esistente"); } _fileName = f.Name; _path = f.DirectoryName; }
public void SetDestination(string path) { hyperLinkEdit1.EditValue = path; NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); if (p.UncFolderExist(path)) { hyperLinkEdit1.Properties.Image = Properties.Resources.tick_16; } else { hyperLinkEdit1.Properties.Image = Properties.Resources.warning_16; } }
private void MoveFile(bool move, bool overwrite) { //prendo il nome del file completo per la destinazione //cartella destinazione + nome file da allegare _createdFileName = GetAttachmentDestinationName(); string _uncFolder = GetAttachmentDestinationFolder(); string _uncFilename = GetAttachmentDestinationFilename(); //se il file di destinazione non esiste lo copio o lo sposto NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); if (p.CretateUncFileFinfo(_createdFileName) == null) { DoMove(_uncFolder, _uncFilename, move, false); _fileMovedOrCopied = true; return; } //se il file di destinazione esiste ed ho impostato il flag di sovrascrittura //chiedo nnotifica all'utente if (overwrite) { if (XtraMessageBox.Show("Si sta per sovrascrivere un file esistente. Continuare?", "Domanda", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DoMove(_uncFolder, _uncFilename, move, true); _fileMovedOrCopied = true; return; } else { _fileMovedOrCopied = false; return; } } //se il file di destinazione esiste e non ho impostato il flag di sovrascrittura //chiedo nnotifica all'utente di rinominare il file di destinazione if (XtraMessageBox.Show("Il file selezionato è gia esistente nella cartella di destinazione. Il sistema rinominerà il file selezionato per copiarlo o spostarlo nella cartella prescelta. Continuare?", "Domanda", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //costruisco il nuovo nome del file string newName = CostruisciNuovoNomeFile(); _createdFileName = Path.Combine(hyperLinkEdit1.EditValue.ToString(), newName); DoMove(_uncFolder, newName, move, false); _fileMovedOrCopied = true; return; } _fileMovedOrCopied = false; }
public void SetAttachment(string path) { hyperLinkEdit2.EditValue = path; NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); if (p.UncFileExist(path)) { hyperLinkEdit2.Properties.Image = Properties.Resources.tick_16; } else { hyperLinkEdit2.Properties.Image = Properties.Resources.warning_16; } }
private void hyperLinkEdit1_OpenLink(object sender, DevExpress.XtraEditors.Controls.OpenLinkEventArgs e) { try { if (hyperLinkEdit1.EditValue != null) { NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); string temp = p.CopyUncFileToLocalTempFolder(hyperLinkEdit1.EditValue.ToString()); System.Diagnostics.Process.Start(temp); } } catch (Exception ex) { ErrorHandler.Show(ex); } }
private void hyperLinkEdit1_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e) { if (hyperLinkEdit1.EditValue != null) { if (!string.IsNullOrEmpty(hyperLinkEdit1.EditValue.ToString())) { NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); FileInfo i = p.CretateUncFileFinfo(hyperLinkEdit1.EditValue.ToString()); if (i != null) { e.DisplayText = i.Name; } } } }
private void imageListBoxControl1_DoubleClick(object sender, EventArgs e) { if (_previewDoc == null) { return; } try { if (imageListBoxControl1.SelectedItem != null) { try { CheckSecurityForAttachmentView(); } catch (AccessDeniedException) { ErrorHandler.Show("Funzionalità non abilitata. Accesso negato"); return; } //una volta verificata la sicurezza devo verificare se l'utente loggato ha il profilo per vedere l'allegato if (!_previewDoc.Scope.IsVisibleFromProfile(SecurityManager.Instance.CurrentUser.Role.Profiles.Select(z => z.Description).ToList(), SecurityManager.Instance.CurrentUser.Username)) { ErrorHandler.Show("Funzionalità non abilitata. Accesso negato"); return; } AttachmentForDocument c = (imageListBoxControl1.SelectedItem as DevExpress.XtraEditors.Controls.ImageListBoxItem).Value as AttachmentForDocument; if (c.AttachmentExist) { NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); string temp = p.CopyUncFileToLocalTempFolder(c.AttachmentCompletePath); Process.Start(temp); } } } catch (Exception ex) { ErrorHandler.Show(ex); } }
private string CostruisciNuovoNomeFile() { int i = 1; //destinazione string m_destination = hyperLinkEdit1.EditValue.ToString(); //nome del file NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); string m_FileRegistry = p.CretateUncFileFinfo(hyperLinkEdit2.Text).Name; string temp = System.IO.Path.Combine(m_destination, m_FileRegistry); while (p.UncFileExist(temp)) { temp = ""; temp = String.Format("{0}-{1}", i, m_FileRegistry); temp = Path.Combine(m_destination, temp); i++; } return(String.Format("{0}-{1}", i - 1, m_FileRegistry)); }
private void lstatt_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) { if (lstatt.SelectedItem != null) { if (_current != null && _current.Key != null) { try { CheckSecurityForAttachmentDeletion(); } catch (AccessDeniedException) { ErrorHandler.Show("Funzionalità non abilitata. Accesso negato"); return; } } FrmEliminaAllegato frm = new FrmEliminaAllegato(); if (frm.ShowDialog() == DialogResult.Yes) { if (frm.EliminaFile) { AttachmentForDocument g = (lstatt.SelectedItem as DevExpress.XtraEditors.Controls.ImageListBoxItem).Value as AttachmentForDocument; if (g != null) { if (g.AttachmentExist) { NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); p.DeleteUncFile(g.AttachmentCompletePath); } } } lstatt.Items.RemoveAt(lstatt.SelectedIndex); StartChangeOperation(); } } } }
private void simpleButton1_Click(object sender, EventArgs e) { try { FrmAttachments frm = new FrmAttachments(); if (_new) { frm.SetDestination(_document.Scope.DefaultPath); frm.SetAttachment("-Nessun allegato-"); } else { frm.SetDestination(_current.Path); frm.SetAttachment(_current.AttachmentCompletePath); } if (frm.ShowDialog() == DialogResult.OK) { hyperLinkEdit1.EditValue = frm.CreatedAttachement; NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); if (p.UncFileExist(frm.CreatedAttachement)) { hyperLinkEdit1.Properties.Image = Properties.Resources.tick_16; } else { hyperLinkEdit1.Properties.Image = Properties.Resources.warning_16; } _current.SetAttachment(frm.CreatedAttachement); } frm.Dispose(); } catch (Exception ex) { ErrorHandler.Show(ex); } }
private int GetFileImageIndex(AttachmentForDocument attachmentForDocument) { if (attachmentForDocument == null) { throw new ArgumentException("Allegato"); } if (!attachmentForDocument.AttachmentExist) { //aggiungo l'icona di warning all'imagecollection imageList1.Images.Add(Properties.Resources.warning_16); return(imageList1.Images.Count - 1); } SHFILEINFO shinfo = new SHFILEINFO(); //SHFILEINFO shinfo1 = new SHFILEINFO(); IntPtr hImgSmall; //the handle to the system image list //IntPtr hImgLarge; //the handle to the system image list //copio il file localmente per fare in modo che possa trarne le informazioni per l'icona NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); string temp = p.CopyUncFileToLocalTempFolder(attachmentForDocument.AttachmentCompletePath); //Use this to get the small Icon hImgSmall = Win32.SHGetFileInfo(temp, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON); //The icon is returned in the hIcon member of the shinfo struct System.Drawing.Icon myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon); ////Use this to get the large Icon //hImgLarge = Win32.SHGetFileInfo(fName, 0, ref shinfo1, (uint)Marshal.SizeOf(shinfo1), Win32.SHGFI_ICON | Win32.SHGFI_LARGEICON); ////The icon is returned in the hIcon member of the shinfo struct //System.Drawing.Icon myIcon1 = System.Drawing.Icon.FromHandle(shinfo1.hIcon); imageList1.Images.Add(myIcon); return(imageList1.Images.Count - 1); }
private void cmdOk_Click(object sender, EventArgs e) { try { //se non esiste un file da allegare if (hyperLinkEdit2.EditValue != null) { if (string.IsNullOrEmpty(hyperLinkEdit2.EditValue.ToString())) { XtraMessageBox.Show("Inserire un nome file corretto", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); FileInfo f = p.CretateUncFileFinfo(hyperLinkEdit2.EditValue.ToString()); if (f == null) { XtraMessageBox.Show("File inesistente", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } //se non eseguo alcuna azione sul file if (((int)(radioGroup1.EditValue)) == 3) { _createdFileName = hyperLinkEdit2.EditValue.ToString(); this.DialogResult = DialogResult.OK; this.Close(); return; } //se non esiste il percorso di destinazione if (hyperLinkEdit1.EditValue != null) { if (string.IsNullOrEmpty(hyperLinkEdit1.EditValue.ToString())) { XtraMessageBox.Show("Impostare un percorso di destinazione corretto", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy(); DirectoryInfo f = p.CreateUncFolderFinfo(hyperLinkEdit1.EditValue.ToString()); if (f == null) { XtraMessageBox.Show("Directory inesistente", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } if (IsFileMovedOrCopied()) { this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.Cancel; } this.Close(); } catch (Exception ex) { ErrorHandler.Show(ex); } }