Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <string> getRawDataFromTextFile()
        {
            List <string> rawData = new List <string>();

            using (stream = new FileStream(this.txtFilePath, FileMode.Open, System.IO.FileAccess.Read))
            {
                using (reader = new StreamReader(stream))
                {
                    try
                    {
                        while (!reader.EndOfStream)
                        {
                            rawData.Add(reader.ReadLine());
                        }
                    }
                    catch (Exception exception)
                    {
                        ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                        error.handle(exception, true);
                    }
                }
            }

            return(rawData);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DataToAppend"></param>
        public void appendDataToTextFile(List <string> DataToAppend)
        {
            if (File.Exists(this.txtFilePath) == false)
            {
                createFileIfNotExist(this.txtFilePath);
            }

            using (stream = new FileStream(this.txtFilePath, FileMode.Append, System.IO.FileAccess.Write))
            {
                using (writer = new StreamWriter(stream))
                {
                    try
                    {
                        foreach (string item in DataToAppend)
                        {
                            writer.WriteLine(item);
                            writer.Flush();
                        }
                    }
                    catch (Exception exception)
                    {
                        ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                        error.handle(exception, true);
                    }
                }
            }
        }
Esempio n. 3
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (chkActiveDirectory.IsChecked == true)
                {
                    ADUser = new ActiveDirectoryEmployee(txtUsername.Text, txtPassword.Password);
                    bool isAuthorised = ADUser.AuthenticateUser();

                    if (isAuthorised == true)
                    {
                        Global.ADUser = ADUser.ADPrincipal;
                        string type = "";
                        if (ADUser.ADPrincipal.IsAdministrator == true)
                        {
                            type = "Administrator - " + txtUsername.Text;
                        }
                        if (ADUser.ADPrincipal.IsEmployee == true)
                        {
                            type = "Employee - " + txtUsername.Text;
                        }
                        if (ADUser.ADPrincipal.IsTechnician == true)
                        {
                            type = "Technician - " + txtUsername.Text;
                        }
                        Task.Run(() => {
                            SystemLogins systemLogins = new SystemLogins(Guid.NewGuid(), ADUser.ADPrincipal.GUID ?? Guid.NewGuid(), DateTime.UtcNow, type, failedCount);
                            systemLogins.insertLogin();
                        }).ConfigureAwait(false);

                        NavigationService.NavigateTo(new MainScreen());
                    }
                    else
                    {
                        // Error Message
                        MessageBox.Show("Incorrect Credentials");
                        failedCount++;
                    }
                }
                else
                {
                    if (txtUsername.Text.Equals("letmein"))
                    {
                        Global.ADUser = new ActiveDirectoryEmployee("1234", "Marno van Niekerk", "*****@*****.**", true, Guid.NewGuid(), "Marno", "van Niekerk", DateTime.UtcNow, false, false, true);
                        NavigationService.NavigateTo(new MainScreen());
                    }
                    else
                    {
                        MessageBox.Show("Incorrect Credentials");
                        failedCount++;
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true);
            }
        }
        private void lvAppointments_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            var item = (sender as ListView).SelectedItem;

            if (item != null)
            {
                AppointmentGrid.IsEnabled = true;
                btnDelete.IsEnabled       = true;
                try
                {
                    //dynamic selectedClient = (ExpandoObject)item;

                    currentAppointment = (Appointment)item;
                    if (currentAppointment.Completed)
                    {
                        AppointmentGrid.IsEnabled = false;
                    }
                    else
                    {
                        AppointmentGrid.IsEnabled = true;
                    }

                    if (currentAppointment.Completed)
                    {
                        chkCompleted.IsEnabled = false;
                    }
                    else
                    {
                        chkCompleted.IsEnabled = true;
                    }

                    if (currentAppointment.Confirmed)
                    {
                        chkConfirmed.IsEnabled = false;
                        chkCompleted.IsEnabled = true;
                    }
                    else
                    {
                        chkConfirmed.IsEnabled = true;
                        chkCompleted.IsEnabled = false;
                    }
                }
                catch (Exception exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, true, true);
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fileName"></param>
 void createFileIfNotExist(string fileName)
 {
     try
     {
         stream = new FileStream(fileName, FileMode.Create);
     }
     catch (Exception exception)
     {
         ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
         error.handle(exception, true, false, string.Format("Cannot create {0}", fileName));
     }
     finally
     {
         stream.Close();
     }
 }
Esempio n. 6
0
 private void lblAppointments_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (clientSelected)
     {
         setSelectedToNone();
         lblAppointments.Background = selectedBrush;
         ClientFragmentHolder.Children.RemoveAt(0);
         appointmentWindow = new Scheduling(currentClientGuid);
         appointmentWindow.DetachContent();
         ClientFragmentHolder.Children.Add(appointmentWindow.SchedulingFragment);
     }
     else
     {
         ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
         error.handle(new CustomExceptionForUI("Please select a Client first."), false, true);
         //EventBus.EventBus.Instance.PostEvent(new CustomEvent("Notify", "Please select a client first", CustomEvent.EventType.warning));
         // Show error message. A android style popup
     }
 }
