Exemple #1
0
        public void Promotion_PremiumUserLoggedAsInstructor()
        {
            profiles[0].Licence.BAPoints    = 10;
            profiles[0].Licence.AccountType = Model.AccountType.PremiumUser;
            insertToDatabase(profiles[0]);

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                //set promotion cost of instructor account to 0
                var manager      = new PaymentsManager();
                var accountTypes = new Dictionary <AccountType, PaymentAccountType>()
                {
                    { AccountType.Instructor, new PaymentAccountType()
                      {
                          AccountType = AccountType.Instructor, Points = 3, PromotionPoints = 0, PromotionStartDate = DateTime.UtcNow.Date
                      } },
                    { AccountType.PremiumUser, new PaymentAccountType()
                      {
                          AccountType = AccountType.PremiumUser, Points = 1
                      } },
                };
                var itemsToBuy = new Dictionary <string, int>();
                service.Configuration.Payments = manager.Load(accountTypes, itemsToBuy, 15);

                ((MockTimerService)service.Configuration.TimerService).UtcNow = DateTime.UtcNow.Date;
                service.Configuration.CurrentApiKey = key;
                ClientInformation info   = new ClientInformation();
                info.ApplicationVersion  = Constants.Version;
                info.ApplicationLanguage = "pl";
                info.Version             = Const.ServiceVersion;
                info.ClientInstanceId    = Guid.NewGuid();
                string password          = CryptographyHelper.ToSHA1Hash("Profile1");

                var session      = service.Login(info, "Profile1", password);
                var securityInfo = SecurityManager.EnsureAuthentication(session.Token);
                Assert.AreEqual(AccountType.Instructor, securityInfo.Licence.CurrentAccountType);
                Assert.AreEqual(10, securityInfo.Licence.BAPoints);
            });
            var dbProfile = Session.Get <Profile>(profiles[0].GlobalId);

            Assert.AreEqual(BodyArchitect.Model.AccountType.PremiumUser, dbProfile.Licence.AccountType);
            Assert.AreEqual(10, dbProfile.Licence.BAPoints);
            Assert.AreEqual(DateTime.UtcNow.Date, dbProfile.Licence.LastPointOperationDate);
        }
Exemple #2
0
        public void SetApiKeyInLoginData()
        {
            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                service.Configuration.CurrentApiKey = key;
                ClientInformation info   = new ClientInformation();
                info.ApplicationVersion  = Constants.Version;
                info.ApplicationLanguage = "pl";
                info.Version             = Const.ServiceVersion;
                info.ClientInstanceId    = Guid.NewGuid();
                string password          = CryptographyHelper.ToSHA1Hash("Profile1");

                service.Login(info, profiles[0].UserName, password);
            });

            var loginData = Session.QueryOver <LoginData>().SingleOrDefault();

            Assert.AreEqual(key, loginData.ApiKey.ApiKey);
        }
Exemple #3
0
        public void WaitCallback(Object state)
        {
            var client = new ClientInformation();

            client.Version             = Const.ServiceVersion;
            client.ApplicationLanguage = "pl";
            client.ClientInstanceId    = Guid.NewGuid();
            client.Platform            = PlatformType.Windows;
            client.PlatformVersion     = "1.0";
            client.ApplicationVersion  = "1.0.0.0";

            for (int i = 0; i < 15; i++)
            {
                var session = NHibernateFactory.OpenSession();
                InternalBodyArchitectService service = new InternalBodyArchitectService(session);
                var sessionData = service.Login(client, "kox", "kwazar".ToSHA1Hash());
                session.Close();
            }
        }
        public SessionData CreateNewSession(ProfileDTO profile, ClientInformation clientInfo, LoginData loginData)
        {
            Version version = new Version(clientInfo.Version);

            if (version != new Version(Const.ServiceVersion))
            {
                Log.WriteError("Client version:{0}, service version:{1}", clientInfo.Version, Const.ServiceVersion);
                throw new DatabaseVersionException("You have old version of the application. Please get the latest version and try again");
            }

            Token       token        = new Token(Guid.NewGuid());
            SessionData sessionData  = new SessionData(token, profile, true);
            var         securityInfo = new SecurityInfo(sessionData, loginData);

            securityInfo.ClientInformation = clientInfo;
            Cache.Add(token.SessionId.ToString(), securityInfo, CacheItemPriority.NotRemovable, null, new SlidingTime(TimeSpan.FromSeconds(SessionTimeout)));

            return(sessionData);
        }
Exemple #5
0
 private void WatchForImages(ClientInformation client)
 {
     try
     {
         while (true)
         {
             if (Clients[client.ID].Connections["ImageReceiver"].DataAvailable)
             {
                 OnImageReceived?.BeginInvoke(Clients[client.ID].Connections["ImageReceiver"].Reader.ReadBytes(Clients[client.ID].Connections["ImageReceiver"].Reader.ReadInt32()), client, result => { try { OnImageReceived.EndInvoke(result); } catch { } }, null);
             }
             else
             {
                 Thread.Sleep(0);
             }
         }
     }
     catch (ThreadInterruptedException) { }
     catch (KeyNotFoundException) { }
 }
