Esempio n. 1
0
        public List <CTask> GetTemplateTasks(IWebHostEnvironment hstEnv, CStat.Models.CStatContext context, CTask tmpl, List <Event> events, DateRange lim)
        {
            List <CTask> taskList = new List <CTask>();

            if (tmpl.GetDueDates(events, out List <DateTimeEv> dueDateEvs, lim))
            {
                foreach (var dueDateEv in dueDateEvs)
                {
                    // Create new task and add it to the list
                    CTask task = new CTask();
                    task.ParentTaskId      = tmpl.Id;
                    task.Type              = 0;
                    task.Description       = tmpl.Description;
                    task.PlanLink          = tmpl.PlanLink;
                    task.EstimatedManHours = tmpl.EstimatedManHours;
                    task.Id                = 0;
                    task.PersonId          = tmpl.PersonId;
                    task.TotalCost         = tmpl.TotalCost;
                    task.EstimatedDoneDate = new DateTime(1900, 1, 1);
                    task.CommittedCost     = 0;
                    task.DueDate           = dueDateEv.dt;
                    task.EventId           = dueDateEv.eventID;
                    task.SetTaskStatus(CTask.eTaskStatus.Not_Started, CTask.eTaskStatus.Unknown, 0);
                    task.Priority       = (int)tmpl.Priority;
                    task.RequiredSkills = tmpl.RequiredSkills;
                    taskList.Add(task);
                }
            }

            return(taskList);
        }
Esempio n. 2
0
 public Index1Model(CStat.Models.CStatContext context, IWebHostEnvironment hostEnv, IConfiguration config, UserManager <CStatUser> userManager)
 {
     _context     = context;
     _hostEnv     = hostEnv;
     _userManager = userManager;
     _config      = config;
     CSSettings.GetCSSettings(config, userManager); // prime settings.
 }
Esempio n. 3
0
 public EquipRptModel(CStat.Models.CStatContext context, IWebHostEnvironment hostEnv, IConfiguration config, UserManager <CStatUser> userManager)
 {
     _context = context;
     _hostEnv = hostEnv;
     _ardMgr  = new ArdMgr(_hostEnv, _config, userManager);
     _config  = config;
     Settings = CSSettings.GetCSSettings(_config, userManager);
     _pMgr    = new PropaneMgr(_hostEnv, _config, userManager);
 }
Esempio n. 4
0
 public CreateModel(CStat.Models.CStatContext context, IWebHostEnvironment hstEnv, IConfiguration config, UserManager <CStatUser> userManager)
 {
     _context     = context;
     hostEnv      = hstEnv;
     _config      = config;
     _userManager = userManager;
     taskData     = new TaskData();
     task         = new CTask();
 }
Esempio n. 5
0
 public CSProcService(ILogger <CSProcService> logger, CStat.Models.CStatContext context, IConfiguration configuration, IWebHostEnvironment hostEnv, UserManager <CStatUser> userManager)
 {
     _hostEnv       = hostEnv;
     _logger        = logger;
     _context       = context;
     _configuration = configuration;
     _userManager   = userManager;
     _csSettings    = CSSettings.GetCSSettings(_configuration, userManager);
 }
Esempio n. 6
0
 public IndexInvModel(IWebHostEnvironment hostEnv, CStat.Models.CStatContext context, IConfiguration configuration, IHttpContextAccessor httpCA, UserManager <CStatUser> userManager)
 {
     _context       = context;
     _configuration = configuration;
     _hostEnv       = hostEnv;
     _userManager   = userManager;
     _httpCA        = httpCA;
     _csSettings    = CSSettings.GetCSSettings(_configuration, userManager);
     var user = _csSettings.GetUser(_httpCA.HttpContext.User.Identity.Name);
 }
Esempio n. 7
0
        public bool SetPersonIDByEmail(CStat.Models.CStatContext context)
        {
            var           lcEMail = !string.IsNullOrEmpty(EMail) ? EMail.ToLower() : "EMPTY";
            List <Person> pList   = context.Person.Where(p => !string.IsNullOrEmpty(p.Email) && lcEMail == p.Email.ToLower()).ToList <Person>();

            if (pList.Count == 1)
            {
                pid = pList[0].Id;
                return(true);
            }
            return(false);
        }
