public SchedulerPresenter(ISchedulerRepo r, ISchedulerform v, int pid)
 {
     _r       = r;
     _v       = v;
     factory  = new ScheduleFactory();
     this.pid = pid;
 }
Пример #2
0
        public override Task <AsyncResult <ISchedule> > CreateScheduleDetailedAsync(IChannel channel, string title, DateTime from, DateTime to, ScheduleRecordingType recordingType, int preRecordInterval, int postRecordInterval, string directory, int priority)
        {
            IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>();
            Schedule         tvSchedule      = ScheduleFactory.CreateSchedule(channel.ChannelId, title, from, to);

            tvSchedule.PreRecordInterval  = preRecordInterval >= 0 ? preRecordInterval : ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvSchedule.PostRecordInterval = postRecordInterval >= 0 ? postRecordInterval : ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            if (!String.IsNullOrEmpty(directory))
            {
                tvSchedule.Directory = directory;
            }
            if (priority >= 0)
            {
                tvSchedule.Priority = priority;
            }
            tvSchedule.PreRecordInterval  = preRecordInterval;
            tvSchedule.PostRecordInterval = postRecordInterval;
            tvSchedule.ScheduleType       = (int)recordingType;
            tvSchedule.Directory          = directory;
            tvSchedule.Priority           = priority;
            scheduleService.SaveSchedule(tvSchedule);
            ISchedule schedule = tvSchedule.ToSchedule();

            return(Task.FromResult(new AsyncResult <ISchedule>(true, schedule)));
        }
Пример #3
0
        public void Dado_um_agendamento_sem_cliente_ele_deve_ser_invalido()
        {
            var _schedule = ScheduleFactory.CreateSchedule(null);

            _schedule.Validate();

            Assert.AreEqual(true, _schedule.Invalid);
        }
 public void Closing()
 {
     if (this.Scheduler.Week.Days.Any(d => d.Hours.Any(h => h.Dirty)))
     {
         ScheduleFactory factory = new ScheduleFactory();
         factory.Save(this.Scheduler);
     }
 }
 public static ScheduleOperator getSchedule()
 {
     if (schedule == null)
     {
         schedule = ScheduleFactory.newSchedule();
     }
     return(schedule);
 }
Пример #6
0
        public bool CreateSchedule(IProgram program)
        {
            IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>();
            Schedule         schedule        = ScheduleFactory.CreateSchedule(program.ChannelId, program.Title, program.StartTime, program.EndTime);

            schedule.PreRecordInterval  = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            schedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            scheduleService.SaveSchedule(schedule);
            return(true);
        }
Пример #7
0
        /// <summary>
        /// Main entry for the program.
        /// </summary>
        /// <param name="args">Args to send (name of the file en the same directory)</param>
        static void Main(string[] args)
        {
            IEmployeeFactory            employeeFactory            = new EmployeeFactory();
            IScheduleFactory            scheduleFactory            = new ScheduleFactory();
            IGetPaymentForEmployeeQuery getPaymentForEmployeeQuery = new GetPaymentForEmployeeQuery(employeeFactory, scheduleFactory);
            Client client = new Client(getPaymentForEmployeeQuery);

            client.PrintCalculatedPayment(args[0]);
            Console.ReadLine();
        }
 public ScheduleViewModel(Context context)
 {
     if (context != null)
     {
         this.Scheduler = context.Schedule;
     }
     else
     {
         this.Scheduler = ScheduleFactory.CreateNew();                 // This is required when we are in design view.
     }
 }
Пример #9
0
        public override bool CreateScheduleByTime(IChannel channel, DateTime from, DateTime to, out ISchedule schedule)
        {
            IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>();
            Schedule         tvSchedule      = ScheduleFactory.CreateSchedule(channel.ChannelId, "Manual", from, to);

            tvSchedule.PreRecordInterval  = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvSchedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            tvSchedule.ScheduleType       = (int)ScheduleRecordingType.Once;
            scheduleService.SaveSchedule(tvSchedule);
            schedule = tvSchedule.ToSchedule();
            return(true);
        }
