override protected void LoadXML(XmlNode cXmlNode) { try { (new Logger()).WriteNotice("________________load XML begin"); if (null == cXmlNode) { return; } (new Logger()).WriteNotice("\n\n" + cXmlNode.OuterXml + "\n\n"); XmlNode cXmlNodeChild; XmlNode[] aXmlNodeChilds; XmlNode cXmlNodeClient = cXmlNode.NodeGet("clients/scr", false); XmlNode cXmlNodeManagement = cXmlNode.NodeGet("clients/management", false); if (null != cXmlNodeManagement) { _cClientManagement = new Clients.Management(); _cClientManagement.sRestartFile = cXmlNodeManagement.AttributeGet <string>("restart"); // нужна только в клиенте } if (null != cXmlNodeClient) { _cClientSCR = new Clients.SCR(); _cClientSCR.sChannelName = cXmlNodeClient.AttributeOrDefaultGet <string>("name", "SCR"); // нужна только в клиенте // нужна и в клиенте и в (cues || player) #region presets if (null != cXmlNodeClient.NodeGet("presets", false)) { aXmlNodeChilds = cXmlNodeClient.NodesGet("presets/preset"); List <Clients.SCR.Preset> aPresets = new List <Clients.SCR.Preset>(); Clients.SCR.Preset cPreset; foreach (XmlNode cXmlNodePreset in aXmlNodeChilds) { cPreset = new Clients.SCR.Preset(); cPreset.sName = cXmlNodePreset.AttributeValueGet("name"); cPreset.nID = cXmlNodePreset.AttributeIDGet("id"); cPreset.sFolder = cXmlNodePreset.AttributeValueGet("folder"); cPreset.sChannel = cXmlNodePreset.AttributeValueGet("channel"); cPreset.sCaption = cXmlNodePreset.AttributeValueGet("caption"); if (0 < aPresets.Count(o => (cPreset.nID == o.nID || cPreset.sName == o.sName) && cPreset.sChannel == o.sChannel)) { throw new Exception("пресет указан повторно [channel:" + cPreset.sChannel + "][id:" + cPreset.nID + "][name:" + cPreset.sName + "][" + cXmlNodePreset.Name + "][" + cXmlNodeClient.Name + "]"); //TODO LANG } aPresets.Add(cPreset); } _cClientSCR.aPresets = aPresets.ToArray(); } #endregion // нужна и в клиенте и в (cues || player) #region plaques if (null != cXmlNodeClient.NodeGet("plaques", false)) { aXmlNodeChilds = cXmlNodeClient.NodesGet("plaques/plaque"); List <Clients.SCR.Plaque> aPlaques = new List <Clients.SCR.Plaque>(); Clients.SCR.Plaque cPlaque; foreach (XmlNode cXmlNodePreset in aXmlNodeChilds) { cPlaque = new Clients.SCR.Plaque(); cPlaque.nPresetID = cXmlNodePreset.AttributeOrDefaultGet <int>("id_preset", 0); cPlaque.bOpened = cXmlNodePreset.AttributeOrDefaultGet <bool>("opened", false); cPlaque.nHeight = cXmlNodePreset.AttributeOrDefaultGet <ushort>("height", 300); aPlaques.Add(cPlaque); } _cClientSCR.aPlaques = aPlaques.ToArray(); } #endregion // нужна и в клиенте и в (cues || player) #region templates XmlNode cXmlNodeTemplates = cXmlNodeClient.NodeGet("templates"); if (null != (cXmlNodeChild = cXmlNodeTemplates.NodeGet("masks", false))) // нужна только в клиенте { _cClientSCR.sTemplateChannelMask = cXmlNodeChild.AttributeOrDefaultGet <string>("channel", ""); _cClientSCR.sTemplatePresetMask = cXmlNodeChild.AttributeOrDefaultGet <string>("preset", ""); } aXmlNodeChilds = cXmlNodeTemplates.NodesGet("template"); List <Clients.SCR.Template> aTemplates = new List <Clients.SCR.Template>(); Clients.SCR.Template cTemplate = null; foreach (XmlNode cXmlNodeTemplate in aXmlNodeChilds) { cTemplate = new Clients.SCR.Template(); cTemplate.eBind = cXmlNodeTemplate.AttributeGet <Clients.SCR.Template.Bind>("bind"); if (0 < aTemplates.Count(o => o.eBind == cTemplate.eBind)) { throw new Exception("шаблон с указанной привязкой уже был добавлен [" + cTemplate.eBind + "][" + cXmlNodeTemplate.Name + "][" + cXmlNodeClient.Name + "]"); //TODO LANG } cTemplate.sFile = cXmlNodeTemplate.AttributeValueGet("file"); cTemplate.sTag = cXmlNodeTemplate.AttributeValueGet("tag", false); cTemplate.nPixelAspectRatio = 1; if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("scale_video", false))) // нужна только в плеере - это принудительно искажать видео и фото (было нужно для пульта SD) { short x, y; ushort w, h; string sAspect; x = cXmlNodeChild.AttributeOrDefaultGet <short>("x", 0); y = cXmlNodeChild.AttributeOrDefaultGet <short>("y", 0); w = cXmlNodeChild.AttributeGet <ushort>("width"); h = cXmlNodeChild.AttributeGet <ushort>("height"); if (0 == w || 0 == h) { cTemplate.stScaleVideo = Area.stEmpty; } else { cTemplate.stScaleVideo = new Area(x, y, w, h); } sAspect = cXmlNodeChild.AttributeOrDefaultGet <string>("pixel_aspect_ratio", "1"); if (null != sAspect) { cTemplate.nPixelAspectRatio = float.Parse(sAspect.Replace('.', ',')); } } if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("offsets", false))) { cTemplate.aOffsets = GetOffsets(cXmlNodeChild.NodesGet("offset")); } if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("conflicts", false))) { cTemplate.aConflicts = GetConflicts(cXmlNodeChild.NodesGet("conflict")); } if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("preset_parameters", false))) { cTemplate.aParameters = GetParameters(cXmlNodeChild.NodesGet("parameters")); } if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("player_parameters", false))) { _cClientSCR.nFragmentBeforeNow = cXmlNodeChild.AttributeOrDefaultGet("fragment_before_now", 60); // нужна только в плеере _cClientSCR.nFragmentAfterNow = cXmlNodeChild.AttributeOrDefaultGet("fragment_after_now", 180); // нужна только в плеере _cClientSCR.sFilesDefaultSort = cXmlNodeChild.AttributeOrDefaultGet("sort_files", "date"); // нужна только в клиенте sCacheFolder = cXmlNodeChild.AttributeValueGet("cache_folder", false); // нужна только в плеере _cClientSCR.bIsWithCacheMode = !sCacheFolder.IsNullOrEmpty(); nCopyDelayMiliseconds = cXmlNodeChild.AttributeOrDefaultGet("copy_delay", 0); // нужна только в плеере nCopyPeriodToDelayMiliseconds = cXmlNodeChild.AttributeOrDefaultGet("copy_period", 0); // нужна только в плеере if (null != cXmlNodeChild.NodeGet("parameters", false)) { cTemplate.aParameters = GetPlayerParameters(cXmlNodeChild.NodesGet("parameters")); // нужна только в клиенте } } aTemplates.Add(cTemplate); } _cClientSCR.aTemplates = aTemplates.ToArray(); #endregion XmlNode cDBI = cXmlNodeClient.NodeGet("dbi_web_service", false); // нужна только в клиенте if (null != cDBI) { _cClientSCR.sDBIServerName = cDBI.AttributeGet <string>("server"); _cClientSCR.sDBUser = cDBI.AttributeGet <string>("user_name"); _cClientSCR.sDBPasswd = cDBI.AttributeGet <string>("user_pass"); } XmlNode cXmlNodeAutomation = cXmlNodeClient.NodeGet("automation", false); // нужна только в плеере if (null != cXmlNodeAutomation) { sClipStartStopAutomationFile = cXmlNodeAutomation.AttributeValueGet("file"); if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(sClipStartStopAutomationFile))) { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(sClipStartStopAutomationFile)); } nFrameDuration_ms = cXmlNodeAutomation.AttributeGet <int>("frame_ms"); nStopOffset = cXmlNodeAutomation.AttributeGet <int>("stop_offset"); } XmlNode cXmlNodeOthers = cXmlNodeClient.NodeGet("others", false); // нужна только в плеере if (null != cXmlNodeOthers) { nQueuesCompensation = cXmlNodeOthers.AttributeGet <int>("queues_compensation"); sPlayerLogFolder = cXmlNodeOthers.AttributeValueGet("player_log"); bDontCheckFiles = cXmlNodeOthers.AttributeGet <bool>("dont_check_files"); } } (new Logger()).WriteNotice("________________load XML end [sPlayerLogFolder=" + sPlayerLogFolder + "][sClipStartStopAutomationFile=" + sClipStartStopAutomationFile + "][sDBIServerName=" + _cClientSCR.sDBIServerName + "]"); } catch (Exception ex) { (new Logger()).WriteError(ex); } }
override protected void LoadXML(XmlNode cXmlNode) { (new Logger()).WriteWarning("________________load XML begin"); if (null == cXmlNode) return; XmlNode cXmlNodeChild; XmlNode[] aXmlNodeChilds; XmlNode cXmlNodeClient = cXmlNode.NodeGet("clients/scr", false); if (null != cXmlNodeClient) { #region presets aXmlNodeChilds = cXmlNodeClient.NodesGet("presets/preset"); _cClientSCR = new Clients.SCR(); List<Clients.SCR.Preset> aPresets = new List<Clients.SCR.Preset>(); Clients.SCR.Preset cPreset; foreach (XmlNode cXmlNodePreset in aXmlNodeChilds) { cPreset = new Clients.SCR.Preset(); cPreset.sName = cXmlNodePreset.AttributeValueGet("name"); cPreset.nID = cXmlNodePreset.AttributeIDGet("id"); cPreset.sFolder = cXmlNodePreset.AttributeValueGet("folder"); cPreset.sChannel = cXmlNodePreset.AttributeValueGet("channel"); cPreset.sCaption = cXmlNodePreset.AttributeValueGet("caption"); if (0 < aPresets.Count(o => (cPreset.nID == o.nID || cPreset.sName == o.sName) && cPreset.sChannel == o.sChannel)) throw new Exception("пресет указан повторно [channel:" + cPreset.sChannel + "][id:" + cPreset.nID + "][name:" + cPreset.sName + "][" + cXmlNodePreset.Name + "][" + cXmlNodeClient.Name + "]"); //TODO LANG aPresets.Add(cPreset); } _cClientSCR.aPresets = aPresets.ToArray(); #endregion #region plaques aXmlNodeChilds = cXmlNodeClient.NodesGet("plaques/plaque"); List<Clients.SCR.Plaque> aPlaques = new List<Clients.SCR.Plaque>(); Clients.SCR.Plaque cPlaque; foreach (XmlNode cXmlNodePreset in aXmlNodeChilds) { cPlaque = new Clients.SCR.Plaque(); cPlaque.nPresetID = cXmlNodePreset.AttributeGet<int>("id_preset", false); cPlaque.bOpened = cXmlNodePreset.AttributeGet<bool>("opened", false); cPlaque.nHeight = cXmlNodePreset.AttributeGet<ushort>("height", false); aPlaques.Add(cPlaque); } _cClientSCR.aPlaques = aPlaques.ToArray(); #endregion #region templates XmlNode cXmlNodeTemplates = cXmlNodeClient.NodeGet("templates"); if (null != (cXmlNodeChild = cXmlNodeTemplates.NodeGet("masks", false))) { _cClientSCR.sTemplateChannelMask = cXmlNodeChild.AttributeValueGet("channel", false) ?? ""; _cClientSCR.sTemplatePresetMask = cXmlNodeChild.AttributeValueGet("preset", false) ?? ""; } aXmlNodeChilds = cXmlNodeTemplates.NodesGet("template"); List<Clients.SCR.Template> aTemplates = new List<Clients.SCR.Template>(); Clients.SCR.Template cTemplate = null; foreach (XmlNode cXmlNodeTemplate in aXmlNodeChilds) { cTemplate = new Clients.SCR.Template(); cTemplate.eBind = cXmlNodeTemplate.AttributeGet<Clients.SCR.Template.Bind>("bind"); if (0 < aTemplates.Count(o => o.eBind == cTemplate.eBind)) throw new Exception("шаблон с указанной привязкой уже был добавлен [" + cTemplate.eBind + "][" + cXmlNodeTemplate.Name + "][" + cXmlNodeClient.Name + "]"); //TODO LANG cTemplate.sFile = cXmlNodeTemplate.AttributeValueGet("file"); if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("scale_video", false))) { short x, y; ushort w, h; string sAspect; x = cXmlNodeChild.AttributeGet<short>("x", false); y = cXmlNodeChild.AttributeGet<short>("y", false); w = cXmlNodeChild.AttributeGet<ushort>("width", false); h = cXmlNodeChild.AttributeGet<ushort>("height", false); sAspect = cXmlNodeChild.AttributeValueGet("pixel_aspect_ratio", false); if (0 == w || 0 == h) cTemplate.stScaleVideo = Area.stEmpty; else cTemplate.stScaleVideo = new Area(x, y, w, h); if (null != sAspect) cTemplate.nPixelAspectRatio = float.Parse(sAspect.Replace('.', ',')); } if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("offsets", false))) cTemplate.aOffsets = GetOffsets(cXmlNodeChild.NodesGet("offset")); if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("conflicts", false))) cTemplate.aConflicts = GetConflicts(cXmlNodeChild.NodesGet("conflict")); if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("preset_parameters", false))) cTemplate.aParameters = GetParameters(cXmlNodeChild.NodesGet("parameters")); if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("player_parameters", false))) cTemplate.aParameters = GetPlayerParameters(cXmlNodeChild.NodesGet("parameters")); aTemplates.Add(cTemplate); } _cClientSCR.aTemplates = aTemplates.ToArray(); #endregion XmlNode cXmlNodeAutomation = cXmlNodeClient.NodeGet("automation", false); sClipStartStopAutomationFile = cXmlNodeAutomation.AttributeValueGet("file", false); nFrameDuration_ms = cXmlNodeAutomation.AttributeGet<int>("frame_ms", false); nStopOffset = cXmlNodeAutomation.AttributeGet<int>("stop_offset", false); XmlNode cXmlNodeOthers = cXmlNodeClient.NodeGet("others", false); nQueuesCompensation = cXmlNodeOthers.AttributeGet<int>("queues_compensation", false); sPlayerLogFolder = cXmlNodeOthers.AttributeValueGet("player_log", false); } }