Beispiel #1
0
        /// <summary>
        /// Loads the options from the XML node.
        /// </summary>
        public void LoadFromXml(XmlNode xmlNode)
        {
            if (xmlNode == null)
            {
                throw new ArgumentNullException(nameof(xmlNode));
            }

            ArcDir     = ScadaUtils.NormalDir(xmlNode.GetChildAsString("ArcDir"));
            ArcCopyDir = ScadaUtils.NormalDir(xmlNode.GetChildAsString("ArcCopyDir"));
            BaseDir    = ScadaUtils.NormalDir(xmlNode.GetChildAsString("BaseDir"));
            ViewDir    = ScadaUtils.NormalDir(xmlNode.GetChildAsString("ViewDir"));
        }
Beispiel #2
0
        /// <summary>
        /// Add directory to tree
        /// </summary>
        private void AddDirToTreeView(TreeNode parentNode, DirectoryInfo dirInfo,
                                      int rootDirLen, HashSet <string> selFiles)
        {
            if (dirInfo.Exists)
            {
                var dirNode = parentNode.Nodes.Add(dirInfo.Name);
                dirNode.ImageKey = dirNode.SelectedImageKey = FolderClosedImageKey;
                string dirNodePath = ScadaUtils.NormalDir(dirInfo.FullName.Substring(rootDirLen));
                dirNode.Tag = new NodeInfo()
                {
                    Path        = dirNodePath,
                    IsDirectory = true
                };

                // adding a subdirectory
                DirectoryInfo[] subdirInfoArr = dirInfo.GetDirectories("*", SearchOption.TopDirectoryOnly);

                foreach (var subdirInfo in subdirInfoArr)
                {
                    AddDirToTreeView(dirNode, subdirInfo, rootDirLen, selFiles);
                }

                // adding files
                FileInfo[] fileInfoArr = dirInfo.GetFiles("*", SearchOption.TopDirectoryOnly);

                foreach (var fileInfo in fileInfoArr)
                {
                    if (fileInfo.Extension != ".bak")
                    {
                        var fileNode = dirNode.Nodes.Add(fileInfo.Name);
                        fileNode.ImageKey = fileNode.SelectedImageKey = FileImageKey;
                        string fileNodePath = fileInfo.FullName.Substring(rootDirLen);
                        fileNode.Tag = new NodeInfo()
                        {
                            Path        = fileNodePath,
                            IsDirectory = false
                        };

                        if (selFiles.Contains(fileNodePath))
                        {
                            fileNode.Checked = true;
                        }
                    }
                }

                // selecting a node and its child nodes after they are added to the tree
                if (selFiles.Contains(dirNodePath))
                {
                    dirNode.Checked = true;
                    CheckAllChildNodes(dirNode, true);
                }
            }
        }
Beispiel #3
0
            /// <summary>
            /// Загрузить настройки из XML-узла
            /// </summary>
            public void LoadFromXml(XmlNode xmlNode)
            {
                if (xmlNode == null)
                {
                    throw new ArgumentNullException("xmlNode");
                }

                SaveToDir            = xmlNode.GetChildAsBool("SaveToDir", true);
                DestDir              = ScadaUtils.NormalDir(xmlNode.GetChildAsString("DestDir", DefConfigDir));
                DestFile             = xmlNode.GetChildAsString("DestFile", DefConfigArc);
                IncludeSpecificFiles = xmlNode.GetChildAsBool("IncludeSpecificFiles", true);
                ImportBase           = xmlNode.GetChildAsBool("ImportBase", true);
            }
Beispiel #4
0
        private void btnBrowseDestDir_Click(object sender, EventArgs e)
        {
            // select directory to save the configuration
            folderBrowserDialog.SelectedPath = txtDestDir.Text.Trim();

            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                txtDestDir.Text = ScadaUtils.NormalDir(folderBrowserDialog.SelectedPath);
            }

            txtDestDir.Focus();
            txtDestDir.DeselectAll();
        }