Пример #10
0
        public override bool CreateSchedule(IProgram program, ScheduleRecordingType recordingType, out ISchedule schedule)
        {
            IScheduleService scheduleService = GlobalServiceProvider.Instance.Get <IScheduleService>();
            Schedule         tvschedule      = ScheduleFactory.CreateSchedule(program.ChannelId, program.Title, program.StartTime, program.EndTime);

            tvschedule.PreRecordInterval  = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvschedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            tvschedule.ScheduleType       = (int)recordingType;
            scheduleService.SaveSchedule(tvschedule);
            schedule = tvschedule.ToSchedule();
            return(true);
        }
Пример #11
0
        public override Task <AsyncResult <ISchedule> > CreateScheduleByTimeAsync(IChannel channel, string title, DateTime from, DateTime to, ScheduleRecordingType recordingType)
        {
            IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>();
            Schedule         tvSchedule      = ScheduleFactory.CreateSchedule(channel.ChannelId, title, from, to);

            tvSchedule.PreRecordInterval  = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvSchedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            tvSchedule.ScheduleType       = (int)recordingType;
            scheduleService.SaveSchedule(tvSchedule);
            var schedule = tvSchedule.ToSchedule();

            return(Task.FromResult(new AsyncResult <ISchedule>(true, schedule)));
        }
Пример #12
0
        public override Task <AsyncResult <ISchedule> > CreateScheduleAsync(IProgram program, ScheduleRecordingType recordingType)
        {
            IScheduleService scheduleService = GlobalServiceProvider.Instance.Get <IScheduleService>();
            Schedule         tvschedule      = ScheduleFactory.CreateSchedule(program.ChannelId, program.Title, program.StartTime, program.EndTime);

            tvschedule.PreRecordInterval  = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvschedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            tvschedule.ScheduleType       = (int)recordingType;
            scheduleService.SaveSchedule(tvschedule);
            var schedule = tvschedule.ToSchedule();
            var success  = schedule != null;

            return(Task.FromResult(new AsyncResult <ISchedule>(success, schedule)));
        }
Пример #13
0
        public ScheduleDto AddSchedule(AddScheduleCommand cmd)
        {
            var      factory  = new ScheduleFactory();
            Schedule schedule = null;

            if (!Enum.TryParse(typeof(ScheduleType), cmd.ScheduleType, out var scheduleType))
            {
                throw new ArgumentException($"Invalid schedule type: '{cmd.ScheduleType}'", nameof(cmd.ScheduleType));
            }

            switch (scheduleType)
            {
            case ScheduleType.DateTime:
                schedule = factory.CreateDateTimeSchedule(cmd.Name, cmd.Description, cmd.StartDate, cmd.StartTime, cmd.Duration, cmd.EnabledUntil, cmd.IsEnabled);
                break;

            case ScheduleType.DaysOfMonth:
                schedule = factory.CreateDayOfMonthSchedule(cmd.Name, cmd.Description, cmd.StartDate, cmd.Days, cmd.StartTime, cmd.Duration, cmd.EnabledUntil, cmd.IsEnabled);
                break;

            case ScheduleType.DaysOfWeek:
                schedule = factory.CreateDayOfWeekSchedule(cmd.Name, cmd.Description, cmd.StartDate, cmd.Days, cmd.StartTime, cmd.Duration, cmd.EnabledUntil, cmd.IsEnabled);
                break;

            case ScheduleType.EvenDays:
                schedule = factory.CreateEvenDaysSchedule(cmd.Name, cmd.Description, cmd.StartDate, cmd.StartTime, cmd.Duration, cmd.EnabledUntil, cmd.IsEnabled);
                break;

            case ScheduleType.OddDays:
                factory.CreateOddDaysSchedule(cmd.Name, cmd.Description, cmd.StartDate, cmd.StartTime, cmd.Duration, cmd.EnabledUntil, cmd.IsEnabled);
                break;
            }

            foreach (var id in cmd.ZoneIds)
            {
                var zone = zoneRepository.Find(id);
                if (zone == null)
                {
                    throw new Exception($"Zone with id '{id}' does not exist");
                }
                schedule.AttachZone(id);
            }
            scheduleRepository.Add(schedule);

            AddToScheduler(schedule);
            return(new ScheduleDto(schedule.Id, schedule.Name, schedule.Description, schedule.ScheduleType.ToString(), schedule.StartTime, schedule.StartDate, schedule.Days, schedule.IsEnabled,
                                   schedule.Duration, schedule.EnabledUntil, schedule.ZoneIds));
        }
