private void UploadProfile(string profilePath, Connection connection) { if (connection != null) { try { connection.Open(); ZebraPrinter genericPrinter = ZebraPrinterFactory.GetInstance(connection); ZebraPrinterLinkOs printer = ZebraPrinterFactory.CreateLinkOsPrinter(genericPrinter); if (printer != null) { printer.LoadProfile(profilePath, FileDeletionOption.NONE, false); string printerAddress = connectionSelector.getConnectionAddress(); MessageBoxCreator.ShowInformation($"Profile loaded successfully to printer {printerAddress}", "Profile Uploaded Successfully"); } else { MessageBoxCreator.ShowError("Profile loading is only available on Link-OS(TM) printers", "Error"); } } catch (ConnectionException e) { MessageBoxCreator.ShowError(e.Message, "Connection Error"); } catch (ZebraPrinterLanguageUnknownException e) { MessageBoxCreator.ShowError(e.Message, "Connection Error"); } catch (IOException e) { MessageBoxCreator.ShowError(e.Message, "Connection Error"); } catch (Exception e) { MessageBoxCreator.ShowError(e.Message, "Upload Profile Error"); } finally { SetButtonStates(true); try { connection.Close(); } catch (ConnectionException) { } } } }
private void CreateProfile(string profilePath, Connection connection) { if (connection != null) { try { connection.Open(); ZebraPrinter genericPrinter = ZebraPrinterFactory.GetInstance(connection); ZebraPrinterLinkOs printer = ZebraPrinterFactory.CreateLinkOsPrinter(genericPrinter); if (printer != null) { if (!profilePath.EndsWith(".zprofile")) { profilePath += ".zprofile"; } printer.CreateProfile(profilePath); MessageBoxCreator.ShowInformation($"Profile created successfully at location '{profilePath}'", "Profile Created Successfully"); } else { MessageBoxCreator.ShowError("Profile creation is only available on Link-OS(TM) printers", "Error"); } } catch (ConnectionException e) { MessageBoxCreator.ShowError(e.Message, "Connection Error"); } catch (ZebraPrinterLanguageUnknownException e) { MessageBoxCreator.ShowError(e.Message, "Connection Error"); } catch (IOException e) { MessageBoxCreator.ShowError(e.Message, "Connection Error"); } catch (ZebraIllegalArgumentException e) { MessageBoxCreator.ShowError(e.Message, "Connection Error"); } catch (Exception e) { MessageBoxCreator.ShowError(e.Message, "Create Profile Error"); } finally { SetButtonStates(true); try { connection.Close(); } catch (ConnectionException) { } } } }