Esempio n. 8
0
        public CUserModel(CStat.Models.CStatContext context, IWebHostEnvironment hostEnv, IHttpContextAccessor httpContextAccessor, IConfiguration config, UserManager <CStatUser> userManager)
        {
            _context     = context;
            _hostEnv     = hostEnv;
            _config      = config;
            _userManager = userManager;
            _csSettings  = CSSettings.GetCSSettings(_config, _userManager);
            string UserId = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Subject.Name;

            _curUser = _csSettings.GetUser(UserId);
            _curUser.SetPersonIDByEmail(context);
        }
Esempio n. 9
0
        public static bool MayNeedItem(CStat.Models.CStatContext context, InventoryItem invIt, OrderedEvents ordEvs = null)
        {
            if (!invIt.CurrentStock.HasValue || !invIt.Date.HasValue || !invIt.UnitsPerDay.HasValue || !invIt.ReorderThreshold.HasValue)
            {
                return(false);
            }

            // Get the Event Days since last
            if (ordEvs == null)
            {
                ordEvs = new OrderedEvents(context);
            }
            double totalDays = ordEvs.getElapsedEventDays(invIt.Date.Value);

            return((invIt.CurrentStock.Value - (invIt.UnitsPerDay.Value * totalDays)) <= invIt.ReorderThreshold.Value);
        }