Пример #14
0
        public async Task AddTeamSchedule(AddSchedule command)
        {
            await _administratorService.ValidateAtLeastModerator(command.UserId, command.GroupId);

            var group = await _groupRepository.GetWithTeamScheduleAndCourses(command.GroupId, command.TeamName);

            if (group == null)
            {
                throw new AppException($"Team with name {command.TeamName} doesn't exist.", AppErrorCode.DOESNT_EXIST);
            }

            var schedule = ScheduleFactory.Create(command.Schedule, group.Courses);
            var team     = group.Teams.First(t => t.Name == command.TeamName);

            team.AddSchedule(schedule);

            await _groupRepository.SaveChangesAsync();
        }
Пример #15
0
        public void agvInit()
        {
            if (FormController.isNeedLogin())
            {
                FormController.getFormController().getLoginFrm().ShowDialog();
            }

            TaskexeDao.getDao().InsertTaskexeSysInfo("AGV通讯服务程序启动!");
            setForkliftStateFirst();

            handleCheckRunning(checkRunning());

            if (isNeedElevator)
            {
                ElevatorFactory.getElevator().startReadSerialPortThread();
            }

            if (isNeedAGVSocketServer)
            {
                AGVSocketServer.getSocketServer().StartAccept();
            }

            if (isNeedSchedule)
            {
                ScheduleFactory.getSchedule().startShedule();
            }

            if (isNeedTaskexe)
            {
                TaskexeService.getInstance().start();
            }

            AGVMessageHandler.getMessageHandler().StartHandleMessage();

            if (isNeedMain)
            {
                FormController.getFormController().getMainFrm().ShowDialog();
            }
            else
            {
                FormController.getFormController().getInfoFrm().ShowDialog();
            }
        }
Пример #16
0
        public bool CreateScheduleByTime(IChannel channel, DateTime from, DateTime to, out ISchedule schedule)
        {
#if TVE3
            TvDatabase.Schedule tvSchedule = _tvBusiness.AddSchedule(channel.ChannelId, "Manual", from, to, (int)ScheduleRecordingType.Once);
            tvSchedule.PreRecordInterval  = Int32.Parse(_tvBusiness.GetSetting("preRecordInterval", "5").Value);
            tvSchedule.PostRecordInterval = Int32.Parse(_tvBusiness.GetSetting("postRecordInterval", "5").Value);
            tvSchedule.Persist();
            _tvControl.OnNewSchedule();
#else
            IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>();
            Schedule         tvSchedule      = ScheduleFactory.CreateSchedule(channel.ChannelId, "Manual", from, to);
            tvSchedule.PreRecordInterval  = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvSchedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            tvSchedule.ScheduleType       = (int)ScheduleRecordingType.Once;
            scheduleService.SaveSchedule(tvSchedule);
#endif
            schedule = tvSchedule.ToSchedule();
            return(true);
        }
