private static List <Rdp> ConvertRdpRdmToRdp(List <RdpRDM> rdpRdmList, List <GroupRDM> groups, List <string> listaIdIstniejacychElementow) { List <Rdp> list = new List <Rdp>(); for (int i = 0; i < list.Count; i++) { if (listaIdIstniejacychElementow.Any(a => a == list[i].id)) { list.Remove(list[i]); ilosPominietychElementow++; } } foreach (RdpRDM RdpRdm in rdpRdmList) { string group = ""; foreach (var item in groups) { if (item.group.Length >= RdpRdm.group.Length && item.group.Substring(0, RdpRdm.group.Length) == RdpRdm.group) { group = item.id; } } Serializator.serializuj(new Rdp(RdpRdm.name, group, RdpRdm.description, "hasło", "Rdp", RdpRdm.url, "", RdpRdm.id)); ilosZaimportowanychElementow++; } return(list); }
private static List <TeamViewer> ConvertTeamViewerRdmToTeamViewer(List <TeamViewerRDM> teamViewersRdmList, List <GroupRDM> groups, List <string> listaIdIstniejacychElementow) { List <TeamViewer> list = new List <TeamViewer>(); for (int i = 0; i < list.Count; i++) { if (listaIdIstniejacychElementow.Any(a => a == list[i].id)) { list.Remove(list[i]); ilosPominietychElementow++; } } foreach (TeamViewerRDM teamVerwerRdm in teamViewersRdmList) { string group = ""; foreach (var item in groups) { if (item.group.Length >= teamVerwerRdm.group.Length && item.group.Substring(0, teamVerwerRdm.group.Length) == teamVerwerRdm.group) { group = item.id; } } Serializator.serializuj(new TeamViewer(teamVerwerRdm.name, teamVerwerRdm.group, teamVerwerRdm.description, "", teamVerwerRdm.connectionType, teamVerwerRdm.teamViewerId)); ilosZaimportowanychElementow++; } return(list); }
public void DodajFolder(object sender, RoutedEventArgs e) { var parent = getSenderParent(sender) as UIElement; Folder folder = new Folder("", "", "", "", parent); if (parent is Folder) { (parent as Folder).IsExpanded = true; parent.Focus(); (parent as Folder).Items.Add(folder); } else { var list = (parent as TreeView).ItemsSource as List <Element>; list.Add(folder); CollectionViewSource.GetDefaultView(list).Refresh(); } Thread watek = new Thread(new ThreadStart(() => { Serializator.serializuj(folder); })); watek.Start(); focusOnFolder(folder); }
public static void ImportRDM(string databasePath) { try { XmlDocument xml = new XmlDocument(); xml.Load(Properties.Settings.Default.baseXmlPath); XmlNodeList nodeList = xml["Connections"].ChildNodes; List <string> listaIdIstniejacychElementow = new List <string>(); foreach (XmlNode node in nodeList) { listaIdIstniejacychElementow.Add(node.Attributes["Id"].InnerText); } List <GroupRDM> groupsRdmList = ImportOfElements.GetGroupsList(databasePath); List <Folder> groupsList = ConvGroupRdmToFolder(groupsRdmList, listaIdIstniejacychElementow); List <TeamViewerRDM> teamViewersRdmList = ImportOfElements.GetTeamViewersList(databasePath); List <TeamViewer> teamViewers = ConvertTeamViewerRdmToTeamViewer(teamViewersRdmList, groupsRdmList, listaIdIstniejacychElementow); List <RdpRDM> rdpRdmList = ImportOfElements.GetRdpList(databasePath); List <Rdp> rdpList = ConvertRdpRdmToRdp(rdpRdmList, groupsRdmList, listaIdIstniejacychElementow); foreach (Folder groupItem in groupsList) { Serializator.serializuj(groupItem); ilosZaimportowanychElementow++; } MyMessageBox.Show("Import kontaktów zakończony pomyślnie.\nIlość zaimportowanych elementów: " + ilosZaimportowanychElementow + "\nIlość pominiętych elementów: " + ilosPominietychElementow, "Import zakończony", MyMessageBoxButtons.Ok); MainWindow.aktualizujTreeView(MainWindow.listOfClients); } catch (Exception ex) { MyMessageBox.Show(ex.Message, "Błąd importu!", MyMessageBoxButtons.Ok); } }
protected override void zapiszKlienta() { if (string.IsNullOrWhiteSpace(nazwaTextBox.Text)) { MessageBox.Show("Pole nazwa nie może być puste!", "Uzupełnij nazwę", MessageBoxButton.OK, MessageBoxImage.Error); } else { XmlDocument xml = new XmlDocument(); xml.Load(Properties.Settings.Default.baseXmlPath); XmlNodeList nodeList = xml["Connections"].ChildNodes; foreach (XmlNode node in nodeList) { if (node.Attributes["Id"].InnerText == klient.id) { xml["Connections"].RemoveChild(node); } } xml.Save(Properties.Settings.Default.baseXmlPath); this.klient.nazwa = nazwaTextBox.Text; this.klient.emailList = this.emailList; this.klient.telefonList = this.telefonList; this.klient.daneLogowaniaList = this.daneLogowaniaList; this.klient.opis = new TextRange(opisRichTextbox.Document.ContentStart, opisRichTextbox.Document.ContentEnd).Text; Serializator.serializuj(this.klient); MainWindow.aktualizujTreeView(MainWindow.listOfClients); this.Close(); } }
protected override void zapiszKlienta() { if (sprawdzCzyKlientIstnieje() == false) { string opis = new TextRange(opisRichTextbox.Document.ContentStart, opisRichTextbox.Document.ContentEnd).Text; using (Klient k = new Klient(nazwaTextBox.Text, "", opis, emailList, telefonList, daneLogowaniaList, "", base.parent)) { if (parent is Folder) { (parent as Folder).Items.Add(k); } else { (MainWindow.listOfClients.ItemsSource as List <Element>).Add(k); } Serializator.serializuj(k); } MainWindow.aktualizujTreeView(MainWindow.listOfClients); this.Close(); } }
private void zapisz() { Regex reg = new Regex(@"^[A-ZĄĆĘŁŃÓŚŹŻa-ząćęłńóśźż0-9 ]*$"); if (string.IsNullOrWhiteSpace(rodzajComboBox.Text) || string.IsNullOrWhiteSpace(nazwaTextBox.Text) || string.IsNullOrWhiteSpace(loginTextBox.Text) || string.IsNullOrWhiteSpace(hasloTextBox.Text)) { MessageBox.Show("Uzupełnij wszystkie pola!", "Błąd", MessageBoxButton.OK, MessageBoxImage.Warning); } else if (!reg.IsMatch(nazwaTextBox.Text)) { MyMessageBox.Show("Wprowadzono nieprawidłowe znaki w pole nazwy"); } else { if (thisRemoteId == null)// dodanie nowego połączenia { //############# DODAJ TEAMVIEWER ############################################################################### if (rodzajComboBox.Text == "TeamViewer") { Serializator.serializuj(new TeamViewer(nazwaTextBox.Text, klientId, "", hasloTextBox.Text, "TeamViewer", loginTextBox.Text)); } //############# DODAJ RDP ############################################################################### else if (rodzajComboBox.Text == "RDP") { if (!string.IsNullOrWhiteSpace(adresTextBox.Text)) { Serializator.serializuj(new Rdp(nazwaTextBox.Text, klientId, "", hasloTextBox.Text, "Rdp", adresTextBox.Text, loginTextBox.Text)); } else { MessageBox.Show("Uzupełnij wszystkie pola!", "Błąd", MessageBoxButton.OK, MessageBoxImage.Warning); return; } } } else// edycja połączenia { XmlDocument xml = new XmlDocument(); xml.Load(Properties.Settings.Default.baseXmlPath); XmlNodeList connectionsNodes = null; if (xml.ChildNodes[0] != null) { connectionsNodes = xml.ChildNodes[0].ChildNodes; } else { MyMessageBox.Show("Plik XML jest uszkodzony, brakuje głównego węzła Connections"); } XmlNodeList remoteNodes; if (rodzajComboBox.SelectedIndex == 0) { remoteNodes = xml.GetElementsByTagName("TeamViewer"); } else { remoteNodes = xml.GetElementsByTagName("Rdp"); } foreach (XmlNode node in remoteNodes) { if (node.Attributes["Id"].InnerText == thisRemoteId) { if (node.Attributes["Type"].InnerText == "TeamViewer") { node.Attributes["Name"].InnerText = nazwaTextBox.Text; node.Attributes["Password"].InnerText = hasloTextBox.Text; node.Attributes["TeamViewerId"].InnerText = loginTextBox.Text; } else if (node.Attributes["Type"].InnerText == "Rdp") { node.Attributes["Name"].InnerText = nazwaTextBox.Text; node.Attributes["Address"].InnerText = adresTextBox.Text; node.Attributes["Login"].InnerText = loginTextBox.Text; node.Attributes["Password"].InnerText = hasloTextBox.Text; } } } xml.Save(Properties.Settings.Default.baseXmlPath); } MainWindow.aktualizujTreeView(MainWindow.listOfClients); this.Close(); } }