예제 #1
0
 public void SavePrintJob(string kiosk, string xml)
 {
     if (!kiosk.HasValue())
         return;
     var d = new PrintJob {Id = kiosk.Replace(" ", ""), Data = xml, Stamp = DateTime.Now};
     DbUtil.Db.PrintJobs.InsertOnSubmit(d);
     DbUtil.Db.SubmitChanges();
 }
예제 #2
0
        public ActionResult PrintLabels(string data)
        {
            if (!Auth())
                return BaseMessage.createErrorReturn("Authentication failed, please try again", BaseMessage.API_ERROR_INVALID_CREDENTIALS);

            BaseMessage dataIn = BaseMessage.createFromString(data);
            List<CheckInPrintLabel> labels = JsonConvert.DeserializeObject<List<CheckInPrintLabel>>(dataIn.data);

            string securityCode = DbUtil.Db.NextSecurityCode(DateTime.Today).Select(c => c.Code).Single();

            StringBuilder builder = new StringBuilder();

            XmlWriter writer = XmlWriter.Create(builder);
            writer.WriteStartDocument();
            writer.WriteStartElement("PrintJob");

            writer.WriteElementString("securitycode", securityCode);

            writer.WriteStartElement("list");

            foreach (CheckInPrintLabel label in labels)
            {
                label.writeToXML(writer, securityCode);
            }

            // list
            writer.WriteEndElement();
            // PrintJob
            writer.WriteEndElement();
            writer.Close();

            PrintJob job = new PrintJob { Id = dataIn.argString, Data = builder.ToString(), Stamp = DateTime.Now };

            DbUtil.Db.PrintJobs.InsertOnSubmit(job);
            DbUtil.Db.SubmitChanges();

            BaseMessage br = new BaseMessage();
            br.setNoError();
            br.count = 1;

            return br;
        }