Exemple #6
0
        private void ConnectToEventstore()
        {
            latestPosition = Position.Start;

            var subs = connection.SubscribeToAllFrom(latestPosition, true, HandleEvent);


            //subscribe to the stream of fraud alert
            connection.SubscribeToStreamFrom("PossiblyStolenCardClients", 0, true,

                                             (sub, e) =>
            {
                var jsonString = Encoding.UTF8.GetString(e.Event.Data);

                JObject o = JObject.Parse(jsonString);

                var clientID = (string)o["ClientID"];

                Bus.Publish(new ClientPossiblyStolen()
                {
                    ClientID = clientID
                });

                var ci = indexer.Get <ClientInformation>(clientID);

                if (ci == null)
                {
                    ci = new ClientInformation()
                    {
                        ID = clientID
                    }
                }
                ;

                ci.PossiblyStolen = true;

                indexer.Index(ci);
            }
                                             );


            Console.WriteLine("Indexing service started");
        }
Exemple #7
0
        public void TestLogin_Statistics()
        {
            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                service.Configuration.CurrentApiKey = key;
                ClientInformation info   = new ClientInformation();
                info.ApplicationVersion  = Constants.Version;
                info.ApplicationLanguage = "pl";
                info.Version             = Const.ServiceVersion;
                info.ClientInstanceId    = Guid.NewGuid();
                string password          = CryptographyHelper.ToSHA1Hash("Profile1");

                service.Login(info, profiles[0].UserName, password);
            });

            var dbProfile = Session.Get <Profile>(profiles[0].GlobalId);

            Assert.IsNotNull(dbProfile.Statistics.LastLoginDate);
        }
        public ClientInformation ToMtlModel()
        {
            ClientInformation mtlModel = new ClientInformation()
            {
                ActivityRate      = ActivityRate,
                AverageWeightInKg = AverageWeightInKg,
                BodyFatPercentage = BodyFatPercentage,
                Goal = new Goal()
            };

            switch (GoalType)
            {
            case "Lose":
                mtlModel.Goal.Type = MTL.Models.GoalType.Lose;
                break;

            case "Maintain":
                mtlModel.Goal.Type = MTL.Models.GoalType.Maintain;
                break;

            case "Gain":
                mtlModel.Goal.Type = MTL.Models.GoalType.Gain;
                break;
            }

            switch (GoalIntensity)
            {
            case "Light":
                mtlModel.Goal.Intensity = MTL.Models.GoalIntensityType.Light;
                break;

            case "Moderate":
                mtlModel.Goal.Intensity = MTL.Models.GoalIntensityType.Moderate;
                break;

            case "Intense":
                mtlModel.Goal.Intensity = MTL.Models.GoalIntensityType.Intense;
                break;
            }

            return(mtlModel);
        }
Exemple #9
0
        public void CalculateGainModerate()
        {
            ClientInformation clientInfo = new ClientInformation();

            clientInfo.ActivityRate      = 1.375;
            clientInfo.AverageWeightInKg = Formulas.LbtoKg(198);
            clientInfo.BodyFatPercentage = 0.15;
            clientInfo.Goal = new Goal
            {
                Intensity = GoalIntensityType.Moderate,
                Type      = GoalType.Gain
            };

            Assert.AreEqual(Math.Round(clientInfo.AverageWeightInKg), 90);

            var leanBodyMass                        = Formulas.LeanBodyMass(clientInfo.AverageWeightInKg, clientInfo.BodyFatPercentage);
            var basalMetabolicRate                  = Formulas.KatchMcArdle(leanBodyMass);
            var totalDailyEnergyExpenditure         = Formulas.CalculateTDEE(clientInfo.ActivityRate, basalMetabolicRate);
            var adjustedTotalDailyEnergyExpenditure = totalDailyEnergyExpenditure + clientInfo.Goal.AdjustBasedOnGoal(clientInfo.AverageWeightInKg);
        }
Exemple #10
0
        private static void AutocreateAccountCallback(IAuthClient client, Account acct)
        {
            if (acct == null)
            {
                OnLoginError(client, AccountStatus.InvalidInformation);

                return;
            }

            var authInfo = new AuthenticationInfo {
                SessionKey        = client.Authenticator.SRP.SessionKey.GetBytes(40),
                Salt              = client.Authenticator.SRP.Salt.GetBytes(32),
                Verifier          = client.Authenticator.SRP.Verifier.GetBytes(),
                SystemInformation = ClientInformation.Serialize(client.ClientInfo)
            };

            client.Server.StoreAuthenticationInfo(client.CurrentUser, authInfo);

            SendAuthProofSuccessReply(client);
        }
