public byte[] ViewDatabasesNames() { string clientName = (Thread.CurrentPrincipal.Identity as GenericIdentity).Name.Split(',', ';')[0].Split('=')[1]; X509Certificate2 certificate = CertManager.GetCertificateFromStorage(StoreName.TrustedPeople, StoreLocation.LocalMachine, clientName); string message = "----------------------------------------------------\nDatabases names:\n\n"; foreach (string databaseName in DbList.Keys) { message += $"{databaseName}\n"; } return(DataCryptography.EncryptData(certificate, message + "\n----------------------------------------------------\n")); }
public byte[] ViewAll(string databaseName) { string message = "----------------------------------------------------\nAll entities:\n\n"; string clientName = (Thread.CurrentPrincipal.Identity as GenericIdentity).Name.Split(',', ';')[0].Split('=')[1]; X509Certificate2 certificate = CertManager.GetCertificateFromStorage(StoreName.TrustedPeople, StoreLocation.LocalMachine, clientName); if (DbList.ContainsKey(databaseName)) { foreach (Information information in DbList[databaseName].Values) { message += information.ToString(); } message += "----------------------------------------------------\n"; return(DataCryptography.EncryptData(certificate, message)); } else { return(DataCryptography.EncryptData(certificate, $"Database with name '{databaseName}' doesn't exists.\n")); } }
public byte[] AverageSalaryByCountryAndPayday(string databaseName, string country, string payDay) { string clientName = (Thread.CurrentPrincipal.Identity as GenericIdentity).Name.Split(',', ';')[0].Split('=')[1]; X509Certificate2 certificate = CertManager.GetCertificateFromStorage(StoreName.TrustedPeople, StoreLocation.LocalMachine, clientName); Dictionary <string, List <Information> > informations = new Dictionary <string, List <Information> >(); string message = "----------------------------------------------------\nAvarage salary by country and payday:\n\n"; if (DbList.ContainsKey(databaseName)) { foreach (Information information in DbList[databaseName].Values) { if (information.Drzava == country.Trim().ToLower() && information.Year == payDay.Trim()) { if (informations.ContainsKey(information.Drzava)) { informations[information.Drzava].Add(information); } else { informations.Add(information.Drzava, new List <Information>() { information }); } } } foreach (var pair in informations) { message += $"{pair.Key}:\t{pair.Value.Average(x => x.MesecnaPrimanja).ToString()}\n"; } } else { return(DataCryptography.EncryptData(certificate, $"Database with name '{databaseName}' doesn't exists.\n")); } return(DataCryptography.EncryptData(certificate, message + "\n----------------------------------------------------\n")); }
public byte[] ViewMaxPayed(string databaseName) { string clientName = (Thread.CurrentPrincipal.Identity as GenericIdentity).Name.Split(',', ';')[0].Split('=')[1]; X509Certificate2 certificate = CertManager.GetCertificateFromStorage(StoreName.TrustedPeople, StoreLocation.LocalMachine, clientName); //Debugger.Launch(); Dictionary <string, List <Information> > informations = new Dictionary <string, List <Information> >(); string message = "----------------------------------------------------\nMax salary from all states:\n\n"; if (DbList.ContainsKey(databaseName)) { foreach (Information information in DbList[databaseName].Values) { if (informations.ContainsKey(information.Drzava)) { informations[information.Drzava].Add(information); } else { informations.Add(information.Drzava, new List <Information>() { information }); } } foreach (var pair in informations) { message += $"{pair.Key}:\t{pair.Value.Max(x => x.MesecnaPrimanja).ToString()}\n"; } } else { return(DataCryptography.EncryptData(certificate, $"Database with name '{databaseName}' doesn't exists.\n")); } return(DataCryptography.EncryptData(certificate, message + "\n----------------------------------------------------\n")); }