コード例 #1
0
ファイル: CSSettings.cs プロジェクト: ronripp/CStat
        public static bool GetEquipLists(IConfiguration config, out List <EquipProp> allEquipProps, out List <EquipProp> activeEquipProps)
        {
            var eqProps = config.GetSection("CSSettings:EquipProps").GetChildren();

            allEquipProps    = new List <EquipProp>();
            activeEquipProps = new List <EquipProp>();
            foreach (var e in eqProps)
            {
                EquipProp eqProp = new EquipProp();
                eqProp.Active        = e.GetValue <bool>("Active");
                eqProp.Title         = e.GetValue <string>("Title");
                eqProp.PropName      = e.GetValue <string>("PropName");
                eqProp.EquipUnits    = e.GetValue <EquipUnitsType>("EquipUnits"); // TBD enum with stable, supported api
                eqProp.ChartBottom   = e.GetValue <double>("ChartBottom");
                eqProp.ChartTop      = e.GetValue <double>("ChartTop");
                eqProp.RedBottom     = e.GetValue <double>("RedBottom");
                eqProp.RedTop        = e.GetValue <double>("RedTop");
                eqProp.GreenBottom   = e.GetValue <double>("GreenBottom");
                eqProp.GreenTop      = e.GetValue <double>("GreenTop");
                eqProp.MinsPerSample = e.GetValue <double>("MinsPerSample");
                var atts = e.GetValue <string>("Attributes");
                eqProp.Attributes = atts ?? "";
                if (eqProp.Active)
                {
                    activeEquipProps.Add(eqProp);
                }
                allEquipProps.Add(eqProp);
            }
            return(eqProps.Count() > 0);
        }
コード例 #2
0
ファイル: CSSettings.cs プロジェクト: ronripp/CStat
        public static string GetColor(List <EquipProp> equipProps, string propName, ArdRecord ar, PropaneLevel pl, bool returnClass = true)
        {
            string ltPropName = propName.ToLower().Trim();

            if (ltPropName == "all")
            {
                return(GetEqColor(equipProps, null, ar, pl, returnClass));
            }
            EquipProp ep = equipProps.Find(e => e.PropName.ToLower().Trim() == ltPropName);

            if (ep != null)
            {
                return(GetEqColor(equipProps, ep, ar, pl, returnClass));
            }
            return((returnClass) ? "greenClass" : CSSettings.green);
        }
