public static string ChartTypeImgClass(IChartBase chartBase, ChartScriptEntity current, ChartScriptEntity script) { string css = "sf-chart-img"; if (!chartBase.Columns.Any(a => a.Token != null && a.Token.ParseException != null) && script.IsCompatibleWith(chartBase)) { css += " sf-chart-img-equiv"; } if (script.Is(current)) { css += " sf-chart-img-curr"; } return(css); }
public static void ImportChartScripts(string folderName, Options options = null) { var files = Directory.GetFiles(folderName, "*.xml").ToDictionary(Path.GetFileNameWithoutExtension); var charts = Database.Query <ChartScriptEntity>().ToDictionary(a => a.Name); options = options ?? new Options(); using (OperationLogic.AllowSave <ChartScriptEntity>()) Synchronizer.SynchronizeReplacing(new Replacements(), "scripts", files, charts, (name, file) => { var cs = new ChartScriptEntity(); cs.ImportXml(XDocument.Load(file), name, force: false); cs.Save(); Console.WriteLine("{0} entity created.".FormatWith(name)); }, (name, script) => { if (AskYesNoAll("Remove {0} entity?".FormatWith(name), ref options.RemoveOld)) { try { script.Delete(); Console.WriteLine("{0} entity removed.".FormatWith(name)); } catch (Exception e) { SafeConsole.WriteLineColor(ConsoleColor.Red, "Error removing {0} entity: {1}".FormatWith(name, e.Message)); } } }, (name, file, script) => { var xDoc = XDocument.Load(file); if (script.Icon != null) { script.Icon.Retrieve(); } try { script.ImportXml(xDoc, name, false); } catch (FormatException f) { SafeConsole.WriteLineColor(ConsoleColor.Yellow, f.Message); if (AskYesNoAll("Force {0}?".FormatWith(name), ref options.ForceAll)) { script.ImportXml(xDoc, name, true); } } if (script.HasChanges() && AskYesNoAll("Override {0} entity?".FormatWith(name), ref options.OverrideAll)) { script.Save(); Console.WriteLine("{0} entity overriden.".FormatWith(name)); } }); }