예제 #1
0
        public static Boolean Print(Registrant registrant, Controller controller)
        {
            // Format the two strings for the label
            var    label        = (DYMO.Label.Framework.ILabel)null;
            string labelName    = registrant.FirstName + ((registrant.FirstName.Length + registrant.LastName.Length >= 16) ? "\n" : " ") + registrant.LastName;
            string labelDetails = FormatRegistrant(registrant);

            // Liable to throw System.IO.FileNotFoundException, and DYMO.DLS.Runtime.DlsRuntimeException
            label = DYMO.Label.Framework.Label.Open("ERK.label");
            label.SetObjectText("Name", labelName);
            label.SetObjectText("Details", labelDetails);
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Printer");
            string printerName = "";

            foreach (ManagementObject printer in searcher.Get())
            {
                printerName = printer["Name"].ToString();
                if (printerName.Equals(@"DYMO LabelWriter 450 DUO Label"))
                {
                    if (printer["WorkOffline"].ToString().ToLower().Equals("true"))
                    {
                        MessageBox.Show("'DYMO LabelWriter 450 DUO Label' - Printer not found.");

                        if (controller != null)
                        {
                            controller.LogError("'DYMO LabelWriter 450 DUO Label' - Printer not found.");
                        }

                        return(false);
                    }
                    else
                    {
                        try
                        {
                            label.Print("DYMO LabelWriter 450 DUO Label");
                            return(true);
                        }
                        catch (DYMO.DLS.Runtime.DlsRuntimeException e)
                        {
                            MessageBox.Show("'DYMO LabelWriter 450 DUO Label' - Failed to print");

                            if (controller != null)
                            {
                                controller.LogError("'DYMO LabelWriter 450 DUO Label' - Failed to print", e.Message);
                            }

                            return(false);
                        }
                    }
                }
            }

            return(false);
        }
예제 #2
0
파일: Printer.cs 프로젝트: dstewartewu/ERK
        public static Boolean Print(Registrant registrant, Controller controller)
        {
            // Format the two strings for the label
            var label = (DYMO.Label.Framework.ILabel)null;
            string labelName = registrant.FirstName + ((registrant.FirstName.Length + registrant.LastName.Length >= 16) ? "\n" : " ") + registrant.LastName;
            string labelDetails = FormatRegistrant(registrant);

            // Liable to throw System.IO.FileNotFoundException, and DYMO.DLS.Runtime.DlsRuntimeException
            label = DYMO.Label.Framework.Label.Open("ERK.label");
            label.SetObjectText("Name", labelName);
            label.SetObjectText("Details", labelDetails);
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Printer");
            string printerName = "";
            foreach (ManagementObject printer in searcher.Get())
            {
                printerName = printer["Name"].ToString();
                if (printerName.Equals(@"DYMO LabelWriter 450 DUO Label"))
                {
                    if (printer["WorkOffline"].ToString().ToLower().Equals("true"))
                    {
                        MessageBox.Show("'DYMO LabelWriter 450 DUO Label' - Printer not found.");

                        if(controller != null)
                        {
                            controller.LogError("'DYMO LabelWriter 450 DUO Label' - Printer not found.");
                        }

                        return false;
                    }
                    else
                    {
                        try
                        {
                            label.Print("DYMO LabelWriter 450 DUO Label");
                            return true;
                        }
                        catch (DYMO.DLS.Runtime.DlsRuntimeException e)
                        {
                            MessageBox.Show("'DYMO LabelWriter 450 DUO Label' - Failed to print");

                            if(controller != null)
                            {
                                controller.LogError("'DYMO LabelWriter 450 DUO Label' - Failed to print", e.Message);
                            }

                            return false;
                        }
                    }
                }
            }

            return false;
        }
예제 #3
0
        private async void LookupRegistrantByEmail()
        {
            txtbxMessages.Text = "Looking up your registration info...";

            //Disable form controls during lookup
            btnSearch.Visibility = System.Windows.Visibility.Collapsed;
            btnSearch.IsEnabled  = false;
            btnCancel.Visibility = System.Windows.Visibility.Collapsed;
            btnCancel.IsEnabled  = false;

            try
            {
                if ((controller.ActiveRegistrant = await controller.WebAPI.GetRegistrantByEmail(txtbxEmail.Text)) == null)
                {
                    txtbxMessages.Text = String.Format("{1}{0}{2}{0}{3}{0}{4}",
                                                       Environment.NewLine,
                                                       "Your registration info was not found.",
                                                       "Please check your email and try again.",
                                                       "If the problem persists, start over and",
                                                       "click 'Register' to continue checking in.");
                }
                else
                {
                    controller.DisplayRegistrant();

                    //Reset prompt
                    txtbxMessages.Text = "Enter your email below.";
                    txtbxEmail.Clear();
                }
            }
            catch (System.Net.Http.HttpRequestException http_ex)
            {
                controller.Disconnect();

                txtbxMessages.Text = String.Format("{1}{0}{2}",
                                                   Environment.NewLine,
                                                   "Online connection lost. Returning to offline mode.",
                                                   "Please check your internet connection and try again.");

                controller.LogError("Online connection lost.", http_ex.Message);

                btnSearch.Visibility = System.Windows.Visibility.Visible;
                btnCancel.Visibility = System.Windows.Visibility.Visible;
                btnCancel.IsEnabled  = true;

                return;
            }
            catch (Exception ex)
            {
                txtbxMessages.Text = String.Format("{1}{0}{2}{0}{3}",
                                                   Environment.NewLine,
                                                   "An error occurred. Please try again.",
                                                   "If the problem persists, start over and",
                                                   "click 'Register' to continue checking in.");

                controller.LogError(ex.Message);
            }

            //Reenable form controls after lookup
            btnSearch.Visibility = System.Windows.Visibility.Visible;
            btnSearch.IsEnabled  = true;
            btnCancel.Visibility = System.Windows.Visibility.Visible;
            btnCancel.IsEnabled  = true;
        }