public async static Task Update(m.Profile obj)
 {
     using (var db = DbAccess.ConnectionFactory())
     {
         await db.ExecuteAsync(DbAccess.Update <m.Profile>(), obj);
     }
 }
        /// <summary>
        ///     Deletes a <paramref name="profile" /> on a given <paramref name="wirelessInterface" />
        /// </summary>
        /// <param name="wirelessInterface">The wireless interface to delete the profile on</param>
        /// <param name="profile">The profile to delete</param>
        public void DeleteProfile(WirelessInterface wirelessInterface, Profile profile)
        {
            Guid interfaceGuid = wirelessInterface.InterfaceGuid;

            uint result = NativeWireless.WlanDeleteProfile(this.GetHandle(), ref interfaceGuid, profile.ProfileName, IntPtr.Zero);

            result.ThrowIfNotSuccess();
        }
        public async static Task <m.Profile> Login(m.Profile p)
        {
            using (var db = DbAccess.ConnectionFactory())
            {
                string    query   = DbAccess.SelectAll <m.Profile>() + " WHERE [LoginId]=@LoginId AND [Pwd]=@Pwd";
                m.Profile profile = await db.QueryFirstOrDefaultAsync <m.Profile>(query,
                                                                                  new { LoginId = p.LoginId, Pwd = p.Pwd });

                return(profile);
            }
        }
