예제 #1
0
 protected void Page_Init(object sender, EventArgs e)
 {
     if (WebClientPrint.ProcessPrintJob(this.Request))
     {
         PrintingManager.Print("AAAA", this);
     }
 }
예제 #2
0
        public ActionResult ShippingMethodEdit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Method = new GenericRepository <ShippingMethod>(db);

            ShippingMethod method = Method.Get(id.Value);

            if (method == null)
            {
                return(HttpNotFound());
            }

            Carriers = new GenericRepository <Carriers>(db);
            ViewData["carrierSelect"] = Carriers.GetAll(true).Where(c => c.IsEnable).OrderBy(c => c.ID).ToList();

            List <object> directLineSelect = new List <object>()
            {
                new { text = "無", value = (byte)0 }
            };

            directLineSelect.AddRange(db.DirectLine.AsNoTracking().Where(d => d.IsEnable).Select(d => new { text = d.Name, value = d.ID }).ToList());
            ViewData["directLineSelect"] = new SelectList(directLineSelect.AsEnumerable(), "value", "text", method.DirectLine);

            ViewBag.WCPScript = WebClientPrint.CreateScript(Url.Action("ProcessRequest", "WebClientPrintAPI", null, HttpContext.Request.Url.Scheme), Url.Action("PrintFile", "File", null, HttpContext.Request.Url.Scheme), HttpContext.Session.SessionID);
            return(View(method));
        }
예제 #3
0
        protected void Page_Init(object sender, System.EventArgs e)
        {
            if (WebClientPrint.ProcessPrintJob(this.Request))
            {
                session_id = this.Request.QueryString["sid"];
                //PrintingManager.Print((string)Application[session_id + CommonConstants.PrintCommand], this);
//                PrintingManager.Print("^XA" + "\n" +
//"^PW900" + "\n" +
//"^FO0,158^GB830,0,2,^FS" + "\n" +
//"^FO0,441^GB830,0,2,^FS" + "\n" +
//"^FO0,562^GB830,0,2,^FS" + "\n" +
//"^FO400,562^GB2,121,2^FS" + "\n" +
//"^FO0,683^GB830,0,2,^FS" + "\n" +
//"^FO600,683^GB2,100,2^FS" + "\n" +
//"^FO0,784^GB830,0,2,^FS" + "\n" +
//"^FO550,784^GB2,100,2^FS" + "\n" +
//"^FO0,884^GB830,0,2,^FS" + "\n" +
//"^FO33,12^AD,18^FDAir Line^FS" + "\n" +
//"^FO33,452^AD,18^FDAir Waybill No.^FS" + "\n" +
//"^FO33,574^AD,18^FDDestination^FS" + "\n" +
//"^FO410,574^AD,18^FDTotal No. of Pieces^FS" + "\n" +
//"^FO610,695^AD,18^FDOrigin^FS" + "\n" +
//"^FO33,796^AD,18^FDHAWB No.^FS" + "\n" +
//"^FO560,796^AD,18^FDHAWB PCS^FS" + "\n" +
//"^FO33,896^AD,18^FDHAWB Weight^FS" + "\n" +
//"^XZ",this);
            }
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetExpires(DateTime.Now); //or a date much earlier than current time
        }
        // GET: Invoice/Details/5
        public ActionResult Details(int id)
        {
            var lBoInvoice = this.LInvoice.bll_GetInvoiceById(id).TrasferToMInvoice();

            ViewBag.WCPScript = WebClientPrint.CreateScript(Url.Action("ProcessRequest", "WebClientPrintAPI", null, HttpContext.Request.Url.Scheme), Url.Action("PrintCommands", "Invoice", new { pIdInvoice = id }, HttpContext.Request.Url.Scheme), HttpContext.Session.SessionID);
            return(this.View(lBoInvoice));
        }
예제 #5
0
        public IActionResult Index()
        {
            ViewData["WCPPDetectionScript"] = WebClientPrint.CreateWcppDetectionScript(
                Url.Action("ProcessRequest", "WebClientPrintAPI", null,
                           Url.ActionContext.HttpContext.Request.Scheme), Url.ActionContext.HttpContext.Session.Id);

            return(View());
        }
