Example #1
0
        static void Main(string[] args)
        {
            try
            {
                string WorkingDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);//fetch the directory of the DLL

                string InputFileNamePath = WorkingDir + "/Input.txt";

                string OutputFileNamePath = WorkingDir + "/Output.txt";
                int    NumberOfTracks     = 2;

                SchedulerController SchedulerController = new SchedulerController(
                    InputFileNamePath, OutputFileNamePath, NumberOfTracks
                    );

                SchedulerController.Run();
                Console.WriteLine("Output available at " + OutputFileNamePath);
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }
Example #2
0
        /// <summary>
        /// Check the DiScribe bot email inbox for Webex invite emails created by scheduling
        /// from Webex.com or from DiScribe web.
        /// </summary>
        /// <param name="appConfig"></param>
        /// <returns></returns>
        private static async Task <object?> CheckForEmails(IConfigurationRoot appConfig)
        {
            MeetingInfo meetingInfo = null;


            try
            {
                var email = await EmailListener.GetEmailAsync();

                meetingInfo = MeetingController.HandleEmail(email.Body.Content.ToString(), email.Subject, "", appConfig);
                await EmailListener.DeleteEmailAsync(email);
            }
            catch (Exception emailEx)
            {
                Console.Error.WriteLine($">\tCould not read bot invite email. Reason: {emailEx.Message}");
                return(null);
            }

            if (meetingInfo != null)
            {
                Console.WriteLine($">\tNew Meeting Found at: {meetingInfo.StartTime.ToLocalTime()}");

                /*Send an audio registration email enabling all unregistered users to enroll on DiScribe website */
                MeetingController.SendEmailsToAnyUnregisteredUsers(meetingInfo.AttendeesEmails, appConfig["DB_CONN_STR"]);


                Console.WriteLine($">\tScheduling dialer to dial in to meeting at {meetingInfo.StartTime}");

                //Kay: According to Oloff, this should not have an "await" in front, otherwise it will wait until the meeting finish before checking the inbox again.
                SchedulerController.Schedule(Run, meetingInfo, appConfig, meetingInfo.StartTime);//Schedule dialer-transcriber workflow as separate task
            }

            return(meetingInfo);
        }
 public HostViewModelController(string applicationName)
 {
     ApplicationName = applicationName;
     Messenger       = new MessengerController();
     Configuration   = new Configuration(ApplicationName, null);
     TasksProcessor  = new TasksQueue();
     Scheduler       = new SchedulerController();
 }
