public void SaveSettings() { var doc = new XmlDocument(); doc.AppendChild(doc.CreateElement("settings")); PropertyXMLTagAttribute.SaveObjectProperties(this, doc.DocumentElement); var fileName = ExecutablePath.ExecPath + "\\ChatSettings.xml"; try { using (var sw = new StreamWriter(fileName, false, Encoding.Unicode)) { using (var xw = new XmlTextWriter(sw) { Formatting = Formatting.Indented }) { doc.Save(xw); } } } catch (Exception ex) { Logger.ErrorFormat("Ошибка сохранения документа настроек \"{0}\": {1}", fileName, ex); } }
public void SaveSettings() { var doc = new XmlDocument(); doc.AppendChild(doc.CreateElement("settings")); PropertyXMLTagAttribute.SaveObjectProperties(this, doc.DocumentElement); doc.Save(string.Format("{0}\\settings.xml", ExecutablePath.ExecPath)); }
public void SaveSettings() { var doc = new XmlDocument(); doc.AppendChild(doc.CreateElement("settings")); PropertyXMLTagAttribute.SaveObjectProperties(this, doc.DocumentElement); doc.Save(fileName); }
public void GetTabSettings(XmlElement tabNode) { try { PropertyXMLTagAttribute.SaveObjectProperties(this, tabNode); } catch (Exception ex) { Logger.ErrorFormat("Ошибка сохранения конфигурации вкладки", ex); } }
public virtual XmlElement SaveInXml(XmlElement parent) { var node = (XmlElement)parent.AppendChild(parent.OwnerDocument.CreateElement("script")); node.Attributes.Append(parent.OwnerDocument.CreateAttribute("name")).Value = ScriptName; node.Attributes.Append(parent.OwnerDocument.CreateAttribute("title")).Value = Title; if (Trigger != null) { Trigger.SaveInXml(node); } PropertyXMLTagAttribute.SaveObjectProperties(this, node); return(node); }
public void SaveSettings() { var doc = new XmlDocument(); doc.AppendChild(doc.CreateElement("settings")); PropertyXMLTagAttribute.SaveObjectProperties(this, doc.DocumentElement); using (var sw = new StreamWriterLog(fileName, false, Encoding.Unicode)) { using (var xw = new XmlTextWriter(sw) { Formatting = Formatting.Indented }) { doc.Save(xw); } } }
public void SaveRobots(XmlElement rootNode) { foreach (var robot in Robots) { // ReSharper disable PossibleNullReferenceException var robotNode = (XmlElement)rootNode.AppendChild(rootNode.OwnerDocument.CreateElement("robot")); // ReSharper restore PossibleNullReferenceException try { PropertyXMLTagAttribute.SaveObjectProperties(robot, robotNode); } catch (Exception ex) { Logger.Error("Ошибка сохранения робота " + robot.GetUniqueName() + ": " + ex); } } }
public bool SaveSettings(XmlDocument doc) { var docNode = (XmlElement)doc.AppendChild(doc.CreateElement("farm")); try { PropertyXMLTagAttribute.SaveObjectProperties(this, docNode); } catch (Exception ex) { Logger.Error("RobotFarm.SaveSettings() - ошибка применения настроек к документу " + ex); return(false); } try { foreach (var acc in Accounts) { // сохранить роботов var accItem = (XmlElement)doc.SelectSingleNode("farm/Account/AccountId[@value='" + acc.AccountId + "']"); if (accItem == null) { continue; } acc.SaveRobots((XmlElement)accItem.ParentNode); } } catch (Exception ex) { Logger.Error("RobotFarm.SaveSettings() - ошибка сохранения роботов " + ex); return(false); } // настройки авто-торговли if (portfolioTradeSettings != null) { portfolioTradeSettings.SaveTradeSettings(docNode, TradeSettingsNodeName); } return(true); }
public void SaveSettings() { var doc = new XmlDocument(); var docNode = (XmlElement)doc.AppendChild(doc.CreateElement("settings")); try { lock (this) { PropertyXMLTagAttribute.SaveObjectProperties(this, docNode); } } catch (Exception ex) { Logger.Error("Ошибка преобразования настроек в формат XML", ex); return; } try { using (var sw = new StreamWriterLog(filePath, false, Encoding.Unicode)) { using (var xw = new XmlTextWriter(sw) { Formatting = Formatting.Indented }) { lock (this) { doc.Save(xw); Logger.Info("Файл настроек сохранен (" + filePath + ")"); } } } } catch (Exception ex) { Logger.ErrorFormat("Ошибка сохранения файла настроек {0}: {1}", filePath, ex); } }
public static void SaveRobots(List <BaseRobot> robots, string path) { var doc = new XmlDocument(); var xmlNode = (XmlElement)doc.AppendChild(doc.CreateElement("RobotsPortfolio")); foreach (var robot in robots) { var xmlChild = (XmlElement)xmlNode.AppendChild(doc.CreateElement("robot")); PropertyXMLTagAttribute.SaveObjectProperties(robot, xmlChild); } using (var sw = new StreamWriterLog(path, false)) { using (var xw = new XmlTextWriter(sw) { Formatting = Formatting.Indented }) { doc.Save(xw); } } }