Esempio n. 1
0
        /// <summary>
        /// Показать окно редактирования
        /// </summary>
        public static bool Show(ED542 ed)
        {
            var pv = new fEdit();

            pv.LoadED(ed);
            DialogResult f = pv.ShowDialog();

            if (f == DialogResult.OK)
            {
                Exception exception = null;
                var       fullPath  = Path.Combine(CommonConst.AppPathFiles, CommonConst.GetUniqueFileName());
                ed.SaveToFile(fullPath, out exception);
                if (exception != null)
                {
                    throw new Exception(string.Format("Файл не сохранен: {0}", exception.Message));
                }
                else
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
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);
            }
        }