示例#1
0
        public static int Label2(this MemoryStream ms, IEnumerable <LabelInfo> li, int nlabels, string code)
        {
            if (nlabels <= 0 || !Program.Printer.HasValue())
            {
                return(0);
            }
            var sw = new StreamWriter(ms);

            var list = new List <string>();

            if (li.First().allergies.HasValue())
            {
                list.Add(" A ");
            }
            if (li.First().transport)
            {
                list.Add(" T ");
            }
            if (li.First().custody)
            {
                list.Add(" C ");
            }
            var s = string.Join("|", list.ToArray());

            if (Program.Printer.Contains("ZDesigner"))
            {
                StartZDesignerLabel(sw);
                sw.WriteLine(@"^FT27,87^A0N,79,79^FH\^FD{0}^FS".Fmt(li.First().first));
                sw.WriteLine(@"^FT26,133^A0N,34,33^FH\^FD{0}^FS".Fmt(li.First().last));
                sw.WriteLine(@"^FT459,150^A0N,28,28^FH\^FD{0:d}^FS".Fmt(li.First().hour));
                sw.WriteLine(@"^FT444,223^A0N,79,79^FH\^FD{0}^FS".Fmt(code));

                sw.WriteLine(@"^FO16,138^GB206,54,8^FS");
                sw.WriteLine(@"^FT27,174^A0N,28,28^FH\^FDWear this label^FS");
                sw.WriteLine(@"^FT241,178^A0N,28,28^FH\^FD{0}^FS".Fmt(s));

                var vertpos = 352;
                foreach (var i in li.OrderByDescending(ll => ll.hour))
                {
                    var loc = i.location;
                    if (!loc.HasValue())
                    {
                        loc = "n/a";
                    }

                    sw.WriteLine(@"^FT28,{0}^A0N,28,28^FH\^FD{1}^FS".Fmt(vertpos, loc));
                    sw.WriteLine(@"^FT112,{0}^A0N,28,28^FH\^FD{1}^FS".Fmt(vertpos,
                                                                          "{0:h:mm t}".Fmt(i.hour).PadLeft(7, '~').Replace("~", "  ")));
                    sw.WriteLine(@"^FT42,{0}^A0N,23,24^FH\^FD{1} ({2})^FS".Fmt(vertpos + 28, i.org, i.mv.Replace("V", "G")));

                    vertpos -= 57;
                }
                sw.WriteLine(@"^PQ{0},0,1,Y^XZ".Fmt(nlabels));

                sw.Flush();
                foreach (var i in li)
                {
                    ms.AllergyLabel2(i, code);
                }
                // Do the Extra labels here
            }
            else if (Program.Printer.Contains("Godex"))
            {
                StartGodexLabel(sw, 1);
                var item = li.First();
                if (!item.requiressecuritylabel)
                {
                    sw.WriteLine("AH,36,40,1,1,0,0," + li.First().first);
                    sw.WriteLine("AH,36,148,1,1,0,0," + li.First().last);
                }
                else
                {
                    sw.WriteLine("AH,18,0,1,1,0,0," + li.First().first);
                    sw.WriteLine("AE,18,84,1,1,0,0," + li.First().last);
                    sw.WriteLine("AD,433,115,1,1,0,0,{0:d}".Fmt(li.First().hour));
                    sw.WriteLine("AH,428,136,1,1,0,0," + code);
                    sw.WriteLine("R14,140,239,181,1,1");
                    sw.WriteLine("AD,22,140,1,1,0,0,Wear this label  " + s);
                }

                var vertpos = 338;
                foreach (var i in li.OrderByDescending(ll => ll.hour))
                {
                    var loc = i.location;
                    if (!loc.HasValue())
                    {
                        loc = "n/a";
                    }
                    if (i.org.StartsWith(loc) && i.org.Length > loc.Length + 2)
                    {
                        i.org = i.org.Substring(loc.Length + 2);
                    }
                    if (loc.Length > 5)
                    {
                        loc = loc.Substring(0, 5);
                    }
                    sw.WriteLine("AC,18,{0},1,1,0,0,{1}".Fmt(vertpos, loc));
                    sw.WriteLine("AC,120,{0},1,1,0,0,{1}".Fmt(vertpos,
                                                              "{0:h:mm t}".Fmt(i.hour).PadLeft(7, '~').Replace("~", "  ")));
                    sw.WriteLine("AB,36,{0},1,1,0,0,{1} ({2})".Fmt(vertpos + 31, i.org, i.mv.Replace("V", "G")));
                    vertpos -= 68;
                }
                sw.WriteLine("E");
                sw.Flush();

                foreach (var i in li)
                {
                    AllergyLabel2(ms, i, code);
                }
                foreach (var i in li.Where(ll => ll.n > 1))
                {
                    StartGodexLabel(sw, i.n - 1);
                    sw.WriteLine("AH,18,0,1,1,0,0," + li.First().first);
                    sw.WriteLine("AE,18,84,1,1,0,0," + li.First().last);
                    sw.WriteLine("AD,286,161,1,1,0,0,{0:d}".Fmt(li.First().hour));
                    sw.WriteLine("AH,422,129,1,1,0,0," + code);
                    sw.WriteLine("AD,19,129,1,1,0,0,Extra | {0}{1}{2}".Fmt(
                                     li.First().allergies.HasValue() ? " A |" : "",
                                     li.First().transport ? " T |" : "",
                                     li.First().custody ? " C |" : ""));

                    var loc = i.location;
                    if (!loc.HasValue())
                    {
                        loc = "n/a";
                    }
                    if (i.org.StartsWith(loc))
                    {
                        i.org = i.org.Substring(loc.Length + 2);
                    }
                    if (loc.Length > 5)
                    {
                        loc = loc.Substring(0, 5);
                    }
                    sw.WriteLine("AC,17,202,1,1,0,0," + loc);
                    sw.WriteLine("AC,120,202,1,1,0,0," +
                                 "{0:h:mm t}".Fmt(i.hour).PadLeft(7, '~').Replace("~", "  "));
                    sw.WriteLine("AB,36,233,1,1,0,0,{0} ({1})".Fmt(i.org, i.mv.Replace("V", "G")));
                    vertpos += 68;
                    sw.WriteLine("E");
                }
            }
            sw.Flush();
            return(nlabels);
        }