Пример #1
0
        void loadPlans()
        {
            var plans = from e in doc.Element("Shared")?.Descendants("Plan")
                        select e;

            int planIndex = 0;

            foreach (var p in plans)
            {
                planIndex++;
                var planName     = p.Attribute("Name")?.Value;
                var startTimeout = X.getDoubleAttr(p, "StartTimeout", -1, true);

                var apps = (from e in p.Descendants("App")
                            select readAppElement(e)).ToList();

                if (string.IsNullOrEmpty(planName))
                {
                    throw new ConfigurationErrorException($"Missing plan name in plan #{planIndex}");
                }

                var groups = p.Attribute("Groups")?.Value ?? string.Empty;

                var applyOnStart = X.getBoolAttr(p, "ApplyOnStart", false, true);

                var applyOnSelect = X.getBoolAttr(p, "ApplyOnSelect", false, true);

                // check if everything is valid
                int index = 1;
                foreach (var a in apps)
                {
                    a.PlanName = planName;

                    if (string.IsNullOrEmpty(a.Id.AppId) || string.IsNullOrEmpty(a.Id.MachineId))
                    {
                        throw new ConfigurationErrorException(string.Format("App #{0} in plan '{1}' not having valid AppTupleId", index, planName));
                    }

                    if (a.ExeFullPath == null)
                    {
                        throw new ConfigurationErrorException(string.Format("App #{0} in plan '{1}' not having valid ExeFullPath", index, planName));
                    }

                    index++;
                }

                cfg.Plans.Add(
                    new PlanDef()
                {
                    Name          = planName,
                    AppDefs       = apps,
                    StartTimeout  = startTimeout,
                    Groups        = groups,
                    ApplyOnStart  = applyOnStart,
                    ApplyOnSelect = applyOnSelect
                }
                    );
            }
        }
Пример #2
0
        void parseXml()
        {
            XElement?xml = null;

            if (!String.IsNullOrEmpty(_appDef.RestarterXml))
            {
                var rootedXmlString = String.Format("<root>{0}</root>", _appDef.RestarterXml);
                var xmlRoot         = XElement.Parse(rootedXmlString);
                xml = xmlRoot.Element("Restarter");
            }

            if (xml == null)
            {
                return;
            }

            RESTART_DELAY = X.getDoubleAttr(xml, "delay", RESTART_DELAY, true);
            MAX_TRIES     = X.getIntAttr(xml, "maxTries", MAX_TRIES, true);
        }
Пример #3
0
        //class KSI_Ctrl : SoftKillAction
        //{
        //    public KSI_Ctrl( XElement xel ) : base(xel) {}
        //}

        void parseXml()
        {
            XElement?xml = null;

            if (!String.IsNullOrEmpty(_appDef.SoftKillXml))
            {
                var rootedXmlString = String.Format("<root>{0}</root>", _appDef.SoftKillXml);
                var xmlRoot         = XElement.Parse(rootedXmlString);
                xml = xmlRoot.Element("SoftKill");
            }

            if (xml == null)
            {
                return;
            }

            foreach (var elem in xml.Descendants())
            {
                double timeout = X.getDoubleAttr(elem, "timeout", -1, true);

                string?        actionName = elem.Name?.ToString();
                SoftKillAction?ksi        = actionName switch
                {
                    "Keys" => new KSI_Keys(elem),
                    "Close" => new KSI_Close(elem),
                    //"Ctrl" => new KSI_Ctrl( elem ),
                    _ => null,
                };

                if (ksi != null)
                {
                    _softKillSeq.Add(ksi);
                }
                else
                {
                    log.ErrorFormat("Unsuported SoftKill action '{0}'", actionName);
                }
            }
        }
Пример #4
0
 public SoftKillAction(XElement?elem)
 {
     xel     = elem;
     timeout = X.getDoubleAttr(elem, "timeout", -1, true);
 }