Example #4
0
        /// <summary>
        /// Init window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InitWindow(object sender, DirectEventArgs e)
        {
            // init id
            var param = e.ExtraParams["Id"];

            // parse id
            if (int.TryParse(param, out var id))
            {
                // init window props
                if (id > 0)
                {
                    // edit
                    wdSetting.Title = @"Cập nhật thông tin chấm công";
                    wdSetting.Icon  = Icon.Pencil;
                }

                // init id
                hdfId.Text = id.ToString();
                // init model
                var model = new SchedulerModel(null);
                // check id
                if (id > 0)
                {
                    var result = SchedulerController.GetById(id);
                    if (result != null)
                    {
                        model = result;
                    }
                }
                // set scheduler prop
                txtName.Text         = model.Name;
                txtDescription.Text  = model.Description;
                txtIntervalTime.Text = model.IntervalTime.ToString();
                txtExpiredAfter.Text = model.ExpiredAfter.ToString();
                txtArguments.Text    = model.Arguments;
                chkEnable.Checked    = model.Enabled;
                if (model.NextRunTime != null)
                {
                    txtNextRuntime.Text = model.NextRunTime.Value.ToString("yyyy/MM/dd HH:mm");
                }
                if (model.Id > 0)
                {
                    // repeat type
                    hdfSchedulerRepeatType.Text = ((int)model.RepeatType).ToString();
                    cbxSchedulerRepeatType.Text = model.RepeatTypeName;
                    // scope
                    hdfSchedulerScope.Text = ((int)model.Scope).ToString();
                    cbxSchedulerScope.Text = model.ScopeName;
                    // status
                    hdfSchedulerStatus.Text = ((int)model.Status).ToString();
                    cbxSchedulerStatus.Text = model.StatusName;
                }
                // show window
                wdSetting.Show();
            }
        }
    public void DeleteTask(int ScheduleID, string AssemblyFileName)
    {
        // Schedule schedule = SchedulerController.GetSchedule(ScheduleID);

        if (!string.IsNullOrEmpty(AssemblyFileName))
        {
            string filepath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "bin\\" + AssemblyFileName);
            SchedulerController.DeleteTask(ScheduleID, filepath);
        }
    }
        public List <Scheduler> GetAllSchedulers()
        {
            SchedulerController schedulerController = new SchedulerController();

            List <Scheduler> schedulerList = schedulerController.GetAllSchedulers();

            Reservation reservation = schedulerList.First().Reservations.First();

            return(schedulerList);
        }
        public void SchedulerController_Should_save_scheduled_image_entity()
        {
            // Arrange
            var controller = new SchedulerController(_context, _client, _postNotificationSender);

            // Act
            controller.Post(new AssetApiModel()
            {
                FileName = "foo",
                Url      = "bar"
            });

            // Assert
            Mock.Get(_scheduledImages).Verify(x => x.Add(It.Is <ScheduledImage>(img => img.FileName == "foo")), "Filename is different from expected.");
            Mock.Get(_scheduledImages).Verify(x => x.Add(It.Is <ScheduledImage>(img => img.CreatedDate != DateTime.MinValue)), "Date was not set.");
        }
Example #8
0
        /// <summary>
        /// Insert or Update scheduler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InsertOrUpdate(object sender, DirectEventArgs e)
        {
            // init model
            var model = new SchedulerModel(null);

            // check id
            if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0)
            {
                var result = SchedulerController.GetById(Convert.ToInt32(hdfId.Text));
                if (result != null)
                {
                    model = result;
                }
            }
            // set new props for model
            model.Name         = txtName.Text;
            model.Description  = txtDescription.Text;
            model.Arguments    = txtArguments.Text;
            model.IntervalTime = !string.IsNullOrEmpty(txtIntervalTime.Text)
                ? Convert.ToInt32(txtIntervalTime.Text) : 0;
            model.ExpiredAfter = !string.IsNullOrEmpty(txtExpiredAfter.Text)
                ? Convert.ToInt32(txtExpiredAfter.Text) : 0;
            model.Enabled         = chkEnable.Checked;
            model.SchedulerTypeId = Convert.ToInt32(hdfSchedulerType.Text);
            model.RepeatType      = (SchedulerRepeatType)Enum.Parse(typeof(SchedulerRepeatType), hdfSchedulerRepeatType.Text);
            model.Scope           = (SchedulerScope)Enum.Parse(typeof(SchedulerScope), hdfSchedulerScope.Text);
            model.Status          = (SchedulerStatus)Enum.Parse(typeof(SchedulerStatus), hdfSchedulerStatus.Text);
            model.NextRunTime     = DateTime.TryParseExact(txtNextRuntime.Text, "yyyy/MM/dd HH:mm",
                                                           CultureInfo.InvariantCulture, DateTimeStyles.None, out var nextRunTime)
                ? nextRunTime
                : DateTime.Now;
            // check model id
            if (model.Id > 0)
            {
                // update
                SchedulerController.Update(model);
            }
            else
            {
                // insert
                SchedulerController.Create(model);
            }
            // hide window
            wdSetting.Hide();
            // reload data
            gpScheduler.Reload();
        }