コード例 #3
0
ファイル: CSSettings.cs プロジェクト: ronripp/CStat
        public void initialize()
        {
            List <CStatUser> Users = GetUsers(_userManager);

            UserSettings = Users.Where(u => u.EmailConfirmed == true).Select(c =>
            {
                var cu      = new CSUser();
                cu.EMail    = c.UserName;
                cu.PhoneNum = c.PhoneNumber;
                return(cu);
            }).ToList();
            var csect = _config.GetSection("CSSettings");

            LastStockUpdate = csect.GetValue <DateTime>("LastStockUpdate");
            LastTaskUpdate  = csect.GetValue <DateTime>("LastTaskUpdate");
            LastEMailRead   = csect.GetValue <DateTime>("LastEMailRead");
            var ch = _config.GetSection("CSSettings:UserSettings").GetChildren();

            foreach (var c in ch)
            {
                var email = c.GetValue <string>("EMail");
                int uidx  = UserSettings.FindIndex(u => u.EMail == email);
                if (uidx == -1)
                {
                    continue;
                }
                UserSettings[uidx].Alias         = c.GetValue <string>("Alias", GetDefAlias(UserSettings[uidx].EMail));
                UserSettings[uidx].ShowAllTasks  = c.GetValue <bool>("ShowAllTasks");
                UserSettings[uidx].SendEquipText = c.GetValue <bool>("SendEquipText");
                UserSettings[uidx].SendStockText = c.GetValue <bool>("SendStockText");
                UserSettings[uidx].SendTaskText  = c.GetValue <bool>("SendTaskText");
                UserSettings[uidx].SendEMailToo  = c.GetValue <bool>("SendEMailToo");
            }
            UserSettings.ForEach(u =>
            {
                if (string.IsNullOrEmpty(u.Alias))
                {
                    u.Alias = GetDefAlias(u.EMail);
                }
            });

            GetEquipLists(_config, out List <EquipProp> allEPs, out List <EquipProp> activeEPs);
            EquipProps  = allEPs;
            ActiveEquip = activeEPs;

            if (UserSettings.Count == 0)
            {
                CSUser u1 = new CSUser
                {
                    EMail         = "*****@*****.**",
                    ShowAllTasks  = true,
                    SendEquipText = false,
                    SendStockText = false,
                    SendTaskText  = false,
                    SendEMailToo  = false
                };
                UserSettings.Add(u1);
                CSUser u2 = new CSUser
                {
                    EMail         = "*****@*****.**",
                    ShowAllTasks  = false,
                    SendEquipText = false,
                    SendStockText = false,
                    SendTaskText  = false,
                    SendEMailToo  = false
                };
                UserSettings.Add(u2);
            }

            if (EquipProps.Count == 0)
            {
                EquipProp e1 = new EquipProp
                {
                    Active        = true,
                    Title         = "Walk-in Freezer",
                    PropName      = "freezerTemp",
                    EquipUnits    = EquipUnitsType.TemperatureF,
                    ChartBottom   = 0,
                    ChartTop      = 36,
                    RedBottom     = 0,
                    RedTop        = 30,
                    GreenBottom   = 0,
                    GreenTop      = 20,
                    MinsPerSample = 15,
                    Attributes    = ""
                };
                EquipProps.Add(e1);

                EquipProp e2 = new EquipProp
                {
                    Active        = true,
                    Title         = "Walk-in Frig.",
                    PropName      = "frigTemp",
                    EquipUnits    = EquipUnitsType.TemperatureF,
                    ChartBottom   = 30,
                    ChartTop      = 50,
                    RedBottom     = 34,
                    RedTop        = 45,
                    GreenBottom   = 36,
                    GreenTop      = 42,
                    MinsPerSample = 15,
                    Attributes    = ""
                };
                EquipProps.Add(e2);

                EquipProp e5 = new EquipProp
                {
                    Active        = true,
                    Title         = "Kitchen Temp",
                    PropName      = "kitchTemp",
                    EquipUnits    = EquipUnitsType.TemperatureF,
                    ChartBottom   = 0,
                    ChartTop      = 100,
                    RedBottom     = 50,
                    RedTop        = 95,
                    GreenBottom   = 60,
                    GreenTop      = 85,
                    MinsPerSample = 15,
                    Attributes    = ""
                };
                EquipProps.Add(e5);

                EquipProp e3 = new EquipProp
                {
                    Active        = true,
                    Title         = "Propane Tank",
                    PropName      = "propaneTank",
                    EquipUnits    = EquipUnitsType.PercentFull,
                    ChartBottom   = 0,
                    ChartTop      = 100,
                    RedBottom     = 10,
                    RedTop        = 0,
                    GreenBottom   = 20,
                    GreenTop      = 100,
                    MinsPerSample = 15,
                    Attributes    = ""
                };
                EquipProps.Add(e3);

                EquipProp e4 = new EquipProp
                {
                    Active        = true,
                    Title         = "Water Plumbing",
                    PropName      = "waterPres",
                    EquipUnits    = EquipUnitsType.PSI,
                    ChartBottom   = 0,
                    ChartTop      = 60,
                    RedBottom     = 25,
                    RedTop        = 55,
                    GreenBottom   = 35,
                    GreenTop      = 50,
                    MinsPerSample = 15,
                    Attributes    = ""
                };
                EquipProps.Add(e4);

                EquipProp e6 = new EquipProp
                {
                    Active        = false,
                    Title         = "Electric Power",
                    PropName      = "?",
                    EquipUnits    = EquipUnitsType.KWH,
                    ChartBottom   = 0,
                    ChartTop      = 100,
                    RedBottom     = 0,
                    RedTop        = 70,
                    GreenBottom   = 0,
                    GreenTop      = 50,
                    MinsPerSample = 15,
                    Attributes    = ""
                };
                EquipProps.Add(e6);
            }

            for (int i = EquipProps.Count; i < CSSettings.MAX_EQUIP; ++i)
            {
                EquipProps.Add(new EquipProp());
            }
            _isInitialized = true;
        }