Exemple #11
0
        public List <ClientInformation> GetAllClientInformation()
        {
            List <ClientInformation> ClientInformationDataList = new List <ClientInformation>();

            SqlConnection con = new SqlConnection(GlobalSettings.connection);

            con.Open();
            SqlCommand Cmd = new SqlCommand("sp_GetAllClientInformation", con);

            Cmd.CommandType = System.Data.CommandType.StoredProcedure;

            SqlDataReader dr = Cmd.ExecuteReader();

            while (dr.Read())
            {
                ClientInformation ClientInformation = new ClientInformation();
                ClientInformation.ClientInformationID = DataTypesConvertor.ConvertToGuid(dr["ClientInformationID"].ToString());
                ClientInformation.Title               = dr["Title"].ToString();
                ClientInformation.Name                = dr["Name"].ToString();
                ClientInformation.MiddleName          = dr["MiddleName"].ToString();
                ClientInformation.Surname             = dr["Surname"].ToString();
                ClientInformation.Gender              = dr["Gender"].ToString();
                ClientInformation.DateOfBirth         = DataTypesConvertor.ConvertToDateTime(dr["DateOfBirth"].ToString());
                ClientInformation.IDNumber            = dr["IDNumber"].ToString();
                ClientInformation.Cell                = dr["Cell"].ToString();
                ClientInformation.TelHome             = dr["TelHome"].ToString();
                ClientInformation.TelWork             = dr["TelWork"].ToString();
                ClientInformation.Email               = dr["Email"].ToString();
                ClientInformation.StreetNameAndNumber = dr["StreetNameAndNumber"].ToString();
                ClientInformation.Suburb              = dr["Suburb"].ToString();
                ClientInformation.City                = dr["City"].ToString();
                ClientInformation.PostalCode          = dr["PostalCode"].ToString();

                ClientInformationDataList.Add(ClientInformation);
            }
            dr.Close();
            con.Close();


            return(ClientInformationDataList);
        }
Exemple #12
0
 public void GetLoginInfo(ClientInformation ClientInfo)
 {
     if (System.Web.HttpContext.Current.Session["UserID"] != null)
     {
         if (ClientInfo != null)
         {
             ClientInfo.LoginUser   = System.Web.HttpContext.Current.Session["UserID"] as string;
             ClientInfo.FactoryCode = System.Web.HttpContext.Current.Session["FactoryCode"] as string;
             ClientInfo.CompanyCode = System.Web.HttpContext.Current.Session["CompanyCode"] as string;
         }
     }
     else
     {
         if (ClientInfo != null)
         {
             ClientInfo.LoginUser   = "******";
             ClientInfo.FactoryCode = "未选择";
             ClientInfo.CompanyCode = "未选择";
         }
     }
 }
Exemple #13
0
        private void OnButtonNextStepClick()
        {
            IServiceForFilingPersonInfoInClientOrder serviceForOrder = _kernel.Get <IServiceForFilingPersonInfoInClientOrder>();

            serviceForOrder.SetClientOrder(_order);

            ClientInformation info = new ClientInformation();

            if (_view.IsDelivery())
            {
                HomeAddress address = new HomeAddress();
                address.City           = _view.GetCity();
                address.Street         = _view.GetStreet();
                address.FlatNumber     = _view.GetFlat();
                address.FloorNumber    = _view.GetFloorNumber();
                address.HomeNumber     = _view.GetHouseNumber();
                address.PavilionNumber = _view.GetPavilion();
                address.PorchNumber    = _view.GetPorchNumber();
                info.Address           = address;
                _order.IsDelivery      = true;
            }
            else
            {
                _order.IsDelivery = false;
            }

            info.Name         = _view.GetName();
            info.Patronymic   = _view.GetPatronymic();
            info.Surname      = _view.GetSurname();
            info.EmailAddress = _view.GetEmailAddress();
            info.PhoneNumber  = _view.GetPhoneNumber();

            serviceForOrder.AddClientInfo(info);

            new ClientManagerEditOrderSecondStepPresenter(_kernel, _kernel.Get <IClientManagerAddOrderSecondStepView>(),
                                                          _kernel.Get <IClientOrderServiceForClientManager>(), _kernel.Get <IServiceForControlProductMovementInClientOrder>(),
                                                          _order)
            .Run();
            _view.Close();
        }
