public virtual void OnException(ExceptionContext fc)
 {
     var model = new errors
     {
         stacktrace = fc.Exception.StackTrace,
         url = fc.HttpContext.Request.RawUrl,
         controller = fc.RouteData.GetRequiredString("controller"),
         source = fc.Exception.Source,
         errordate = DateTime.Now,
         message = fc.Exception.Message//,
         //InnExc = String.IsNullOrEmpty(fc.Exception.InnerException.ToString()) ? fc.Exception.InnerException.ToString() : ""
     };
     var message = "<html><head></head><body><h2>An error occured on " + _bs.GetKeyValue<string>("Mobile Chat App") + ".</h2>";
     message += "<strong>Message:</strong> <pre style=\"background-color:#FFFFEF\"> " + model.message + "</pre><br />";
     message += "<strong>Source:</strong> <pre style=\"background-color:#FFFFEF\">" + model.source + "</pre><br />";
     message += "<strong>Stacktrace:</strong><pre style=\"background-color:#FFFFEF\"> " + model.stacktrace + "</pre><br />";
     message += "<strong>Raw URL:</strong> <pre style=\"background-color:#FFFFEF\">" + model.url + "</pre></br />";
     message += "<strong>Inner Exception:</strong> <pre style=\"background-color:#FFFFEF\">" + model.InnExc + "</pre></br />";
     message += "<strong>Any Form values</strong>: <pre>" + fc.HttpContext.Request.Form + "</pre><br />";
     message += "</body></html>";
     fc.ExceptionHandled = true;
     fc.HttpContext.Response.Clear();
     fc.HttpContext.Response.StatusCode = 500;
     fc.HttpContext.Response.TrySkipIisCustomErrors = true;
     _bs.SendErrorMail(message);
     fc.ExceptionHandled = true;
     //var res = new ViewResult { ViewName = "error" };
     //fc.Result = res;
     fc.HttpContext.Response.Redirect("/ErrorPage");
     //fc.HttpContext.Response.RedirectToRoute("error",new{controller="Home",action="ErrorPage"});
 }
示例#2
0
 private void error_handle(errors err) {
     is_paused = true;
     switch (err) {
         case errors.DIVBY0:
             inputBox.Text = "Không thể chia cho 0";
             break;
     };
 }
示例#3
0
        /// <summary>
        /// 返回失败模型
        /// </summary>
        /// <param name="message">传入的输入源</param>
        /// <returns></returns>
        public static HttpResponseMessage ErrorModel(string VerlCode)
        {
            errors model = new errors()
            {
                code = "200", datas = "null", message = "message", sign = VerlCode
            };

            return(new HttpResponseMessage()
            {
                Content = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json")
            });
        }
示例#4
0
        /// <summary>
        /// 返回失败模型
        /// </summary>
        /// <param name="message">传入的输入源</param>
        /// <returns></returns>
        public static HttpResponseMessage ErrorModel(string sign, string message)
        {
            errors model = new errors()
            {
                code = "500", datas = null, message = message, sign = sign
            };

            return(new HttpResponseMessage()
            {
                Content = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json")
            });
        }
