Beispiel #1
0
        public ViewModelCrew()
        {
            if (Client.State == CommunicationState.Closed)
            {
                Client.Open();
            }

            crew = new Crew();

            AddEntityCommand      = new RelayCommand(AddEntityCommand_Execute, AddEntityCommand_CanExecute);
            RemoveEntityCommand   = new RelayCommand(RemoveEntityCommand_Execute, RemoveEntityCommand_CanExecute);
            AddToCrewCommand      = new RelayCommand(AddToCrewCommand_Execute, AddToCrewCommand_CanExecute);
            RemoveFromCrewCommand = new RelayCommand(RemoveFromCrewCommand_Execute, RemoveFromCrewCommand_CanExecute);
            AddAllCommand         = new RelayCommand(AddAllCommand_Execute, AddAllCommand_CanExecute);
            RemoveAllCommand      = new RelayCommand(RemoveAllCommand_Execute, RemoveAllCommand_CanExecute);

            Crews                   = new ObservableCollection <Crew>(Client.GetEntityByType(EntityType.Crew).Cast <Crew>());
            AllMembers              = new ObservableCollection <CrewMember>(Client.GetEntityByType(EntityType.CrewMember).Cast <CrewMember>().Where(member => string.IsNullOrEmpty(member.Crew)));
            CrewMembers             = new ObservableCollection <CrewMember>();
            SelectedMembers         = new ObservableCollection <CrewMember>();
            SelectedMembersToRemove = new ObservableCollection <CrewMember>();

            MakeProxy(this);

            try
            {
                proxy.Subscribe(EntityType.Crew.ToString());
                proxy.Subscribe(EntityType.CrewMember.ToString());
            }
            catch (Exception ex)
            {
                CrFSMLogger.CrFSMLogger.Instance.WriteToLog(ex);
            }
        }
Beispiel #2
0
        public ViewModelCrewMember()
        {
            if (Client.State == CommunicationState.Closed)
            {
                Client.Open();
            }

            crewMember = new CrewMember();

            AddEntityCommand       = new RelayCommand(AddEntityCommand_Execute);
            RemoveEntityCommand    = new RelayCommand(RemoveEntityCommand_Execute, RemoveEntityCommand_CanExecute);
            AddSkillCommand        = new RelayCommand(AddSkillCommand_Execute, AddSkillCommand_CanExecute);
            RemoveSkillCommand     = new RelayCommand(RemoveSkillCommand_Execute, RemoveSkillCommand_CanExecute);
            AddAllSkillsCommand    = new RelayCommand(AddAllSkillsCommand_Execute, AddAllSkillsCommand_CanExecute);
            RemoveAllSkillsCommand = new RelayCommand(RemoveAllSkillsCommand_Execute, RemoveAllSkillsCommand_CanExecute);

            Crews       = new ObservableCollection <Crew>(Client.GetEntityByType(EntityType.Crew).Cast <Crew>());
            CrewMembers = new ObservableCollection <CrewMember>(Client.GetEntityByType(EntityType.CrewMember).Cast <CrewMember>());

            UserTypes = new ObservableCollection <UserType> {
                UserType.Manager, UserType.Worker
            };

            AllSkills = new ObservableCollection <Skills>
            {
                Skills.OperateInSubstation,
                Skills.OperateOutOfSubstation,
                Skills.PerformPlannedWork,
                Skills.PerformSwitching,
                Skills.PerformUnplannedWork
            };

            MemeberSkills        = new ObservableCollection <Skills>();
            SelectedAllSkills    = new ObservableCollection <Skills>();
            SelectedMemberSkills = new ObservableCollection <Skills>();
            AllShifts            = new ObservableCollection <Shift>(Client.GetEntityByType(EntityType.Shift).Cast <Shift>());

            MakeProxy(this);

            try
            {
                proxy.Subscribe(EntityType.CrewMember.ToString());
                proxy.Subscribe(EntityType.Crew.ToString());
                proxy.Subscribe(EntityType.Shift.ToString());
            }
            catch (Exception ex)
            {
                CrFSMLogger.CrFSMLogger.Instance.WriteToLog(ex);
            }
        }
Beispiel #3
0
 void Main(string[] args)
 {
     _endpoint = Common.Config.SubscriberEndpointAddres;
     MakeProxy(_endpoint, this);
     _proxy.Subscribe("TestTopic");
     Console.ReadLine();
 }
Beispiel #4
0
        public static Awaiter GetAwaiter(this ISubscribe s)
        {
            var d1 = React.Scope(out var scope);
            var aw = new Awaiter(scope, d1.Dispose);

            s.Subscribe(d1.Dispose, scope);
            return(aw);
        }
Beispiel #5
0
        public static Awaiter <T> GetAwaiter <T>(this ISubscribe <T> s)
        {
            var result = new Option <T>();
            var d1     = React.Scope(out var scope);
            var aw     = new Awaiter(scope, d1.Dispose);
            var res    = new Awaiter <T>(aw, () => result.GetOrFail());

            s.Subscribe(msg =>
            {
                result = msg;
                d1.Dispose();
            }, scope);
            return(res);
        }
Beispiel #6
0
        static IScope Delay(float seconds, ISubscribe s)
        {
            if (DefaultScope.Disposing)
            {
                return(Never.Instance);
            }

            var pub   = DefaultScope.SubScope(out var res);
            var timer = Time.time + seconds;

            s.Subscribe(() =>
            {
                if (timer.KeepWaiting(Time.time))
                {
                    return;
                }

                pub.Dispose();
            }, res);

            return(res);
        }