Esempio n. 7
0
        private void label8_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (clientSelected)
            {
                setSelectedToNone();
                label8.Background = selectedBrush;
                ClientFragmentHolder.Children.RemoveAt(0);
                detailsWindow.DetachContent();
                ClientFragmentHolder.Children.Add(detailsWindow.DetailFragment);
            }
            else
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(new CustomExceptionForUI("Please select a Client first."), false, true);

                //EventBus.EventBus.Instance.PostEvent(new CustomEvent("Notify", "Please select a client first", CustomEvent.EventType.accept));
                // Show error message. A android style popup
            }
        }
        private void lvAllTechnicians_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            var item = (sender as ListView).SelectedItem;

            if (item != null)
            {
                try
                {
                    //dynamic selectedClient = (ExpandoObject)item;

                    TechnicianDBInfo selectedDictionaryItem = (TechnicianDBInfo)item;

                    TechnicianSchedule technicianSchedule = new TechnicianSchedule();

                    currentSelectedTechnician = selectedDictionaryItem;

                    bool isAvailable = technicianSchedule.checkIfTechnicianIsAvailable(appointment.Time, selectedDictionaryItem.ADTechnician.GUID ?? Guid.NewGuid());

                    txtNameSurname.Text = selectedDictionaryItem.ADTechnician.Name;



                    if (isAvailable)
                    {
                        txtAvailable.Text             = "Yes";
                        btnAssignTechnician.IsEnabled = true;
                    }
                    else
                    {
                        txtAvailable.Text             = "No, Slot unavailable";
                        btnAssignTechnician.IsEnabled = false;
                    }

                    txtAppointmentsDone.Text = string.Format("{0} done", selectedDictionaryItem.TotalAppointments);
                }
                catch (Exception exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, true);
                }
            }
        }
        private void lvUnassignedAppointments_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            var item = (sender as ListView).SelectedItem;

            if (item != null)
            {
                try
                {
                    //dynamic selectedClient = (ExpandoObject)item;

                    AppointmentPriority selectedDictionaryItem = (AppointmentPriority)item;

                    NavigationService.NavigateToWithoutHide(new UnassignedWindow(selectedDictionaryItem, serviceDelivery.TechniciansList));
                }
                catch (Exception exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, true);
                }
            }
        }
