public bool Modify(Baza b) { bool allowed = false; string serviceName = OperationContext.Current.IncomingMessageHeaders.Action; string name = ServiceSecurityContext.Current.PrimaryIdentity.Name; string role = Manager.CertManager.GetRole(name); string ime_klijenta = Manager.CertManager.GetName(name); if (role == "Admini") { ServiceApp.Program.Baza_podataka.Add(b); ServiceApp.Program.update.Enqueue(b); ServiceApp.Program.provera.Enqueue(false); Contracts.Serijalizacija ser = new Contracts.Serijalizacija(); ser.SerializeObject <List <Baza> >(ServiceApp.Program.Baza_podataka, "../../bin/data.txt"); Audit.AuthorizationSuccess(ime_klijenta, serviceName); Console.WriteLine("Modify() passed for user {0}.", ime_klijenta); allowed = true; return(allowed); } else { Audit.AuthorizationFailed(ime_klijenta, serviceName, "modify"); Console.WriteLine("Modify() failed for user {0}.", ime_klijenta); return(allowed); } }
public void Update(Queue <Baza> upd, Queue <bool> b) { bool provera; if (upd.Count > 0) { Console.WriteLine("REPLICATION: {0} values replicated.", upd.Count); } if (upd.Count == 0) { } else { for (int i = 0; i < upd.Count; i++) { provera = b.Dequeue(); if (provera == true) { Baza trenutna = new Baza(); trenutna = upd.Dequeue(); ServiceApp.Program.Baza_podataka.RemoveAt(trenutna.Id - 1); ServiceApp.Program.Baza_podataka.Insert(trenutna.Id - 1, trenutna); Contracts.Serijalizacija ser = new Contracts.Serijalizacija(); ser.SerializeObject <List <Baza> >(ServiceApp.Program.Baza_podataka, "../../bin/data.txt"); Console.WriteLine("Updated azur \n"); string srvCertCN = Formatter.ParseName(WindowsIdentity.GetCurrent().Name); Audit.AuthorizationSuccess(srvCertCN, "Database updated from other server");//dodato } else { Baza trenutna2 = new Baza(); trenutna2 = upd.Dequeue(); ServiceApp.Program.Baza_podataka.Add(trenutna2); Contracts.Serijalizacija ser = new Contracts.Serijalizacija(); ser.SerializeObject <List <Baza> >(ServiceApp.Program.Baza_podataka, "../../bin/data.txt"); Console.WriteLine("Updated modify \n"); string srvCertCN = Formatter.ParseName(WindowsIdentity.GetCurrent().Name); Audit.AuthorizationSuccess(srvCertCN, "Database updated from other server"); //dodato } } } }
private static List <Baza> napraviBazu() { List <Baza> baze = new List <Contracts.Baza>(); ///// Contracts.Baza baza1 = new Contracts.Baza(); baza1.Id = 1; baza1.Godina = 2016; baza1.Grad = "Novi Sad"; baza1.Region = "juzni"; baza1.Potrosnja = new List <double>(); for (int i = 0; i < 12; i++) { baza1.Potrosnja.Add(i + 2); } Contracts.Baza baza2 = new Contracts.Baza(); baza2.Id = 2; baza2.Godina = 2016; baza2.Grad = "Subotica"; baza2.Region = "severni"; baza2.Potrosnja = new List <double>(); for (int i = 0; i < 12; i++) { baza2.Potrosnja.Add(i + 1); } baze.Add(baza1); baze.Add(baza2); Contracts.Serijalizacija ser = new Contracts.Serijalizacija(); ser.SerializeObject <List <Baza> >(baze, "../../bin/data.txt"); return(baze); }
public bool Azuriranje(List <double> lista, int id) { bool allowed = false; string serviceName = OperationContext.Current.IncomingMessageHeaders.Action; string name = ServiceSecurityContext.Current.PrimaryIdentity.Name; string role = Manager.CertManager.GetRole(name); string ime_klijenta = Manager.CertManager.GetName(name); if (role == "Editor") { Audit.AuthorizationSuccess(ime_klijenta, serviceName);//dodato Console.WriteLine("Azuriranje() passed for user {0}.", ime_klijenta); allowed = true; for (int i = 0; i < ServiceApp.Program.Baza_podataka.Count; i++) { if (ServiceApp.Program.Baza_podataka[i].Id == id) { ServiceApp.Program.Baza_podataka[i].Potrosnja = lista; ServiceApp.Program.update.Enqueue(ServiceApp.Program.Baza_podataka[i]); ServiceApp.Program.provera.Enqueue(true); } } Contracts.Serijalizacija ser = new Contracts.Serijalizacija(); ser.SerializeObject <List <Baza> >(ServiceApp.Program.Baza_podataka, "../../bin/data.txt"); return(allowed); } else { Audit.AuthorizationFailed(ime_klijenta, serviceName, "azuriranje"); Console.WriteLine("Azuriranje() failed for user {0}.", ime_klijenta); return(allowed); } }