Exemple #14
0
        protected S2SClientBase(ClientInformation clientInformation, ILogger logger)
        {
            if (clientInformation == null)
            {
                throw new ArgumentException(nameof(clientInformation));
            }
            if (clientInformation.Credentials == null)
            {
                throw new ArgumentException(nameof(clientInformation.Credentials));
            }
            if (String.IsNullOrWhiteSpace(clientInformation.Credentials.ClientId))
            {
                throw new ArgumentNullException(nameof(clientInformation.Credentials.ClientId));
            }
            if (String.IsNullOrWhiteSpace(clientInformation.Credentials.ClientSecret))
            {
                throw new ArgumentNullException(nameof(clientInformation.Credentials.ClientSecret));
            }
            if (String.IsNullOrWhiteSpace(clientInformation.TargetApiName))
            {
                throw new ArgumentNullException(nameof(clientInformation.TargetApiName));
            }
            if (String.IsNullOrWhiteSpace(clientInformation.TargetBaseUrl))
            {
                throw new ArgumentNullException(nameof(clientInformation.TargetBaseUrl));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            this._client = new HttpClient {
                BaseAddress = new Uri(clientInformation.TargetBaseUrl)
            };

            this.ApiName   = clientInformation.TargetApiName;
            _clientOptions = clientInformation;
            this.Logger    = logger;
        }
        public void Update(ClientInformation clientInformation)
        {
            InformationGrabbed = true;

            var offlineClient = clientInformation as OfflineClientInformation;

            if (offlineClient != null)
            {
                LastSeen = offlineClient.LastSeen;
                IsOnline = false;
            }
            else
            {
                IsOnline = true;
                var onlineClient = (OnlineClientInformation)clientInformation;
                OnlineSince      = onlineClient.OnlineSince;
                IpAddress        = onlineClient.IpAddress;
                Port             = onlineClient.Port;
                Version          = onlineClient.Version;
                FrameworkVersion = onlineClient.FrameworkVersion;
            }

            UserName         = clientInformation.UserName;
            OsType           = clientInformation.OsType;
            ApiVersion       = clientInformation.ApiVersion;
            IsAdministrator  = clientInformation.IsAdministrator;
            IsServiceRunning = clientInformation.IsServiceRunning;
            Language         = clientInformation.Language;
            OsName           = clientInformation.OsName;
            if (clientInformation.LocatedCountry != null)
            {
                GeoLocationTwoLetter = clientInformation.LocatedCountry;
            }

            IsComputerInformationAvailable = clientInformation.IsComputerInformationAvailable;
            IsPasswordDataAvailable        = clientInformation.IsPasswordDataAvailable;

            OnPropertyChanged(nameof(LanguageName));
            OnPropertyChanged(nameof(Country));
        }
Exemple #16
0
        private void ButtonSearchClient_Click(object sender, EventArgs e)
        {
            selectedClient = workspaceLibrarian.ClientInformationRegister.FindByLibraryTicket(Convert.ToInt32(textBoxManageClient.Text));

            if (selectedClient != null)
            {
                using (ClientLibraryInfoControlForm clientLibraryInfo = new ClientLibraryInfoControlForm(workspaceLibrarian, ref selectedClient))
                {
                    clientLibraryInfo.ShowDialog();
                }
            }
            else
            {
                DialogResult result = MessageBox.Show(Properties.Resources.searchFailed, Properties.Resources.failed,
                                                      MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                if (DialogResult.OK == result)
                {
                    CreateNewClient();
                }
            }
            Activate();
        }
Exemple #17
0
        public async Task Test_GetAccessToken()
        {
            var config = GetConfig();
            var info   = new GatewayInformation(config);

            var clientInfo = new ClientInformation()
            {
                Credentials = new ClientCredentials()
                {
                    ClientId     = info.ClientInfo.ClientId,
                    ClientSecret = info.ClientInfo.ClientSecret
                },
                TargetBaseUrl      = info.Apis[APINAME_RECIPEAPI],
                TargetApiName      = APINAME_RECIPEAPI,
                AuthServerLocation = info.AuthServerUrl
            };

            var tokenResponse = await GetAccessTokenFromAuthServer(clientInfo);

            Assert.False(tokenResponse.IsError);
            Assert.NotEmpty(tokenResponse.AccessToken);
        }
Exemple #18
0
        public override void createTestFixture()
        {
            base.createTestFixture();
            ObjectsConverter.Configure();
            configureLogging();
            clientInformation = new ClientInformation()
            {
                Version = Const.ServiceVersion
            };
            clientInformation.ApplicationLanguage = "en";
            clientInformation.PlatformVersion     = "fgfdgdfg";
            clientInformation.ApplicationVersion  = "1.0.0.0";
            var conf = new ConfigurationSourceBuilder();

            conf.ConfigureCaching().ForCacheManagerNamed(SecurityManager.AuthenticationCacheName).StoreInMemory();

            var configSource = new DictionaryConfigurationSource();

            conf.UpdateConfigurationWithReplace(configSource);

            EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource);
        }
Exemple #19
0
        public void RemoveOldRepetitionsOnceReminders_AnotherProfile()
        {
            var reminderFuture = CreateReminder("test", profiles[0], DateTime.UtcNow.Date.AddDays(2));
            var reminderPast   = CreateReminder("test", profiles[1], DateTime.UtcNow.Date.AddDays(-3));

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                service.Configuration.CurrentApiKey = key;
                ClientInformation info   = new ClientInformation();
                info.ApplicationVersion  = Constants.Version;
                info.ApplicationLanguage = "pl";
                info.Version             = Const.ServiceVersion;
                info.ClientInstanceId    = Guid.NewGuid();
                string password          = CryptographyHelper.ToSHA1Hash("Profile1");

                service.Login(info, profiles[0].UserName, password);
            });

            var count = Session.QueryOver <ReminderItem>().RowCount();

            Assert.AreEqual(2, count);
        }
        public void ImportLicence_DataInLicenceKey_LoginDataSet()
        {
            LicenceGenerator generator = new LicenceGenerator();
            var    goodLicenceKey      = generator.GenerateLicenceKey(30);
            string password            = CryptographyHelper.ToSHA1Hash(profiles[0].UserName);

            profiles[0].Password = password;
            insertToDatabase(profiles[0]);

            APIKey apiKey = new APIKey();

            apiKey.ApiKey           = key;
            apiKey.ApplicationName  = "UnitTest";
            apiKey.EMail            = "*****@*****.**";
            apiKey.RegisterDateTime = DateTime.UtcNow;
            insertToDatabase(apiKey);

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                //first login to have LoginData
                service.Configuration.CurrentApiKey = key;
                ClientInformation info   = new ClientInformation();
                info.ApplicationVersion  = Constants.Version;
                info.ApplicationLanguage = "pl";
                info.Version             = Const.ServiceVersion;
                info.ClientInstanceId    = Guid.NewGuid();


                var sessionData = service.Login(info, profiles[0].UserName, password);

                ((MockTimerService)service.Configuration.TimerService).UtcNow = DateTime.UtcNow.Date.AddHours(4);
                service.ImportLicence(sessionData.Token, goodLicenceKey);
            });

            var licence = Session.QueryOver <BAPoints>().SingleOrDefault();

            Assert.IsNotNull(licence.LoginData);
        }
