public void CreateNewSmartCard(string username, string pin) { List <User> existingUsersDe = serializer.DeSerializeObject <List <User> >("existingUsers.xml"); if (existingUsersDe != null) { ExistingUsers = existingUsersDe.ToDictionary(x => x.Username, x => x); } Console.WriteLine("CreateNewSmartcard started + username: {0} + pin: {1} ", username, pin); //Common.Certificate.ExecuteCommandSync("cd " + AppDomain.CurrentDomain.BaseDirectory); Common.Certificate.ExecuteCommandSync("makecert -sv " + username + ".pvk -iv TestCA.pvk -n \"CN = " + username + "\" -pe -ic TestCA.cer " + username + ".cer -sr localmachine -ss My -sky exchange"); Common.Certificate.ExecuteCommandSync("pvk2pfx.exe /pvk " + username + ".pvk /pi ftn /spc " + username + ".cer /pfx " + username + ".pfx"); Console.WriteLine("Instalirati pfx fajl u cmm <enter>"); Console.ReadKey(); //Common.Certificate.ExecuteCommandSync("cd C:\\Program Files (x86)\\Windows Resource Kits\\Tools"); Common.Certificate.ExecuteCommandSync(@"winhttpcertcfg - g - c LOCAL_MACHINE\My - s " + username + " - a " + username); Console.WriteLine("winhttpcertcfg uspesno izvrsen"); ///kriptovanje pina pre serijalizacije u fajl na sistemu //SHA256 mySHA256 = SHA256Managed.Create(); //byte[] hashPin; //string hashPinString; //hashPin = mySHA256.ComputeHash(Encoding.UTF8.GetBytes(pin)); //hashPinString = System.Text.Encoding.UTF8.GetString(hashPin); //Console.WriteLine("Hash pina u string interpretaciji izgleda ovako: " + hashPinString); //nakon kriptovanja dodajemo na stticnu listu svih usera //ExistingUsers.Add(username, new User(username, hashPinString , 0)); /// korisnik vec postoji u listi - pokrenuto je generisanje novog sertifikata nakon invalidacije prethodnog if (ExistingUsers.ContainsKey(username)) { ExistingUsers[username].Pin = pin; } else { ExistingUsers.Add(username, new User(username, pin, 0)); } //preuzimamo usere iz recnika kako bi mogli da serijalizujemo List <User> existingUsersSe = ExistingUsers.Values.ToList(); //serijalizacija nakon dodavanja novog usera serializer.SerializeObject(existingUsersSe, "existingUsers.xml"); // salje podatke na SmartCardBackupService binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; using (ScToScbServiceProxy scToScbProxy = new ScToScbServiceProxy(binding, address)) { scToScbProxy.UserListBackup(existingUsersSe); } Audit.NewSmartCardCreatedSuccess(username); }
public NetworkViewViewModel() { Roads.Clear(); // We clear the list of the old elements if (serializer.DeSerializeObject <ObservableCollection <Road> >("roads.xml") != null) { serializer.DeSerializeObject <ObservableCollection <Road> >("roads.xml").ToList().ForEach(Roads.Add); // And then we deserialize the file holding a list of Roads } NotifiedVms.Instance.Register(this); }
public SHES() { try { SolarPanels = serializer.DeSerializeObject <ObservableCollection <SolarPanel> >("SolarPanels.xml"); Consumers = serializer.DeSerializeObject <ObservableCollection <Consumer> >("Consumers.xml"); Batteries = serializer.DeSerializeObject <ObservableCollection <Battery> >("Batteries.xml"); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void LoadDevices() { devicesList = importer.DeSerializeObject <ObservableCollection <Consumers> >("../../ConfigFiles/ConsumersConfig.xml"); foreach (var device in devicesList) { device.Working = false; } }
public void DeSerializeObject_EmptyOrNull_Test(string fileName) { DataIO importer = new DataIO(); ObservableCollection <Consumers> retVal = new ObservableCollection <Consumers>(); retVal = importer.DeSerializeObject <ObservableCollection <Consumers> >(fileName); Assert.IsTrue(retVal == default(ObservableCollection <Consumers>)); }
// Provides a generic collection that supports data binding. public MainWindow() { Kalashnikovs = serializer.DeSerializeObject <BindingList <Classes.Kalashnikov> >("kalashnikovs.xml"); if (Kalashnikovs == null) { Kalashnikovs = new BindingList <Classes.Kalashnikov>(); } DataContext = this; // Na nivou prozora i nasledjuje se u child kontrolama }
public List<CollectionDescription> Deserialization(int dataset) { List<CollectionDescription> tempList = new List<CollectionDescription>(); switch(dataset) { case 1: if (!File.Exists("DataSet1.xml")) { File.Create("DataSet1.xml").Dispose(); tempList = serializer.DeSerializeObject<List<CollectionDescription>>("DataSet1.xml"); } break; case 2: if (!File.Exists("DataSet2.xml")) { File.Create("DataSet2.xml").Dispose(); tempList = serializer.DeSerializeObject<List<CollectionDescription>>("DataSet2.xml"); } break; case 3: if (!File.Exists("DataSet3.xml")) { File.Create("DataSet3.xml").Dispose(); tempList = serializer.DeSerializeObject<List<CollectionDescription>>("DataSet3.xml"); } break; case 4: if (!File.Exists("DataSet4.xml")) { File.Create("DataSet4.xml").Dispose(); tempList = serializer.DeSerializeObject<List<CollectionDescription>>("DataSet4.xml"); } break; } if(tempList == null) { tempList = new List<CollectionDescription>(); } return tempList; }
/// <summary> /// konstruktor koji ce uvek kada se kreira objekat SmarCardServic-a da osvezi podatke /// </summary> public SmartCardService() { DataIO serializer = new DataIO(); List <User> existingUsersDe = serializer.DeSerializeObject <List <User> >("existingUsers.xml"); if (existingUsersDe != null) { ExistingUsers = existingUsersDe.ToDictionary(x => x.Username, x => x); } }
// When we create a NetworkDataView view instance, a viewmodel of this type will be created, we will call it VM-1 // When we instantiate the AddWindow window a new viewmodel of this type will be created, we will call it VM-2 // Obviously, VM-1 and VM-2 will be different instances, so because of that there will be 2 different properties "Roads" // Although there are 2 properties, there is only one ROADS LIST we are using, and that's the "RoadsObs.Instance.Road" observable collection // Because of that, when we instantiate the NetworkDataView again, we will have the right elements in it // When we add an element via AddWindow, we change the "Roads" property of VM-2, not the VM-1, and because of that // NetworkDataView view will not be updated until we instantiate it again and read the data again from the deserialization public NetworkDataViewModel() { Roads.Clear(); // We clear the list of the old elements if (serializer.DeSerializeObject <ObservableCollection <Road> >("roads.xml") != null) { serializer.DeSerializeObject <ObservableCollection <Road> >("roads.xml").ToList().ForEach(Roads.Add); // And then we deserialize the file holding a list of Roads } // and add each element to the "Roads" property // This LINQ expression is the same as if we manually did the foreach loop FilterCollection = new CollectionViewSource(); FilterCollection.Source = Roads; // Sets the collection from which to create a view DeleteCommand = new MyICommand(OnDelete, CanDelete); AddOpenCommand = new MyICommand(OnAddOpen); AddCommand = new MyICommand(OnAdd); CancelCommand = new MyICommand(OnCancel); FilterCommand = new MyICommand(OnFilter); ClearCommand = new MyICommand(OnClear); NotifiedVms.Instance.Register(this); //ovde registrujemo ovaj VM da bude u listi u singletonu i prosledimo this, a taj this implementira neki nas interfejs }
public static void Deserialze() { Models.Models.AppUsers.AddRange(serializer.DeSerializeObject <List <AppUser> >("AppUsers")); Models.Models.Complaints.AddRange(serializer.DeSerializeObject <List <Complaint> >("Complaints")); Models.Models.Subforums.AddRange(serializer.DeSerializeObject <List <Subforum> >("Subforums")); }
public void DeserializeTestNotThrow() { Assert.DoesNotThrow(() => dataIO.DeSerializeObject <List <string> >(filenameOk)); }
public List <CollectionDescription> Deserialization(int dataset) { List <CollectionDescription> tempList = new List <CollectionDescription>(); switch (dataset) { case 1: if (!File.Exists("DataSet1.xml")) { File.Create("DataSet1.xml").Dispose(); tempList = serializer.DeSerializeObject <List <CollectionDescription> >("DataSet1.xml"); } else { tempList = serializer.DeSerializeObject <List <CollectionDescription> >("DataSet1.xml"); } break; case 2: if (!File.Exists("DataSet2.xml")) { File.Create("DataSet2.xml").Dispose(); tempList = serializer.DeSerializeObject <List <CollectionDescription> >("DataSet2.xml"); } else { tempList = serializer.DeSerializeObject <List <CollectionDescription> >("DataSet2.xml"); } break; case 3: if (!File.Exists("DataSet3.xml")) { File.Create("DataSet3.xml").Dispose(); tempList = serializer.DeSerializeObject <List <CollectionDescription> >("DataSet3.xml"); } else { tempList = serializer.DeSerializeObject <List <CollectionDescription> >("DataSet3.xml"); } break; case 4: if (!File.Exists("DataSet4.xml")) { File.Create("DataSet4.xml").Dispose(); tempList = serializer.DeSerializeObject <List <CollectionDescription> >("DataSet4.xml"); } else { tempList = serializer.DeSerializeObject <List <CollectionDescription> >("DataSet4.xml"); } break; } if (tempList == null) { tempList = new List <CollectionDescription>(); return(tempList); } List <CollectionDescription> temp = new List <CollectionDescription>(); foreach (var item in tempList) { if (item.m_HistoricalCollection.m_WorkerProperty[0].Code != Code.CODE_DIGITAL) { temp.Add(item); } } return(temp); }
public void DeserializeTesThrow() { Assert.Catch(() => dataIO.DeSerializeObject <List <string> >("wrong")); }