Пример #1
0
        private async void printButton_Clicked(object sender, EventArgs e)
        {
            List <LabelObject>  labels  = new List <LabelObject>();
            List <DeviceObject> devices = new List <DeviceObject>();

            try
            {
                foreach (DataGridViewRow v in deviceList.SelectedRows)
                {
                    StringBuilder builder = new StringBuilder();

                    LabelObject label = new LabelObject();

                    Task <DeviceObject> t1 = Task.Run(() => RunDataGridView(v));
                    await t1;



                    Console.WriteLine("THIS IS VALIUE: " + v.Cells[0].Value);

                    label.title = v.Cells[0].Value == null ? " " : v.Cells[0].Value.ToString();
                    builder.AppendLine(v.Cells[1].Value == null ? " " : v.Cells[1].Value.ToString());
                    builder.AppendLine(v.Cells[2].Value == null ? " " : v.Cells[2].Value.ToString());
                    builder.AppendLine(v.Cells[3].Value == null ? " " : v.Cells[3].Value.ToString());
                    builder.AppendLine(v.Cells[4].Value == null ? " " : v.Cells[4].Value.ToString());
                    builder.AppendLine(v.Cells[6].Value == null ? " " : v.Cells[6].Value.ToString());
                    label.content        = builder.ToString();
                    label.qrCodeLocation = "code.png";
                    label.uuid           = v.Cells[1].Value == null ? " " : v.Cells[1].Value.ToString();

                    labels.Add(label);

                    if (!skuCheckBox.Checked)
                    {
                        LocationPrompt locs = new LocationPrompt();

                        DeviceObject device = new DeviceObject();

                        device.serialID = v.Cells[1].Value == null ? " " : v.Cells[1].Value.ToString();
                        device.location = locs.location;
                        device.caseID   = locs.theCase;

                        devices.Add(device);
                    }
                    else
                    {
                        if (t1.Result != null)
                        {
                            devices.Add(t1.Result);
                        }
                    }
                }

                if (devices.Count != 0)
                {
                    Console.WriteLine(labels.Count);
                    await ProcessLabels(labels, @"C:\Users\Vince\Documents\QrCodeLabelTemp2.dotx", true);

                    CheckInDevices(devices);
                }
            }
            catch (Exception ex) {
                Trace.WriteLine(ex.ToString());
            }
        }
Пример #2
0
        private DeviceObject RunDataGridView(DataGridViewRow v)
        {
            Bitmap       bitmap    = (Bitmap)v.Cells[5].Value;
            DeviceObject deviceObj = null;

            string device  = v.Cells[0].Value == null ? " " : v.Cells[0].Value.ToString();
            string serial  = v.Cells[1].Value == null ? " " : v.Cells[1].Value.ToString();
            string imei    = v.Cells[2].Value == null ? " " : v.Cells[2].Value.ToString();
            string mei     = v.Cells[3].Value == null ? " " : v.Cells[3].Value.ToString();
            string model   = v.Cells[4].Value == null ? " " : v.Cells[4].Value.ToString();
            string color   = v.Cells[5].Value == null ? " " : ColorTranslator.ToHtml(bitmap.GetPixel(0, 0));
            string carrier = v.Cells[6].Value == null ? " " : v.Cells[6].Value.ToString();

            List <string> fields = new List <string>()
            {
                device, serial, mei, imei, model, color, carrier
            };

            if (skuCheckBox.Checked)
            {
                SkuPrompt skuPrompt = new SkuPrompt();

                skuPrompt.Initialize(fields);

                if (skuPrompt.skuString != null)
                {
                    StreamWriter writer = new StreamWriter(dataLocation.Text, false);
                    deviceObj = new DeviceObject();

                    if (!File.Exists(dataLocation.Text))
                    {
                        File.Create(dataLocation.Text);
                    }

                    writer.WriteLine("DEVICE-SERIAL-IMEI-MEI-MODEL-COLOR-CARRIER");

                    writer.WriteLineAsync($"{skuPrompt.skuString}-{serial}-{imei}-{mei}-{model}-{color}-{skuPrompt.carrierString}");

                    writer.Close();

                    Task.Run(() => PrintProcess());

                    deviceObj.serialID = serial;
                    deviceObj.location = skuPrompt.locationString;
                    deviceObj.caseID   = skuPrompt.caseIDString;
                }
            }
            else
            {
                Console.WriteLine(device + " " + serial + " " + imei + " " + mei + " " + model + " " + color + " " + carrier);

                StreamWriter writer = new StreamWriter(dataLocation.Text, false);

                if (!File.Exists(dataLocation.Text))
                {
                    File.Create(dataLocation.Text);
                }

                writer.WriteLine("DEVICE-SERIAL-IMEI-MEI-MODEL-COLOR-CARRIER");

                if (carrier.Length > 1)
                {
                    if (modelCheckBox.Checked)
                    {
                        writer.WriteLineAsync(device + " (" + carrier + ") {" + model + "}-" + serial + "-" + imei + "-" + mei + "-" + model + "-" + color + "-" + carrier);
                    }
                    else
                    {
                        writer.WriteLineAsync(device + " (" + carrier + ")-" + serial + "-" + imei + "-" + mei + "-" + model + "-" + color + "-" + carrier);
                    }
                }
                else
                {
                    if (modelCheckBox.Checked)
                    {
                        writer.WriteLineAsync(device + " {" + model + "}-" + serial + "-" + imei + "-" + mei + "-" + model + "-" + color);
                    }
                    else
                    {
                        writer.WriteLineAsync(device + "-" + serial + "-" + imei + "-" + mei + "-" + model + "-" + color);
                    }
                }


                writer.Close();

                Task.Run(() => PrintProcess());
            }
            return(deviceObj);
        }