public PartialViewResult ChaSubject(int w, int d, int s)
        {
            Subject         sub        = new Subject();
            ScheduleContext sc         = new ScheduleContext();
            ScheduleView    scv        = sc.GetSchedule(User.Identity.Name);
            List <string>   TimeDateSt = new List <string>();
            List <string>   TimeDateEn = new List <string>();

            if (scv.Weeks[w].Days[d].Subjects != null)
            {
                foreach (var t in scv.Weeks[w].Days[d].Subjects)
                {
                    TimeDateSt.Add(t.TimeStart.ToLocalTime().ToShortTimeString());
                    TimeDateEn.Add(t.TimeEnd.ToLocalTime().ToShortTimeString());
                }
                ;
            }
            ;
            ViewBag.TimeSt = TimeDateSt;
            ViewBag.TimeEn = TimeDateEn;
            sub            = scv.Weeks[w].Days[d].Subjects[s];
            TempData["d"]  = d;
            TempData.Keep("d");
            TempData["s"] = s;
            TempData.Keep("s");
            TempData["w"] = w;
            TempData.Keep("w");
            return(PartialView("_ChaSubjForm", sub));
        }
示例#2
0
 private static ScheduleContext GetScheduleContext(Guid sid)
 {
     using (var scope = new Core.ScopeDbContext())
     {
         var db    = scope.GetDbContext();
         var model = db.Schedules.FirstOrDefault(x => x.Id == sid && x.Status != (int)ScheduleStatus.Deleted);
         if (model != null)
         {
             ScheduleContext context = new ScheduleContext()
             {
                 Schedule = model
             };
             if (model.MetaType == (int)ScheduleMetaType.Http)
             {
                 context.HttpOption = db.ScheduleHttpOptions.FirstOrDefault(x => x.ScheduleId == sid);
             }
             context.Keepers = (from t in db.ScheduleKeepers
                                join u in db.SystemUsers on t.UserId equals u.Id
                                where t.ScheduleId == model.Id && !string.IsNullOrEmpty(u.Email)
                                select new KeyValuePair <string, string>(u.RealName, u.Email)
                                ).ToList();
             context.Children = (from c in db.ScheduleReferences
                                 join t in db.Schedules on c.ChildId equals t.Id
                                 where c.ScheduleId == model.Id && c.ChildId != model.Id
                                 select new { t.Id, t.Title }
                                 ).ToDictionary(x => x.Id, x => x.Title);
             return(context);
         }
         throw new InvalidOperationException($"不存在的任务id:{sid}");
     }
 }
示例#3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            HangfireAspNet.Use(GetHangfireServers);
            ScheduleContext context = new ScheduleContext();

            //string UserName = "******";
            //    string Password = "******";
            if (context.Users.Count(x => x.Username == "ash.barbour") == 0)
            {
                var user = new User
                {
                    Username      = "******",
                    RoleId        = (int)Roles.Admin,
                    Email         = "*****@*****.**",
                    Password      = "******",
                    FirstName     = "Ash",
                    LastName      = "Barbour",
                    EmailVerified = true,
                    InActive      = false
                };
                context.Users.Add(user);
                context.SaveChanges();
            }
        }
        public PartialViewResult FormGrid(int w, int d, int s)
        {
            ScheduleContext sc       = new ScheduleContext();
            ScheduleView    scv      = sc.GetSchedule(User.Identity.Name);
            string          coursnum = scv.Weeks[w].Days[d].Subjects[s].GroupStud;
            string          gc       = "";

            foreach (var g in coursnum)
            {
                if (Char.IsDigit(g))
                {
                    gc = g + " курс";
                    break;
                }
            }
            ;
            Grid gr = new Grid()
            {
                Course        = gc,
                Group         = scv.Weeks[w].Days[d].Subjects[s].GroupStud,
                KindOfSubject = scv.Weeks[w].Days[d].Subjects[s].KindOfSubject,
                SubjectName   = scv.Weeks[w].Days[d].Subjects[s].SubjectName,
                UserName      = User.Identity.Name,
                Date          = scv.Weeks[w].Days[d].Date,
                Audit         = scv.Weeks[w].Days[d].Subjects[s].Audit,
                TimeStart     = scv.Weeks[w].Days[d].Subjects[s].TimeStart,
                TimeEnd       = scv.Weeks[w].Days[d].Subjects[s].TimeEnd,
            };

            return(PartialView("_SetGrid", gr));
        }