Example #9
0
        /// <summary>
        /// Delete scheduler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Delete(object sender, DirectEventArgs e)
        {
            // init id
            var param = e.ExtraParams["Id"];

            // parse id
            if (!int.TryParse(param, out var id) || id <= 0)
            {
                // parse error, show error
                Dialog.ShowError("Có lỗi xảy ra trong quá trình xử lý");
                return;
            }
            // delete scheduler
            SchedulerController.Delete(id);
            // reload data
            gpScheduler.Reload();
        }
Example #10
0
        /// <summary>
        /// Listens for MS graph events occuring as a result of a meeting invite from Outlook.
        /// The bot schedules a Webex meeting if a valid meeting invite event is detected.
        /// </summary>
        /// <param name="appConfig"></param>
        /// <returns></returns>
        private static async Task <object?> CheckForGraphEvents(IConfigurationRoot appConfig)
        {
            MeetingInfo meetingInfo = null;

            Microsoft.Graph.Event inviteEvent;

            try
            {
                /*Attempt to get. latest event from bot's Outlook account.
                 * If there are no events, nothing will be scheduled. */
                inviteEvent = await EmailListener.GetEventAsync();

                await EmailListener.DeleteEventAsync(inviteEvent);

                /*Handle the invite.
                 * Assign the returned meeting info about the scheduled meeting or
                 * null if this is not an Outlook invite*/
                meetingInfo = await MeetingController.HandleInvite(inviteEvent, appConfig);
            }
            catch (Exception ex)
            {
                //throw new Exception($"Could not get any MS Graph events. Reason: {ex.Message}");
                Console.WriteLine($">\tCould not get any MS Graph events. Reason: {ex.Message}");
                return(null);
            }

            if (meetingInfo != null)
            {
                Console.WriteLine($">\tNew Meeting Found at: {meetingInfo.StartTime}");

                /*Send an audio registration email enabling all unregistered users to enroll on DiScribe website */
                MeetingController.SendEmailsToAnyUnregisteredUsers(meetingInfo.AttendeesEmails, appConfig["DB_CONN_STR"]);


                Console.WriteLine($">\tScheduling dialer to dial in to meeting at {meetingInfo.StartTime}");

                /*Convert start time and end time to the DiScribe bot time zone from the Webex host's time zone */
                var botStartTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(meetingInfo.StartTime, meetingInfo.HostInfo.TimeZone, TimeZoneInfo.Local.Id);

                //Kay: According to Oloff, this should not have an "await" in front, otherwise it will wait until the meeting finish before checking the inbox again.
                SchedulerController.Schedule(Run, meetingInfo, appConfig, meetingInfo.StartTime);//Schedule dialer-transcriber workflow as separate task
            }
            return(meetingInfo);
        }