示例#5
0
 CollectErrors(errors, keyType);
        protected void btnCalc_Click(object sender, EventArgs e)
        {
            // clear error messages
            dialog.InnerHtml = "";


            // FORM ITEMS ================================================================
            //file info:
            fileName.InnerHtml = HttpUtility.HtmlEncode(Context.Request.Form["cFileName"]);
            string fPath    = Context.Server.MapPath(@"imgLibrary");
            string fullPath = fPath + @"\" + Context.Request.Form["cFileName"];
            string fName    = Context.Request.Form["cFileName"];

            // user selected options:
            int materialId = Convert.ToInt32(svgMaterial.SelectedValue);
            int quantity   = Convert.ToInt32(svgQuantity.Text);
            int mmId       = Convert.ToInt32(svgMm.SelectedValue);

            // END FORM ==================================================================


            //get the template size id from the uloaded file
            templateSize myTemp         = new templateSize();
            int          templateSizeId = myTemp.detectTemplate(fullPath);

            if (templateSizeId == 0)
            {
                // is not a valid template - show error
                errors errType = new errors();
                errType.errTemplate();
                openError(errType.currentError + errType.helpUrl);
                errType = null;
                return;
            }

            //show template size on screen
            lblSvgTemplateSize.Text = "Template size " + myTemp.txtTemplateSize;
            myTemp = null;


            //load the svg doc into the svg library
            SvgDoc myDoc = new SvgDoc();

            myDoc.LoadFromFile(fullPath);


            SVGLib.SvgElement elYourDesigns = myDoc.GetSvgElement("Your_Designs");
            if (elYourDesigns.getChild() != null)
            {
                AddFromSvg2(elYourDesigns);
            }
            else
            {
                //check inkscape added group labled "Your Designs"
                // get the id by searching for the label then us the ID with getSvgElement
                inkscapeGroupFix gf      = new inkscapeGroupFix();
                string           groupId = gf.getgroupId("Your Designs", fullPath, "Your Designs");
                if (groupId == "")
                {
                    //throw error, no design detected
                    errors errType = new errors();
                    errType.errDesign();
                    openError(errType.currentError + errType.helpUrl);
                    errType = null;
                    return;
                }
                else
                {
                    elYourDesigns = myDoc.GetSvgElement(groupId);
                    AddFromSvg2(elYourDesigns);
                }

                gf = null;
            }

            myDoc = null;

            List <shapePrice> priceArray = allShapes;
            zapQuote          newQuote   = new zapQuote(materialId, templateSizeId, mmId);

            //check if error returned from AddFromSvg
            if (isValidSvgDesign == false)
            {
                //show error and halt progress
                openError(svgError);
                return;
            }


            foreach (shapePrice i in priceArray)
            {
                newQuote.appendShapeData(i.length, i.area, i.zapType, i.height, i.xpos, i.ypos);
                // raster line area from objects
                rasterExtraArea += i.rasterArea;
            }


            //calculate extra raster area from coordinates
            if (rasterPoints.Count > 0)
            {
                //find 4 outer points and calculate area as a rectangle

                double lX = rasterPoints.Min(c => c.X);
                double rX = rasterPoints.Max(c => c.X);
                double tY = rasterPoints.Min(c => c.Y);
                double bY = rasterPoints.Max(c => c.Y);

                rasterExtraArea = Common.rasterAreaFromPoints(lX, rX, tY, bY);
                extraHeight     = Common.rasterHeight(tY, bY);
            }



            newQuote.calcTotalTime(materialId, templateSizeId, mmId, rasterExtraArea, extraHeight);



            materialPrice mPrice = new materialPrice();

            mPrice.getMaterialPrices(materialId, templateSizeId, mmId);


            //cut lines price
            decimal cutPrice = Convert.ToDecimal(newQuote.cutTime * mPrice.costCutSec);
            // engrave lines
            decimal engravePrice = Convert.ToDecimal(newQuote.engraveTime * mPrice.costVectorSec);
            // raster engrave
            //decimal rasterPrice = Convert.ToDecimal((newQuote.totalAreaFill / 100) * mPrice.costRasterPerSqCm);

            decimal rasterPrice = Convert.ToDecimal(newQuote.fillTime * mPrice.costRasterPerSec);

            decimal totalLaserPrice = cutPrice + engravePrice + rasterPrice;

            decimal materialCost = Convert.ToDecimal(mPrice.pricePerUnit);

            decimal unitPrice = totalLaserPrice + materialCost;

            decimal totalPrice = unitPrice * quantity;


            //populate labels / session values

            StringBuilder quoteInfo = new StringBuilder();

            quoteInfo.Append("<ul>");
            quoteInfo.Append("<li><b>File Cost</b>");
            quoteInfo.Append("<div class='formInfo'>- " + fName + " = <span class='formBlue'>" + string.Format(CultureInfo.CreateSpecificCulture("en-GB"), "{0:C}", totalLaserPrice) + "</span></div>");
            quoteInfo.Append("<div class='formInfo'>- Quantity = <span class='formBlue'>x" + quantity + "</span></div>");
            quoteInfo.Append("<div class='formBlue'>Total File Cost = " + string.Format(CultureInfo.CreateSpecificCulture("en-GB"), "{0:C}", totalLaserPrice * quantity) + "</div>");
            quoteInfo.Append("</li>");
            quoteInfo.Append("<li><b>Material Cost</b>");
            quoteInfo.Append("<div class='formInfo'>- " + svgMaterial.SelectedItem.Text + "</div>");
            quoteInfo.Append("<div class='formInfo'>- " + svgMm.SelectedItem.Text + "</div>");
            quoteInfo.Append("<div class='formInfo'>- " + materialColour.SelectedItem.Text + "</div>");
            quoteInfo.Append("<div class='formInfo'>- = <span class='formBlue'>" + string.Format(CultureInfo.CreateSpecificCulture("en-GB"), "{0:C}", materialCost) + "</span></div>");
            quoteInfo.Append("<div class='formInfo'>- Quantity = <span class='formBlue'>x" + quantity + "</span></div>");
            quoteInfo.Append("<div class='formInfo'>- Total material cost= <span class='formBlue'>" + string.Format(CultureInfo.CreateSpecificCulture("en-GB"), "{0:C}", materialCost * quantity) + "</span></div>");
            quoteInfo.Append("</li>");
            quoteInfo.Append("<li><b>Total Cost</b> <span class='formBlue'>" + string.Format(CultureInfo.CreateSpecificCulture("en-GB"), "{0:C}", totalPrice) + "</span>");
            quoteInfo.Append("</li>");
            quoteInfo.Append("</ul>");

            divQuote.InnerHtml = quoteInfo.ToString();

            quoteInfo = null;



            StringBuilder debugInfo = new StringBuilder();


            debugInfo.Append("<p>Cut price:" + cutPrice + "</p>");
            debugInfo.Append("<p>Cut time:" + newQuote.cutTime + "</p>");
            debugInfo.Append("<p>Cut length mm:" + newQuote.totalCutLength + "</p>");
            debugInfo.Append("<p>Cut cost per sec:" + mPrice.costCutSec + "</p>");
            debugInfo.Append("<p>Number of cuts:" + newQuote.cutCount + "</p>");
            debugInfo.Append("<p>Cut area:" + newQuote.totalCutArea + "</p>");

            debugInfo.Append("<p>Vector engrave price:" + engravePrice + "</p>");
            debugInfo.Append("<p>Vector engrave time:" + newQuote.engraveTime + "</p>");
            debugInfo.Append("<p>Vector engrave cost per sec:" + mPrice.costVectorSec + "</p>");

            debugInfo.Append("<p>Vector engrave light length:" + newQuote.totalLightEngrave + "</p>");
            debugInfo.Append("<p>Vector engrave med length:" + newQuote.totalMedEngrave + "</p>");
            debugInfo.Append("<p>Vector engrave heavy length:" + newQuote.totalHeavyEngrave + "</p>");


            debugInfo.Append("<p>Raster price:" + rasterPrice + "</p>");
            debugInfo.Append("<p>Raster time:" + newQuote.fillTime + "</p>");
            debugInfo.Append("<p>Raster cost per sec:" + mPrice.costRasterPerSec + "</p>");
            debugInfo.Append("<p>Raster area:" + newQuote.rasterArea + "</p>");



            litErr.Text = debugInfo.ToString();

            debugInfo = null;
        }