示例#5
0
 public void CreateRunnableInstance(ScheduleContext context)
 {
     RunnableInstance = new HttpTask()
     {
         HttpOption = context.HttpOption
     };
 }
        public ActionResult ExistSubgroup(string group, string subname)
        {
            ScheduleContext sc = new ScheduleContext();
            bool            t  = sc.ExistSubg(group, subname, User.Identity.Name);

            return(Json(new { returnvalue = t }));
        }
示例#7
0
        public void Schedule()
        {
            using (var context = new ScheduleContext(Database))
            {
                if (context.Database.Exists())
                {
                    Console.WriteLine("ScheduleContext is existing");
                    return;
                }

                context.Database.Create();
                Console.WriteLine("ScheduleContext is created successfully");

                try
                {
                    context.Database.ExecuteSqlCommand("DROP TABLE [__MigrationHistory]");

                    context.SaveChanges();
                }
                catch { }

                context.FilePaths.Add(new FilePath
                {
                    //Path = @"C:\Users\Dell-PC\OneDrive\RevolutionTwo\Schedule",
                    Path = @"\\svproxy\Department\CP\Planning Team\生管進度 - Production Schedule - Tiến độ của sinh quản",
                    Type = "schedule"
                });
                context.SaveChanges();
            }
        }
示例#8
0
        string[] GetScheduleModelName(Building buildind, ScheduleClass cls)
        {
            var             productionLines = BuildingQuery.GetProductionLines(buildind.id);
            List <Schedule> schedules       = new List <Schedule>();

            foreach (var line in productionLines)
            {
                using (ScheduleContext db = new ScheduleContext(_SERVER.ServerName.Database))
                {
                    var schs = db.Schedules.Where(i => i.ScheduleClass_Id == cls.id && i.ProductionLine_Id == line.id);
                    if (schs.Count() > 0)
                    {
                        schedules.AddRange(schs.ToList());
                    }
                }
            }

            IEnumerable <IGrouping <string, Schedule> > group = schedules.GroupBy(i => i.ModelName).ToList();

            List <string> modelName = new List <string>();

            foreach (var item in group)
            {
                modelName.Add(item.Key);
            }
            return(modelName.ToArray());
        }
示例#9
0
 public FastCareController(FastCareContext context, ArisContext context2, HKMasterContext hkcontext, ScheduleContext contextSched)
 {
     _context      = context;
     _hkcontext    = hkcontext;
     _contextSched = contextSched;
     _context2     = context2;
 }
示例#10
0
        public bool DeletSchedule(Schedule schedule)
        {
            try
            {
                using (ScheduleContext = new ScheduleContext(database))
                {
                    var sche = schedule = ScheduleContext.Schedules.Where(
                        i => i.PoNumber == schedule.PoNumber &&
                        i.Model == schedule.Model &&
                        i.ModelName == schedule.ModelName &&
                        i.Article == schedule.Article &&
                        i.Quantity == schedule.Quantity &&
                        i.ProductionLine_Id == schedule.ProductionLine_Id).First();
                    if (sche == null)
                    {
                        return(false);
                    }

                    ScheduleContext.Entry(sche).State = EntityState.Deleted;
                    ScheduleContext.SaveChanges();
                    return(true);
                }
            }
            catch (Exception e)
            { return(false); }
        }
示例#11
0
 private void Stop_Loaded(object sender, RoutedEventArgs e)
 {
     using (ScheduleContext db = new ScheduleContext())
     {
         scheduleList.ItemsSource = db.Stop.ToList();
     }
 }