Esempio n. 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="RawDataToWrite"></param>
 public void readDataToTextFile(List <string> RawDataToWrite)
 {
     using (stream = new FileStream(this.txtFilePath, FileMode.OpenOrCreate, System.IO.FileAccess.Write))
     {
         using (writer = new StreamWriter(stream))
         {
             try
             {
                 foreach (string item in RawDataToWrite)
                 {
                     writer.WriteLine(item);
                     writer.Flush();
                 }
             }
             catch (Exception exception)
             {
                 ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                 error.handle(exception, true);
             }
         }
     }
 }
        private Task <bool> doNotificationAsync(string message, CustomEvent.EventType type)
        {
            SolidColorBrush critical = new SolidColorBrush(Color.FromArgb(0xFF, Convert.ToByte(220), Convert.ToByte(53), Convert.ToByte(69)));
            SolidColorBrush warning  = new SolidColorBrush(Color.FromArgb(0xFF, Convert.ToByte(255), Convert.ToByte(193), Convert.ToByte(7)));
            SolidColorBrush accept   = new SolidColorBrush(Color.FromArgb(0xFF, Convert.ToByte(40), Convert.ToByte(167), Convert.ToByte(69)));
            //SolidColorBrush backgroundBrush = new SolidColorBrush(Color.FromArgb(0xFF, Convert.ToByte(230), Convert.ToByte(231), Convert.ToByte(237)));

            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();

            object locker  = new object();
            object locker2 = new object();

            try
            {
                Task.Run(() => {
                    lock (locker)
                    {
                        Application.Current.Dispatcher.Invoke((Action) delegate {
                            lock (locker2)
                            {
                                System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
                                dispatcherTimer.Interval = new TimeSpan(0, 0, 3);

                                dispatcherTimer.Tick += (sernder, e) => { ViewModel.NotificationEnabled = false; };

                                dispatcherTimer.Start();

                                switch (type)
                                {
                                case CustomEvent.EventType.warning:
                                    {
                                        notificationGrid.Background   = warning;
                                        tbNotifyMessage.Text          = message;
                                        ViewModel.NotificationEnabled = true;
                                    }
                                    break;

                                case CustomEvent.EventType.critical:
                                    {
                                        notificationGrid.Background   = critical;
                                        tbNotifyMessage.Text          = message;
                                        ViewModel.NotificationEnabled = true;
                                    }
                                    break;

                                case CustomEvent.EventType.accept:
                                    {
                                        notificationGrid.Background   = accept;
                                        tbNotifyMessage.Text          = message;
                                        ViewModel.NotificationEnabled = true;
                                    }
                                    break;

                                default:
                                    break;
                                }
                            }
                        });
                    }

                    tcs.SetResult(true);
                });

                // set a timmer for how long the notification should be visible
                // return true when timer is done.

                return(tcs.Task);
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true);
            }

            return(tcs.Task);
        }
        private void lvActiveTechnicions_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            var item = (sender as ListView).SelectedItem;

            if (item != null)
            {
                try
                {
                    //dynamic selectedClient = (ExpandoObject)item;

                    KeyValuePair <ActiveDirectoryEmployee, AppointmentPriority> selectedDictionaryItem = (KeyValuePair <ActiveDirectoryEmployee, AppointmentPriority>)item;

                    Client client = new Client();
                    client = client.getClientOnAppointmentGuid(selectedDictionaryItem.Value.GUID);


                    txtDate.Text      = selectedDictionaryItem.Value.Time.ToString("d MMMM, yyyy hh:mm tt");
                    txtCost.Text      = string.Format("R {0}", selectedDictionaryItem.Value.Cost);
                    txtOperation.Text = selectedDictionaryItem.Value.Operation;
                    switch (selectedDictionaryItem.Value.Priority)
                    {
                    case 0:
                        txtPriority.Text = string.Format("{0}  - Very Urgent", selectedDictionaryItem.Value.Priority);
                        break;

                    case 1:
                        txtPriority.Text = string.Format("{0}  - Very Urgent", selectedDictionaryItem.Value.Priority);
                        break;

                    case 2:
                        txtPriority.Text = string.Format("{0}  - Moderate Urgent", selectedDictionaryItem.Value.Priority);
                        break;

                    case 3:
                        txtPriority.Text = string.Format("{0}  - Medium Urgent", selectedDictionaryItem.Value.Priority);
                        break;

                    case 4:
                        txtPriority.Text = string.Format("{0}  - Least Urgent", selectedDictionaryItem.Value.Priority);
                        break;

                    case 5:
                        txtPriority.Text = string.Format("{0}  - Least Urgent", selectedDictionaryItem.Value.Priority);
                        break;

                    default:
                        break;
                    }
                    txtNameAndSurname.Text    = client.Name + " " + client.Surname;
                    txtClientID.Text          = client.ID;
                    txtClientIdenficator.Text = client.ClientIdetifier;
                    tbExtraDtails.Text        = selectedDictionaryItem.Value.ExtraDetails;

                    chkConfirmed.IsChecked = true;
                    chkCompleted.IsChecked = false;
                }
                catch (Exception exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, true);
                }
            }
        }