Пример #17
0
        public ScheduleDto UpdateSchedule(UpdateScheduleCommand cmd)
        {
            var      factory  = new ScheduleFactory();
            Schedule schedule = scheduleRepository.Find(cmd.ScheduleId);

            if (schedule == null)
            {
                throw new ArgumentException($"Schedule with id '{cmd.ScheduleId}' does not exist");
            }


            if (!Enum.TryParse(typeof(ScheduleType), cmd.ScheduleType, out var scheduleType))
            {
                throw new ArgumentException($"Invalid schedule type: '{cmd.ScheduleType}'", nameof(cmd.ScheduleType));
            }

            var newSchedule = new Schedule((ScheduleType)scheduleType, cmd.Name, cmd.Description, cmd.Days, cmd.StartDate, cmd.StartTime, cmd.Duration, cmd.EnabledUntil, cmd.IsEnabled);

            foreach (var id in cmd.ZoneIds)
            {
                var zone = zoneRepository.Find(id);
                if (zone == null)
                {
                    throw new Exception($"Zone with id '{id}' does not exist");
                }
                newSchedule.AttachZone(id);
            }

            var jobKey     = BuildJobKey(schedule.Id);
            var jobTrigger = BuildTriggerKey(schedule.Id);

            scheduler.DeleteJob(jobKey);
            scheduler.UnscheduleJob(jobTrigger);


            schedule.UpdateFrom(newSchedule);
            scheduleRepository.Update(schedule);

            AddToScheduler(schedule);
            return(new ScheduleDto(schedule.Id, schedule.Name, schedule.Description, schedule.ScheduleType.ToString(), schedule.StartTime, schedule.StartDate, schedule.Days, schedule.IsEnabled,
                                   schedule.Duration, schedule.EnabledUntil, schedule.ZoneIds));
        }
Пример #18
0
        private void handleCheckRunning(ENV_ERR_TYPE err)
        {
            if (err == ENV_ERR_TYPE.ENV_LIFT_COM_ERR)
            {
                DialogResult dr;
                dr = MessageBox.Show(env_err_type_text(err), "错误提示", MessageBoxButtons.OK);

                if (dr == DialogResult.OK)
                {
                    Console.WriteLine(" exit ");
                    Environment.Exit(0);
                }
            }
            else if (err == ENV_ERR_TYPE.ENV_CACHE_TASKRECORD_WARNING)
            {
                DialogResult dr;
                dr = MessageBox.Show(env_err_type_text(err), "检测到缓存任务", MessageBoxButtons.YesNo);

                if (dr == DialogResult.Yes)
                {
                    Console.WriteLine(" do nothing ");
                }
                else if (dr == DialogResult.No)
                {
                    TaskReordService.getInstance().deleteAllTaskRecord();
                }
            }
            else if (err == ENV_ERR_TYPE.ENV_CACHE_UPTASKRECORD_WARNING)
            {
                DialogResult dr;
                dr = MessageBox.Show(env_err_type_text(err), "缓存任务", MessageBoxButtons.YesNo);

                if (dr == DialogResult.Yes)
                {
                    ScheduleFactory.getSchedule().setDownDeliverPeriod(true);                      //设置当前处于上货阶段
                }
                else if (dr == DialogResult.No)
                {
                    TaskReordService.getInstance().deleteAllTaskRecord();
                }
            }
        }
Пример #19
0
        public bool CreateSchedule(IProgram program, ScheduleRecordingType recordingType, out ISchedule schedule)
        {
#if TVE3
            TvDatabase.Schedule tvSchedule = _tvBusiness.AddSchedule(program.ChannelId, program.Title, program.StartTime, program.EndTime, (int)recordingType);
            tvSchedule.ScheduleType       = (int)recordingType;
            tvSchedule.PreRecordInterval  = Int32.Parse(_tvBusiness.GetSetting("preRecordInterval", "5").Value);
            tvSchedule.PostRecordInterval = Int32.Parse(_tvBusiness.GetSetting("postRecordInterval", "5").Value);
            tvSchedule.Persist();
            _tvControl.OnNewSchedule();
            schedule = tvSchedule.ToSchedule();
            return(true);
#else
            IScheduleService scheduleService = GlobalServiceProvider.Instance.Get <IScheduleService>();
            Schedule         tvschedule      = ScheduleFactory.CreateSchedule(program.ChannelId, program.Title, program.StartTime, program.EndTime);
            tvschedule.PreRecordInterval  = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvschedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            tvschedule.ScheduleType       = (int)recordingType;
            scheduleService.SaveSchedule(tvschedule);
            schedule = tvschedule.ToSchedule();
            return(true);
#endif
        }