Beispiel #5
0
        private void btnBrowseDestDir_Click(object sender, EventArgs e)
        {
            // выбор директории для сохранения конфигурации
            folderBrowserDialog.SelectedPath = txtDestDir.Text.Trim();

            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                txtDestDir.Text = ScadaUtils.NormalDir(folderBrowserDialog.SelectedPath);
            }

            txtDestDir.Focus();
            txtDestDir.DeselectAll();
        }
Beispiel #6
0
        /// <summary>
        /// Добавить директорию в дерево
        /// </summary>
        private void AddDirToTreeView(TreeNode parentNode, DirectoryInfo dirInfo,
                                      int rootDirLen, HashSet <string> selFiles)
        {
            if (dirInfo.Exists)
            {
                TreeNode dirNode = parentNode.Nodes.Add(dirInfo.Name);
                dirNode.ImageKey = dirNode.SelectedImageKey = FolderClosedImageKey;
                string dirNodePath = ScadaUtils.NormalDir(dirInfo.FullName.Substring(rootDirLen));
                dirNode.Tag = new NodeInfo()
                {
                    Path = dirNodePath, IsDirectory = true
                };

                // добавление поддиректорий
                DirectoryInfo[] subdirInfoArr = dirInfo.GetDirectories("*", SearchOption.TopDirectoryOnly);

                foreach (DirectoryInfo subdirInfo in subdirInfoArr)
                {
                    AddDirToTreeView(dirNode, subdirInfo, rootDirLen, selFiles);
                }

                // добавление файлов
                FileInfo[] fileInfoArr = dirInfo.GetFiles("*", SearchOption.TopDirectoryOnly);

                foreach (FileInfo fileInfo in fileInfoArr)
                {
                    if (fileInfo.Extension != ".bak")
                    {
                        TreeNode fileNode = dirNode.Nodes.Add(fileInfo.Name);
                        fileNode.ImageKey = fileNode.SelectedImageKey = FileImageKey;
                        string fileNodePath = fileInfo.FullName.Substring(rootDirLen);
                        fileNode.Tag = new NodeInfo()
                        {
                            Path = fileNodePath, IsDirectory = false
                        };

                        if (selFiles.Contains(fileNodePath))
                        {
                            fileNode.Checked = true;
                        }
                    }
                }

                // выбор узла и его дочерних узлов после того, как они добавлены в дерево
                if (selFiles.Contains(dirNodePath))
                {
                    dirNode.Checked = true;
                    CheckAllChildNodes(dirNode, true);
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Заполнить дерево выбранных файлов
        /// </summary>
        private void FillTreeView(string srcDir, List <string> selectedFiles)
        {
            try
            {
                tvFiles.BeginUpdate();
                tvFiles.Nodes.Clear();

                srcDir = ScadaUtils.NormalDir(srcDir);
                int srcDirLen = srcDir.Length;
                rootNode = tvFiles.Nodes.Add(srcDir.TrimEnd('\\'));

                // добавление узла базы конфигурации
                HashSet <string> selFiles = new HashSet <string>(selectedFiles);
                AddDirToTreeView(rootNode, srcDir + "BaseDAT\\", srcDirLen, selFiles);

                // добавление узла интерфейса
                AddDirToTreeView(rootNode, srcDir + "Interface\\", srcDirLen, selFiles);

                // добавление узла Коммуникатора
                string commDir = srcDir + "ScadaComm\\";
                if (Directory.Exists(commDir))
                {
                    TreeNode commNode = rootNode.Nodes.Add("ScadaComm");
                    AddDirToTreeView(commNode, commDir + "Config\\", srcDirLen, selFiles);
                }

                // добавление узла Сервера
                string serverDir = srcDir + "ScadaServer\\";
                if (Directory.Exists(serverDir))
                {
                    TreeNode serverNode = rootNode.Nodes.Add("ScadaServer");
                    AddDirToTreeView(serverNode, serverDir + "Config\\", srcDirLen, selFiles);
                }

                // добавление узла Вебстанции
                string webDir = srcDir + "ScadaWeb\\";
                if (Directory.Exists(webDir))
                {
                    TreeNode serverNode = rootNode.Nodes.Add("ScadaWeb");
                    AddDirToTreeView(serverNode, webDir + "config\\", srcDirLen, selFiles);
                    AddDirToTreeView(serverNode, webDir + "storage\\", srcDirLen, selFiles);
                }

                rootNode.Expand();
            }
            finally
            {
                tvFiles.EndUpdate();
            }
        }
Beispiel #8
0
        private void btnWebDir_Click(object sender, EventArgs e)
        {
            // выбор директории веб-приложения
            folderBrowserDialog.SelectedPath = txtWebDir.Text.Trim();
            folderBrowserDialog.Description  = AppPhrases.ChooseWebDir;

            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                txtWebDir.Text = ScadaUtils.NormalDir(folderBrowserDialog.SelectedPath);
            }

            txtWebDir.Focus();
            txtWebDir.DeselectAll();
        }
Beispiel #9
0
        /// <summary>
        /// Загрузить настройки приложения из файла
        /// </summary>
        public bool Load(string fileName, out string errMsg)
        {
            // установка значений по умолчанию
            SetToDefault();

            // загрузка настроек
            try
            {
                if (!File.Exists(fileName))
                {
                    throw new FileNotFoundException(string.Format(CommonPhrases.NamedFileNotFound, fileName));
                }

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(fileName);
                XmlNodeList paramNodes = xmlDoc.DocumentElement.SelectNodes("Param");

                foreach (XmlElement paramElem in paramNodes)
                {
                    string name  = paramElem.GetAttribute("name");
                    string nameL = name.ToLowerInvariant();
                    string val   = paramElem.GetAttribute("value");

                    try
                    {
                        if (nameL == "webdir")
                        {
                            WebDir = ScadaUtils.NormalDir(val);
                        }
                        else if (nameL == "browser")
                        {
                            Browser = (Browsers)Enum.Parse(typeof(Browsers), val, true);
                        }
                    }
                    catch
                    {
                        throw new Exception(string.Format(CommonPhrases.IncorrectXmlParamVal, name));
                    }
                }

                errMsg = "";
                return(true);
            }
            catch (Exception ex)
            {
                errMsg = CommonPhrases.LoadAppSettingsError + ":" + Environment.NewLine + ex.Message;
                return(false);
            }
        }
Beispiel #10
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            if (lblFileName.Visible)
            {
                // select file to import
                if (cbTable.SelectedItem is ImportArchiveItem)
                {
                    openFileDialog.Title  = AppPhrases.ChooseArchiveFile;
                    openFileDialog.Filter = AppPhrases.ArchiveFileFilter;
                }
                else
                {
                    openFileDialog.Title  = AppPhrases.ChooseBaseTableFile;
                    openFileDialog.Filter = AppPhrases.BaseTableFileFilter;
                }

                string fileName = txtFileName.Text.Trim();
                openFileDialog.FileName = fileName;

                if (fileName != "")
                {
                    openFileDialog.InitialDirectory = Path.GetDirectoryName(fileName);
                }

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    txtFileName.Text = openFileDialog.FileName;
                }

                txtFileName.Focus();
                txtFileName.DeselectAll();
            }
            else
            {
                // directory selection
                folderBrowserDialog.SelectedPath = txtFileName.Text.Trim();
                folderBrowserDialog.Description  = CommonPhrases.ChooseBaseDATDir;

                if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
                {
                    txtFileName.Text = ScadaUtils.NormalDir(folderBrowserDialog.SelectedPath);
                }

                txtFileName.Focus();
                txtFileName.DeselectAll();
            }
        }
