Esempio n. 1
0
        private string GetAttachmentDestinationFilename()
        {
            //nome del file
            NetworkFileSystemUtilsProxy p = new NetworkFileSystemUtilsProxy();
            FileInfo a = p.CretateUncFileFinfo(hyperLinkEdit2.Text);

            return(a.Name);
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        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;
                    }
                }
            }
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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);
            }
        }