Exemple #21
0
        public void RemoveOldRepetitionsOnceReminders_ConnectedObjectReminder_ForCustomer()
        {
            var         cust           = CreateCustomer("tesst", profiles[0]);
            var         reminderFuture = CreateReminder("test", profiles[0], DateTime.UtcNow.Date.AddDays(2));
            var         reminderPast   = CreateReminder("test", profiles[0], DateTime.UtcNow.Date.AddDays(-3));
            TrainingDay day            = new TrainingDay(DateTime.Now);
            SizeEntry   size           = new SizeEntry();

            size.Wymiary = new Wymiary();
            day.AddEntry(size);
            day.Customer  = cust;
            day.Profile   = profiles[0];
            size.Reminder = reminderPast;
            insertToDatabase(day);
            reminderPast.ConnectedObject = "EntryObjectDTO:" + size.GlobalId.ToString();
            insertToDatabase(reminderPast);

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                service.Configuration.CurrentApiKey = key;
                ClientInformation info   = new ClientInformation();
                info.ApplicationVersion  = Constants.Version;
                info.ApplicationLanguage = "pl";
                info.Version             = Const.ServiceVersion;
                info.ClientInstanceId    = Guid.NewGuid();
                string password          = CryptographyHelper.ToSHA1Hash("Profile1");

                service.Login(info, profiles[0].UserName, password);
            });

            var dbReminder = Session.QueryOver <ReminderItem>().SingleOrDefault();

            Assert.AreEqual(dbReminder.GlobalId, reminderFuture.GlobalId);

            var dbSize = Session.Get <SizeEntry>(size.GlobalId);

            Assert.IsNull(dbSize.Reminder);
        }
Exemple #22
0
        /// <summary>
        /// Validates the auth-info sent by the client.
        /// Called within the IO-Queue's Context
        /// </summary>
        /// <returns>The session key or null if authentication failed</returns>
        private static bool ValidateAuthentication(IRealmClient client, string accountName)
        {
            var authInfo = RealmServer.Instance.GetAuthenticationInfo(accountName);

            if (authInfo == null)
            {
                RealmServer.Instance.Error(client, Resources.FailedToRetrieveAccount, accountName);

                LoginHandler.SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_FAILED);
            }
            else
            {
                try
                {
                    client.SessionKey = authInfo.SessionKey;
                    client.Info       = ClientInformation.Deserialize(authInfo.SystemInformation);

                    var srp = new SecureRemotePassword(accountName, authInfo.Verifier, authInfo.Salt);

                    BigInteger clientVerifier = srp.Hash(srp.Username, new byte[4], client.ClientSeed, RealmServer.Instance.AuthSeed, client.SessionKey);

                    if (clientVerifier != client.ClientDigest)
                    {
                        LoginHandler.SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_FAILED);
                    }
                    else
                    {
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    LogUtil.ErrorException(e, false, "Failed to validate authentication of Account " + accountName);
                    LoginHandler.SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_FAILED);
                }
            }
            return(false);
        }
Exemple #23
0
        private void btnClientInformation_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (clientInfoHandler == null)
                {
                    clientInfoHandler = new ClientInformation();
                }
                clientInfoHandler.SelectedFileNumber = txtFileNo.Text;

                if (clientInfoHandler.WindowState == System.Windows.WindowState.Minimized)
                {
                    clientInfoHandler.WindowState = System.Windows.WindowState.Maximized;
                    clientInfoHandler.Activate();
                }
                clientInfoHandler.Show();
                this.Close();
            }
            catch (Exception ex)
            {
                Helper.LogException(ex);
            }
        }
Exemple #24
0
        public ActionResult CreateClients()
        {
            ClientInformation clientInfoObj = new ClientInformation
            {
                // SetRegions();
                //TempData["RegionList"] = clientInformation.StateList;
                StateList           = SetRegions(),
                CountryList         = SetCountries(),
                PhoneTypeList       = SetPhoneTypes(),
                BusinessStatusList  = SetBusinessStatus(),
                BusinessTypeList    = SetBusinessType(),
                CounsellingTypeList = SetCounsellingType(),
                ExportList          = SetExportType(),
                GenderList          = SetGender(),
                RaceList            = SetRaceTypes(),
                SBAClientList       = SetSBAClientTypes(),
                VeteranStatusList   = SetVeteranStatus()
            };

            //TempData["StateList"] = objc.StateList;

            return(View("CreateClients", clientInfoObj));
        }