Beispiel #11
0
        /// <summary>
        /// Fill the tree of selected files
        /// </summary>
        private void FillTreeView(string srcDir, List <string> selectedFiles)
        {
            try {
                tvFiles.BeginUpdate();
                tvFiles.Nodes.Clear();

                srcDir = ScadaUtils.NormalDir(srcDir);
                int srcDirLen = srcDir.Length;
                rootNode = tvFiles.Nodes.Add(srcDir.TrimEnd('\\'));

                // adding configuration base node
                var selFiles = new HashSet <string>(selectedFiles);
                AddDirToTreeView(rootNode, srcDir + "BaseDAT\\", srcDirLen, selFiles);

                // add interface node
                AddDirToTreeView(rootNode, srcDir + "Interface\\", srcDirLen, selFiles);

                // adding a Communicator node
                string commDir = srcDir + "ScadaComm\\";
                if (Directory.Exists(commDir))
                {
                    var commNode = rootNode.Nodes.Add("ScadaComm");
                    AddDirToTreeView(commNode, commDir + "Config\\", srcDirLen, selFiles);
                }

                // adding a Server node
                string serverDir = srcDir + "ScadaServer\\";
                if (Directory.Exists(serverDir))
                {
                    var serverNode = rootNode.Nodes.Add("ScadaServer");
                    AddDirToTreeView(serverNode, serverDir + "Config\\", srcDirLen, selFiles);
                }

                // add a web station node
                string webDir = srcDir + "ScadaWeb\\";
                if (Directory.Exists(webDir))
                {
                    var serverNode = rootNode.Nodes.Add("ScadaWeb");
                    AddDirToTreeView(serverNode, webDir + "config\\", srcDirLen, selFiles);
                    AddDirToTreeView(serverNode, webDir + "storage\\", srcDirLen, selFiles);
                }

                rootNode.Expand();
            } finally {
                tvFiles.EndUpdate();
            }
        }