Exemple #4
0
        public async Task <IActionResult> Post([FromBody] m.Profile data)
        {
            try
            {
                await d.Profile.Insert(data);

                return(Ok(data));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public void Get()
        {
            try
            {
                m.Profile obj = d.Profile.Get(profile.ProfileId).Result;
                IEnumerable <m.Profile> profiles = d.Profile.Get().Result;

                Assert.IsTrue(true);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        // Find all directories in profiles folder, and read their settings.txt. Add profile to profiles.
        private void createProfiles()
        {
            string[] profileDirs = Directory.GetDirectories(@"Resources\Profiles\");
            foreach (string profileDir in profileDirs)
            {
                string settingsPath = profileDir + "\\settings.txt";
                if (File.Exists(settingsPath))
                {
                    string name = "", config = "", crosshair = "", autoexec = "", videoSettings = "", launchOptions = "", nvidiaProfile = "";

                    string[] settings = File.ReadAllLines(settingsPath);
                    foreach (string line in settings)
                    {
                        if (line.Contains("Name = "))
                        {
                            name = line.Split('=').Last().Replace(" ", "");
                        }
                        if (line.Contains("Config = "))
                        {
                            config = line.Split('=').Last().Replace(" ", "");
                        }
                        if (line.Contains("Crosshair = "))
                        {
                            crosshair = line.Split('=').Last().Replace(" ", "");
                        }
                        if (line.Contains("Autoexec = "))
                        {
                            autoexec = line.Split('=').Last().Replace(" ", "");
                        }
                        if (line.Contains("VideoSettings = "))
                        {
                            videoSettings = line.Split('=').Last().Replace(" ", "");
                        }
                        if (line.Contains("LaunchOptions = "))
                        {
                            launchOptions = line.Split('=').Last();
                        }
                        if (line.Contains("NvidiaProfile = "))
                        {
                            nvidiaProfile = line.Split('=').Last().Replace(" ", "");
                        }
                    }
                    Profile profile = new Profile(name, config, crosshair, autoexec, videoSettings, launchOptions, nvidiaProfile, profileDir + "\\");
                    profiles.Add(profile);
                }
            }
        }
Exemple #7
0
        public async Task <IActionResult> Put(Guid id, [FromBody] m.Profile data)
        {
            try
            {
                if (id != data.ProfileId)
                {
                    return(BadRequest());
                }

                await d.Profile.Update(data);

                return(Ok(data));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #8
0
        public async Task <IActionResult> Post([FromBody] m.Profile data)
        {
            try
            {
                IEnumerable <m.Profile> profiles = await Get();

                m.Profile exists = profiles.FirstOrDefault(p => p.LoginId == data.LoginId);
                if (exists != null)
                {
                    return(BadRequest("Login ID is duplicated"));
                }

                await d.Profile.Insert(data);

                return(Ok(data));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        private void populateControls(Profile selectedProfile)
        {
            if (selectedProfile.Data != null)
            {
                txtAppId.Text = selectedProfile.Data.ResourceId;
                txtClientId.Text = selectedProfile.Data.ClientId;
                txtClientKey.Text = selectedProfile.Data.ClientKey;
                txtUsername.Text = selectedProfile.Data.Username;
                txtPassword.Text = selectedProfile.Data.Password;
            }
            if (selectedProfile.Type == ProfileType.Client)
            {
                radClient.Checked = true;
            }
            else {
                radUser.Checked = true;
            }

            if (selectedProfile.TenantType == TenantType.Single)
            {
                radSingleTenant.Checked = true;
                txtTenant.Text = selectedProfile.Data.Tenant;
            }
            else
            {
                radMultiTenant.Checked = true;
                txtTenant.Text = String.Empty;
            }

            toggleConfigurationGroup(true);
        }
Exemple #10
0
        private void lnkNew_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            bool handledDirty = handleContextChange();
            if (!handledDirty)
                return;

            var name = Prompt.ShowDialog("What would you like to call this profile?", "New Profile");

            if (String.IsNullOrWhiteSpace(name))
            {
                return;
            }
            reset();

            var profile = new Profile
            {
                Name = name
            };
            _profileService.Save(profile);
            loadProfiles();
            var index = cboProfile.Items.IndexOf(profile);

            cboProfile.SelectedIndex = index;
            toggleProfileButtons(true);
            tstat.Text = String.Concat("Created profile '", profile.Name, "'");
        }
Exemple #11
0
        private void lnkDelete_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var confirmation = MessageBox.Show(this, String.Format("Are you sure you would like to delete the profile '{0}'", cboProfile.Text), "Are you sure you want to delete?",
                            MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
            if (confirmation == DialogResult.No)
            {
                return;
            }
            var profile = (Profile)cboProfile.SelectedItem;
            string profileName = profile.Name;
            _profileService.Delete(profile);
            loadProfiles();
            toggleConfigurationGroup(false);

            if (cboProfile.Items.Count < 1)
            {
                toggleProfileButtons(false);
            }
            tstat.Text = String.Format("Deleted profile '{0}'", profileName);
            _currentProfile = null;
            reset();
            toggleProfileButtons(false);
        }
Exemple #12
0
        private bool isDirty(Profile target)
        {
            if (_currentProfile == null || target == null)
                return false;

            if (String.Compare(target.Name, _currentProfile.Name, StringComparison.InvariantCultureIgnoreCase) != 0)
                return true;

            if (target.Type != _currentProfile.Type)
                return true;

            if (target.Data == null || _currentProfile.Data == null)
                return true;

            if (target.Data.ClientId != _currentProfile.Data.ClientId)
                return true;

            if (target.Type == ProfileType.Client && (target.Data.ClientKey != _currentProfile.Data.ClientKey))
                return true;

            if (target.Type == ProfileType.User && (target.Data.Username != _currentProfile.Data.Username))
                return true;

            if (target.Type == ProfileType.User && (target.Data.Password != _currentProfile.Data.Password))
                return true;

            if (target.Data.ResourceId != _currentProfile.Data.ResourceId)
                return true;

            if (target.Data.Tenant != _currentProfile.Data.Tenant)
                return true;

            if (target.TenantType != _currentProfile.TenantType)
                return true;

            return false;
        }
Exemple #13
0
        private Profile getProposedProfile()
        {
            //populate a profile from the controls
            var profile = new Profile
            {
                Name = cboProfile.Text,
                Data = createTokenParametersFromInput(),
                Type = radClient.Checked ? ProfileType.Client : ProfileType.User,
                TenantType = radMultiTenant.Checked ? TenantType.Multi : TenantType.Single,
            };

            return profile;
        }
Exemple #14
0
 private void cboProfile_SelectedIndexChanged(object sender, EventArgs e)
 {
     reset(keepSelectedItem: true);
     var selectedProfile = cboProfile.SelectedItem as Profile;
     if (selectedProfile != null)
     {
         populateControls(selectedProfile);
         toggleProfileButtons(true);
         tstat.Text = String.Concat("Loaded profile '", selectedProfile.Name, "'");
         _currentProfile = selectedProfile;
     }
 }
        /// <summary>
        ///     Move the <paramref name="profile" /> to a given <paramref name="position" /> for the given <paramref name="wirelessInterface" />
        /// </summary>
        /// <param name="wirelessInterface">The wireless interface</param>
        /// <param name="profile">The profile</param>
        /// <param name="position">The position requested</param>
        public void SetProfilePosition(WirelessInterface wirelessInterface, Profile profile, uint position)
        {
            Guid interfaceGuid = wirelessInterface.InterfaceGuid;

            uint result = NativeWireless.WlanSetProfilePosition(this.GetHandle(), interfaceGuid, profile.ProfileName, position, IntPtr.Zero);

            result.ThrowIfNotSuccess();
        }
Exemple #16
0
        private Profile save()
        {
            Profile targetProfile = getProposedProfile();
            _profileService.Save(targetProfile);

            foreach (var item in cboProfile.Items)
            {
                var profileItem = (Profile)item;
                if (profileItem.Name == targetProfile.Name)
                {
                    profileItem.Data = targetProfile.Data;
                    profileItem.TenantType = targetProfile.TenantType;
                    profileItem.Type = targetProfile.Type;
                }
            }
            _currentProfile = targetProfile;
            return _currentProfile;
        }
Exemple #17
0
 public async Task <IActionResult> Login([FromBody] m.Profile profile)
 {
     return(Ok(await d.Profile.Login(profile)));
 }