예제 #6
0
    public ActionResult Index()
    {
        ViewBag.WCPScript = WebClientPrint.CreateScript(Url.Action("ProcessRequest", "WebClientPrintAPI", null, HttpContext.Request.Url.Scheme),
                                                        Url.Action("PrintCommands", "PrintESCPOS", null, HttpContext.Request.Url.Scheme),
                                                        HttpContext.Session.SessionID);

        return(View());
    }
        public void PrintCommands(string sid)
        {
            if (WebClientPrint.ProcessPrintJob(System.Web.HttpContext.Current.Request.Url.Query))
            {
                HttpApplicationStateBase app = HttpContext.Application;

                //Create a ClientPrintJob obj that will be processed at the client side by the WCPP
                ClientPrintJob cpj = new ClientPrintJob();

                //get printer commands for this user id
                object printerCommands = app[sid + PRINTER_COMMANDS];
                if (printerCommands != null)
                {
                    cpj.PrinterCommands = printerCommands.ToString();
                    cpj.FormatHexValues = true;
                }

                //get printer settings for this user id
                int printerTypeId = (int)app[sid + PRINTER_ID];

                if (printerTypeId == 0) //use default printer
                {
                    cpj.ClientPrinter = new DefaultPrinter();
                }
                else if (printerTypeId == 1) //show print dialog
                {
                    cpj.ClientPrinter = new UserSelectedPrinter();
                }
                else if (printerTypeId == 2) //use specified installed printer
                {
                    cpj.ClientPrinter = new InstalledPrinter(app[sid + INSTALLED_PRINTER_NAME].ToString());
                }
                else if (printerTypeId == 3) //use IP-Ethernet printer
                {
                    cpj.ClientPrinter = new NetworkPrinter(app[sid + NET_PRINTER_HOST].ToString(), int.Parse(app[sid + NET_PRINTER_PORT].ToString()));
                }
                else if (printerTypeId == 4) //use Parallel Port printer
                {
                    cpj.ClientPrinter = new ParallelPortPrinter(app[sid + PARALLEL_PORT].ToString());
                }
                else if (printerTypeId == 5) //use Serial Port printer
                {
                    cpj.ClientPrinter = new SerialPortPrinter(app[sid + SERIAL_PORT].ToString(),
                                                              int.Parse(app[sid + SERIAL_PORT_BAUDS].ToString()),
                                                              (SerialPortParity)Enum.Parse(typeof(SerialPortParity), app[sid + SERIAL_PORT_PARITY].ToString()),
                                                              (SerialPortStopBits)Enum.Parse(typeof(SerialPortStopBits), app[sid + SERIAL_PORT_STOP_BITS].ToString()),
                                                              int.Parse(app[sid + SERIAL_PORT_DATA_BITS].ToString()),
                                                              (SerialPortHandshake)Enum.Parse(typeof(SerialPortHandshake), app[sid + SERIAL_PORT_FLOW_CONTROL].ToString()));
                }

                //Send ClientPrintJob back to the client
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.BinaryWrite(cpj.GetContent());
                System.Web.HttpContext.Current.Response.End();
            }
        }
예제 #8
0
 protected void Page_Init(object sender, System.EventArgs e)
 {
     if (WebClientPrint.ProcessPrintJob(this.Request))
     {
         ClientPrintJob cpj = new ClientPrintJob();
         cpj.ClientPrinter   = new UserSelectedPrinter();
         cpj.PrinterCommands = (string)Application[this.Request.QueryString["sid"] + CommonConstants.PrintCommand];
         cpj.SendToClient(Response);
     }
     Response.Cache.SetCacheability(HttpCacheability.NoCache);
     Response.Cache.SetExpires(DateTime.Now); //or a date much earlier than current time
 }