Beispiel #12
0
        private void btnConfigDir_Click(object sender, EventArgs e)
        {
            folderBrowserDialog.SelectedPath = txtConfigDir.Text.Trim();

            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                string selectedPath = ScadaUtils.NormalDir(folderBrowserDialog.SelectedPath);

                if (configDir != selectedPath)
                {
                    configDir = txtConfigDir.Text = selectedPath;
                    LoadSettings();
                }
            }

            txtConfigDir.Focus();
            txtConfigDir.DeselectAll();
        }
Beispiel #13
0
        /// <summary>
        /// Отобразить форму настроек приложения
        /// </summary>
        public static DialogResult Show(ref string baseDATDir)
        {
            // создание и перевод формы
            FrmSettings frmSettings = new FrmSettings();

            Translator.TranslateForm(frmSettings, "ScadaTableEditor.FrmSettings");
            frmSettings.folderBrowserDialog.Description = CommonPhrases.ChooseBaseDATDir;

            // настройка и отображение формы
            frmSettings.txtBaseDATDir.Text = baseDATDir;
            DialogResult dlgRes = frmSettings.ShowDialog();

            if (dlgRes == DialogResult.OK)
            {
                baseDATDir = ScadaUtils.NormalDir(frmSettings.txtBaseDATDir.Text);
            }
            return(dlgRes);
        }
Beispiel #14
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            // определение директории исполняемого файла приложения
            exeDir = ScadaUtils.NormalDir(Path.GetDirectoryName(Application.ExecutablePath));

            // локализация приложения
            string langDir = exeDir + "Lang\\";
            string errMsg;

            if (Localization.LoadingRequired(langDir, "ScadaData"))
            {
                if (Localization.LoadDictionaries(langDir, "ScadaData", out errMsg))
                {
                    CommonPhrases.Init();
                }
                else
                {
                    ScadaUiUtils.ShowError(errMsg);
                }
            }

            if (Localization.LoadingRequired(langDir, "ScadaTableEditor"))
            {
                if (Localization.LoadDictionaries(langDir, "ScadaTableEditor", out errMsg))
                {
                    Translator.TranslateForm(this, "ScadaTableEditor.FrmMain", toolTip);
                    WebPhrases.Init();
                    AppPhrases.Init();
                    openFileDialog.Filter = AppPhrases.OpenFileFilter;
                    saveFileDialog.Filter = AppPhrases.SaveFileFilter;
                }
                else
                {
                    ScadaUiUtils.ShowError(errMsg);
                }
            }

            // настройка элементов управления
            dgvCnls.AutoGenerateColumns  = false;
            dgvItems.AutoGenerateColumns = false;

            // создание нового представления
            CreateTableView();
        }