Пример #20
0
        public async Task UpdateTeamSchedule(UpdateSchedule command)
        {
            await _administratorService.ValidateAtLeastModerator(command.UserId, command.GroupId);

            var group = await _groupRepository.GetWithTeamScheduleAndCourses(command.GroupId, command.TeamName);

            if (group == null)
            {
                throw new AppException($"Team with name {command.TeamName} doesn't exist.", AppErrorCode.DOESNT_EXIST);
            }

            var schedule         = ScheduleFactory.Create(command.Schedule, group.Courses);
            var scheduleToUpdate = group.Teams.First(t => t.Name == command.TeamName)
                                   .Schedules.FirstOrDefault(s => s.Semester == command.Schedule.Semester);

            if (scheduleToUpdate == null)
            {
                throw new AppException($"There is no schedule to update for semester {command.Schedule.Semester}", AppErrorCode.DOESNT_EXIST);
            }

            scheduleToUpdate.Update(schedule.Semester, schedule.ScheduledCourses);

            await _groupRepository.SaveChangesAsync();
        }
        private void UpdateDisplayList()
        {
            Schedule onSchedule  = null;
            Schedule offSchedule = null;

            // Scan through schedules
            scheduleList = new ObservableCollection <Schedule>();
            var unsupportedSchedules = new List <Schedule>();

            foreach (var schedule in BridgeManager.Instance.CurrentBridge.ScheduleList)
            {
                if (schedule.IsSupportedSchedule)
                {
                    if (schedule.Name == Schedule.DefaultAllOnScheduleName)
                    {
                        // Lights on schedule
                        onSchedule = schedule;
                    }
                    else if (schedule.Name == Schedule.DefaultAllOffScheduleName)
                    {
                        // Lights off schedule
                        offSchedule = schedule;
                    }
                }
                else
                {
                    unsupportedSchedules.Add(schedule);
                }
            }

            // Always make sure the default supported schedules are on top
            if (onSchedule == null)
            {
                onSchedule = ScheduleFactory.newAllOnSchedule();
            }

            scheduleList.Add(onSchedule);

            if (offSchedule == null)
            {
                offSchedule = ScheduleFactory.newAllOffSchedule();
            }

            scheduleList.Add(offSchedule);

            // Append the other unsupported schedules
            foreach (var s in unsupportedSchedules)
            {
                scheduleList.Add(s);
            }

            ScheduleListView.ItemsSource = scheduleList;

            ScheduleToggle.IsEnabled = true;

            // Determine the on/off state of the toggle
            if (BridgeManager.Instance.HasSupportedSchedules)
            {
                ScheduleToggle.IsOn = true;
                EnableScheduleListView();
            }
            else
            {
                ScheduleToggle.IsOn = false;
                DisableScheduleListView();
            }
        }
Пример #22
0
 public void Awake()
 {
     scheduleFactory = Instantiate <GameObject>(scheduleFactoryPrefab).GetComponent <ScheduleFactory>();
     scheduleObjects = new GameObject[TOTAL_SCHEDULE_NUM];
 }
Пример #23
0
 private void RegisterAll()
 {
     _dependencies.Register <IPollable <DateTime> >(r => new Time(), true);
     _dependencies.Register <IMetronome>(r => new Metronome(r.Resolve <IPollable <DateTime> >()), true);
     _dependencies.Register <IScheduleFactory>(r => new ScheduleFactory(r.Resolve <IMetronome>()));
     _dependencies.Register <IPollable <TemperatureHumidity> >(
         r => new TemperatureHumiditySensor(r.Resolve <ArduinoI2C>(Instances.Arduino1)), true,
         Instances.TempHumidity1);
     _dependencies.Register(r => new TestRunnable2(r.Resolve <IPollable <TemperatureHumidity> >(Instances.TempHumidity1))
                            .AsResilient().AsScheduled(
                                r.Resolve <IScheduleFactory>().RepeatingScheduleFor(seconds: ScheduleFactory.EveryNIn60(20))
                                ), true, Instances.Test);
     _dependencies.Register(r => new ArduinoI2C(Instances.Arduino1, Pi3.I2C_0x40), true, Instances.Arduino1);
 }
