예제 #1
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                //Set license info for Web Editor and SDK
                ThermalLabelWebEditor.LicenseOwnerForEditor = "LICENSE OWNER FOR WEB EDITOR HERE";
                ThermalLabelWebEditor.LicenseKeyForEditor   = "LICENSE KEY FOR WEB EDITOR HERE";
                ThermalLabelWebEditor.LicenseOwnerForSDK    = "LICENSE OWNER FOR SDK HERE";
                ThermalLabelWebEditor.LicenseKeyForSDK      = "LICENSE KEY FOR SDK HERE";

                //Set physical path of this website root folder
                ThermalLabelWebEditor.WebsiteRootPhysicalPath = context.Server.MapPath("~/");


                //Pass data processing to ThermalLabelWebEditor
                ThermalLabelWebEditorHttpResponse httpResponse = ThermalLabelWebEditor.ProcessRequest(context.Request.HttpMethod == "POST" ? context.Request.Form : context.Request.QueryString);


                //set http response data
                context.Response.ContentType = httpResponse.ContentType;
                context.Response.Write(httpResponse.Content);
                if (string.IsNullOrEmpty(httpResponse.HeaderName) == false)
                {
                    context.Response.Headers.Add(httpResponse.HeaderName, httpResponse.HeaderValue);
                }
            }
            catch (Exception ex)
            {
                context.Response.StatusCode  = 400;
                context.Response.ContentType = "text/plain";
                context.Response.Write(ex.Message);
            }
        }
        public void ProcessRequest()
        {
            try
            {
                //Set license info for Web Editor and SDK
                ThermalLabelWebEditor.LicenseOwnerForEditor = "LICENSE OWNER FOR WEB EDITOR HERE";
                ThermalLabelWebEditor.LicenseKeyForEditor   = "LICENSE KEY FOR WEB EDITOR HERE";
                ThermalLabelWebEditor.LicenseOwnerForSDK    = "LICENSE OWNER FOR SDK HERE";
                ThermalLabelWebEditor.LicenseKeyForSDK      = "LICENSE KEY FOR SDK HERE";

                //Set physical path of this website root folder
                ThermalLabelWebEditor.WebsiteRootPhysicalPath = _env.WebRootPath;

                //Pass data processing to ThermalLabelWebEditor
                var httpRequestData = new System.Collections.Specialized.NameValueCollection();
                if (_ctx.Request.Method == "POST")
                {
                    foreach (var entry in _ctx.Request.Form)
                    {
                        httpRequestData.Add(entry.Key, entry.Value);
                    }
                }
                else
                {
                    foreach (var entry in _ctx.Request.Query)
                    {
                        httpRequestData.Add(entry.Key, entry.Value);
                    }
                }


                var httpResponse = ThermalLabelWebEditor.ProcessRequest(httpRequestData);


                //set http response data
                if (string.IsNullOrEmpty(httpResponse.HeaderName) == false)
                {
                    _ctx.Response.Headers.Add(httpResponse.HeaderName, httpResponse.HeaderValue);
                }
                _ctx.Response.ContentType = httpResponse.ContentType;
                _ctx.Response.Body.Write(Encoding.UTF8.GetBytes(httpResponse.Content)); //await _ctx.Response.WriteAsync(httpResponse.Content);
            }
            catch (Exception ex)
            {
                _ctx.Response.StatusCode  = 400;
                _ctx.Response.ContentType = "text/plain";
                _ctx.Response.Body.Write(Encoding.UTF8.GetBytes(ex.Message)); //await _ctx.Response.WriteAsync(ex.Message);
            }
        }
예제 #3
0
        public async Task ThermalLabelWebEditorProcessRequest(HttpContext context)
        {
            try
            {
                //Set license info for Web Editor and SDK
                ThermalLabelWebEditor.LicenseOwnerForEditor = "LICENSE OWNER FOR WEB EDITOR HERE";
                ThermalLabelWebEditor.LicenseKeyForEditor   = "LICENSE KEY FOR WEB EDITOR HERE";
                ThermalLabelWebEditor.LicenseOwnerForSDK    = "LICENSE OWNER FOR SDK HERE";
                ThermalLabelWebEditor.LicenseKeyForSDK      = "LICENSE KEY FOR SDK HERE";

                //Set physical path of this website root folder
                ThermalLabelWebEditor.WebsiteRootPhysicalPath = this.WebRootPath;


                //Pass data processing to ThermalLabelWebEditor
                var reqData = new NameValueCollection();
                foreach (var entry in context.Request.Form)
                {
                    reqData.Add(entry.Key, entry.Value.ToString());
                }

                ThermalLabelWebEditorHttpResponse httpResponse = ThermalLabelWebEditor.ProcessRequest(reqData);


                //set http response data
                context.Response.ContentType = httpResponse.ContentType;
                if (string.IsNullOrEmpty(httpResponse.HeaderName) == false)
                {
                    context.Response.Headers.Add(httpResponse.HeaderName, httpResponse.HeaderValue);
                }
                await context.Response.WriteAsync(httpResponse.Content);
            }
            catch (Exception ex)
            {
                context.Response.StatusCode  = 400;
                context.Response.ContentType = "text/plain";
                await context.Response.WriteAsync(ex.Message);
            }
        }