Beispiel #15
0
        /// <summary>
        /// Загрузить настройки представлений из файла
        /// </summary>
        public bool LoadFromFile(string fileName, out string errMsg)
        {
            // установка значений по умолчанию
            ViewSetList = new List <ViewSet>();

            try
            {
                if (!File.Exists(fileName))
                {
                    throw new FileNotFoundException(string.Format(CommonPhrases.NamedFileNotFound, fileName));
                }

                // загрузка настроек
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(fileName);

                XmlNodeList viewSetNodeList = xmlDoc.DocumentElement.SelectNodes("ViewSet");

                foreach (XmlElement viewSetElement in viewSetNodeList)
                {
                    ViewSet viewSet = new ViewSet(viewSetElement.GetAttribute("name"),
                                                  ScadaUtils.NormalDir(viewSetElement.GetAttribute("directory")));
                    ViewSetList.Add(viewSet);

                    XmlNodeList viewNodeList = viewSetElement.SelectNodes("View");

                    foreach (XmlElement viewElement in viewNodeList)
                    {
                        ViewInfo viewInfo = new ViewInfo(viewElement.InnerText,
                                                         viewElement.GetAttribute("type"), viewElement.GetAttribute("fileName"));
                        viewSet.Items.Add(viewInfo);
                    }
                }

                errMsg = "";
                return(true);
            }
            catch (Exception ex)
            {
                errMsg = WebPhrases.LoadViewSettingsError + ": " + ex.Message;
                return(false);
            }
        }
Beispiel #16
0
        /// <summary>
        /// Fills the list of files.
        /// </summary>
        private void FillFileList()
        {
            try
            {
                string dir = GetDirectory();
                txtDir.Text = ScadaUtils.NormalDir(dir);
                lbFiles.BeginUpdate();
                lbFiles.Items.Clear();

                if (Directory.Exists(dir))
                {
                    DirectoryInfo dirInfo     = new DirectoryInfo(dir);
                    FileInfo[]    fileInfoArr = dirInfo.GetFiles("*.dat", SearchOption.TopDirectoryOnly);

                    foreach (FileInfo fileInfo in fileInfoArr)
                    {
                        lbFiles.Items.Add(new FileItem()
                        {
                            FileName = fileInfo.Name,
                            FilePath = fileInfo.FullName
                        });
                    }
                }

                if (lbFiles.Items.Count > 0)
                {
                    lbFiles.SelectedIndex = 0;
                    btnView.Enabled       = true;
                    btnEdit.Enabled       = true;
                }
                else
                {
                    btnView.Enabled = false;
                    btnEdit.Enabled = false;
                }
            }
            finally
            {
                lbFiles.EndUpdate();
            }
        }
Beispiel #17
0
        /// <summary>
        /// Инициализировать общие данные приложения
        /// </summary>
        public static void InitAppData()
        {
            if (!Inited)
            {
                Inited = true;

                // определение директорий приложения
                if (HttpContext.Current == null)
                {
                    AppDir = ScadaUtils.NormalDir(Path.GetDirectoryName(Application.ExecutablePath));
                    BinDir = AppDir;
                }
                else
                {
                    AppDir = ScadaUtils.NormalDir(HttpContext.Current.Request.PhysicalApplicationPath);
                    BinDir = AppDir + "bin\\";
                }

                ConfigDir   = AppDir + "config\\";
                LangDir     = AppDir + "lang\\";
                LogDir      = AppDir + "log\\";
                ReportDir   = AppDir + "report\\";
                TemplateDir = AppDir + "templates\\";

                // настройка объекта для работы с данными системы
                MainData.SettingsFileName = ConfigDir + CommSettings.DefFileName;

                // настройка журнала приложения
                Log.FileName = LogDir + LogFileName;
                Log.Encoding = Encoding.UTF8;
                Log.WriteBreak();
                Log.WriteAction(Localization.UseRussian ? "Инициализация общих данных приложения" :
                                "Initialize common application data", Log.ActTypes.Action);
            }

            // обновление словарей
            RefreshDictionaries();

            // обновление настроек веб-приложения
            RefreshWebSettings();
        }