Exemple #25
0
        // TODO: rework params
        public Bot(int amountShards, ICacheClient client, ClientInformation cInfo, string rabbitUrl)
        {
            Information = cInfo;

            Client = new DiscordClient(new DiscordClientConfigurations
            {
                CacheClient          = client,
                RabbitMQExchangeName = "consumer",
                RabbitMQQueueName    = "gateway",
                RabbitMQUri          = rabbitUrl,
                Token = cInfo.Token
            });

            CacheClient = new CacheClient(
                Client._websocketClient,
                client, Client._apiClient
                );

            if (Instance == null)
            {
                Instance = this;
            }
        }
Exemple #26
0
        private void simpleButtonSave_Click(object sender, EventArgs e)
        {
            if (dxValidationProviderClient.Validate())
            {
                // Get the data from the binding source
                bindingSourceClient.EndEdit();

                // Pull the object from the data source
                _clientObj = bindingSourceClient.DataSource as ClientInformation;

                if (EditMode)
                {
                    _clientObj?.Update();
                }
                else
                {
                    // Save the data to the database
                    _clientObj?.Insert();
                }

                // close the screen
                DialogResult = DialogResult.OK;
            }
        }
        public void handleMessage(string message)
        {
            message = message.Substring("DEVINFO".Length);

            ClientInformation dev = new ClientInformation();

            dev = JSONManager.deserialize <ClientInformation>(message);
            dev.LastConnected = DateTime.Now;
            dev.IP            = address.ToString();
            dev.Connected     = true;

            if (ClientMangager.knownDevices.ContainsKey(dev.id))
            {
                ClientMangager.knownDevices[dev.id] = dev;
            }
            else
            {
                ClientMangager.knownDevices.Add(dev.id, dev);
            }

            ClientMangager.saveDevices();
            logic.device = dev;
            MainWindow.Instance.NotifyDeviceDatasetChanged();
        }
Exemple #28
0
        private void barButtonItemEditProgressNote_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // get the client id
            int clientId = GetSelectedNodeId();

            if (clientId > 0)
            {
                ProgressNoteLists noteLists = new ProgressNoteLists();
                noteLists.Client = ClientInformation.GetClientInfo(clientId);
                noteLists.ShowDialog();
            }
            // Attach a client
            //int noteId = GetSelectedNodeId();
            //if (noteId < 0)
            //{
            //    ShowProgressNote(0, Math.Abs(noteId));
            //    ShowProgressNoteReport(Math.Abs(noteId));
            //}
            //else
            //{
            //    MessageBox.Show("Please select a progress note from the current client list.", "Select Note",
            //        MessageBoxButtons.OK, MessageBoxIcon.Information);
            //}
        }
        private void ProgressNoteForm_Load(object sender, EventArgs e)
        {
            // Fill the mental status drop downs
            FillDropDownLists();

            // Only can delete a note that previously exists
            ButtonDeleteNote.Enabled = EditMode;

            // Write out the full name
            labelControlClientName.Text = ClientInformation.GetClientInfo(CurrentProgressNote.ClientId).FullName;

            //if (CurrentProgressNote.NextSession == null)
            //{
            //    DateTime? nextAppt = AppointmentExtender.GetNextClientAppointment(CurrentProgressNote.ClientId);

            //    if (nextAppt != null)
            //    {
            //        CurrentProgressNote.NextSession = Convert.ToDateTime(nextAppt);
            //    }
            //}

            // Set the binding source
            progressNoteBindingSource.DataSource = CurrentProgressNote;
        }
Exemple #30
0
        public void StartServer()
        {
            try
            {
                IPAddress address = IPAddress.Parse(SERVER_ADDRESS);

                TcpListener listener = new TcpListener(address, PORT_NUMBER);

                listener.Start();
                Console.WriteLine("Server started on " + listener.LocalEndpoint);
                while (true)
                {
                    Console.WriteLine("Waiting for a connection...");

                    Socket socket = listener.AcceptSocket();
                    Console.WriteLine("Connection received from " + socket.RemoteEndPoint);
                    ClientInformation clientInfo = new ClientInformation(socket);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex);
            }
        }
Exemple #31
0
 public void Set(string name, ClientInformation clientInformation)
 {
     _concurrentDictionary.AddOrUpdate(name, clientInformation, (s, information) => clientInformation);
 }