Esempio n. 13
0
        DataTable dynamicQueries <T>(QueryType queryType, object objectClass, KeyValuePair <string, string[, ]> table)
        {
            //return dalk n Datatable. As dit insert, delete, of update is, return null

            DataTable returnTable = null;

            try
            {
                StringBuilder queryString = new StringBuilder();
                queryString.Append("SELECT ");

                for (int i = 0; i < table.Value.GetLength(0); i++)
                {
                    if (i != table.Value.GetLength(0) - 1)
                    {
                        queryString.Append(table.Value[i, 0] + ", ");
                    }
                    else
                    {
                        queryString.Append(table.Value[i, 0] + " ");
                    }
                }

                queryString.Append("FROM ");
                queryString.Append(table.Key);

                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.log(queryString.ToString());

                DbProviderFactory factory = DbProviderFactories.GetFactory(providerName);

                DbConnection connection = factory.CreateConnection();
                connection.ConnectionString = connectionStringSHS;

                // Create the DbCommand.
                DbCommand command = factory.CreateCommand();
                command.CommandText = queryString.ToString();
                command.Connection  = connection;

                DbDataAdapter adapter = factory.CreateDataAdapter();
                adapter.SelectCommand = command;

                if (queryType == QueryType.SELECT)
                {
                    // Fill the DataTable.
                    returnTable = new DataTable();
                    adapter.Fill(returnTable);

                    return(returnTable);
                }

                if (queryType != QueryType.SELECT)
                {
                    // Create the DbCommandBuilder.
                    DbCommandBuilder builder = factory.CreateCommandBuilder();
                    builder.DataAdapter = adapter;

                    // Cast it to itself
                    T spesificClass = (T)Convert.ChangeType(objectClass, typeof(T));

                    if (queryType == QueryType.INSERT)
                    {
                        // Get the insert commands.
                        adapter.InsertCommand = builder.GetInsertCommand();
                        System.Diagnostics.Debug.WriteLine(adapter.InsertCommand.CommandText);

                        // Fill the DataTable.
                        returnTable = new DataTable();
                        adapter.Fill(returnTable);

                        // Fill the DataTable.
                        //returnTable = new DataTable();
                        //adapter.Fill(returnTable);

                        // Insert a new row.
                        DataRow newRow = returnTable.NewRow();
                        //  newRow["CustomerID"] = "XYZZZ";

                        for (int i = 0; i < table.Value.GetLength(0); i++)
                        {
                            //PropertyInfo info = spesificClass.GetType().GetProperty(table.Value[i,1]);
                            //newRow[table.Value[i, 0]] = info.GetValue(spesificClass);
                            string dbColumn = table.Value[i, 0];
                            string propName = table.Value[i, 1];
                            var    value    = spesificClass.GetType().GetProperty(propName).GetValue(spesificClass);
                            newRow[dbColumn] = value;
                        }

                        returnTable.Rows.Add(newRow);

                        adapter.Update(returnTable);

                        return(returnTable);
                    }
                    else

                    if (queryType == QueryType.UPDATE)
                    {
                        // Get the update commands.
                        adapter.UpdateCommand = builder.GetUpdateCommand();
                        System.Diagnostics.Debug.WriteLine(adapter.UpdateCommand.CommandText);

                        // Fill the DataTable.
                        returnTable = new DataTable();
                        adapter.Fill(returnTable);

                        // Edit an existing row.
                        //DataRow[] editRow = returnTable.Select("CustomerID = 'XYZZZ'");
                        //editRow[0]["CompanyName"] = "XYZ Corporation";

                        // Update the row based on GUID
                        DataRow[] editRow = returnTable.Select(string.Format("guid = '{0}'", spesificClass.GetType().GetProperty("GUID").GetValue(spesificClass)));
                        //editRow[0]["CompanyName"] = "XYZ Corporation";
                        for (int i = 0; i < table.Value.GetLength(0); i++)
                        {
                            editRow[0][table.Value[i, 0]] = spesificClass.GetType().GetProperty(table.Value[i, 1]).GetValue(spesificClass);
                        }

                        adapter.Update(returnTable);

                        return(returnTable);
                    }
                    else

                    if (queryType == QueryType.DELETE)
                    {
                        // Get the delete commands.
                        adapter.DeleteCommand = builder.GetDeleteCommand();
                        System.Diagnostics.Debug.WriteLine(adapter.DeleteCommand.CommandText);

                        // Fill the DataTable.
                        returnTable = new DataTable();
                        adapter.Fill(returnTable);

                        // Delete a row.
                        DataRow[] deleteRow = returnTable.Select(string.Format("guid = '{0}'", spesificClass.GetType().GetProperty("GUID").GetValue(spesificClass)));
                        foreach (DataRow row in deleteRow)
                        {
                            row.Delete();
                        }

                        adapter.Update(returnTable);

                        return(returnTable);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(ex, true, false, ex.ToString());
            }


            return(returnTable);
        }
Esempio n. 14
0
        public DataTable dynamicDeleteQuery <T>(object objectClass)
        {
            DataTable returnTable = new DataTable();

            try
            {
                // Cast it to itself
                T      spesificClass = (T)Convert.ChangeType(objectClass, typeof(T));
                string tableName     = (string)spesificClass.GetType().GetProperty("TableName").GetValue(spesificClass);
                SortedDictionary <string, string> valuePair = (SortedDictionary <string, string>)spesificClass.GetType().GetProperty("TableDataInfo").GetValue(spesificClass);

                // Create the DbProviderFactory and DbConnection.
                DbProviderFactory factory = DbProviderFactories.GetFactory(providerName);

                DbConnection connection = factory.CreateConnection();
                connection.ConnectionString = connectionStringSHS;

                using (connection)
                {
                    string simpleQuery = "SELECT * FROM " + tableName;
                    // Create the select command.
                    DbCommand command = factory.CreateCommand();
                    command.CommandText = simpleQuery;
                    command.Connection  = connection;

                    // Create the DbDataAdapter.
                    DbDataAdapter adapter = factory.CreateDataAdapter();
                    adapter.SelectCommand = command;

                    // Create the DbCommandBuilder.
                    DbCommandBuilder builder = factory.CreateCommandBuilder();
                    builder.DataAdapter = adapter;

                    // Get the insert, update and delete commands.
                    adapter.DeleteCommand = builder.GetDeleteCommand();

                    // Fill the DataTable.
                    //DataTable table = new DataTable();
                    adapter.Fill(returnTable);

                    // edit a row.
                    string    guid      = spesificClass.GetType().GetProperty("GUID").GetValue(spesificClass).ToString();
                    DataRow[] deleteRow = returnTable.Select("guid = '" + guid + "'");
                    foreach (DataRow row in deleteRow)
                    {
                        row.Delete();
                    }

                    adapter.Update(returnTable);

                    //returnTable.Columns[1].DataType.UnderlyingSystemType
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true, false, exception.ToString());
            }

            return(returnTable);
        }
Esempio n. 15
0
        public DataTable dynamicUpdateQuery <T>(object objectClass)
        {
            DataTable returnTable = new DataTable();

            try
            {
                // Cast it to itself
                T      spesificClass = (T)Convert.ChangeType(objectClass, typeof(T));
                string tableName     = (string)spesificClass.GetType().GetProperty("TableName").GetValue(spesificClass);
                SortedDictionary <string, string> valuePair = (SortedDictionary <string, string>)spesificClass.GetType().GetProperty("TableDataInfo").GetValue(spesificClass);

                // Create the DbProviderFactory and DbConnection.
                DbProviderFactory factory = DbProviderFactories.GetFactory(providerName);

                DbConnection connection = factory.CreateConnection();
                connection.ConnectionString = connectionStringSHS;

                using (connection)
                {
                    string simpleQuery = "SELECT * FROM " + tableName;
                    // Create the select command.
                    DbCommand command = factory.CreateCommand();
                    command.CommandText = simpleQuery;
                    command.Connection  = connection;

                    // Create the DbDataAdapter.
                    DbDataAdapter adapter = factory.CreateDataAdapter();
                    adapter.SelectCommand = command;

                    // Create the DbCommandBuilder.
                    DbCommandBuilder builder = factory.CreateCommandBuilder();
                    builder.DataAdapter = adapter;

                    // Get the insert, update and delete commands.
                    adapter.InsertCommand = builder.GetUpdateCommand();

                    // Fill the DataTable.
                    //DataTable table = new DataTable();
                    adapter.Fill(returnTable);

                    // edit a row.
                    DataRow[] editRow = returnTable.Select("guid = '" + (string)spesificClass.GetType().GetProperty("GUID").GetValue(spesificClass).ToString() + "'");
                    for (int i = 0; i < valuePair.Count; i++)
                    {
                        // Get the table columnName from the sorted dictionary where i, the counter, is at in the valuePair, which is the list of properties and values at that specific point.
                        string columnName      = valuePair.Keys.ElementAt(i);
                        string propertyName    = valuePair.Values.ElementAt(i);
                        string valueAtProperty = spesificClass.GetType().GetProperty(propertyName).GetValue(spesificClass).ToString();

                        editRow[0][columnName] = valueAtProperty;
                    }

                    adapter.Update(returnTable);
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true, false, exception.ToString());
            }

            return(returnTable);
        }
Esempio n. 16
0
        DataTable dynamicSelectQuery <T>(object objectClass, object[] selectParameters = null)
        {
            //return dalk n Datatable. As dit insert, delete, of update is, return null

            DataTable returnTable = new DataTable();

            try
            {
                // Cast it to itself
                T      spesificClass = (T)Convert.ChangeType(objectClass, typeof(T));
                string tableName     = (string)spesificClass.GetType().GetProperty("TableName").GetValue(spesificClass);
                SortedDictionary <string, string> valuePair = (SortedDictionary <string, string>)spesificClass.GetType().GetProperty("TableDataInfo").GetValue(spesificClass);

                StringBuilder queryString = new StringBuilder();
                queryString.Append("SELECT ");


                for (int i = 0; i < valuePair.Count; i++)
                {
                    if (i != valuePair.Count - 1)
                    {
                        queryString.Append(valuePair.Keys.ElementAt(i) + ", ");
                    }
                    else
                    {
                        queryString.Append(valuePair.Keys.ElementAt(i) + " ");
                    }
                }

                queryString.Append("FROM ");
                queryString.Append(tableName);



                // providerName = "System.Data.SqlClient"
                // connectionStringSHS = "Data Source=192.168.2.222;Initial Catalog=SmartHomeSystem;User ID=applicationLogin;Password=BelgiumCampus123."


                //connectionStringSHS = ConfigurationManager.ConnectionStrings["default"].ConnectionString);
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.log(queryString.ToString());

                DbProviderFactory factory = DbProviderFactories.GetFactory(providerName);

                DbConnection connection = factory.CreateConnection();
                connection.ConnectionString = connectionStringSHS;

                using (connection)
                {
                    // Create the DbCommand.
                    DbCommand command = factory.CreateCommand();
                    command.CommandText = queryString.ToString();
                    //command.CommandText = "SELECT * FROM tblProduct";
                    command.Connection = connection;
                    connection.Open();

                    DbDataAdapter adapter = factory.CreateDataAdapter();
                    adapter.SelectCommand = command;

                    // Fill the DataTable.

                    adapter.Fill(returnTable);
                }



                return(returnTable);
            }
            catch (Exception ex)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(ex, true, false, ex.ToString());
            }


            return(returnTable);
        }