示例#12
0
        public PartialViewResult AddSubj(int w, int d, string usern)
        {
            TempData["w"] = w;
            TempData.Keep("w");
            TempData["d"] = d;
            TempData.Keep("d");
            TempData["username"] = usern;
            TempData.Keep("username");
            if (d == -1)
            {
                d = 0;
            }
            List <string>   TimeDateSt = new List <string>();
            List <string>   TimeDateEn = new List <string>();
            ScheduleContext sc         = new ScheduleContext();
            ScheduleView    scv        = sc.GetSchedule(usern);

            if (scv.Weeks[w].Days[d].Subjects != null)
            {
                foreach (var t in scv.Weeks[w].Days[d].Subjects)
                {
                    TimeDateSt.Add(t.TimeStart.ToLocalTime().ToShortTimeString());
                    TimeDateEn.Add(t.TimeEnd.ToLocalTime().ToShortTimeString());
                }
                ;
            }
            ;
            ViewBag.TimeSt = TimeDateSt;
            ViewBag.TimeEn = TimeDateEn;

            Day da = new Day();

            return(PartialView("_AddSubjForm", da));
        }
示例#13
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              ILoggerFactory loggerFactory, ScheduleContext scheduleContext)
        {
            loggerFactory.AddNLog();

            app.UseSwagger();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler();
            }

            scheduleContext.EnsureSeedDataForContext();

            app.UseStatusCodePages();

            AutoMapper.Mapper.Initialize(config =>
            {
                config.CreateMap <Schedule, ScheduleViewModel>().ReverseMap();
                config.CreateMap <Schedule, Schedule>();
            });

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "TimeTable API V1");
            });

            app.UseAuthentication();

            app.UseMvc();
        }
示例#14
0
        public static async Task <IHosSchedule> GetHosSchedule(ScheduleContext context)
        {
            IHosSchedule result;

            switch ((ScheduleMetaType)context.Schedule.MetaType)
            {
            case ScheduleMetaType.Assembly:
            {
                result = new AssemblySchedule();
                await LoadPluginFile(context.Schedule);

                break;
            }

            case ScheduleMetaType.Http:
            {
                result = new HttpSchedule();
                break;
            }

            default: throw new InvalidOperationException("unknown schedule type.");
            }
            result.Main                    = context.Schedule;
            result.CustomParams            = ConvertParamsJson(context.Schedule.CustomParamsJson);
            result.Keepers                 = context.Keepers;
            result.Children                = context.Children;
            result.CancellationTokenSource = new System.Threading.CancellationTokenSource();
            result.CreateRunnableInstance(context);
            result.RunnableInstance.TaskId            = context.Schedule.Id;
            result.RunnableInstance.CancellationToken = result.CancellationTokenSource.Token;
            result.RunnableInstance.Initialize();
            return(result);
        }
示例#15
0
        public async Task <ActionResult> UpdatePageId(string pageId, string authToken)
        {
            var currentUser = ScheduleContext.Users.FirstOrDefault(x => x.Id == user.Id);

            using (var client = new HttpClient())
            {
                string url      = $@"https://graph.facebook.com/v7.0/{pageId}?fields=instagram_business_account&access_token={authToken}";
                var    response = await client.GetAsync(url);

                var result = await response.Content.ReadAsStringAsync();

                try
                {
                    var jsonObject = JsonConvert.DeserializeObject <IGUser>(result);

                    if (jsonObject.instagram_business_account == null || string.IsNullOrWhiteSpace(jsonObject.instagram_business_account.id))
                    {
                        return(Json("noAccount"));
                    }
                    else
                    {
                        currentUser.InstagramUserId = jsonObject.instagram_business_account.id;
                    }
                }
                catch (Exception)
                {
                    return(Json("noAccount"));
                }
            }

            currentUser.FacebookPageId = pageId;
            ScheduleContext.SaveChanges();
            Session["User"] = new SessionUser(currentUser);
            return(Json(true));
        }
