Ejemplo n.º 1
0
 public void RegisterClient(string Token)
 {
     ServiceLog.Instance.LogInfo("New client registration request received.");
     ClientRegistered?.Invoke(this, new RegisterEventArgs {
         Token = Token, Status = 0
     });
 }
        public void Handle(ClientRegistered e)
        {
            if (e.ExistClientId.HasValue)
            {
                _clients.Remove(_clients.Single(c => c.Id == e.ExistClientId.Value));
            }

            _clients.Add(e.ClientMachine);
        }
        public void RegisterClientMachine(ClientMachine machine)
        {
            var @event = new ClientRegistered(machine);

            if (machine.Id > 0)
            {
                @event.ExistClientId = machine.Id;
            }

            ApplyChange(@event);
        }
Ejemplo n.º 4
0
        public void On(ClientRegistered @event)
        {
            using (var session = _documentStore.OpenSession())
            {
                session.Store(new AccountEntry
                {
                    Email    = @event.Email,
                    Username = @event.Username
                });

                session.SaveChanges();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Register a new client (this client is connected now)
        /// </summary>
        /// <param name="uuid"></param>
        /// <param name="host"></param>
        /// <param name="port"></param>
        /// <exception cref="InvalidOperationException"></exception>
        public void RegisterClient(string uuid, string host, int port)
        {
            Logger.Info($"> Register new client <{uuid}> from {host}:{port}");
            lock (_clientDict)
            {
                if (_clientDict.ContainsKey(uuid))
                {
                    throw new InvalidOperationException($"Client already registered: {uuid}");
                }

                var client = new Client(host, port);
                _clientDict.Add(uuid, client);
                ClientRegistered?.Invoke(this, new ClientRegistrationEventArgs(client));
            }
        }
Ejemplo n.º 6
0
        bool RegisterNewUsers(Update[] result)
        {
            bool registered = false;

            foreach (Update upd in result)
            {
                if (upd.Message == null || string.IsNullOrEmpty(upd.Message.Text))
                {
                    continue;
                }
                if (upd.Message.Text.Trim() == "/regme " + RegistrationCode)
                {
                    registered = true;
                    long chatId = upd.Message.Chat.Id;
                    if (Clients.Values.FirstOrDefault(c => c.ChatId.Identifier == chatId) != null)
                    {
                        ClientRegistered.Invoke(this, new TelegramClientInfoEventArgs()
                        {
                            Client = Clients.Values.FirstOrDefault(c => c.ChatId.Identifier == chatId)
                        });
                        continue;
                    }

                    TelegramClientInfo clientInfo = new TelegramClientInfo();
                    clientInfo.ChatId           = new ChatId(chatId);
                    clientInfo.ClientId         = RegistrationId;
                    clientInfo.RegistrationCode = RegistrationCode;
                    clientInfo.Enabled          = true;

                    Clients.Add(chatId, clientInfo);
                    if (ClientRegistered != null)
                    {
                        ClientRegistered.Invoke(this, new TelegramClientInfoEventArgs()
                        {
                            Client = clientInfo
                        });
                    }
                }
            }
            if (!registered)
            {
                Telemetry.Default.TrackEvent("Telegram bot not recv /regme command");
                Telemetry.Default.Flush();
            }
            return(true);
        }
Ejemplo n.º 7
0
 private void WhenClientRegistered(string clientId)
 {
     ClientRegistered?.Invoke(this, new ClientNotificationEventArgs(clientId));
 }
Ejemplo n.º 8
0
        public void Apply(ClientRegistered command)
        {
            FirstName             = command.FirstName;
            LastName              = command.LastName;
            Gender                = command.Gender;
            DateOfBirth           = command.DateOfBirth;
            Email                 = command.Email;
            ContactNumber         = command.ContactNumber;
            Address.Line1         = command.AddressLine1;
            Address.Line2         = command.AddressLine2;
            Address.Suburb        = command.Suburb;
            Address.City          = command.City;
            ExcerciseFrequency    = command.ExcerciseFrequency;
            IsSmoker              = command.IsSmoker;
            CurrentMedications    = command.CurrentMedications;
            PreviousAilments      = command.PreviousAilments;
            GeneralPractionerName = command.GeneralPractionerName;
            MedicalClearance      = command.MedicalClearance;
            HasHadPreviousTherapy = command.HasHadPreviousTherapy;
            TouchPreference       = command.TouchPreference;
            ContraIndications.Arteriosclerosis        = command.ContraIndicationsArteriosclerosis;
            ContraIndications.Arthritis               = command.ContraIndicationsArthritis;
            ContraIndications.Asthma                  = command.ContraIndicationsAsthma;
            ContraIndications.Cancer                  = command.ContraIndicationsCancer;
            ContraIndications.ColdOrFlu               = command.ContraIndicationsColdOrFlu;
            ContraIndications.ContactLenses           = command.ContraIndicationsContactLenses;
            ContraIndications.CutsBurnsBruises        = command.ContraIndicationsCutsBurnsBruises;
            ContraIndications.Depression              = command.ContraIndicationsDepression;
            ContraIndications.Diabetes                = command.ContraIndicationsDiabetes;
            ContraIndications.Dizziness               = command.ContraIndicationsDizziness;
            ContraIndications.Epilepsy                = command.ContraIndicationsEpilepsy;
            ContraIndications.Headache                = command.ContraIndicationsHeadache;
            ContraIndications.HeartDisease            = command.ContraIndicationsHeartDisease;
            ContraIndications.Hemophilia              = command.ContraIndicationsHemophilia;
            ContraIndications.Hernia                  = command.ContraIndicationsHernia;
            ContraIndications.HighBloodPressure       = command.ContraIndicationsHighBloodPressure;
            ContraIndications.Imflamation             = command.ContraIndicationsImflammation;
            ContraIndications.IrritatedSkinRash       = command.ContraIndicationsIrritatedSkinRash;
            ContraIndications.IsPregnant              = command.ContraIndicationsIsPregnant;
            ContraIndications.LowBloodPressure        = command.ContraIndicationsLowBloodPressure;
            ContraIndications.MusculoskeletalProblems = command.ContraIndicationsMusculoskletalProblems;
            ContraIndications.PinsPacemaker           = command.ContraIndicationsPinsPacemaker;
            ContraIndications.SeverePain              = command.ContraIndicationsSeverePain;
            ContraIndications.SleepDisturbance        = command.ContraIndicationsSleepDisturbance;
            ContraIndications.StomachUlcers           = command.ContraIndicationsStomachUlcers;
            ContraIndications.Sunburn                 = command.ContraIndicationsSunburn;
            ContraIndications.VaricoseVeins           = command.ContraIndicationsVaricoseVeins;

            CurrentStressLevels        = command.CurrentStressLevels;
            CurrentPainOrTensionLevels = command.CurrentPainOrTensionLevels;
            Difficuties                   = command.Difficulties;
            AreasNotToBeMassaged          = command.AreasNotToBeMassaged;
            TermsAndConditions.Condition1 = command.TermsAndConditionsConditions1;
            TermsAndConditions.Condition2 = command.TermsAndConditionsConditions2;
            TermsAndConditions.Condition3 = command.TermsAndConditionsConditions3;
            TermsAndConditions.Condition4 = command.TermsAndConditionsConditions4;
            TermsAndConditions.Condition5 = command.TermsAndConditionsConditions5;
            TermsAndConditions.Condition6 = command.TermsAndConditionsConditions6;
            TermsAndConditions.Condition7 = command.TermsAndConditionsConditions7;
            TermsAndConditions.Condition8 = command.TermsAndConditionsConditions8;


            OrganizationId = command.OrganizationId;
        }
Ejemplo n.º 9
0
        public void Apply(ClientRegistered domainEvent)
        {
            OrganizationId                    = domainEvent.OrganizationId;
            FirstName                         = domainEvent.FirstName;
            LastName                          = domainEvent.LastName;
            Gender                            = domainEvent.Gender;
            DateOfBirth                       = domainEvent.DateOfBirth;
            Email                             = domainEvent.Email;
            ContactNumber                     = domainEvent.ContactNumber;
            AddressLine1                      = domainEvent.AddressLine1;
            AddressLine2                      = domainEvent.AddressLine2;
            Suburb                            = domainEvent.Suburb;
            City                              = domainEvent.City;
            ExcerciseFrequency                = domainEvent.ExcerciseFrequency;
            IsSmoker                          = domainEvent.IsSmoker;
            CurrentMedications                = domainEvent.CurrentMedications;
            PreviousAilments                  = domainEvent.PreviousAilments;
            GeneralPractionerName             = domainEvent.GeneralPractionerName;
            MedicalClearance                  = domainEvent.MedicalClearance;
            HasHadPreviousTherapy             = domainEvent.HasHadPreviousTherapy;
            TouchPreference                   = domainEvent.TouchPreference;
            ContraIndicationsArteriosclerosis = domainEvent.ContraIndicationsArteriosclerosis;

            ContraIndicationsArthritis              = domainEvent.ContraIndicationsArthritis;
            ContraIndicationsAsthma                 = domainEvent.ContraIndicationsAsthma;
            ContraIndicationsCancer                 = domainEvent.ContraIndicationsCancer;
            ContraIndicationsColdOrFlu              = domainEvent.ContraIndicationsColdOrFlu;
            ContraIndicationsContactLenses          = domainEvent.ContraIndicationsContactLenses;
            ContraIndicationsCutsBurnsBruises       = domainEvent.ContraIndicationsCutsBurnsBruises;
            ContraIndicationsDepression             = domainEvent.ContraIndicationsDepression;
            ContraIndicationsDiabetes               = domainEvent.ContraIndicationsDiabetes;
            ContraIndicationsDizziness              = domainEvent.ContraIndicationsDizziness;
            ContraIndicationsEpilepsy               = domainEvent.ContraIndicationsEpilepsy;
            ContraIndicationsHeadache               = domainEvent.ContraIndicationsHeadache;
            ContraIndicationsHeartDisease           = domainEvent.ContraIndicationsHeartDisease;
            ContraIndicationsHemophilia             = domainEvent.ContraIndicationsHemophilia;
            ContraIndicationsHernia                 = domainEvent.ContraIndicationsHernia;
            ContraIndicationsHighBloodPressure      = domainEvent.ContraIndicationsHighBloodPressure;
            ContraIndicationsImflammation           = domainEvent.ContraIndicationsImflammation;
            ContraIndicationsIrritatedSkinRash      = domainEvent.ContraIndicationsIrritatedSkinRash;
            ContraIndicationsIsPregnant             = domainEvent.ContraIndicationsIsPregnant;
            ContraIndicationsLowBloodPressure       = domainEvent.ContraIndicationsLowBloodPressure;
            ContraIndicationsMusculoskletalProblems = domainEvent.ContraIndicationsMusculoskletalProblems;
            ContraIndicationsPinsPacemaker          = domainEvent.ContraIndicationsPinsPacemaker;
            ContraIndicationsSeverePain             = domainEvent.ContraIndicationsSeverePain;
            ContraIndicationsSleepDisturbance       = domainEvent.ContraIndicationsSleepDisturbance;
            ContraIndicationsStomachUlcers          = domainEvent.ContraIndicationsStomachUlcers;
            ContraIndicationsSunburn                = domainEvent.ContraIndicationsSunburn;
            ContraIndicationsVaricoseVeins          = domainEvent.ContraIndicationsVaricoseVeins;

            CurrentStressLevels           = domainEvent.CurrentStressLevels;
            CurrentPainOrTensionLevels    = domainEvent.CurrentPainOrTensionLevels;
            AreasNotToBeMassaged          = domainEvent.AreasNotToBeMassaged;
            TermsAndConditionsConditions1 = domainEvent.TermsAndConditionsConditions1;
            TermsAndConditionsConditions2 = domainEvent.TermsAndConditionsConditions2;
            TermsAndConditionsConditions3 = domainEvent.TermsAndConditionsConditions3;
            TermsAndConditionsConditions4 = domainEvent.TermsAndConditionsConditions4;
            TermsAndConditionsConditions5 = domainEvent.TermsAndConditionsConditions5;
            TermsAndConditionsConditions6 = domainEvent.TermsAndConditionsConditions6;
            TermsAndConditionsConditions7 = domainEvent.TermsAndConditionsConditions7;
            TermsAndConditionsConditions8 = domainEvent.TermsAndConditionsConditions8;
        }
Ejemplo n.º 10
0
 private ClientMachine ClientMachineFromEvent(ClientRegistered @event) => @event.ClientMachine;