Esempio n. 10
0
        public IndexModel(CStat.Models.CStatContext context, IWebHostEnvironment hstEnv, IConfiguration config, IHttpContextAccessor httpCA, UserManager <CStatUser> userManager)
        {
            _context = context;
            hostEnv  = hstEnv;
            var    csSettings = CSSettings.GetCSSettings(config, userManager);
            string email      = httpCA.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Subject.Name;

            if (email == null)
            {
                email = httpCA.HttpContext.User.Identity.Name;
            }
            _userSettings = csSettings.GetUser(email);
            if (_userSettings != null)
            {
                _userSettings.SetPersonIDByEmail(context);
            }
            Person person = (email != null) ? context.Person.FirstOrDefault(m => m.Email == email) : null;

            _personId    = (person != null) ? person.Id : -1;
            _personRoles = ((person != null) && (person.Roles.HasValue)) ? person.Roles.Value : 0;
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        public static int RemoveChangedEventTasks(CStat.Models.CStatContext context, Event newEvent)
        {
            int NumDeleted = 0;
            var oldEvent   = context.Event.AsNoTracking().FirstOrDefaultAsync(e => e.Id == newEvent.Id).Result;

            if ((oldEvent != null) && ((newEvent.StartTime != oldEvent.StartTime) || (newEvent.EndTime != oldEvent.EndTime)))
            {
                var evTasks = context.Task.Where(t => (t.EventId.HasValue && t.EventId == newEvent.Id));
                foreach (var t in evTasks)
                {
                    try
                    {
                        context.Task.Remove(t);
                        context.SaveChangesAsync();
                        ++NumDeleted;
                    }
                    catch
                    {
                        // TBD : log these errors
                    }
                }
            }
            return(NumDeleted);
        }
Esempio n. 13
0
 public FindModel(CStat.Models.CStatContext context)
 {
     _context = context;
 }
Esempio n. 14
0
 public IndexModel(CStat.Models.CStatContext context)
 {
     _context = context;
 }
Esempio n. 15
0
 public DetailsModel(CStat.Models.CStatContext context)
 {
     _context = context;
 }
Esempio n. 16
0
 public DeleteModel(CStat.Models.CStatContext context, IWebHostEnvironment hostEnv, IConfiguration configuration)
 {
     _context       = context;
     _configuration = configuration;
     _hostEnv       = hostEnv;
 }
Esempio n. 17
0
 public CreateModel(CStat.Models.CStatContext context)
 {
     _context = context;
 }
Esempio n. 18
0
 public IndexModel(CStat.Models.CStatContext context)
 {
     _context = context;
     Calendar = new List <string>();
     ECList   = new List <KeyValuePair <int, string> >();
 }
Esempio n. 19
0
 public CreateInvModel(CStat.Models.CStatContext context, IWebHostEnvironment hstEnv)
 {
     hostEnv  = hstEnv;
     _context = context;
 }
Esempio n. 20
0
 public EditModel(CStat.Models.CStatContext context)
 {
     _context = context;
 }
Esempio n. 21
0
 public AutoGen(CStat.Models.CStatContext context)
 {
     _context = context;
 }
Esempio n. 22
0
 public CreateModel(CStat.Models.CStatContext context)
 {
     _context = context;
     _Person  = new Person();
 }
Esempio n. 23
0
        public EquipModel(CStat.Models.CStatContext context, IWebHostEnvironment hostEnv, IConfiguration config, UserManager <CStatUser> userManager)
        {
            _context = context;
            _hostEnv = hostEnv;
            _ardMgr  = new ArdMgr(_hostEnv, _config, userManager);
            _config  = config;
            Settings = CSSettings.GetCSSettings(_config, userManager);
            PropaneMgr pmgr = new PropaneMgr(_hostEnv, _config, userManager);

            _ar = _ardMgr.GetLast();
            if (_ar == null)
            {
                _ar = new ArdRecord(PropMgr.NotSet, PropMgr.NotSet, PropMgr.NotSet, 0, PropMgr.ESTNow);
            }
            _pl = pmgr.GetTUTank();
            if (_pl == null)
            {
                _pl = new PropaneLevel(0, PropMgr.ESTNow, PropMgr.NotSet);
            }

            ActiveEqHistory = new List <List <double> >();
            int NumActive = Settings.ActiveEquip.Count;

            if (NumActive > 0)
            {
                List <ArdRecord> ardHist = _ardMgr.GetAll();
                if (ardHist == null)
                {
                    ardHist = new List <ArdRecord>();
                }
                List <PropaneLevel> propaneHist = pmgr.GetAll(30);
                if (propaneHist == null)
                {
                    propaneHist = new List <PropaneLevel>();
                }

                // Ensure latest is at end of list
                int ahCount = ardHist.Count;
                if (ahCount > 0)
                {
                    if (ardHist[ahCount - 1].TimeStamp != _ar.TimeStamp)
                    {
                        if (ardHist[ahCount - 2].TimeStamp == _ar.TimeStamp)
                        {
                            _ar = _ardMgr.GetLast(); // get latest
                        }
                        else
                        {
                            ardHist.Add(_ar); // set latest
                            if (ahCount >= ArdMgr.MAX_USE_ARS)
                            {
                                ardHist.RemoveAt(0);
                            }
                        }
                    }
                }
                int plCount = propaneHist.Count;
                if (plCount > 0)
                {
                    if (propaneHist[plCount - 1].ReadingTime != _pl.ReadingTime)
                    {
                        if (propaneHist[plCount - 2].ReadingTime == _pl.ReadingTime)
                        {
                            _pl = pmgr.GetTUTank(); // get latest
                        }
                        else
                        {
                            propaneHist.Add(_pl); // set latest
                            if (plCount >= PropaneMgr.MAX_USE_PLS)
                            {
                                propaneHist.RemoveAt(0);
                            }
                        }
                    }
                }

                foreach (var ar in Settings.ActiveEquip)
                {
                    List <double> dlist;
                    dlist = ar.PropName switch
                    {
                        "freezerTemp" => ardHist.Select(a => a.FreezerTempF).Reverse().ToList(),
                        "frigTemp" => ardHist.Select(a => a.FridgeTempF).Reverse().ToList(),
                        "kitchTemp" => ardHist.Select(a => a.KitchTempF).Reverse().ToList(),
                        "propaneTank" => propaneHist.Select(p => p.LevelPct).Reverse().ToList(),
                        "waterPres" => ardHist.Select(a => a.WaterPress).Reverse().ToList(),
                        _ => new List <double>()
                    };
                    ActiveEqHistory.Add(dlist);
                }
            }
        }
Esempio n. 24
0
 public EditModel(IWebHostEnvironment hostEnv, CStat.Models.CStatContext context)
 {
     _context = context;
     _hostEnv = hostEnv;
 }
Esempio n. 25
0
 public CreateItemsModel(IWebHostEnvironment hstEnv, CStat.Models.CStatContext context)
 {
     _context = context;
     hostEnv  = hstEnv;
 }
Esempio n. 26
0
 public DeleteModel(CStat.Models.CStatContext context)
 {
     _context = context;
 }
Esempio n. 27
0
 public OrderedEvents(CStat.Models.CStatContext ctx)
 {
     _context = ctx;
     isSet    = false;
 }