public static string Print(Dictionary <string, string> labelDict)
 {
     foreach (KeyValuePair <string, string> labelInfo in labelDict)
     {
         string orderNum = labelInfo.Key.ToString();
         if (orderNum == "EmailSent")
         {
             return("Error, Email Sent");
         }
         string labelBinary        = labelInfo.Value;
         byte[] data               = Convert.FromBase64String(labelBinary);
         string encodedLabelBinary = Encoding.UTF8.GetString(data);
         RawPrinterHelper.SendStringToPrinter(ConfigurationManager.AppSettings["printerName"], encodedLabelBinary);
     }
     return("Printed");
 }
Пример #2
0
        private void _ReprintBtn_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show("Reprint existing label(Yes) or create new label(No)?", "Warning", MessageBoxButtons.YesNo);

            if (dialog == DialogResult.Yes)
            {
                DataRow dr                 = Db.GetShipmentInfoByOrder(this._OrderNumTxt.Text, this._ChannelTxt.Text);
                string  nativeCommand      = dr["LabelCommand"].ToString();
                byte[]  data               = Convert.FromBase64String(nativeCommand);
                string  encodedLabelBinary = Encoding.UTF8.GetString(data);
                RawPrinterHelper.SendStringToPrinter(ConfigurationManager.AppSettings["printerName"], encodedLabelBinary);
            }
            else if (dialog == DialogResult.No)
            {
                if (this._ShipCountry.Text != "US")
                {
                    MessageBox.Show("Not Support Yet!");
                    //Dictionary<string, string> labelDict = ProcessShippingLabel.GetInternationalLabel(this._OrderNumTxt.Text, this._ChannelTxt.Text);
                    //string printResult = PrintShippingLabel.Print(labelDict);
                    //if (printResult == "Error, Email Sent")
                    //{
                    //   MessageBox.Show("Error, Email Sent");
                    //}
                }
                else
                {
                    string customizedWeight = (Interaction.InputBox("Input Weight", this._OrderNumTxt.Text));
                    Dictionary <string, string> labelDict = ProcessShippingLabel.GetDomesticLabel(this._OrderNumTxt.Text, this._ChannelTxt.Text, customizedWeight, "");
                    string printResult = PrintShippingLabel.Print(labelDict);
                    if (printResult == "Error, Email Sent")
                    {
                        MessageBox.Show("Error, Email Sent");
                    }
                }
            }
        }