Beispiel #18
0
        /// <summary>
        /// Recursively packs the directory to the archive.
        /// </summary>
        private static void PackDirectory(ZipArchive zipArchive, string path, string entryPrefix)
        {
            DirectoryInfo dirInfo = new DirectoryInfo(path);

            if (dirInfo.Exists)
            {
                // pack subdirectories
                foreach (DirectoryInfo subdirInfo in dirInfo.EnumerateDirectories("*", SearchOption.TopDirectoryOnly))
                {
                    PackDirectory(zipArchive, subdirInfo.FullName, entryPrefix + subdirInfo.Name + '/');
                }

                // pack files
                int dirLen = ScadaUtils.NormalDir(path).Length;
                foreach (FileInfo fileInfo in dirInfo.EnumerateFiles("*", SearchOption.TopDirectoryOnly))
                {
                    string entryName = entryPrefix + fileInfo.FullName.Substring(dirLen).Replace('\\', '/');
                    zipArchive.CreateEntryFromFile(fileInfo.FullName, entryName, CompressionLevel.Fastest);
                }
            }
        }
Beispiel #19
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            // choose a text box
            TextBox textBox = null;
            string  descr   = "";

            if (sender == btnBrowseBaseDATDir)
            {
                textBox = txtBaseDATDir;
                descr   = CommonPhrases.ChooseBaseDATDir;
            }
            else if (sender == btnBrowseItfDir)
            {
                textBox = txtItfDir;
                descr   = ServerShellPhrases.ChooseItfDir;
            }
            else if (sender == btnBrowseArcDir)
            {
                textBox = txtArcDir;
                descr   = ServerShellPhrases.ChooseArcDir;
            }
            else if (sender == btnBrowseArcCopyDir)
            {
                textBox = txtArcCopyDir;
                descr   = ServerShellPhrases.ChooseArcCopyDir;
            }

            // browse directory
            if (textBox != null)
            {
                fbdDir.SelectedPath = textBox.Text.Trim();
                fbdDir.Description  = descr;

                if (fbdDir.ShowDialog() == DialogResult.OK)
                {
                    textBox.Text = ScadaUtils.NormalDir(fbdDir.SelectedPath);
                }
            }
        }
Beispiel #20
0
        /// <summary>
        /// Finds the interface directory, relative to the bindings file name.
        /// </summary>
        private bool FindInterfaceDir()
        {
            if (!string.IsNullOrEmpty(fileName))
            {
                DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fileName));

                while (dirInfo.Parent != null)
                {
                    dirInfo = dirInfo.Parent;

                    foreach (DirectoryInfo parentDirInfo in
                             dirInfo.EnumerateDirectories(InterfaceDirPattern, SearchOption.TopDirectoryOnly))
                    {
                        interfaceDir = ScadaUtils.NormalDir(parentDirInfo.FullName);
                        return(true);
                    }
                }
            }

            interfaceDir = "";
            return(false);
        }