예제 #9
0
        public void PrintCommands(string sid)
        {
            if (WebClientPrint.ProcessPrintJob(System.Web.HttpContext.Current.Request))
            {
                HttpApplicationStateBase app = HttpContext.Application;
                //Create a ClientPrintJob obj that will be processed at the client side by the WCPP
                ClientPrintJob cpj = new ClientPrintJob();
                //get printer commands for this user id
                object printerCommands = app[sid + PRINTER_COMMANDS];
                if (printerCommands != null)
                {
                    cpj.PrinterCommands = printerCommands.ToString();
                    cpj.FormatHexValues = true;
                }
                cpj.ClientPrinter = new UserSelectedPrinter();
                //Send ClientPrintJob back to the client
                cpj.SendToClient(System.Web.HttpContext.Current.Response);
            }

        }
예제 #10
0
        public ActionResult ShippingMethodEdit(int id)
        {
            if (!MyHelp.CheckAuth("shipping", "shippingMethod", EnumData.AuthType.Edit))
            {
                return(RedirectToAction("index", "main"));
            }

            Method = new GenericRepository <ShippingMethod>(db);

            ShippingMethod method = Method.Get(id);

            if (method == null)
            {
                return(HttpNotFound());
            }

            if (TryUpdateModel(method) && ModelState.IsValid)
            {
                Method.SaveChanges();

                MyHelp.Log("ShippingMethod", method.ID, "編輯運輸方式");
                return(RedirectToAction("shippingMethod", "shipping"));
            }

            Carriers = new GenericRepository <Carriers>(db);
            ViewData["carrierSelect"] = Carriers.GetAll(true).Where(c => c.IsEnable).OrderBy(c => c.ID).ToList();

            List <object> directLineSelect = new List <object>()
            {
                new { text = "無", value = (byte)0 }
            };

            directLineSelect.AddRange(db.DirectLine.AsNoTracking().Where(d => d.IsEnable).Select(d => new { text = d.Name, value = d.ID }).ToList());
            ViewData["directLineSelect"] = new SelectList(directLineSelect.AsEnumerable(), "value", "text", method.DirectLine);

            ViewBag.WCPScript = WebClientPrint.CreateScript(Url.Action("ProcessRequest", "WebClientPrintAPI", null, HttpContext.Request.Url.Scheme), Url.Action("PrintFile", "File", null, HttpContext.Request.Url.Scheme), HttpContext.Session.SessionID);
            return(View(method));
        }
예제 #11
0
        public IActionResult ProcessRequest()
        {
            //get session ID
            string sessionID = HttpContext.Request.Query["sid"].ToString();

            //get Query String
            string queryString = HttpContext.Request.QueryString.Value;

            try
            {
                //Determine and get the Type of Request
                RequestType prType = WebClientPrint.GetProcessRequestType(queryString);

                if (prType == RequestType.GenPrintScript ||
                    prType == RequestType.GenWcppDetectScript)
                {
                    //Let WebClientPrint to generate the requested script
                    byte[] script = WebClientPrint.GenerateScript(Url.Action("ProcessRequest", "WebClientPrintAPI", null, HttpContext.Request.Scheme), queryString);

                    return(File(script, "application/x-javascript", "WebClientPrintScript"));
                }
                else if (prType == RequestType.ClientSetWcppVersion)
                {
                    //This request is a ping from the WCPP utility
                    //so store the session ID indicating it has the WCPP installed
                    //also store the WCPP Version if available
                    string wcppVersion = HttpContext.Request.Query["wcppVer"];
                    if (string.IsNullOrEmpty(wcppVersion))
                    {
                        wcppVersion = "1.0.0.0";
                    }

                    _MemoryCache.Set(sessionID + "wcppInstalled", wcppVersion);
                }
                else if (prType == RequestType.ClientSetInstalledPrinters)
                {
                    //WCPP Utility is sending the installed printers at client side
                    //so store this info with the specified session ID
                    string printers = HttpContext.Request.Query["printers"].ToString();
                    if (!string.IsNullOrEmpty(printers) && printers.Length > 0)
                    {
                        printers = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(printers));
                    }

                    _MemoryCache.Set(sessionID + "printers", printers);
                }
                else if (prType == RequestType.ClientGetWcppVersion)
                {
                    //return the WCPP version for the specified sid if any
                    bool sidWcppVersion = (_MemoryCache.Get <string>(sessionID + "wcppInstalled") != null);

                    return(Ok(sidWcppVersion ? _MemoryCache.Get <string>(sessionID + "wcppInstalled") : ""));
                }
                else if (prType == RequestType.ClientGetInstalledPrinters)
                {
                    //return the installed printers for the specified sid if any
                    bool sidHasPrinters = (_MemoryCache.Get <string>(sessionID + "printers") != null);

                    return(Ok(sidHasPrinters ? _MemoryCache.Get <string>(sessionID + "printers") : ""));
                }
            }
            catch
            {
                return(BadRequest());
            }

            return(null);
        }
