Пример #1
0
        private void cmdTestConnection_Click(object sender, EventArgs e)
        {
            ThreadPool.QueueUserWorkItem(a =>
            {
                StringBuilder messages = new StringBuilder();
                try
                {
                    DatabaseProfile dbProfile = _dbSettings.Profiles[dgdSettings.CurrentRow.Index];
                    Query dbQuery             = new Query(dbProfile);
                    if (dbProfile.EnablePing)
                    {
                        messages.AppendLine("Ping results");
                        PingReply reply = dbQuery.Ping();
                        messages.AppendLine(reply.Status.ToString());
                        messages.AppendLine();
                    }

                    messages.AppendLine("Connection results");
                    using (var con = dbQuery.CreateConnection())
                    {
                        con.Open();
                        messages.AppendLine(String.Format("Connected to datasource {0}", dbProfile.DataSource));
                    }

                    MessageBox.Show(messages.ToString(), "Test connection succeeded");
                }
                catch (Exception ex)
                {
                    messages.AppendLine(ex.Message);
                    MessageBox.Show(messages.ToString(), "Test connection failed");
                }
            });
        }
Пример #2
0
        public ProfileSetup(DatabaseProfile profile)
        {
            InitializeComponent();

            //database settings
            _dbProfile         = profile;
            _strDefaultProfile = DatabaseConfiguration.DatabaseSettings.DefaultProfile;

            try
            {
                _dbTemp = new DBProfileTemp(profile);
                propProfile.SelectedObject = _dbTemp;
                if (_dbTemp.Name == _strDefaultProfile)
                {
                    _dbTemp.DefaultProfile = true;
                }
                else
                {
                    _dbTemp.DefaultProfile = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
            }
        }
Пример #3
0
        private void cmdCopy_Click(object sender, EventArgs e)
        {
            if (dgdSettings.CurrentRow == null)
            {
                return;
            }

            try
            {
                DatabaseProfile dbProfile     = _dbSettings.Profiles[dgdSettings.CurrentRow.Index];
                DatabaseProfile dbProfileCopy = new DatabaseProfile("Copy of " + dbProfile.Name);

                dbProfileCopy.ProviderType     = dbProfile.ProviderType;
                dbProfileCopy.Timeout          = dbProfile.Timeout;
                dbProfileCopy.ConnectionString = dbProfile.ConnectionString;

                ProfileSetup frmEdit = new ProfileSetup(dbProfileCopy);
                if (DialogResult.OK == frmEdit.ShowDialog())
                {
                    _dbSettings.Profiles.Add(dbProfileCopy);
                    ShowProfiles();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Copy profile");
            }
        }
Пример #4
0
        private void cmdNew_Click(object sender, EventArgs e)
        {
            try
            {
                DatabaseProfile dbProfile = new DatabaseProfile(string.Format("New"));

RenameProfile:
                NewProfile frmAddProfile = new NewProfile(dbProfile.Name);

                if (DialogResult.OK == frmAddProfile.ShowDialog())
                {
                    dbProfile.Name = frmAddProfile.ProfileName;
                    if (_dbSettings.Profiles[dbProfile.Name] != null)
                    {
                        MessageBox.Show("The profile you entered already exists. Choose a different name for the profile.");
                        goto RenameProfile;
                    }
                    ProfileSetup newProfile = new ProfileSetup(dbProfile);
                    if (newProfile.ShowDialog() == DialogResult.OK)
                    {
                        _dbSettings.Profiles.Add(dbProfile);
                        ShowProfiles();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Add profile");
            }
        }
Пример #5
0
 /*
  *  Shell relativa all'utente admin
  */
 public MainPageAdmin()
 {
     InitializeComponent();
     Application.Current.Properties["logged"] = "true";
     Application.Current.Properties["Admin"]  = "true";
     Application.Current.Properties["UID"]    = DatabaseProfile.GetUid();
     Application.Current.SavePropertiesAsync();
 }
Пример #6
0
 public DBProfileTemp(DatabaseProfile dbProfile)
 {
     this.Name            = dbProfile.Name;
     this.Timeout         = dbProfile.Timeout;
     this.ProviderType    = dbProfile.ProviderType;
     this._connectionType = new ConnectionType(ProviderType, dbProfile.ConnectionString);
     this.EnablePing      = dbProfile.EnablePing;
     this.PingTimeout     = dbProfile.PingTimeout;
     this._pingTTL        = dbProfile.PingTTL;
 }
Пример #7
0
 internal PhpWorkloadResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, WorkloadKind kind, WorkloadsSku sku, PhpWorkloadResourceIdentity identity, AzureLocation?appLocation, ManagedRGConfiguration managedResourceGroupConfiguration, UserProfile adminUserProfile, VmssNodesProfile webNodesProfile, NodeProfile controllerProfile, NetworkProfile networkProfile, DatabaseProfile databaseProfile, SiteProfile siteProfile, FileshareProfile fileshareProfile, PhpProfile phpProfile, SearchProfile searchProfile, CacheProfile cacheProfile, BackupProfile backupProfile, PhpWorkloadProvisioningState?provisioningState) : base(id, name, resourceType, systemData, tags, location)
 {
     Kind        = kind;
     Sku         = sku;
     Identity    = identity;
     AppLocation = appLocation;
     ManagedResourceGroupConfiguration = managedResourceGroupConfiguration;
     AdminUserProfile  = adminUserProfile;
     WebNodesProfile   = webNodesProfile;
     ControllerProfile = controllerProfile;
     NetworkProfile    = networkProfile;
     DatabaseProfile   = databaseProfile;
     SiteProfile       = siteProfile;
     FileshareProfile  = fileshareProfile;
     PhpProfile        = phpProfile;
     SearchProfile     = searchProfile;
     CacheProfile      = cacheProfile;
     BackupProfile     = backupProfile;
     ProvisioningState = provisioningState;
 }
Пример #8
0
        private void cmdEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgdSettings.CurrentRow != null)
                {
                    DatabaseProfile dbProfile = _dbSettings.Profiles[dgdSettings.CurrentRow.Index];
                    ProfileSetup    frmEdit   = new ProfileSetup(dbProfile);

                    if (DialogResult.OK == frmEdit.ShowDialog())
                    {
                        ShowProfiles();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Edit profile");
            }
        }
Пример #9
0
        /// <summary>
        /// Returns all data from a table and stores it in a DataSet using Control.Database.SQLite3
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public DataSet GrabData(string table)
        {
            string _command = $"SELECT * FROM {table};";

            DataSet data = new DataSet();

            using (DbCommand command = FileConnection.CreateCommand())
            {
                DatabaseProfile profile = new DatabaseProfile("sqlite", constr, "SQLite 3");
                SQLiteQuery     query   = new SQLiteQuery(profile);

                command.CommandText = _command;
                command.CommandType = CommandType.Text;
                data = query.Execute(command);
            }

            Console.Clear();

            return(data);
        }
Пример #10
0
        public async Task Startup()
        {
            Application.Current.Properties["MyUID"] = DatabaseProfile.GetUid();
            Application.Current.Properties["ABC"]   = "A";
            await Application.Current.SavePropertiesAsync();

            if (await DatabaseProfile.GetProfile())
            {
                if (await DatabaseUser.ListUser() && await DatabaseExercise.ListExercise())
                {
                    App.Current.MainPage = new MainPageAdmin();
                    Navigation.PopAsync();
                }
                else
                {
                    await DisplayAlert("Error", "Something went wrong1", "OK");

                    Navigation.PopAsync();
                }
            }
            else
            {
                if (await DatabaseDaysInWeek.CheckDaysInWeek(DatabaseProfile.GetUid(), "A", 1) &&
                    await DatabaseDaysInWeek.CheckDaysInWeek(DatabaseProfile.GetUid(), "A", 2) &&
                    await DatabaseDaysInWeek.CheckDaysInWeek(DatabaseProfile.GetUid(), "A", 3) &&
                    await DatabaseDaysInWeek.CheckDaysInWeek(DatabaseProfile.GetUid(), "A", 4))
                {
                    App.Current.MainPage = new MainPage();
                    Navigation.PopAsync();
                }
                else
                {
                    await DisplayAlert("Error", "Something went wrong2", "OK");

                    Navigation.PopAsync();
                }
            }
        }
Пример #11
0
        private async void Btn_PickImage_Clicked(object sender, EventArgs e)
        {
            await CrossMedia.Current.Initialize();

            try
            {
                file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                {
                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium
                });

                if (file == null)
                {
                    return;
                }
                string uri = await DatabaseProfile.UploadFile(file.GetStream(), user.Id);

                if (DatabaseUser.UpdateUserPic(user, uri))
                {
                    await DisplayAlert("Profile picture updated", "Press OK to continue", "OK");

                    Console.WriteLine("Propic Updated");
                }
                else
                {
                    await DisplayAlert("Error, profile picture update failure", "Press OK to continue", "OK");

                    Console.WriteLine("Error Propic");
                }
                StartUp();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception in ProfilePage: " + ex.Message);
            }
        }
Пример #12
0
        internal static PhpWorkloadResourceData DeserializePhpWorkloadResourceData(JsonElement element)
        {
            WorkloadKind            kind = default;
            Optional <WorkloadsSku> sku  = default;
            Optional <PhpWorkloadResourceIdentity> identity     = default;
            IDictionary <string, string>           tags         = default;
            AzureLocation                           location    = default;
            ResourceIdentifier                      id          = default;
            string                                  name        = default;
            ResourceType                            type        = default;
            SystemData                              systemData  = default;
            Optional <AzureLocation>                appLocation = default;
            Optional <ManagedRGConfiguration>       managedResourceGroupConfiguration = default;
            Optional <UserProfile>                  adminUserProfile  = default;
            Optional <VmssNodesProfile>             webNodesProfile   = default;
            Optional <NodeProfile>                  controllerProfile = default;
            Optional <NetworkProfile>               networkProfile    = default;
            Optional <DatabaseProfile>              databaseProfile   = default;
            Optional <SiteProfile>                  siteProfile       = default;
            Optional <FileshareProfile>             fileshareProfile  = default;
            Optional <PhpProfile>                   phpProfile        = default;
            Optional <SearchProfile>                searchProfile     = default;
            Optional <CacheProfile>                 cacheProfile      = default;
            Optional <BackupProfile>                backupProfile     = default;
            Optional <PhpWorkloadProvisioningState> provisioningState = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("kind"))
                {
                    kind = new WorkloadKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sku = WorkloadsSku.DeserializeWorkloadsSku(property.Value);
                    continue;
                }
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    identity = PhpWorkloadResourceIdentity.DeserializePhpWorkloadResourceIdentity(property.Value);
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = new AzureLocation(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("appLocation"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            appLocation = new AzureLocation(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("managedResourceGroupConfiguration"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            managedResourceGroupConfiguration = ManagedRGConfiguration.DeserializeManagedRGConfiguration(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("adminUserProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            adminUserProfile = UserProfile.DeserializeUserProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("webNodesProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            webNodesProfile = VmssNodesProfile.DeserializeVmssNodesProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("controllerProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            controllerProfile = NodeProfile.DeserializeNodeProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("networkProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            networkProfile = NetworkProfile.DeserializeNetworkProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("databaseProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            databaseProfile = DatabaseProfile.DeserializeDatabaseProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("siteProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            siteProfile = SiteProfile.DeserializeSiteProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("fileshareProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            fileshareProfile = FileshareProfile.DeserializeFileshareProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("phpProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            phpProfile = PhpProfile.DeserializePhpProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("searchProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            searchProfile = SearchProfile.DeserializeSearchProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("cacheProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            cacheProfile = CacheProfile.DeserializeCacheProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("backupProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            backupProfile = BackupProfile.DeserializeBackupProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            provisioningState = new PhpWorkloadProvisioningState(property0.Value.GetString());
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new PhpWorkloadResourceData(id, name, type, systemData, tags, location, kind, sku.Value, identity.Value, Optional.ToNullable(appLocation), managedResourceGroupConfiguration.Value, adminUserProfile.Value, webNodesProfile.Value, controllerProfile.Value, networkProfile.Value, databaseProfile.Value, siteProfile.Value, fileshareProfile.Value, phpProfile.Value, searchProfile.Value, cacheProfile.Value, backupProfile.Value, Optional.ToNullable(provisioningState)));
        }
Пример #13
0
        async void SignUp(object sender, EventArgs e)
        {
            string username        = Entry_Username.Text;
            string password        = Entry_Password.Text;
            string confirmPassword = Entry_ConfirmPassword.Text;
            string email           = Entry_Email.Text;
            string name            = Entry_Name.Text;
            string surname         = Entry_Surname.Text;

            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(surname))
            {
                await DisplayAlert("Error", "Please, enter all the fields", "Cancel");
            }
            else if (string.IsNullOrWhiteSpace(email))
            {
                await DisplayAlert("Incorrect email", "Please, enter a valid email", "Cancel");
            }
            else if (string.IsNullOrEmpty(password))
            {
                await DisplayAlert("Incorrect password", "Please, enter a valid password", "Cancel");
            }
            else if (password.Length < 8)
            {
                await DisplayAlert("Incorrect password", "The password must be at least 8 characters long", "Cancel");
            }
            else if (!password.Equals(confirmPassword))
            {
                await DisplayAlert("Incorrect password", "Passwords do not match", "Cancel");
            }
            else if (username.Length > 10)
            {
                await DisplayAlert("Incorrect username", "Write username up to 10 characters", "OK");
            }
            else if (name.Length > 10)
            {
                await DisplayAlert("Incorrect name", "Write name up to 10 characters", "OK");
            }
            else if (surname.Length > 15)
            {
                await DisplayAlert("Incorrect surname", "Write surname up to 15 characters", "OK");
            }
            else
            {
                // Firebase Authentication
                string uri = await DatabaseProfile.GetDefaultPic();

                Console.WriteLine("Register Page URI: " + uri);
                User   user  = new User(name, surname, uri, username, email);
                string Token = await Auth.RegisterToFirebase(username, email, password);

                if (Token != "" && DatabaseUser.InsertUser(user))
                {
                    await DisplayAlert("Registration successful", "Press OK to continue", "OK");

                    App.Current.MainPage = new NavigationPage(new Splash());
                }
                else
                {
                    await DisplayAlert("Registration unsuccesful", "Wrong email or password", "Cancel");
                }
            }
        }
Пример #14
0
        private void dgdSettings_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
        {
            // Update the database profile
            try
            {
                if (dgdSettings.CurrentRow != null && dgdSettings.IsCurrentRowDirty == true)
                {
                    DatabaseProfile dbProfile;

                    if (dgdSettings.CurrentRow.Index >= _dbSettings.Profiles.Count)
                    {
                        dbProfile = new DatabaseProfile();
                    }
                    else
                    {
                        dbProfile = _dbSettings.Profiles[dgdSettings.CurrentRow.Index];
                    }

                    // Find any duplicates in the list
                    int intDup = 0;
                    foreach (DatabaseProfile profile in _dbSettings.Profiles)
                    {
                        if (profile.Name == ((string)dgdSettings.CurrentRow.Cells["Name"].Value).Trim())
                        {
                            intDup++;
                        }
                    }
                    if (intDup > 1)
                    {
                        e.Cancel = true;
                        MessageBox.Show("The profile name must be unique. ", "Validating profile");
                        return;
                    }

                    dbProfile.Name         = ((string)dgdSettings.CurrentRow.Cells["Name"].Value).Trim();
                    dbProfile.ProviderType = (string)dgdSettings.CurrentRow.Cells["Provider"].Value;
                    try
                    {
                        dbProfile.ConnectionString = (string)dgdSettings.CurrentRow.Cells["ConnectionString"].Value;
                    }
                    catch (Exception ex)
                    {
                        e.Cancel = true;
                        MessageBox.Show("The ConnectionString is not valid. " + ex.Message, "Validating profile");
                        return;
                    }

                    dbProfile.Timeout = Convert.ToInt16(dgdSettings.CurrentRow.Cells["Timeout"].Value);

                    // Update the combobox
                    string strSelected = cboProfiles.Text;
                    if (cboProfiles.SelectedIndex == dgdSettings.CurrentRow.Index)
                    {
                        strSelected = dbProfile.Name;
                        cboProfiles.Items.RemoveAt(dgdSettings.CurrentRow.Index);
                        cboProfiles.Items.Insert(dgdSettings.CurrentRow.Index, dbProfile.Name);
                    }
                    cboProfiles.Text = strSelected;

                    // Add the profile
                    if (dgdSettings.CurrentRow.Index >= _dbSettings.Profiles.Count)
                    {
                        _dbSettings.Profiles.Add(dbProfile);
                        ShowDefaultProfile();
                    }
                }
            }
            catch (Exception ex)
            {
                e.Cancel = true;
                MessageBox.Show(ex.Message, "Validating profile");
            }
        }