示例#1
0
        public ActionResult EditExportType(EditParaVmAlt p)
        {
            var u = db.mc_reports.Find(p.Id);

            //List<string> errors = new List<string>();
            try
            {
                u.export_option1 = p.Value;
                u.export_option2 = p.Value2;
                if (string.IsNullOrWhiteSpace(u.export_option1))
                {
                    u.export_option1 = "";
                }
                if (string.IsNullOrWhiteSpace(u.export_option2))
                {
                    u.export_option2 = "";
                }
                if (string.IsNullOrWhiteSpace(u.export_option1) && string.IsNullOrWhiteSpace(u.export_option2))
                {
                    throw new Exception("At least one export option must be selected!");
                }
                db.SaveChanges();
                return(Json(new { success = true, Message = "Updated export options values." + p.Value + " " + p.Value2, id = u.id }));
            }
            catch (Exception ex)
            {
                //errors.Add(ex.Message);
                return(Json(new { success = false, Message = "Failed to update export options values. " + ex.Message, id = p.Id }));
            }
            //return PartialView(db.mc_scheduled_job_params.Find(p.id));
        }
        public ActionResult GetImagesFromPDF(EditParaVmAlt p)
        {
            var id     = p.Value;
            var h      = new pdfHelper();
            var images = h.GetImages(id);

            h = null;
            List <PDFImageVM> vmImages = new List <PDFImageVM>();

            foreach (var i in images)
            {
                vmImages.Add(
                    new PDFImageVM()
                {
                    CalcSize  = i.CalcSize.ToString(),
                    width     = i.width,
                    height    = i.height,
                    imagePath = i.imageRelativePath()
                });
            }

            JObject json = new JObject();

            json["jsonList"] = JToken.FromObject(vmImages);

            return(new JSONNetResult(json));
        }
        public ActionResult PostDeleteOutputAction(EditParaVmAlt p)
        {
            var a = db.mc_output_actions.Find(p.Id);

            if (a != null)
            {
                db.mc_output_actions.Remove(a);
                db.SaveChanges();
            }
            else
            {
                return
                    (Json(
                         new
                {
                    success = true,
                    Message = "Could not delete output action for: " + p.Id,
                    id = p.Id
                }));
            }
            return
                (Json(
                     new
            {
                success = true,
                Message = "Deleted Output Action: " + p.Id,
                id = p.Id
            }));
        }
示例#4
0
        public ActionResult AddEmail(EditParaVmAlt p)
        {
            var u = db.mc_reports.Find(p.Id);
            var f = p.Value.ToLower();

            //List<string> errors = new List<string>();
            try
            {
                var r = new RegexUtilities();
                if (!r.IsValidEmail(f))
                {
                    throw new Exception("The email address " + f + " is not valid!");
                }
                if (string.IsNullOrWhiteSpace(p.Value))
                {
                    throw new Exception("There is no email to update!");
                }
                //make sure it is not already there
                if (u.mc_email_notifications.Any(x => x.email == f && x.deleted == false))
                {
                    throw new Exception("Email has already been added!");
                }
                else if (u.mc_email_notifications.Any(x => x.email == f))
                {
                    //email was previously deleted just reinstate
                    var uEmail = db.mc_email_notifications.First(x => x.email == f && x.report_id == u.id);
                    uEmail.deleted = false;
                }
                else
                {
                    //no email found create a new one
                    var e = new mc_email_notifications()
                    {
                        date_changed = DateTime.Now,
                        date_created = DateTime.Now,
                        deleted      = false,
                        email        = f,
                        isInternal   = false
                    };
                    u.mc_email_notifications.Add(e);
                }

                db.SaveChanges();

                return(Json(new { success = true, Message = "Updated email values:" + p.Value, id = u.id }));
            }
            catch (Exception ex)
            {
                //errors.Add(ex.Message);
                return(Json(new { success = false, Message = "Failed to update email. " + ex.Message, id = p.Id }));
            }
            //return PartialView(db.mc_scheduled_job_params.Find(p.id));
        }
示例#5
0
        public ActionResult RemoveEmail(EditParaVmAlt p)
        {
            var id      = p.Id;
            var emailId = int.Parse(p.Value);
            var u       = db.mc_email_notifications.Find(emailId);

            //List<string> errors = new List<string>();
            try
            {
                if (u.report_id != id)
                {
                    throw new Exception("Cannot delete an email notification of another report!");
                }
                u.deleted = true;
                db.SaveChanges();
                return(Json(new { success = true, Message = "Removed email: " + u.email, id = u.report_id }));
            }
            catch (Exception ex)
            {
                //errors.Add(ex.Message);
                return(Json(new { success = false, Message = "Failed to delete email." + ex.Message, id = p.Id }));
            }
            //return PartialView(db.mc_scheduled_job_params.Find(p.id));
        }