Example #11
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IWebHostEnvironment env,
            ProjectContext _context,
            IBackgroundJobClient backgroundJobClient,
            IRecurringJobManager recurringJobManager
            )
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();
            app.UseCors("CorsApi");
            app.UseAuthorization();

            app.UseSession();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            //_context.Database.EnsureDeleted();
            //_context.Database.EnsureCreated();
            //new Seeder(_context);
            //DBSeed.Initialize(IUnitOfWork<ProjectContext>);

            SchedulerController scheduler = new SchedulerController(null, null, null);

            app.UseHangfireDashboard();
            //backgroundJobClient.Enqueue(() => scheduler.seeder());
            //recurringJobManager.AddOrUpdate("compile reorder",() => scheduler.reorder(), "*/5 * * * *");
            recurringJobManager.AddOrUpdate("compile reorder monthly", () => scheduler.reorder(), "5 0 1 * *", TimeZoneInfo.Local);            //Cron string
            recurringJobManager.AddOrUpdate("autorevoke delegate", () => scheduler.reorder(), "0 0 * * *", TimeZoneInfo.Local);                //Cron string
            recurringJobManager.AddOrUpdate("disbursement reminder", () => scheduler.disbursementreminder(), "0 8 * * *", TimeZoneInfo.Local); //Cron string
        }
    public void UpdateSchedule(string ScheduleName, string FullNameSpace, string StartDate, string EndDate, int StartHour, int StartMin, int RepeatWeeks, int RepeatDays,
                               int WeekOfMonth, int EveryHour, int EveryMin, string Dependencies, int RetryTimeLapse, int RetryFrequencyUnit, int AttachToEvent, bool CatchUpEnabled,
                               string Servers, string CreatedByUserID, bool IsEnable, int RunningMode, List <string> WeekDays, List <string> Months, string Dates, int ScheduleID)
    {
        MembershipUser user        = Membership.GetUser();
        Schedule       objSchedule = new Schedule();

        objSchedule.ScheduleID         = ScheduleID;
        objSchedule.ScheduleName       = ScheduleName;
        objSchedule.StartDate          = StartDate ?? DateTime.Now.ToString();
        objSchedule.EndDate            = EndDate ?? DateTime.Now.ToString();
        objSchedule.StartHour          = StartHour;
        objSchedule.StartMin           = StartMin;
        objSchedule.FullNamespace      = FullNameSpace;
        objSchedule.RepeatWeeks        = RepeatWeeks;
        objSchedule.RepeatDays         = RepeatDays;
        objSchedule.WeekOfMonth        = WeekOfMonth;
        objSchedule.EveryMin           = EveryMin;
        objSchedule.EveryHours         = EveryHour;
        objSchedule.ObjectDependencies = Dependencies;
        objSchedule.RetryTimeLapse     = RetryTimeLapse;
        objSchedule.RetryFrequencyUnit = RetryFrequencyUnit;
        objSchedule.AttachToEvent      = AttachToEvent.ToString();
        objSchedule.CatchUpEnabled     = CatchUpEnabled;
        objSchedule.Servers            = Servers;

        objSchedule.CreatedOnDate = DateTime.Now.ToString();
        objSchedule.IsEnable      = IsEnable;
        objSchedule.RunningMode   = (RunningMode)RunningMode;

        try
        {
            SchedulerController.UpdateSchedule(objSchedule, WeekDays, Months, Dates);
            // SchedulerController.UpdateTaskHistoryNextStartDate(objSchedule.ScheduleID);
        }
        catch (Exception)
        {
            throw;
        }
    }
        public void SchedulerController_Should_start_background_process_on_post()
        {
            // Arrange
            Mock.Get(_scheduledImages)
            .Setup(si => si.Add(It.IsAny <ScheduledImage>()))
            .Callback <ScheduledImage>((img) =>
            {
                img.Id = 3;
            });

            var controller = new SchedulerController(_context, _client, _postNotificationSender);

            // Act
            controller.Post(new AssetApiModel()
            {
                FileName = "foo", Url = "bar"
            });

            // Assert
            Mock.Get(_client).Verify(x => x.Create(
                                         It.Is <Job>(job => job.Method.Name == "DownloadAndReadMetadata" && Convert.ToInt32(job.Args[0]) == 3),
                                         It.IsAny <EnqueuedState>()));
        }
Example #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SaveDynamicColumnClick(object sender, DirectEventArgs e)
        {
            try
            {
                //Update status schedule create new timeSheet
                var scheduler = SchedulerController.GetByName(SchedulerName);
                if (scheduler != null)
                {
                    scheduler.Status = SchedulerStatus.Ready;
                    var symbol = string.Empty;
                    foreach (var itemRow in chkSelectionModelSymbol.SelectedRows)
                    {
                        symbol += "," + itemRow.RecordID;
                    }

                    if (!string.IsNullOrEmpty(symbol))
                    {
                        scheduler.Arguments = "-column {0} -symbol {1} -payrollId {2}".FormatWith(hdfColumnCode.Text, symbol.TrimStart(','), Convert.ToInt32(hdfPayrollId.Text));

                        SchedulerController.Update(scheduler);
                    }
                }

                //close window
                wdDynamicColumn.Hide();
                hdfColumnCode.Reset();
                cbxColumnCode.Reset();
                hdfPayrollId.Reset();
                cboPayroll.Reset();
                chkSelectionModelSymbol.ClearSelections();
            }
            catch (Exception exception)
            {
                Dialog.Alert(exception.Message);
            }
        }