예제 #12
0
        public void ProcessRequest()
        {
            //get session ID
            string sessionID = (HttpContext.Request["sid"] != null ? HttpContext.Request["sid"] : null);

            //get Query String
            string queryString = HttpContext.Request.Url.Query;

            try
            {
                //Determine and get the Type of Request
                RequestType prType = WebClientPrint.GetProcessRequestType(queryString);

                if (prType == RequestType.GenPrintScript ||
                    prType == RequestType.GenWcppDetectScript)
                {
                    //Let WebClientPrint to generate the requested script
                    byte[] script = WebClientPrint.GenerateScript(Url.Action("ProcessRequest", "WebClientPrintAPI", null, HttpContext.Request.Url.Scheme), queryString);

                    HttpContext.Response.ContentType = "text/javascript";
                    HttpContext.Response.BinaryWrite(script);
                    HttpContext.Response.End();
                }
                else if (prType == RequestType.ClientSetWcppVersion)
                {
                    //This request is a ping from the WCPP utility
                    //so store the session ID indicating it has the WCPP installed
                    //also store the WCPP Version if available
                    string wcppVersion = HttpContext.Request["wcppVer"];
                    if (string.IsNullOrEmpty(wcppVersion))
                    {
                        wcppVersion = "1.0.0.0";
                    }

                    HttpContext.Application.Set(sessionID + "wcppInstalled", wcppVersion);
                }
                else if (prType == RequestType.ClientSetInstalledPrinters)
                {
                    //WCPP Utility is sending the installed printers at client side
                    //so store this info with the specified session ID
                    string printers = HttpContext.Request["printers"];
                    if (string.IsNullOrEmpty(printers) == false)
                    {
                        printers = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(printers));
                    }

                    HttpContext.Application.Set(sessionID + "printers", printers);
                }
                else if (prType == RequestType.ClientGetWcppVersion)
                {
                    //return the WCPP version for the specified sid if any
                    bool sidWcppVersion = (HttpContext.Application.Get(sessionID + "wcppInstalled") != null);

                    HttpContext.Response.ContentType = "text/plain";
                    HttpContext.Response.Write((sidWcppVersion ? HttpContext.Application.Get(sessionID + "wcppInstalled") : ""));
                    HttpContext.Response.End();
                }
                else if (prType == RequestType.ClientGetInstalledPrinters)
                {
                    //return the installed printers for the specified sid if any
                    bool sidHasPrinters = (HttpContext.Application.Get(sessionID + "printers") != null);

                    HttpContext.Response.ContentType = "text/plain";
                    HttpContext.Response.Write((sidHasPrinters ? HttpContext.Application.Get(sessionID + "printers") : ""));
                    HttpContext.Response.End();
                }
            }
            catch (Exception ex)
            {
                HttpContext.Response.StatusCode  = 500;
                HttpContext.Response.ContentType = "text/plain";
                HttpContext.Response.Write(ex.Message + " - StackTrace: " + ex.StackTrace);
                HttpContext.Response.End();
            }
        }
