/// <summary> /// Получить скрипты компонентов схемы /// </summary> private string GetCompScripts() { StringBuilder sbCompScripts = new StringBuilder(); CompManager compManager = CompManager.GetInstance(); List <string> compScripts = compManager.GetAllScripts(); foreach (string scriptPath in compScripts) { sbCompScripts.AppendFormat(WebUtils.ScriptTemplate, ResolveUrl(PluginsRoot + scriptPath)).AppendLine(); } return(sbCompScripts.ToString()); }
/// <summary> /// Создать веб-страницу редактора /// </summary> public bool CreateWebPage(string webDir, string serviceUrl) { try { // загрузка шаблона веб-страницы string webPageTemplate; using (Stream stream = Assembly.GetExecutingAssembly(). GetManifestResourceStream("Scada.Scheme.Editor.Web.plugins.SchemeEditor.editor.html")) { using (StreamReader reader = new StreamReader(stream)) { webPageTemplate = reader.ReadToEnd(); } } // формирование списка стилей компонентов схемы StringBuilder sbCompStyles = new StringBuilder(); List <string> compStyles = compManager.GetAllStyles(); foreach (string stylePath in compStyles) { sbCompStyles.AppendFormat(WebUtils.StyleTemplate, PluginsRoot + stylePath).AppendLine(); } // формирование списка скриптов компонентов схемы StringBuilder sbCompScripts = new StringBuilder(); List <string> compScripts = compManager.GetAllScripts(); foreach (string scriptPath in compScripts) { sbCompScripts.AppendFormat(WebUtils.ScriptTemplate, PluginsRoot + scriptPath).AppendLine(); } // формирование скрипта редактора StringBuilder sbEditorScript = new StringBuilder(); sbEditorScript .AppendLine("<script type=\"text/javascript\">") .AppendFormat("var editorID = '{0}';", EditorID) .AppendLine() .Append("var phrases = ") .Append(WebUtils.DictionaryToJs("Scada.Scheme.Editor.Js")) .AppendLine(";") .AppendFormat("var serviceUrl = '{0}';", serviceUrl) .AppendLine() .Append("</script>"); // формирование содержимого веб-страницы string webPageContent = string.Format(webPageTemplate, sbCompStyles.ToString(), sbCompScripts.ToString(), sbEditorScript.ToString()); // запись файла веб-страницы using (StreamWriter writer = new StreamWriter(GetWebPageFilePath(webDir), false, Encoding.UTF8)) { writer.Write(webPageContent); } return(true); } catch (Exception ex) { log.WriteException(ex, Localization.UseRussian ? "Ошибка при создании веб-страницы редактора" : "Error creating editor web page"); return(false); } }