Пример #24
0
        /// <summary>This is the main entrypoint of the application.</summary>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // Set the Current Culture.
            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            // Setup the Logger
            ILogger logger = LogManager.GetLogger();

            logger.Log(LogLevel.Info, "Loading the Application.");

            // Load up the Context & Engine
            Engine  engine  = null;
            Context context = null;

            {
                // Load the Accounts
                ObservableCollection <Account> accounts;
                try
                {
                    AccountsFactory accountFactory = new AccountsFactory();
                    accounts = accountFactory.Load();
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, "Failed to load the Accounts.", ex);
                    accounts = new ObservableCollection <Account>();
                }

                // Load the Sites
                ObservableCollection <Site> sites = null;
                try
                {
                    SitesFactory siteFactory = new SitesFactory();
                    sites = siteFactory.Load();
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, "Failed to load the Sites.", ex);
                    sites = new ObservableCollection <Site>();
                }

                // Load the AlertPreferences
                ObservableCollection <AlertPreference> alertPreferences = null;
                AlertPreferencesFactory alertPreferencesFactory         = new AlertPreferencesFactory();
                try
                {
                    alertPreferences = alertPreferencesFactory.Load();
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, "Failed to load the AlertPreferences.", ex);
                    alertPreferences = alertPreferencesFactory.CreateNew();
                }

                // Load the Scheduler
                Schedule scheduler = null;
                try
                {
                    ScheduleFactory schedulerFactory = new ScheduleFactory();
                    scheduler = schedulerFactory.Load();
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, "Failed to load the Scheduler.", ex);
                    scheduler = new Schedule();
                }

                // Check to see that we have a site for each account loaded
                foreach (Account account in accounts)
                {
                    Site site = sites.FirstOrDefault(s => s.SiteCode == account.SiteCode);
                    if (site == null)
                    {
                        PopulateSitesJob job = new PopulateSitesJob();
                        site = job.PopulateSite(sites, account);
                    }

                    account.Site = site;
                }

                // Load the Context
                context = new Context(accounts, sites, alertPreferences, scheduler);

                // Load the Engine
                engine = new Engine(context);

                DependencyFactory.RegisterInstance(context);
                DependencyFactory.RegisterInstance(engine);
            }

            // Create Initial Account (if no acount exists)
            if (context.Accounts.Count == 0)
            {
                logger.Log(LogLevel.Info, "No accounts exist. Creating initial account.");
                StartupWizardView      view      = new StartupWizardView();
                StartupWizardViewModel viewModel = (StartupWizardViewModel)view.DataContext;

                Application.Current.MainWindow = view;
                Application.Current.MainWindow.ShowDialog();
            }

            // If the user hit cancel and no accounts are saved, end the application
            if (context.Accounts.Count == 0)
            {
                Shutdown();
            }

            // Load up the Alert balloon
            try
            {
                logger.Log(LogLevel.Info, "Loading up the Alert balloons...");

                PopupView   view       = new PopupView();
                TaskbarIcon notifyIcon = (TaskbarIcon)FindResource("NotifyIcon");

                notifyIcon.ShowCustomBalloon(view, PopupAnimation.None, null);
            }
            catch (Exception ex)
            {
                logger.Log(LogLevel.Error, "Failed loading the alert balloons.", ex);
            }

            // Login.
            logger.Log(LogLevel.Info, "Performing Login...");
            engine.Login();
        }