Exemple #32
0
 public void SetClientInfo(ClientInformation clientInfo)
 {
     _clientInformation = clientInfo;
 }
        private byte[] GenerateZipPackage(string fileName, string workSpace, ClientInformation clientInformation, List<DeviceInformation> deviceInformations)
        {
            string path = System.IO.Path.Combine(workSpace, fileName);
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string content = Resources.Metrics.Metrics.index;
            content = content.Replace(@"{{CSID}}",clientInformation.CSID);
            content = content.Replace(@"{{PrimaryFirstName}}", clientInformation.PrimaryFirstName);
            content = content.Replace(@"{{PrimaryLastName}}", clientInformation.PrimaryLastName);
            content = content.Replace(@"{{PrimaryEmailAddress}}", clientInformation.PrimaryEmailAddress);
            content = content.Replace(@"{{PrimaryPhone}}", clientInformation.PrimaryPhone);
            content = content.Replace(@"{{SecondaryFirstName}}", clientInformation.SecondaryFirstName);
            content = content.Replace(@"{{SecondaryLastName}}", clientInformation.SecondaryLastName);
            content = content.Replace(@"{{SecondaryEmailAddress}}", clientInformation.SecondaryEmailAddress);
            content = content.Replace(@"{{SecondaryPhone}}", clientInformation.SecondaryPhone);
            //updating client company in Index
            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(content);
            XmlNode xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/PRS_Address/Address1");
            xmlNode.InnerText = clientInformation.Street;
            xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/PRS_Address/City");
            xmlNode.InnerText = clientInformation.City;
            xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/PRS_Address/PostalCode");
            xmlNode.InnerText = clientInformation.PostalCode;
            xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/PRS_Address/Country");
            xmlNode.InnerText = clientInformation.CountryCode;
            xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/PRS_Address/Region");
            xmlNode.InnerText = clientInformation.StateProvince;
            xmlNode = xmlDocument.SelectSingleNode("*/HP_ISEECustomer/Name");
            xmlNode.InnerText = clientInformation.CompanyName;
            string index = System.IO.Path.Combine(path, "index.xml");
            xmlDocument.Save(index);
            List<string> endpointList = new List<string>();
            //updateing device serial number and product number
            foreach (DeviceInformation item in deviceInformations)
            {
                string endpoint = Guid.NewGuid().ToString().Replace("-", "");
                string deviceFullName = string.Format("{0}.{1}", item.DeviceName, item.Domain);
                string osNameAndVersion = string.Format("{0},{1}", item.OSName, item.OSVersion);
                content = Resources.Metrics.Metrics.endpoint;
                content = content.Replace(@"{{PrimaryFirstName}}", clientInformation.PrimaryFirstName);
                content = content.Replace(@"{{PrimaryLastName}}", clientInformation.PrimaryLastName);
                content = content.Replace(@"{{PrimaryEmailAddress}}", clientInformation.PrimaryEmailAddress);
                content = content.Replace(@"{{PrimaryPhone}}", clientInformation.PrimaryPhone);
                content = content.Replace(@"{{SecondaryFirstName}}", clientInformation.SecondaryFirstName);
                content = content.Replace(@"{{SecondaryLastName}}", clientInformation.SecondaryLastName);
                content = content.Replace(@"{{SecondaryEmailAddress}}", clientInformation.SecondaryEmailAddress);
                content = content.Replace(@"{{SecondaryPhone}}", clientInformation.SecondaryPhone);
                //CSID
                xmlDocument.LoadXml(content);
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_OOSIdentifiers/CSID/Section/Property[@name='AutoDetectedSystemSerialNumber']");
                xmlNode.Attributes["value"].Value = item.SerialNumber;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_OOSIdentifiers/CSID/Section/Property[@name='TimestampGenerated']");
                xmlNode.Attributes["value"].Value = DateTime.UtcNow.ToString(@"yyyy/MM/dd HH:mm:ss \G\M\T");
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_OOSIdentifiers/CSID/Section/Property[@name='ProductId']");
                xmlNode.Attributes["value"].Value = item.ProductNumber;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_OOSIdentifiers/CSID/Section/Property[@name='SystemModel']");
                xmlNode.Attributes["value"].Value = item.CoreSystemModel;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_OOSIdentifiers/CSID/Section/Property[@name='CoreSystemModel']");
                xmlNode.Attributes["value"].Value = item.CoreSystemModel;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_OOSIdentifiers/CSID/Section/Property[@name='Hostname']");
                xmlNode.Attributes["value"].Value = item.DeviceName;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_OOSIdentifiers/CSID/Section/Property[@name='FQDN']");
                xmlNode.Attributes["value"].Value = deviceFullName;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_OOSIdentifiers/CSID/Section/Property[@name='IPAddress']");
                xmlNode.Attributes["value"].Value = item.IPAddress;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_OOSIdentifiers/CSID/Section/Property[@name='MacAddress']");
                xmlNode.Attributes["value"].Value = item.MAC;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_OOSIdentifiers/CSID/Section/Property[@name='HPID']");
                xmlNode.Attributes["value"].Value = clientInformation.HPPID;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_OOSIdentifiers/CSID/Section/Property[@name='OSNameAndVersionString']");
                xmlNode.Attributes["value"].Value = osNameAndVersion;
                //PN&SN
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_ISEEEntitlementParameters/SerialNumber");
                xmlNode.InnerText = item.SerialNumber;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_ISEEEntitlementParameters/ProductNumber");
                xmlNode.InnerText = item.ProductNumber;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/HP_ISEEEntitlementParameters/ProductId");
                xmlNode.InnerText = item.ProductNumber;
                //delete device flag
                xmlNode = xmlDocument.SelectSingleNode("*/LDID");
                xmlNode.InnerText = endpoint;
                if (deviceFullName.Equals(this.DeleteDeviceFullName))
                {
                    xmlNode = xmlDocument.SelectSingleNode("*/LDID");
                    xmlNode.Attributes["state"].Value = "disabled";
                    xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/ObjectOfServiceProperties/Property[@name='Transport_Enabled']");
                    xmlNode.Attributes["value"].Value = "0";
                }
                //Service&Support Partner Id
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/ObjectOfServiceProperties/Property[@name='CPServiceProviderID']");
                xmlNode.Attributes["value"].Value = clientInformation.ServicePartnerId;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/ObjectOfServiceProperties/Property[@name='CPSupportProviderID']");
                xmlNode.Attributes["value"].Value = clientInformation.SupportPartnerId;
                //collectionFlag
                if (!"false".Equals(item.CollectionProblem))
                {
                    xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/ObjectOfServiceProperties/Property[@name='Service::Server_Basic_Configuration_Collection::functional']");
                    xmlNode.Attributes["value"].Value = "false";
                }
                //monitor Flag
                if (!"false".Equals(item.MonitoringProblem))
                {
                    xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/ObjectOfServiceProperties/Property[@name='Service::Query Connection::functional']");
                    xmlNode.Attributes["value"].Value = "false";
                    xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/ObjectOfServiceProperties/Property[@name='Service::Subscription Manager::functional']");
                    xmlNode.Attributes["value"].Value = "false";
                }
                //company
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/PRS_Address/Address1");
                xmlNode.InnerText = clientInformation.Street;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/PRS_Address/City");
                xmlNode.InnerText = clientInformation.City;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/PRS_Address/PostalCode");
                xmlNode.InnerText = clientInformation.PostalCode;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/PRS_Address/Country");
                xmlNode.InnerText = clientInformation.CountryCode;
                xmlNode = xmlDocument.SelectSingleNode("*/AssociatedDevice/PRS_Address/Region");
                xmlNode.InnerText = clientInformation.StateProvince;
                xmlNode = xmlDocument.SelectSingleNode("*/HP_ISEECustomer/Name");
                xmlNode.InnerText = clientInformation.CompanyName;
                xmlDocument.Save(System.IO.Path.Combine(path, endpoint+".xml"));
                endpointList.Add(endpoint);
            }
            //attach endpoint detail information to index
            xmlDocument.Load(index);
            xmlNode = xmlDocument.SelectSingleNode("*//AssociatedDevice");
            foreach (string item in endpointList)
            {
                XmlElement xmlElement = xmlDocument.CreateElement("PRS_Attachment");
                xmlDocument.DocumentElement.InsertAfter(xmlElement, xmlNode);
                XmlNode parentNode = xmlDocument.SelectSingleNode("*/PRS_Attachment");

                xmlElement = xmlDocument.CreateElement("Caption");
                parentNode.AppendChild(xmlElement);

                xmlElement = xmlDocument.CreateElement("Description");
                parentNode.AppendChild(xmlElement);

                xmlElement = xmlDocument.CreateElement("DirtyFlag");
                xmlElement.InnerText = "0";
                parentNode.AppendChild(xmlElement);

                xmlElement = xmlDocument.CreateElement("AttachmentName");
                xmlElement.InnerText = item + ".xml";
                parentNode.AppendChild(xmlElement);

                xmlElement = xmlDocument.CreateElement("AttachmentObject");
                parentNode.AppendChild(xmlElement);

                xmlElement = xmlDocument.CreateElement("AttachmentReference");
                parentNode.AppendChild(xmlElement);

                xmlElement = xmlDocument.CreateElement("AttachmentSize");
                FileInfo fileInfo = new FileInfo(System.IO.Path.Combine(path, item + ".xml"));
                xmlElement.InnerText = fileInfo.Length.ToString();
                parentNode.AppendChild(xmlElement);

                xmlElement = xmlDocument.CreateElement("AttachmentType");
                xmlElement.InnerText = "1";
                parentNode.AppendChild(xmlElement);

                xmlElement = xmlDocument.CreateElement("Format");
                xmlElement.InnerText = "xml";
                parentNode.AppendChild(xmlElement);

                xmlElement = xmlDocument.CreateElement("Protocol");
                parentNode.AppendChild(xmlElement);
            }
            xmlNode = xmlDocument.SelectSingleNode("*/OOS_Support/Property[@name='MetricsTime']");
            xmlNode.Attributes["value"].Value = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
            xmlDocument.Save(index);

            using (ZipFile zipFile = new ZipFile())
            {
                zipFile.AddDirectory(path);
                zipFile.Save(path+".zip");
            }
            System.IO.Directory.Delete(path,true);
            FileStream fileStream = new FileStream(path+".zip", FileMode.Open, FileAccess.Read, FileShare.None);
            StreamReader streamReader = new StreamReader(fileStream);
            byte[] source = new byte[fileStream.Length];
            fileStream.Read(source, 0, (int)fileStream.Length);
            return source;
        }