示例#1
0
        public CSUser SetUser(string userName, CSUser modUser)
        {
            if (UserSettings == null)
            {
                return(null);
            }
            int i = 0;

            for (i = 0; i < UserSettings.Count; ++i)
            {
                if (UserSettings[i].EMail == userName)
                {
                    var SavedPhone = UserSettings[i].PhoneNum;
                    UserSettings[i] = modUser; // Replace existing user
                    if (string.IsNullOrEmpty(UserSettings[i].PhoneNum))
                    {
                        UserSettings[i].PhoneNum = SavedPhone;
                    }
                    break;
                }
            }
            if (i == UserSettings.Count)
            {
                UserSettings.Add(modUser); // Add new user
            }
            return(null);
        }
示例#2
0
文件: CmdMgr.cs 项目: ronripp/CStat
        public CmdMgr(CStat.Models.CStatContext context, CSSettings cset, IWebHostEnvironment hostEnv, IConfiguration config, UserManager <CStatUser> userManager, CSUser curUser)
        {
            _context     = context;
            _csSettings  = cset;
            _hostEnv     = hostEnv;
            _config      = config;
            _userManager = userManager;
            _curUser     = curUser;

            _srcDelegateDict.Add(CmdSource.MENU, HandleMenu);
            _srcDelegateDict.Add(CmdSource.INVENTORY, HandleInventory);
            _srcDelegateDict.Add(CmdSource.TASK, HandleTasks);
            _srcDelegateDict.Add(CmdSource.PERSON, HandlePeople);
            _srcDelegateDict.Add(CmdSource.TRUSTEE, HandlePeople);
            _srcDelegateDict.Add(CmdSource.EC, HandlePeople);

            _srcDelegateDict.Add(CmdSource.DOC, HandleDocs);
            _srcDelegateDict.Add(CmdSource.REQ, HandleDocs);
            _srcDelegateDict.Add(CmdSource.BYLAWS, HandleDocs);

            _srcDelegateDict.Add(CmdSource.EQUIP, HandleEquip);
            _srcDelegateDict.Add(CmdSource.PROPANE, HandleEquip);
            _srcDelegateDict.Add(CmdSource.FRIDGE, HandleEquip);
            _srcDelegateDict.Add(CmdSource.FREEZER, HandleEquip);
            _srcDelegateDict.Add(CmdSource.PRESSURE, HandleEquip);
            _srcDelegateDict.Add(CmdSource.ELECTRIC, HandleEquip);
            _srcDelegateDict.Add(CmdSource.CAMERA, HandleEquip);

            _srcDelegateDict.Add(CmdSource.INTERNET, HandleBiz);
            _srcDelegateDict.Add(CmdSource.TRASH, HandleBiz);
            _srcDelegateDict.Add(CmdSource.NYSDOH, HandleBiz);

            _srcDelegateDict.Add(CmdSource.EVENT, HandleEvents);
            _srcDelegateDict.Add(CmdSource.ATTENDANCE, HandleAttendance);
            _srcDelegateDict.Add(CmdSource.URGENCY, HandleUrgency);
            _srcDelegateDict.Add(CmdSource.CHURCH, HandleChurch);
        }
示例#3
0
        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;
        }