Пример #25
0
        private void handleMessage()
        {
            while (!isStop)
            {
                Thread.Sleep(1000);
                if (message_next.getMessageType() == AGVMessageHandler_TYPE_T.AGVMessageHandler_MIN)
                {
                    continue;
                }
                message.setMessageStr(message_next.getMessageStr());
                message.setMessageType(message_next.getMessageType());

                message_next.clear();

                startBeep(message.getMessageType());

                if (message.getMessageType() == AGVMessageHandler_TYPE_T.AGVMessageHandler_LOWPOWER)
                {
                    FormController.getFormController().getMainFrm().setFrmEnable(false);
                    DialogResult dr = MessageBox.Show(message.getMessageStr(), "低电量警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    if (dr == DialogResult.OK)
                    {
                        FormController.getFormController().getMainFrm().setFrmEnable(true);
                        FormController.getFormController().getMainFrm().setWindowState(FormWindowState.Normal);
                        clearBeep();
                    }
                }
                else if (message.getMessageType() == AGVMessageHandler_TYPE_T.AGVMEASAGE_LIFT_UPDOWN)
                {
                    bool ddp = ScheduleFactory.getSchedule().getDownDeliverPeriod();
                    if (ddp)
                    {
                        AGVSystem.getSystem().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_DOWN_WITH_START);                          //如果当前处于上货阶段,楼上楼下都有货,需要暂停楼下的车
                    }
                    else
                    {
                        AGVSystem.getSystem().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_UP_WITH_START);                         //如果当前处于下货阶段,楼上楼下都有货,需要暂停楼上的车
                    }

                    DialogResult dr = MessageBox.Show(message.getMessageStr(), "升降机提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    if (dr == DialogResult.OK)
                    {
                        AGVSystem.getSystem().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_TYPE_MIN);                         //解除楼上或楼下的暂停
                        clearBeep();
                    }
                }
                else if (message.getMessageType() == AGVMessageHandler_TYPE_T.AGVMessageHandler_LIFT_COM)
                {
                    AGVSystem.getSystem().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_SYSTEM_WITH_START);
                    FormController.getFormController().getMainFrm().setFrmEnable(false);
                    DialogResult dr = MessageBox.Show(message.getMessageStr(), "升降机错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    if (dr == DialogResult.OK)
                    {
                        if (ElevatorFactory.getElevator().isNeed())
                        {
                            ElevatorFactory.getElevator().reStart();                             //重新启动升降机 PLC读取线程
                        }
                        FormController.getFormController().getMainFrm().setFrmEnable(true);
                        AGVSystem.getSystem().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_TYPE_MIN);                         //解除系统暂停
                        clearBeep();
                    }
                }
                else if (message.getMessageType() == AGVMessageHandler_TYPE_T.AGVMessageHandler_LIFT_BUG)
                {
                    AGVSystem.getSystem().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_SYSTEM_WITH_START);
                    FormController.getFormController().getMainFrm().setFrmEnable(false);
                    DialogResult dr = MessageBox.Show(message.getMessageStr(), "升降机错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    if (dr == DialogResult.OK)
                    {
                        //AGVInitialize.getInitialize().getAGVElevatorOperator().reStart(); //重新启动升降机 PLC读取线程
                        FormController.getFormController().getMainFrm().setFrmEnable(true);
                        AGVSystem.getSystem().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_TYPE_MIN);                         //解除系统暂停
                        clearBeep();
                    }
                }
                else if (message.getMessageType() == AGVMessageHandler_TYPE_T.AGVMessageHandler_NET_ERR)
                {
                    AGVSystem.getSystem().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_SYSTEM_WITH_START);
                    DialogResult dr = MessageBox.Show(message.getMessageStr(), "网络异常", MessageBoxButtons.OK, MessageBoxIcon.Warning);                     //网络中断时,系统暂停
                    if (dr == DialogResult.OK)
                    {
                        AGVSystem.getSystem().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_TYPE_MIN);
                        clearBeep();
                    }
                }
                else if (message.getMessageType() == AGVMessageHandler_TYPE_T.AGVMessageHandler_SENDPAUSE_ERR)
                {
                    AGVSystem.getSystem().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_UP_WITHOUT_START);
                    DialogResult dr = MessageBox.Show(message.getMessageStr(), "网络异常", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    if (dr == DialogResult.OK)
                    {
                        AGVSystem.getSystem().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_TYPE_MIN);                         //清除楼上暂停的标志,但是车子暂停不会解除
                        clearBeep();
                    }
                }
                else if (message.getMessageType() == AGVMessageHandler_TYPE_T.AGVMessageHandler_AGV_ALARM)                    //检测到防撞信号,暂停所有AGV
                {
                    AGVSystem.getSystem().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_SYSTEM_WITH_START);
                    //DialogResult dr = MessageBox.Show(message.getMessageStr(), "防撞提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    //if (dr == DialogResult.OK) {
                    AGVSystem.getSystem().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_TYPE_MIN);                             //清除楼上暂停的标志,但是车子暂停不会解除
                    clearBeep();
                    //}
                }
                message.clear();                  //清除消息
            }
        }