示例#16
0
        public ActionResult Index(int option = 2)
        {
            ViewBag.Option = option;
            var      context      = new ScheduleContext();
            DateTime monthOldDate = new DateTime();

            if (option == 1)
            {
                monthOldDate = DateTime.Now.AddDays(-7);
            }
            else if (option == 2)
            {
                monthOldDate = DateTime.Now.AddMonths(-1);
            }
            else if (option == 3)
            {
                monthOldDate = DateTime.Now.AddYears(-1);
            }
            else
            {
                monthOldDate = DateTime.Now.AddMonths(-1);
            }

            var data = context.DailyFollowerCount
                       .Where(x => x.UserId == user.Id && x.RecordedDate > monthOldDate)
                       .OrderBy(x => x.RecordedDate).ToList();

            ViewBag.GraphData = data;
            return(View());
        }
示例#17
0
        public void DelSubjects(int w, int d)
        {
            ScheduleContext sc  = new ScheduleContext();
            ScheduleView    scv = sc.GetSchedule(User.Identity.Name);

            scv.Weeks[w].Days[d].Subjects.Clear();
            sc.AddSubject(scv, User.Identity.Name);
        }
示例#18
0
        public void Initialize()
        {
            string connectionString = "Server=den1.mssql7.gear.host; Database=dotnottests;User Id=dotnottests;Password=Ky4DwF?7-YQY;";
            var    builder          = new DbContextOptionsBuilder <ScheduleContext>().UseSqlServer(connectionString);

            context        = new ScheduleContext(builder.Options);
            teacherService = new TeacherService(context, context);
        }
示例#19
0
        /// <summary>
        /// Constructor that builds a form request to ucsd act to grab all html pages for a given term and
        /// course request.
        /// </summary>
        /// <param name="selectedTerm">Usually a four character code that specifies the term you want
        /// to search from. Ex: "FA17" would return courses from the Fall 2017 quarter.</param>
        /// <param name="courses">The space seperated course search parameter. See the ucsd act class
        /// search for full information on how to use this. Ex: "cse 1-199" returns all CSE courses between
        /// 1 and 199</param>
        public ClassScrape(ScheduleContext context, string selectedTerm, string courses)
        {
            _context        = context;
            _actFormRequest = new ActFormRequest(selectedTerm, courses);

            // Course abbreviation prefix
            department = courses.Split(" ")[0].ToUpper();
        }
示例#20
0
 private void ScheduleList_ItemClick(object sender, ItemClickEventArgs e)
 {
     using (ScheduleContext db = new ScheduleContext())
     {
         Stop select = (Stop)e.ClickedItem;
         Times.St = select.Id;
         Frame.Navigate(typeof(Times));
     }
 }
        public PowerPointExporter(ScheduleContext context, Presentation presentation)
        {
            if (context == null) throw new ArgumentNullException("context");
            if (presentation == null) throw new ArgumentNullException("presentation");

            Context = context;
            Presentation = presentation;
            defaultLayout = GetLayout("Announcements");
        }
示例#22
0
 private void Rout_Loaded(object sender, RoutedEventArgs e)
 {
     using (ScheduleContext db = new ScheduleContext())
     {
         scheduleRoute.ItemsSource = db.Route.ToList();
         comboBox.ItemsSource      = Enum.GetValues(typeof(Types));
         comboBox.SelectedIndex    = 0;
     }
 }
示例#23
0
        /// <summary>
        /// Initiate a new todo list for new user
        /// </summary>
        /// <param name="userName"></param>
        private static void InitiateDatabaseForNewUser(string userName)
        {
            ScheduleContext db       = new ScheduleContext();
            Schedule        schedule = new Schedule();

            schedule.UserId = userName;
            schedule.Title  = "My schedule #1";
            schedule.Events = new List <Event>();
            db.Schedules.Add(schedule);
            db.SaveChanges();
        }