Beispiel #21
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            // определение директории исполняемого файла приложения
            exeDir = ScadaUtils.NormalDir(Path.GetDirectoryName(Application.ExecutablePath));

            // локализация приложения
            string langDir = exeDir + "Lang\\";
            string errMsg;

            if (Localization.LoadingRequired(langDir, "ScadaData"))
            {
                if (Localization.LoadDictionaries(langDir, "ScadaData", out errMsg))
                {
                    CommonPhrases.Init();
                }
                else
                {
                    ScadaUiUtils.ShowError(errMsg);
                }
            }

            if (Localization.LoadingRequired(langDir, "ScadaWebConfig"))
            {
                if (Localization.LoadDictionaries(langDir, "ScadaWebConfig", out errMsg))
                {
                    Translator.TranslateForm(this, "ScadaWebConfig.FrmMain");
                    WebPhrases.Init();
                    AppPhrases.Init();
                    folderBrowserDialog.Description = AppPhrases.ChooseConfigDir;
                    openFileDialog.Title            = AppPhrases.ChooseViewFile;
                    openFileDialog.Filter           = AppPhrases.FileFilter;
                }
                else
                {
                    ScadaUiUtils.ShowError(errMsg);
                }
            }
        }
Beispiel #22
0
        /// <summary>
        /// Loads the options from the XML node.
        /// </summary>
        public void LoadFromXml(XmlNode xmlNode)
        {
            if (xmlNode == null)
            {
                throw new ArgumentNullException("xmlNode");
            }

            foreach (XmlElement paramElem in xmlNode)
            {
                string name  = paramElem.GetAttribute("name");
                string nameL = name.ToLowerInvariant();
                string val   = paramElem.GetAttribute("value");

                if (nameL == "serverdir")
                {
                    ServerDir = ScadaUtils.NormalDir(val);
                }
                else if (nameL == "commdir")
                {
                    CommDir = ScadaUtils.NormalDir(val);
                }
            }
        }
Beispiel #23
0
        /// <summary>
        /// Загрузить директорию конфигурации из файла
        /// </summary>
        private void LoadConfigDir()
        {
            // установка директории конфигурации по умолчанию
            configDir = DefaultConfigDir;

            // загрузка директории конфигурации
            try
            {
                string fileName = exeDir + SettingsFileName;
                if (!File.Exists(fileName))
                {
                    throw new FileNotFoundException(string.Format(CommonPhrases.NamedFileNotFound, fileName));
                }

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(fileName);

                XmlNodeList paramNodeList = xmlDoc.DocumentElement.SelectNodes("Param");
                foreach (XmlElement paramElem in paramNodeList)
                {
                    if (paramElem.GetAttribute("name").Trim().ToLower() == "configdir")
                    {
                        configDir = ScadaUtils.NormalDir(paramElem.GetAttribute("value"));
                    }
                }
            }
            catch (Exception ex)
            {
                ScadaUiUtils.ShowError(AppPhrases.LoadConfigDirError + ":\n" + ex.Message);
            }

            // вывод директории конфигурации
            txtConfigDir.Text = configDir;

            // определение директории веб-приложения
            webAppDir = configDir.EndsWith(@"\config\") ? configDir.Substring(0, configDir.Length - 7) : "";
        }
Beispiel #24
0
        /// <summary>
        /// Gets the directories affected by the uploaded configuration.
        /// </summary>
        private List <string> GetAffectedDirectories(TransferOptions uploadOptions)
        {
            List <string> dirs = new List <string>();

            void AddDir(RelativePath relativePath)
            {
                dirs.Add(ScadaUtils.NormalDir(PathBuilder.GetAbsolutePath(relativePath)));
            }

            if (uploadOptions.IncludeBase)
            {
                AddDir(new RelativePath(TopFolder.Base));
            }

            if (uploadOptions.IncludeView)
            {
                AddDir(new RelativePath(TopFolder.View));
            }

            if (uploadOptions.IncludeServer)
            {
                AddDir(new RelativePath(TopFolder.Server, AppFolder.Config));
            }

            if (uploadOptions.IncludeComm)
            {
                AddDir(new RelativePath(TopFolder.Comm, AppFolder.Config));
            }

            if (uploadOptions.IncludeWeb)
            {
                AddDir(new RelativePath(TopFolder.Web, AppFolder.Config));
            }

            return(dirs);
        }