Ejemplo n.º 1
0
        public void Run(IHostServer server, WebContext context, string callbackEndPoint, CancellationToken cancel)
        {
            if (null != Override)
            {
                if (Override(this, server, context))
                {
                    return;
                }
            }

            var error = GetError?.Invoke(this, server, context) ?? Error;

            if (null != error)
            {
                throw error;
            }

            var status  = GetStatus?.Invoke(this, server, context) ?? Status;
            var mime    = GetMime?.Invoke(this, server, context) ?? Mime;
            var content = GetContent?.Invoke(this, server, context) ?? Content;
            var timeout = GetTimeout?.Invoke(this, server, context) ?? Timeout;

            if (0 < timeout)
            {
                Thread.Sleep(timeout);
            }

            context.Finish(content, mime, status);
        }
Ejemplo n.º 2
0
        protected void Unnamed_ServerClick(object sender, EventArgs e)
        {
            string message = "success";
            bool   v       = UploadImage(out message);

            if (!v)
            {
                GetError.Invoke(this, EventArgs.Empty);
            }
        }
        public ActionResult AddStudentInfo(StudentModel studentModel)
        {
            if (ModelState.IsValid)
            {
                ErrorEnums insertCheck = StudentServiceTest.InsertStudent(studentModel);
                string     errorString = GetError.GetErrorFromEnum(insertCheck);
                if (errorString.Equals("Added Successfully"))
                {
                    TempData["toastError"] = errorString;
                    return(RedirectToAction("StudentInfo"));
                }
                else
                {
                    TempData["toastError"] = errorString;
                    return(this.View());
                }

                //if (insertCheck == ErrorEnums.Successful)
                //{
                //    TempData["toast"] = "Student Added successfully";
                //    return RedirectToAction("StudentInfo");
                //}
                //else if(insertCheck == ErrorEnums.EmailAddress)
                //{
                //    ModelState.AddModelError("AddFailedError", "Error in adding the student. The Email Address should be unique");
                //    return this.View();
                //}
                //else if(insertCheck == ErrorEnums.PhoneNumber)
                //{
                //    ModelState.AddModelError("AddFailedError", "Error in adding the student. The Contact Number should be unique");
                //    return this.View();
                //}
                //else if(insertCheck == ErrorEnums.Code)
                //{
                //    ModelState.AddModelError("AddFailedError", "Error in adding the student. The Student Code should be unique");
                //    return this.View();
                //}
                //else
                //{
                //    ModelState.AddModelError("AddFailedError", "Error in adding the student. The Student Code, Email Address and the Contact Number should be unique");
                //    return this.View();
                //}
            }
            else
            {
                return(this.View());
            }
        }
        protected void Application_Error()
        {
            Exception ex = Server.GetLastError();

            if (ex != null)
            {
                //Server.ClearError();

                string detailError = GetError.getHtmlError(HttpContext.Current.Request, HttpContext.Current.Session, ex);

                if (Convert.ToBoolean(WebConfigurationManager.AppSettings["SendErrorMail"]))
                {
                    // INVIO EMAIL DI ERRORE
                    Mail.Send(Mail.getMailMessage(new String[] { ConfigurationManager.AppSettings["MailTo"], ConfigurationManager.AppSettings["MailToCC"] },
                                                  "Avviso da Portale VA", detailError));
                }


                UrlHelper url         = new UrlHelper(HttpContext.Current.Request.RequestContext);
                var       redirectUrl = url.RouteUrl("Error", new { Controller = "Error", Action = "NotFound" });
                HttpContext.Current.Response.Redirect(redirectUrl);
            }
        }