示例#24
0
 public void TestCourseContext()
 {
     var scheduleContext = new ScheduleContext
                           (
         new WebHtmlReader(),
         new HtmlTableToListConverter(new NLogLogger(new TimeTableAppContextProvider())),
         new HtmlDropDownToListConverter(new NLogLogger(new TimeTableAppContextProvider())),
         new Config(ConfigurationManager.AppSettings)
                           );
     var result = scheduleContext.ListSemestersAsync().Result.ToList();
 }
示例#25
0
 public FilePath GetFilePath(string _type)
 {
     try
     {
         using (ScheduleContext = new ScheduleContext(database))
         {
             return(ScheduleContext.FilePaths.Where(i => i.Type.Contains(_type)).First());
         }
     }
     catch { return(null); }
 }
示例#26
0
 public ICollection <ScheduleClass> GetScheduleClasses()
 {
     try
     {
         using (ScheduleContext = new ScheduleContext(database))
         {
             return(ScheduleContext.ScheduleClasses.ToList());
         }
     }
     catch { return(null); }
 }
示例#27
0
        public bool DeleteProxy(int ProxyId)
        {
            var Proxy = ScheduleContext.Proxies.FirstOrDefault(x => x.Id == ProxyId);

            if (Proxy != null)
            {
                ScheduleContext.Proxies.Remove(Proxy);
                ScheduleContext.SaveChanges();
            }
            Notify("Success", "Successfully Deleted", "Proxy Deleted Successfully", IsRedirectMessage: true);
            return(true);
        }
示例#28
0
        public bool ToggleBlockUser(int UserId)
        {
            var user = ScheduleContext.Users.FirstOrDefault(x => x.Id == UserId);

            if (user != null)
            {
                user.InActive = !user.InActive;
                ScheduleContext.SaveChanges();
            }
            Notify("Success", "Successfully Deleted", "User Deleted Successfully", IsRedirectMessage: true);
            return(true);
        }
        public ActionResult Authorize(string code, string state)
        {
            var user = ScheduleContext.Users.FirstOrDefault(x => x.Username == state);

            user.InstagramAuthToken = code;
            ScheduleContext.SaveChanges();
            if (Session["User"] == null)
            {
                Session["User"] = new SessionUser(user);
            }
            return(RedirectToAction("Index", "Dashboard"));
        }
示例#30
0
        public bool DeleteException(int ExceptionId)
        {
            var user = ScheduleContext.DailyFollowerCount.FirstOrDefault(x => x.Id == ExceptionId);

            if (user != null)
            {
                ScheduleContext.DailyFollowerCount.Remove(user);
                ScheduleContext.SaveChanges();
            }
            Notify("Success", "Successfully Deleted", "Record Deleted Successfully", IsRedirectMessage: true);
            return(true);
        }
示例#31
0
        public bool DeleteUser(int UserId)
        {
            var user = ScheduleContext.Users.FirstOrDefault(x => x.Id == UserId);

            if (user != null)
            {
                ScheduleContext.Users.Remove(user);
                ScheduleContext.SaveChanges();
            }
            Notify("Success", "Successfully Deleted", "User Deleted Successfully", IsRedirectMessage: true);
            return(true);
        }
示例#32
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            Waiter.ExecAsync(ui => {
                ui.Caption = "Connecting to SQL Server...";
                context = new ScheduleContext(DB.Default);
                loader = new CellLoader(context);
                ui.Caption = "Loading data...";
                context.LoadCells(calendar.MonthStart.Last(DayOfWeek.Sunday), calendar.MonthStart.Last(DayOfWeek.Sunday) + 7 * 6);

                BeginInvoke(new Action(delegate {
                    calendar.ContentRenderer = new Controls.SchedulizerCalendarContentRenderer(calendar.CalendarPainter, loader);
                    calendar.Invalidate();

                    UpdateCellPanel();

                    if (IsWordRunning) {
                        HandleWord();
                    } else {
                        wordBinderMenu.BeforePopup += wordBinderMenu_BeforePopup;
                        //TODO: Timer?
                    }
                }));
            }, "Loading", false);
        }
