Beispiel #1
0
 /// <summary>
 /// Обновление списка файла
 /// </summary>
 public void UpdateFileList()
 {
     if (!Directory.Exists(CommonConst.constFolderFiles))
     {
         return;
     }
     listBoxFiles.BeginUpdate();
     try
     {
         listBoxFiles.Items.Clear();
         string[] filesname = Directory.GetFiles(CommonConst.constFolderFiles);
         foreach (var item in filesname)
         {
             listBoxFiles.Items.Add(item);
         }
     }
     catch (Exception ex)
     {
         CommonMsg.ShowError(ex);
     }
     finally
     {
         listBoxFiles.EndUpdate();
     }
 }
Beispiel #2
0
        /// <summary>
        /// Событие нажатия на кнопку удалить
        /// </summary>
        private void buttonDel_Click(object sender, EventArgs e)
        {
            var t = (string)listBoxFiles.SelectedItem;

            if (CommonMsg.ShowQuestionYesNo(string.Format("Вы уверены, что хотите удалить файл \"{0}\"?", t)) != DialogResult.Yes)
            {
                return;
            }
            Log.Write(string.Format("Удаление файла {0}", t));
            listBoxFiles.Items.Remove(listBoxFiles.SelectedItem);
            if (File.Exists(t))
            {
                File.Delete(t);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Событие нажатия на кнопку редактировать
        /// </summary>
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            var t  = (string)listBoxFiles.SelectedItem;
            var ed = new object();

            try
            {
                Log.Write(string.Format("Редактирование файла {0}", t));
                ed = EntityBase <EDRefID> .LoadFromFile(t);

                fEdit.Show((ED542)ed);
            }
            catch (Exception ex)
            {
                CommonMsg.ShowError(ex);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Событие нажатия на кнопку скачать
 /// </summary>
 private void buttonDownload_Click(object sender, EventArgs e)
 {
     try
     {
         Log.Write("Begin:Скачивание файла");
         var res = fDownload.ShowForm();
         if (res)
         {
             Log.Write("End: Скачивание файла");
             UpdateFileList();
         }
     }
     catch (Exception ex)
     {
         CommonMsg.ShowError(ex);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Событие нажатия на кнопку добавить
        /// </summary>
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            Log.Write("Begin: Добавление файла");
            var ed = new ED542();

            try
            {
                bool res = fEdit.Show(ed);
                if (res)
                {
                    Log.Write("End: Добавление файла");
                    UpdateFileList();
                }
            } catch (Exception ex)
            {
                CommonMsg.ShowError(ex);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Проверить и сохраниьт файл
        /// </summary>
        private bool SaveFile(string url)
        {
            var       ed = new ED542();
            Exception ex = null;

            using (var client = new WebClient())
            {
                string xmlString = client.DownloadString(url);

                if (!ValidatorXML.Instance.Validate(xmlString))
                {
                    fResult.Show(ValidatorXML.Instance);
                    return(false);
                }
                string   fullPath     = Path.Combine(CommonConst.AppPathFiles, CommonConst.GetUniqueFileName());
                FileInfo xmlFile      = new FileInfo(fullPath);
                var      streamWriter = xmlFile.CreateText();
                streamWriter.WriteLine(xmlString);
                streamWriter.Close();
                CommonMsg.ShowMessage(string.Format("Файл {0} успешно загружен", fullPath));
                return(true);
            }
        }