public NetworkInventory CreateNetworkInventory(int customerNumber) { currentNetworkInventory = new NetworkInventory(customerNumber, list_networkinventories.Count, new ArrayList()); list_networkinventories.Add(currentNetworkInventory); db.SaveNetworkInventory(currentNetworkInventory); return currentNetworkInventory; }
public override void SelectedCustomerChanged(Object customer) { base.SelectedCustomerChanged(customer); Log.WriteLog(string.Format("Customer changed successfully: New Customer: {0}", currentCustomer.Name)); //Get Networkinventory of the customer currentNetworkInventory = null; foreach (NetworkInventory n in list_networkInventories) { if (n.Customernumber == currentCustomer.Cnumber) { currentNetworkInventory = n; Log.WriteLog(string.Format("NetworkInventory for customer {0} found", currentCustomer.Name)); } } //Get LicenseInventory of the customer currentLicenseInventory = null; foreach (LicenseInventory li in list_licenseInventories) { if (li.Customernumber == currentCustomer.Cnumber) { currentLicenseInventory = li; Log.WriteLog(string.Format("LicenseInventory for customer {0} found", currentCustomer.Name)); } } //Get latest SystemInventory of the customer currentSystemInventory = null; foreach (SystemInventory si in list_systemInventories) { if (si.Customernumber == currentCustomer.Cnumber) { currentSystemInventory = si; Log.WriteLog(string.Format("SystemInventory for customer {0} found", currentCustomer.Name)); } } //Get latest Audit of the customer currentAudit = null; foreach (Audit a in list_Audits) { if (a.CustomerNumber == currentCustomer.Cnumber) { currentAudit = a; Log.WriteLog(string.Format("Audit for customer {0} found", currentCustomer.Name)); } } UpdateView(false); }
public void SaveNetworkInventory(NetworkInventory ni) { try { connection = new SQLiteConnection("Data Source=" + dbpath + ";Version=3; foreign keys=true;"); connection.Open(); command = new SQLiteCommand(connection); command.CommandText = "INSERT INTO networkinventory (networkInventoryNumber, customerNumber) VALUES(@networkInventoryNumber, @customerNumber);"; command.Parameters.AddWithValue("@networkInventoryNumber", ni.NetworkInventoryNumber); command.Parameters.AddWithValue("@customerNumber", ni.Customernumber); command.ExecuteNonQuery(); } catch (Exception e) { MessageBox.Show("Error SQL Write NetworkInventory", "", MessageBoxButtons.OK, MessageBoxIcon.Error); Log.WriteLog(e.Message); } connection.Close(); }
public void SaveNetwork(Network n, NetworkInventory ni) { try { //Create Progress Form FormProgress fp = new FormProgress(); //Create Query connection = new SQLiteConnection("Data Source=" + dbpath + ";Version=3; foreign keys=true;"); connection.Open(); command = new SQLiteCommand(connection); command.CommandText = "INSERT INTO network (networkNumber, name, inputtype, networkInventoryNumber) VALUES(@networkNumber, @name, @inputtype, @networkInventoryNumber);"; command.Parameters.AddWithValue("@networkNumber", n.NetworkNumber); command.Parameters.AddWithValue("@name", n.Name); command.Parameters.AddWithValue("@inputtype", n.InputType); command.Parameters.AddWithValue("@networkInventoryNumber", ni.NetworkInventoryNumber); command.ExecuteNonQuery(); SQLiteTransaction transaction = connection.BeginTransaction(); //Initialize Progress Form fp.SetMax(n.IpAddresses.Count); fp.Show(); foreach (IPAddress ip in n.IpAddresses) { try {//Write IP to table, if it is already there, throw exception command.CommandText = "INSERT INTO ipaddresses (ipaddress) VALUES(@ipaddress);"; command.Parameters.AddWithValue("@ipaddress", ip.ToString()); command.ExecuteNonQuery(); //Log.WriteLog("IPAddress {0} saved to database", ip.ToString()); } catch (Exception e) { Log.WriteLog("Error writing IP to DB: " + e.Message); } try {//Connect ip to netwok in database command.CommandText = "INSERT INTO networkipadress (networkNumber, ipaddress) VALUES(@networkNumber, @ipaddress);"; command.Parameters.AddWithValue("@networkNumber", n.NetworkNumber); command.Parameters.AddWithValue("@ipaddress", ip.ToString()); command.ExecuteNonQuery(); //Log.WriteLog("IPaddress {0} connected to network {1} in database.", ip.ToString(), n.Name); } catch (Exception e) { Log.WriteLog("Error writing IP/NW to DB: " + e.Message); } fp.Progress(); } transaction.Commit(); Log.WriteLog(string.Format("Network {0} saved to database.", n.Name)); fp.Close(); } catch (Exception e) { MessageBox.Show("Error SQL Write Network", "", MessageBoxButtons.OK, MessageBoxIcon.Error); Log.WriteLog(e.Message); } connection.Close(); }
public override void SelectedCustomerChanged(Object customer) { base.SelectedCustomerChanged(customer); currentLicenseInventory = null; currentNetworkInventory = null; Log.WriteLog(string.Format("Customer changed successfully: New Customer: {0}", currentCustomer.Name)); //Get Licenseinventory of the customer foreach (LicenseInventory li in list_licenseInventories) { if (li.Customernumber == currentCustomer.Cnumber) { currentLicenseInventory = li; Log.WriteLog(string.Format("Licenseinventory for customer {0} found", currentCustomer.Name)); } } if (currentLicenseInventory == null) { MessageBox.Show("Kein Lizenzinventar für diesen Kunden gefunden.", "Kein Lizenzinventar gefunden", MessageBoxButtons.OK, MessageBoxIcon.Information); } //Get Networkinventory of the customer foreach (NetworkInventory ni in list_networkInventories) { if (ni.Customernumber == currentCustomer.Cnumber) { currentNetworkInventory = ni; Log.WriteLog(string.Format("Networkinventory for customer {0} found", currentCustomer.Name)); } } if (currentNetworkInventory == null) { MessageBox.Show("Kein Netzwerkinventar für diesen Kunden gefunden.", "Kein Netzwerkinventar gefunden", MessageBoxButtons.OK, MessageBoxIcon.Information); } UpdateView(false); }
public override void SelectedCustomerChanged(Object customer) { base.SelectedCustomerChanged(customer); currentNetworkInventory = null; currentSystemInventory = null; Log.WriteLog(string.Format("Customer changed successfully: New Customer: {0}", currentCustomer.Name)); //Get Networkinventory of the customer foreach (NetworkInventory n in list_networkinventories) { if (n.Customernumber == currentCustomer.Cnumber) { currentNetworkInventory = n; Log.WriteLog(string.Format("Networkinventory for customer {0} found", currentCustomer.Name)); } } if (currentNetworkInventory == null) { Log.WriteLog("No Networkinventory found"); MessageBox.Show("Kein Netzwerkinventar gefunden, bitte ein Netzwerkinventar für den Kunden erstellen", "Kein Netzwerkinventar", MessageBoxButtons.OK, MessageBoxIcon.Error); } //Get latest Systeminventory of the customer foreach (SystemInventory si in list_systemInventories) { if (si.Customernumber == currentCustomer.Cnumber) { if (currentSystemInventory == null) { currentSystemInventory = si; Log.WriteLog(string.Format("Systeminventory for customer {0} found", currentCustomer.Name)); } //if a systeminventory is newer than the current take this instead else if (DateTime.Compare(si.Date, currentSystemInventory.Date) > 0) { currentSystemInventory = si; Log.WriteLog(string.Format("Newer Systeminventory for customer {0} found", currentCustomer.Name)); } } } //Inform the customer and select all networks to show all Clientsystems of the latest Systeminventory if (currentSystemInventory != null) { // check if all belonging networks still exist bool deletednetworks = false; foreach (ClientSystem c in currentSystemInventory.List_Systems) { if (c.Networknumber == -1) { deletednetworks = true; break; } } if (!deletednetworks) { MessageBox.Show(String.Format("Es wird das aktuellste Systeminventar vom {0} dargestellt.", currentSystemInventory.Date), "Systeminventar gefunden", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(String.Format("Es wird das aktuellste Systeminventar vom {0} dargestellt. Dies enthält jedoch bereits gelöschte Netzwerke. Daher werden nicht mehr alle Clientsysteme dieses Inventars angezeigt. Es wird empfohlen eine erneute Inventarisierung für diesen Kunden durchzufürhen.", currentSystemInventory.Date), "Systeminventar gefunden", MessageBoxButtons.OK, MessageBoxIcon.Information); } UpdateView(false); view.SetChkAll(true); return; } UpdateView(false); }
public override void SelectedCustomerChanged(Object customer) { base.SelectedCustomerChanged(customer); currentNetworkInventory = null; Log.WriteLog(string.Format("Customer changed successfully: New Customer: {0}", currentCustomer.Name)); //Get Networkinventor of the customer or create a new one foreach (NetworkInventory n in list_networkinventories) { if (n.Customernumber == currentCustomer.Cnumber) { currentNetworkInventory = n; Log.WriteLog(string.Format("Inventory for customer {0} found", currentCustomer.Name)); } } if (currentNetworkInventory == null) { currentNetworkInventory = CreateNetworkInventory(currentCustomer.Cnumber); Log.WriteLog(string.Format("new NetworkInventory created")); } UpdateView(false); }