示例#33
0
        public HttpResponseMessage GetGroupsSchedule(dynamic data)
        {

            // Todo
            // Match input with player
            // Get player group 
            // continue as below


            try
            {
                var response = new HttpResponseMessage(HttpStatusCode.OK);

                string IPAddress = data.IPAddress;

                Guid scheduleId = data.ScheduleId;

                var player = GetPlayerByIpAddress(IPAddress);

                var repository = factory.GetRepository<Repository<Groups>>();

                Guid groupID = player.Groups.Id;

                var group = repository.GetById(groupID, false);

                if (group.Schedule.Id == scheduleId)
                {
                    response.Content = new JsonContent(new DownloadQueryResult { IsCurrentSchedule = true });
                }
                else
                {
                    var schedule = group.Schedule;

                    var se = schedule.ScheduleEvents
                             .Select(w => w.Campaign)
                             .GroupBy(w => w.Id)
                             .Select(w => w.FirstOrDefault());

                    var scheduleContext = new ScheduleContext()
                    {
                        Id = schedule.Id
                    };
                    // campaign
                    scheduleContext.Campaigns = se
                            .Select(o => new
                            {
                                Id = o.Id,
                                Data = new CampaignData()
                                {

                                    Id = o.Id,
                                    TotalDuration = o.TotalDuration
                                }
                            }).ToDictionary(prop => prop.Id, prop => prop.Data);

                    // campaign timelines
                    scheduleContext.CampaignTimelines = se
                       .Select(o => new
                       {

                           Id = o.Id,
                           Timelines = o.Timelines
                                        .Select(w => new TimelineData()
                                        {
                                            Id = w.Id,
                                            Duration = w.TotalDuration,
                                            ScreenType = w.ScreenType.Name,
                                        })

                       }).ToDictionary(prop => prop.Id, prop => prop.Timelines.ToArray());

                    // timeline channels
                    scheduleContext.TimelineChannels = se
                        .SelectMany(o => o.Timelines)
                        .Select(o => new
                        {
                            Id = o.Id,
                            Channels = o.Channels.Select(w => new ChannelData()
                            {
                                Id = w.Id,
                                Name = w.ScreenDivision.Name,
                                TotalLength = w.Duration
                            })
                        })
                        .ToDictionary(prop => prop.Id, prop => prop.Channels.ToArray())
                        ;

                    var resources = se
                                   .SelectMany(o => o.Timelines.SelectMany(w => w.Channels))
                                   .SelectMany(o => o.Blocks)
                                   .Select(o => new ResourceData()
                                   {

                                       Id = o.Resource.Id,
                                       ResourceType = o.Resource.ResourceType.ToString(),
                                       Location = o.Resource.ResourcePath


                                   }).Distinct()
                                   .ToDictionary(o => o.Id, o => o)
                                   ;

                    // channel blocks
                    scheduleContext.ChannelBlocks = se
                        .SelectMany(o => o.Timelines.SelectMany(w => w.Channels))
                        .Select(o => new
                        {
                            Id = o.Id,
                            Blocks = o.Blocks.Select(w => new BlockData()
                                {
                                    Resources = resources[w.Resource.Id],
                                    Id = w.Id,
                                    Length = w.Length
                                })
                        })
                        .ToDictionary(prop => prop.Id, prop => prop.Blocks.ToArray());


                    // resources
                    scheduleContext.Resources = new List<ResourceData>(resources.Values);


                    scheduleContext.Schedules = schedule.ScheduleEvents
                                                        .Select(o => new
                                                        ScheduleData()
                                                        {
                                                            CampaignId = o.Campaign.Id,
                                                            DayOfWeek = o.DayOfWeek,
                                                            StartTime = o.StartTime,
                                                            ExpirationTime = o.EndTime

                                                        }).ToList();

                    response.Content = new JsonContent(new
                    DownloadQueryResult()
                    {
                        IsCurrentSchedule = false,
                        ScheduleContext = scheduleContext
                    });

                }


                return response;
            }
            catch (Exception ex)
            {
                // log this
                return new HttpResponseMessage(HttpStatusCode.InternalServerError);

            }


        }