Example #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Delete_Click(object sender, DirectEventArgs e)
        {
            if (!string.IsNullOrEmpty(hdfChoseMonth.Text) && !string.IsNullOrEmpty(hdfChoseYear.Text))
            {
                if (!string.IsNullOrEmpty(hdfGroupWorkShiftId.Text))
                {
                    var groupWorkShiftId = Convert.ToInt32(hdfGroupWorkShiftId.Text);

                    //get all detail workShift
                    var order        = " [StartDate] ASC ";
                    var lstWorkShift =
                        TimeSheetWorkShiftController.GetAll(null, false, groupWorkShiftId, null, null, null, null, Convert.ToInt32(hdfChoseMonth.Text), Convert.ToInt32(hdfChoseYear.Text), order, null);

                    var listWorkShiftIds = lstWorkShift.Select(ws => ws.Id).ToList();
                    if (listWorkShiftIds.Count > 0)
                    {
                        TimeSheetEventController.DeleteByCondition(listWorkShiftIds, null, null, null, TimeSheetAdjustmentType.Default);
                    }

                    //Update status schedule create new timeSheet
                    var scheduler = SchedulerController.GetByName(Constant.SchedulerTimeSheet);
                    if (scheduler != null)
                    {
                        scheduler.Status    = SchedulerStatus.Ready;
                        scheduler.Arguments = "-m {0} -y {1} -groupWorkShiftId {2}".FormatWith(hdfChoseMonth.Text, hdfChoseYear.Text, hdfGroupWorkShiftId.Text);
                        //update
                        SchedulerController.Update(scheduler);
                    }
                }

                hdfGroupWorkShiftId.Reset();
                wdWindow.Hide();
                //reload
                gpScheduler.Reload();
            }
        }
    public Schedule GetTask(int id)
    {
        Schedule s = SchedulerController.GetSchedule(id);

        return(s);
    }
    public void AddNewSchedule(string ScheduleName, string FullNameSpace, string StartDate, string EndDate, int StartHour, int StartMin, int RepeatWeeks, int RepeatDays,
                               int WeekOfMonth, int EveryHour, int EveryMin, string Dependencies, int RetryTimeLapse, int RetryFrequencyUnit, int AttachToEvent, bool CatchUpEnabled,
                               string Servers, string CreatedByUserID, bool IsEnable, int RunningMode, List <string> WeekDays, List <string> Months, string Dates, string AssemblyFileName)
    {
        MembershipUser user = Membership.GetUser();

        Schedule objSchedule = new Schedule();

        objSchedule.ScheduleName       = ScheduleName;
        objSchedule.FullNamespace      = FullNameSpace;
        objSchedule.StartDate          = StartDate ?? DateTime.Now.ToString();
        objSchedule.EndDate            = EndDate ?? DateTime.Now.ToString();
        objSchedule.StartHour          = StartHour;
        objSchedule.StartMin           = StartMin;
        objSchedule.RepeatWeeks        = RepeatWeeks;
        objSchedule.RepeatDays         = RepeatDays;
        objSchedule.WeekOfMonth        = WeekOfMonth;
        objSchedule.EveryMin           = EveryMin;
        objSchedule.EveryHours         = EveryHour;
        objSchedule.ObjectDependencies = Dependencies;
        objSchedule.RetryTimeLapse     = RetryTimeLapse;
        objSchedule.RetryFrequencyUnit = RetryFrequencyUnit;
        objSchedule.AttachToEvent      = AttachToEvent.ToString();
        objSchedule.CatchUpEnabled     = CatchUpEnabled;
        objSchedule.Servers            = Servers;
        // objSchedule.CreatedByUserID = user.ProviderUserKey.ToString();

        objSchedule.CreatedOnDate    = DateTime.Now.ToString();
        objSchedule.IsEnable         = IsEnable;
        objSchedule.RunningMode      = (RunningMode)RunningMode;
        objSchedule.AssemblyFileName = AssemblyFileName;


        try
        {
            Schedule schedule = SchedulerController.AddNewSchedule(objSchedule);
            if (schedule.ScheduleID < 1)
            {
                string fileName = objSchedule.AssemblyFileName;
                string filepath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "bin\\" + fileName);
                SchedulerController.DeleteFile(filepath);
            }
            else
            {
                if (WeekDays.Count > 0)
                {
                    SchedulerController.AddNewScheduleWeeks(schedule.ScheduleID, WeekDays);
                }
                if (Months.Count > 0)
                {
                    SchedulerController.AddNewScheduleMonths(schedule.ScheduleID, Months);
                }
                if (!string.IsNullOrEmpty(Dates) && Dates.Trim().Length > 0)
                {
                    SchedulerController.AddNewScheduleDate(schedule.ScheduleID, Dates);
                }

                SchedulerController.RunScheduleItemNow(schedule);
            }
        }
        catch (Exception)
        {
            throw;
        }
    }
        public void MakeScheduler(DateTime date, TimeSpan time, int movieID, int hallID)
        {
            SchedulerController SchCtr = new SchedulerController();

            SchCtr.CreateScheduler(date, time, movieID, hallID);
        }
    public List <ScheduleMonth> GetScheduleMonths(int ScheduleID)
    {
        List <ScheduleMonth> list = SchedulerController.GetScheduleMonths(ScheduleID);

        return(list);
    }
    public List <ScheduleDate> GetScheduleDates(int ScheduleID)
    {
        List <ScheduleDate> list = SchedulerController.GetScheduleDates(ScheduleID);

        return(list);
    }
    public List <ScheduleWeek> GetScheduleWeeks(int ScheduleID)
    {
        List <ScheduleWeek> list = SchedulerController.GetScheduleWeeks(ScheduleID);

        return(list);
    }
        public void DeleteSch(int schID)
        {
            SchedulerController schCtr = new SchedulerController();

            schCtr.DeleteSch(schID);
        }
        public Scheduler GetSchedulerByMovieID(int movieID)
        {
            SchedulerController schedulerController = new SchedulerController();

            return(schedulerController.GetSchedulerByMovie(movieID));
        }
    public List <SchedularView> GetAllActiveTasks(int offset, int limit)
    {
        List <SchedularView> lstSchedule = SchedulerController.GetAllActiveTasks(offset, limit);

        return(lstSchedule);
    }
 public void RunScheduleNow(int id)
 {
     SchedulerController.RunScheduleNow(id);
 }
        public List <Scheduler> GetSchedulerListByMovieID(int movieID)
        {
            SchedulerController SchCtr = new SchedulerController();

            return(SchCtr.GetSchListByMovieID(movieID));
        }
        public Scheduler GetSchedulerByID(int schedulerID)
        {
            SchedulerController schedulerController = new SchedulerController();

            return(schedulerController.GetSchedulerByID(schedulerID));
        }
        public List <Scheduler> GetSchListByDate(DateTime date)
        {
            SchedulerController schCtr = new SchedulerController();

            return(schCtr.GetByDate(date));
        }
    public List <ScheduleHistoryView> GetAllScheduleHistory(int ScheduleID, int offset, int limit)
    {
        List <ScheduleHistoryView> lstSchedule = SchedulerController.GetAllScheduleHistory(ScheduleID, offset, limit);

        return(lstSchedule);
    }
        public void UpdateScheduler(int schID, DateTime date, TimeSpan time, int movieID, int hallID)
        {
            SchedulerController schCtr = new SchedulerController();

            schCtr.UpdateSchedulers(schID, date, time, movieID, hallID);
        }