예제 #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Neodynamic.SDK.Web.WebClientPrint.CreateScript();


            //Is a Print Request?
            if (WebClientPrint.ProcessPrintJob(Request))
            {
                bool   useDefaultPrinter = (Request["useDefaultPrinter"] == "checked");
                string printerName       = Server.UrlDecode(Request["printerName"]);


                /*
                 * Response.Redirect("PrinterReciept.aspx?PolicyNr=" + model.MemeberNumber.ToString() +
                 * "&DatePaid=" + model.PaymentDate.ToString("YYYY-MMM-dd") +
                 * "&AmountPaid=" + model.Amount.ToString() +
                 * "&LateAmountPaid=" + model.LatePaymentPenalty.ToString() +
                 * "&PolicyHolder=" + model.FullNames +
                 * "&ReceivedBy=" + model.ReceivedBy +
                 * "&TimePrinted=" + DateTime.Now.ToString("YYYY-MMM-dd hh:mm") +
                 * "&Method=" + model.MethodOfPayment +
                 * "&Notes=" + model.Notes +
                 * "&Plan=" + model.PlanName);
                 *
                 *
                 *  Dim zlabel As New Com.SharpZebra.Example.BorderedLabel("   Branch Name...... " & vbTab & vbTab & ConfigurationManager.AppSettings("branch"), _
                 *                                 "   Receipt Nr....... " & vbTab & vbTab & intReceipt, _
                 * "   Policy Nr........ " & vbTab & vbTab & txtMemberNo.Text.ToUpper, _
                 * "   Date Paid........ " & vbTab & vbTab & dtDatepaid.ToString("dd-MMM-yyyy"), _
                 * "   Amount Paid...... " & vbTab & vbTab & FormatCurrency(txtAmount.Text, 2), _
                 * "   Policy Holder.... " & vbTab & vbTab & BL.pFullNames & "  " & BL.pSurname, _
                 * "   Received By...... " & vbTab & vbTab & txtRecievedBy.Text, _
                 * "   Time Printed..... " & vbTab & vbTab & DateTime.Now.ToString("dd-MMM-yyyy hh:mm"), _
                 * "   Method........... " & vbTab & vbTab & strMethod, _
                 * notes, _
                 * "   Underwriter...... " & vbTab & vbTab & BL.pAddress4, "123", strAppName, dtAdditionalAppSettings.Rows(0).Item("slogan"))
                 *
                 *
                 */


                //Create ESC/POS commands for sample receipt
                string ESC     = "0x1B";    //ESC byte in hex notation
                string NewLine = "0x0A";    //LF byte in hex notation

                string cmds = ESC + "@";    //Initializes the printer (ESC @)
                cmds += ESC + "!" + "0x38"; //Emphasized + Double-height + Double-width mode selected (ESC ! (8 + 16 + 32)) 56 dec => 38 hex
                cmds += "UnpluggIT";        //text to print
                cmds += NewLine + NewLine;
                cmds += ESC + "!" + "0x00"; //Character font A selected (ESC ! 0)
                cmds += "Policy Nr........  ";
                cmds += NewLine;
                cmds += "Date Paid........  ";
                cmds += NewLine + NewLine;
                cmds += "Amount Paid......  ";
                cmds += NewLine;
                cmds += "Policy Holder....  ";
                cmds += NewLine;
                cmds += "Time Printed.....  " + System.DateTime.Now.ToString("dd-MMM-yyyy");
                cmds += NewLine;
                cmds += "Method...........  ";
                cmds += NewLine;
                cmds += "Product Name.....  ";
                cmds += NewLine;
                cmds += System.DateTime.Now.ToString("dd-MMM-yyyy");

                cmds += "0x1D 0x56 <m>";

                //Create a ClientPrintJob and send it back to the client!
                ClientPrintJob cpj = new ClientPrintJob();
                //set ESC/POS commands to print...
                cpj.PrinterCommands = cmds;
                cpj.FormatHexValues = true;

                //set client printer...
                if (useDefaultPrinter || printerName == "null")
                {
                    cpj.ClientPrinter = new DefaultPrinter();
                }
                else
                {
                    cpj.ClientPrinter = new InstalledPrinter(printerName);
                }
                //send it...
                cpj.SendToClient(Response);
            }
        }
예제 #14
0
 public ActionResult Index()
 {
     ViewBag.WCPPDetectionScript = WebClientPrint.CreateWcppDetectionScript(Url.Action("ProcessRequest", "WebClientPrintAPI", null, HttpContext.Request.Url.Scheme),
                                                                            HttpContext.Session.SessionID);
     return(View());
 }