Exemplo n.º 1
0
        private void MainMenuProcessData(ThemeListsMenu currentMenu, UiRequest request)
        {
            var userId = request.UserId;

            if (request.IsBackward)
            {
                usersDailyTasks[userId] = null;
            }
            else if (!usersDailyTasks.ContainsKey(userId) || usersDailyTasks[userId] == null)
            {
                var datesCount   = GetUsersDateTimesCount(userId);
                var dates        = GetUsersDateTimes(userId, datesCount);
                var tasksOnDates = dates
                                   .Select(d =>
                {
                    var tasksCount = GetUsersTasksCountByDate(userId, d);
                    return(Tuple.Create(d, GetAllTasksOnDate(userId, d, tasksCount)));
                })
                                   .ToList();
                usersDailyTasks[userId]     = new DailyTasks(tasksOnDates);
                mainMenu.Options[0].Options = usersDailyTasks[userId]
                                              .GetAllDateTimes()
                                              .Select(d => new ThemeListsMenu()
                {
                    MenuName      = d.ToString(),
                    MenuType      = MenuType.Menu,
                    Options       = null,
                    PreviousMenu  = mainMenu.Options[0],
                    ProcessData   = ChooseTaskNumberProcessData,
                    RequestFormat = ExpectingRequestFormat.Number
                })
                                              .ToList();
            }
        }
        // GET: DailyTasks/Edit/5
        public ActionResult Edit(int?id, string name, string prod)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DailyTasks dailyTasks = db.dailyTasks.Find(id);

            if (dailyTasks == null)
            {
                return(HttpNotFound());
            }

            ApplicationDbContext cont = new ApplicationDbContext();

            var task  = new List <string>();
            var Query = from q in cont.Users
                        where q.businessname == "Employee"
                        orderby q.fullname
                        select q.fullname;

            task.AddRange(Query.Distinct());
            ViewBag.name = new SelectList(task);

            var task2  = new List <string>();
            var Query2 = from q in cont.Products orderby q.ProductId select q.ProductName;

            task2.AddRange(Query2);
            ViewBag.prod = new SelectList(task2);

            return(View(dailyTasks));
        }
        public ActionResult Create([Bind(Include = "TaskId,ProductId,Product,Quantity,Name,Date,Stime,Etime,Complete")] DailyTasks dailyTasks, string name, string prod)
        {
            if (ModelState.IsValid)
            {
                ApplicationDbContext cont = new ApplicationDbContext();

                var task  = new List <string>();
                var Query = from q in cont.Users
                            where q.businessname == "Employee"
                            orderby q.fullname
                            select q.fullname;
                task.AddRange(Query.Distinct());
                ViewBag.name = new SelectList(task);

                var List2  = new List <string>();
                var Query2 = from q in cont.Products orderby q.ProductId select q.ProductName;
                List2.AddRange(Query2);
                ViewBag.prod = new SelectList(List2);

                var ss = cont.Products.ToList().Find(x => x.ProductName == prod);

                dailyTasks.Name      = name;
                dailyTasks.Product   = prod;
                dailyTasks.ProductId = ss.ProductId;
                dailyTasks.Complete  = false;
                dailyTasks.done      = false;

                db.dailyTasks.Add(dailyTasks);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dailyTasks));
        }
        public ActionResult DeleteConfirmed2(int id)
        {
            DailyTasks dailyTasks = db.dailyTasks.Find(id);

            db.dailyTasks.Remove(dailyTasks);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
        private void RemoveTasks(DailyTasksResource dtResource, DailyTasks dtDb)
        {
            var removed = dtDb.Tasks.Where(x => !dtResource.Tasks.Any(y => y.Id == x.Id));

            foreach (var task in removed.ToList())
            {
                context.Tasks.Remove(task);
            }
        }
Exemplo n.º 6
0
        protected override bool Start(params object[] parameters)
        {
            ICommonCompomentsFactory factory = (ICommonCompomentsFactory)parameters[0];

            //if (ran) throw new InvalidOperationException("Initializing only allowed at program start!");
            if (ran)
            {
                return(false);
            }
            ran = true;

            Config.Initialize();
            CommonComponent.Current.Config = Config.Current;
            StopTransfers.WalkingSpeed     = () => PlanSettingsModel.WalkingSpeedInMps;
            factory.InitializeTools();

            InitializeFields();
            //StopPicker.LoadItemSource();

            //Alkalmazás első indításakor hívódik meg
            if (AppFields.VersionId == null)
            {
                FirstRun = true;
            }
            //verzió kezelés, meghívódik verzió váltáskor
            if (AppFields.VersionId != CommonComponent.Current.Config.Version)
            {
                //Reset();
                AppFields.VersionId            = CommonComponent.Current.Config.Version;
                AppFields.ForceUpdate          = true;
                AppFields.PlanningTrialExpired = false;
                factory.StopBackgroundAgent();
            }
            try
            {
                //adatbázisok betöltése
                CommonComponent.Current.UB = factory.CreateUserBase();
                //előzmények öregítése, itt csinálom gyorsan, hogy ne legyenek konkurens tranzakciók, amik a model teljes betöltésének a hatására fog indulni
                DailyTasks.Subscribe(CommonComponent.Current.UB.History.OldenHistory);
                DailyTasks.DoAll();
                //majd a statikus adatbázist is betöltöm
                CommonComponent.Current.LoadTransitBase();
            }
            catch (Exception ex)
            {
                Reset();
                throw;
            }
            //csempe frissítő BackgroundAgent indítása
            factory.StartBackgroundAgent();

            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets or sets the daily task for the passed date
        /// </summary>
        /// <param name="dateTime">The date you want to get the daily task for</param>
        /// <returns>The daily task for that day</returns>
        private TimeTrackerTask GetDailyTask(DateTime dateTime)
        {
            var foundTask = DailyTasks.FirstOrDefault(x => x.TaskName == dateTime.Date.ToShortDateString());

            if (foundTask == null)
            {
                foundTask = new TimeTrackerTask()
                {
                    TaskName = dateTime.Date.ToShortDateString()
                };
                DailyTasks.Add(foundTask);
            }
            return(foundTask);
        }
        // GET: DailyTasks/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DailyTasks dailyTasks = db.dailyTasks.Find(id);

            if (dailyTasks == null)
            {
                return(HttpNotFound());
            }
            return(View(dailyTasks));
        }
Exemplo n.º 9
0
        public object Any(DailyTasks request)
        {
            return(new DailyTasksResponse
            {
                TechStackFavCountRowsUpdated = Db.ExecuteSql(@"UPDATE technology_stack SET fav_count=fav.count 
                    FROM (SELECT technology_stack_id, Count(*) AS Count FROM user_favorite_technology_stack GROUP BY technology_stack_id) as fav
                    WHERE id = fav.technology_stack_id"),

                TechnologyFavCountRowsUpdated = Db.ExecuteSql(@"UPDATE technology SET fav_count=fav.count 
                    FROM (SELECT technology_id, Count(*) AS Count FROM user_favorite_technology GROUP BY technology_id) as fav
                    WHERE id = fav.technology_id"),

                TechStackViewCountRowsUpdated = Db.ExecuteSql(@"UPDATE technology_stack SET view_count=v.view_count
                    FROM (SELECT ref_slug, view_count FROM page_stats WHERE ref_type='stack') AS v
                    WHERE v.ref_slug = slug"),

                TechnologyViewCountRowsUpdated = Db.ExecuteSql(@"UPDATE technology SET view_count=v.view_count
                    FROM (SELECT ref_slug, view_count FROM page_stats WHERE ref_type='tech') AS v
                    WHERE v.ref_slug = slug"),

                UserTechStackCountRowsUpdated = Db.ExecuteSql(@"UPDATE user_activity SET tech_stacks_count=t.total
                    FROM (SELECT owner_id, COUNT(*) as total FROM technology_stack GROUP BY owner_id) AS t
                    WHERE t.owner_id::int = id"),

                UserTechnologyCountRowsUpdated = Db.ExecuteSql(@"UPDATE user_activity SET technology_count=t.total
                    FROM (SELECT owner_id, COUNT(*) as total FROM technology GROUP BY owner_id) AS t
                    WHERE t.owner_id::int = id"),

                UserCommentCountRowsUpdated = Db.ExecuteSql(@"UPDATE user_activity SET comments_count=t.total
                    FROM (SELECT user_id, COUNT(*) as total FROM post_comment GROUP BY user_id) AS t
                    WHERE t.user_id = id"),

                UserUpVotesRowsUpdated = Db.ExecuteSql(@"UPDATE user_activity SET up_votes=t.total
                    FROM (SELECT user_id, SUM(up_votes) as total FROM post GROUP BY user_id) AS t
                    WHERE t.user_id = id"),

                UserDownVotesRowsUpdated = Db.ExecuteSql(@"UPDATE user_activity SET down_votes=t.total
                    FROM (SELECT user_id, SUM(down_votes) as total FROM post GROUP BY user_id) AS t
                    WHERE t.user_id = id"),

                UserReportCountRowsUpdated = Db.ExecuteSql(@"UPDATE user_activity SET report_count=t.report_count
                    FROM (SELECT id as user_id, 
                                 (select count(*) from post_report where user_id = c.id) + 
                                 (select count(*) from post_comment where user_id = c.id and report_user_ids != null) as report_count 
                            FROM custom_user_auth c) t
                     WHERE t.user_id = id")
            });
        }
Exemplo n.º 10
0
        public async Task <AddTaskResponse> Handle(AddTaskCommand request, CancellationToken cancellationToken)
        {
            DailyTasks dailyTasks = new DailyTasks
            {
                AddedDate     = DateTime.UtcNow,
                Priority      = request.Priority,
                TaskEndTime   = request.TaskEndTime,
                TaskStartTime = request.TaskStartTime,
                Title         = request.Title,
                Owner         = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Email).Value
            };

            await _taskService.AddTask(dailyTasks);

            return(new AddTaskResponse
            {
                Message = "New task has successfully added"
            });
        }
        public ActionResult EditEmp([Bind(Include = "TaskId,ProductId,Product,Quantity,Name,Date,Stime,Etime,Complete")] DailyTasks dailyTasks)
        {
            if (ModelState.IsValid)
            {
                Products pro = db.Products.ToList().Find(x => x.ProductId == dailyTasks.ProductId);

                var now  = DateTime.Now;
                var time = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0);
                var t    = time.TimeOfDay;

                //Points obj = new Points();
                //DateTime today = DateTime.Today;
                //DateTime time1 = DateTime.Now;

                //DateTime t2 = Convert.ToDateTime(t);
                //DateTime t1 = dailyTasks.Etime;
                //Points name1 = db.points.ToList().Find(x => x.Name == dailyTasks.Name);

                //int i = DateTime.Compare(t1, t2);
                //if (name1 != null)
                //{
                //    if (i < 0)
                //    {
                //        name1.EmPoints = name1.EmPoints + 1;

                //    }
                //    if (i == 0)
                //    {
                //        name1.EmPoints = name1.EmPoints + 0;

                //    }
                //    if (i > 0)
                //    {
                //        name1.EmPoints = name1.EmPoints - 1;

                //    }


                //}
                //else
                //{
                //    obj.Name = dailyTasks.Name;

                //    if (i < 0)
                //    {
                //        obj.EmPoints = obj.EmPoints + 1;
                //    }
                //    if (i == 0)
                //    {
                //        obj.EmPoints = obj.EmPoints + 0;
                //    }
                //    if (i > 0)
                //    {
                //        obj.EmPoints = obj.EmPoints - 1;
                //    }
                //}

                if (dailyTasks.Complete == true)
                {
                    pro.qtyh = pro.qtyh + dailyTasks.Quantity;
                }

                dailyTasks.CompTime        = t.ToString();
                db.Entry(dailyTasks).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index2"));
            }
            return(View(dailyTasks));
        }
        public ActionResult Edit([Bind(Include = "TaskId,ProductId,Product,Quantity,Name,Date,Stime,Etime,Complete")] DailyTasks dailyTasks, string name, string prod)
        {
            if (ModelState.IsValid)
            {
                ApplicationDbContext cont = new ApplicationDbContext();

                var task  = new List <string>();
                var Query = from q in cont.Users
                            where q.businessname == "Employee"
                            orderby q.fullname
                            select q.fullname;
                task.AddRange(Query.Distinct());
                ViewBag.name = new SelectList(task);

                var List2  = new List <string>();
                var Query2 = from q in cont.Products orderby q.ProductId select q.ProductName;
                List2.AddRange(Query2);
                ViewBag.prod = new SelectList(List2);

                var ss = cont.Products.ToList().Find(x => x.ProductName == prod);

                dailyTasks.Name      = name;
                dailyTasks.Product   = prod;
                dailyTasks.ProductId = ss.ProductId;

                Products pro = db.Products.ToList().Find(x => x.ProductId == dailyTasks.ProductId);

                ApplicationDbContext db2 = new ApplicationDbContext();
                var daily = db2.dailyTasks.ToList().Find(x => x.TaskId == dailyTasks.TaskId && x.done == false);

                ApplicationDbContext db3 = new ApplicationDbContext();
                var current = db3.dailyTasks.ToList().Find(x => x.TaskId == dailyTasks.TaskId);

                //Points obj = new Points();
                //DateTime today = DateTime.Today;
                //DateTime time1 = DateTime.Now;

                //DateTime t2 = Convert.ToDateTime(t);
                //DateTime t1 = dailyTasks.Etime;
                //Points name1 = db.points.ToList().Find(x => x.Name == dailyTasks.Name);

                //int i = DateTime.Compare(t1, t2);
                //if (name1 != null)
                //{
                //    if (i < 0)
                //    {
                //        name1.EmPoints = name1.EmPoints + 1;

                //    }
                //    if (i == 0)
                //    {
                //        name1.EmPoints = name1.EmPoints + 0;

                //    }
                //    if (i > 0)
                //    {
                //        name1.EmPoints = name1.EmPoints - 1;

                //    }


                //}
                //else
                //{
                //    obj.Name = dailyTasks.Name;

                //    if (i < 0)
                //    {
                //        obj.EmPoints = obj.EmPoints + 1;
                //    }
                //    if (i == 0)
                //    {
                //        obj.EmPoints = obj.EmPoints + 0;
                //    }
                //    if (i > 0)
                //    {
                //        obj.EmPoints = obj.EmPoints - 1;
                //    }
                //}

                if (daily != null)
                {
                    if (dailyTasks.Complete == true)
                    {
                        pro.qtyh        = pro.qtyh + dailyTasks.Quantity;
                        dailyTasks.done = true;
                    }
                }
                else if (dailyTasks.Complete == true)
                {
                    int dif = 0;

                    if (current.Quantity > dailyTasks.Quantity)
                    {
                        dif      = dif + (current.Quantity - dailyTasks.Quantity);
                        pro.qtyh = pro.qtyh - dif;
                    }
                    else if (current.Quantity < dailyTasks.Quantity)
                    {
                        dif      = dif + (dailyTasks.Quantity - current.Quantity);
                        pro.qtyh = pro.qtyh + dif;
                    }
                    else if (current.Quantity == dailyTasks.Quantity)
                    {
                        pro.qtyh = pro.qtyh;
                    }
                }

                db.Entry(dailyTasks).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(dailyTasks));
        }
 public void RemoveDailyTask(int Id)
 {
     DailyTasks.Remove(Id);
     RemoveJob(Id);
 }
Exemplo n.º 14
0
 public async Task AddTask(DailyTasks dailyTasks)
 {
     await _taskRepository.Insert(dailyTasks);
 }