ProfileUtil Interface |
Namespace: Zebra.Sdk.Printer
The ProfileUtil type exposes the following members.
Name | Description | |
---|---|---|
CreateBackup |
Save a backup of your printer's settings, alerts, and files for later restoration.
| |
CreateProfile(Stream) |
Create a profile of your printer's settings, alerts, and files for cloning to other printers.
| |
CreateProfile(String) |
Create a profile of your printer's settings, alerts, and files for cloning to other printers.
| |
LoadBackup(String) |
Takes settings, alerts, and files from a backup, and applies them to a printer.
| |
LoadBackup(String, Boolean) |
Takes settings, alerts, and files from a backup, and applies them to a printer.
| |
LoadProfile(String) |
Takes settings, alerts, and files from a profile, and applies them to a printer.
| |
LoadProfile(String, FileDeletionOption, Boolean) |
Takes settings, alerts, and files from a profile, and applies them to a printer.
|
using System; using System.IO; using Zebra.Sdk.Comm; using Zebra.Sdk.Device; using Zebra.Sdk.Printer; public class ProfileUtilExample { private enum ProfileOperations { CREATE_PROFILE, RESTORE_BACKUP, CLONE_A_PRINTER }; public static void Main(string[] args) { string pathToProfile = "C:\\MyNewProfile.zprofile"; ProfileOperations whatToDo = ProfileOperations.CREATE_PROFILE; // Change this to load the profile. TcpConnection connection = new TcpConnection("192.168.1.32", TcpConnection.DEFAULT_ZPL_TCP_PORT); try { connection.Open(); ZebraPrinter genericPrinter = ZebraPrinterFactory.GetInstance(connection); ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.CreateLinkOsPrinter(genericPrinter); if (linkOsPrinter != null) { Console.WriteLine("Start profile operation"); switch (whatToDo) { case ProfileOperations.CREATE_PROFILE: linkOsPrinter.CreateProfile(pathToProfile); break; case ProfileOperations.RESTORE_BACKUP: linkOsPrinter.LoadBackup(pathToProfile); break; case ProfileOperations.CLONE_A_PRINTER: linkOsPrinter.LoadProfile(pathToProfile); break; } } } catch (ConnectionException e) { Console.WriteLine("Could not use connection"); Console.WriteLine(e.ToString()); } catch (ZebraPrinterLanguageUnknownException e) { Console.WriteLine("Could not recognize Zebra printer"); Console.WriteLine(e.ToString()); } catch (ZebraIllegalArgumentException e) { Console.WriteLine("Unexpected response from Zebra printer"); Console.WriteLine(e.ToString()); } catch (IOException e) { Console.WriteLine("Could not write to " + pathToProfile); Console.WriteLine(e.ToString()); } finally { connection.Close(); } } }
using Android.App; using Android.OS; using Android.Views; using Android.Widget; using System; using System.IO; using System.Threading.Tasks; using Zebra.Sdk.Comm; using Zebra.Sdk.Device; using Zebra.Sdk.Printer; public class ProfileUtilExample : Activity { public enum ProfileOperations { CREATE_PROFILE, RESTORE_BACKUP, CLONE_A_PRINTER }; protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); LinearLayout layout = (LinearLayout)View.Inflate(this, Android.Resource.Layout.ActivityListItem, null); layout.Orientation = Orientation.Vertical; Button testButton = new Button(this) { Text = "Run Profile Util Example", LayoutParameters = new ViewGroup.LayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)) }; layout.AddView(testButton); SetContentView(layout); testButton.Click += async (sender, e) => { await Task.Run(() => { string ipAddress = "1.2.3.4"; string pathToProfile = "/path/to/MyNewProfile.zprofile"; ProfileOperations profileOperation = ProfileOperations.CREATE_PROFILE; // Change this to load the profile. ProfileUtil(ipAddress, pathToProfile, profileOperation); }); }; } public void ProfileUtil(string ipAddress, string pathToProfile, ProfileOperations profileOperation) { TcpConnection connection = new TcpConnection(ipAddress, TcpConnection.DEFAULT_ZPL_TCP_PORT); try { connection.Open(); ZebraPrinter genericPrinter = ZebraPrinterFactory.GetInstance(connection); ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.CreateLinkOsPrinter(genericPrinter); if (linkOsPrinter != null) { Console.WriteLine("Start profile operation"); switch (profileOperation) { case ProfileOperations.CREATE_PROFILE: linkOsPrinter.CreateProfile(pathToProfile); break; case ProfileOperations.RESTORE_BACKUP: linkOsPrinter.LoadBackup(pathToProfile); break; case ProfileOperations.CLONE_A_PRINTER: linkOsPrinter.LoadProfile(pathToProfile); break; } } } catch (ConnectionException e) { Console.WriteLine("Could not use connection"); Console.WriteLine(e.ToString()); } catch (ZebraPrinterLanguageUnknownException e) { Console.WriteLine("Could not recognize Zebra printer"); Console.WriteLine(e.ToString()); } catch (ZebraIllegalArgumentException e) { Console.WriteLine("Unexpected response from Zebra printer"); Console.WriteLine(e.ToString()); } catch (IOException e) { Console.WriteLine("Could not write to " + pathToProfile); Console.WriteLine(e.ToString()); } finally { connection.Close(); } } }
using CoreGraphics; using System; using System.IO; using System.Threading.Tasks; using UIKit; using Zebra.Sdk.Comm; using Zebra.Sdk.Device; using Zebra.Sdk.Printer; public class ProfileUtilExample : UIViewController { public enum ProfileOperations { CREATE_PROFILE, RESTORE_BACKUP, CLONE_A_PRINTER }; public ProfileUtilExample(IntPtr handle) : base(handle) { UIButton testButton = new UIButton(UIButtonType.System) { Frame = new CGRect(25, 25, 300, 150) }; testButton.SetTitle("Run Profile Util Example", UIControlState.Normal); testButton.TouchUpInside += async (sender, e) => { await Task.Run(() => { string ipAddress = "1.2.3.4"; string pathToProfile = "/path/to/MyNewProfile.zprofile"; ProfileOperations profileOperation = ProfileOperations.CREATE_PROFILE; // Change this to load the profile. ProfileUtil(ipAddress, pathToProfile, profileOperation); }); }; View.AddSubview(testButton); } public void ProfileUtil(string ipAddress, string pathToProfile, ProfileOperations profileOperation) { TcpConnection connection = new TcpConnection(ipAddress, TcpConnection.DEFAULT_ZPL_TCP_PORT); try { connection.Open(); ZebraPrinter genericPrinter = ZebraPrinterFactory.GetInstance(connection); ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.CreateLinkOsPrinter(genericPrinter); if (linkOsPrinter != null) { Console.WriteLine("Start profile operation"); switch (profileOperation) { case ProfileOperations.CREATE_PROFILE: linkOsPrinter.CreateProfile(pathToProfile); break; case ProfileOperations.RESTORE_BACKUP: linkOsPrinter.LoadBackup(pathToProfile); break; case ProfileOperations.CLONE_A_PRINTER: linkOsPrinter.LoadProfile(pathToProfile); break; } } } catch (ConnectionException e) { Console.WriteLine("Could not use connection"); Console.WriteLine(e.ToString()); } catch (ZebraPrinterLanguageUnknownException e) { Console.WriteLine("Could not recognize Zebra printer"); Console.WriteLine(e.ToString()); } catch (ZebraIllegalArgumentException e) { Console.WriteLine("Unexpected response from Zebra printer"); Console.WriteLine(e.ToString()); } catch (IOException e) { Console.WriteLine("Could not write to " + pathToProfile); Console.WriteLine(e.ToString()); } finally { connection.Close(); } } }