コード例 #1
0
 public ContentResult AddContact()
 {
     var m = new QueryModel();
     m.LoadScratchPad();
     var cid = CmsData.Contact.AddContact(m.QueryId.Value);
     return Content("/Contact.aspx?id=" + cid);
 }
コード例 #2
0
 public ActionResult AddTasks()
 {
     var m = new QueryModel();
     m.LoadScratchPad();
     var c = new ContentResult();
     c.Content = Task.AddTasks(m.QueryId.Value).ToString();
     return c;
 }
コード例 #3
0
 public ActionResult CopyAsNew(int id)
 {
     var m = new QueryModel { SelectedId = id };
     m.LoadScratchPad();
     m.CopyAsNew();
     var c = new ContentResult();
     c.Content = m.QueryId.ToString();
     return c;
 }
コード例 #4
0
 public ActionResult AddToGroup()
 {
     var m = new QueryModel();
     UpdateModel<IQBUpdateable>(m);
     m.LoadScratchPad();
     if (Validate(m))
         m.AddConditionToGroup();
     return PartialView("TryConditions", m);
 }
コード例 #5
0
        private bool Validate(QueryModel m)
        {
            m.SetVisibility();
            DateTime dt = DateTime.MinValue;
            if (m.StartDateVisible)
                if (!DateTime.TryParse(m.StartDate, out dt) || dt.Year <= 1900 || dt.Year >= 2200)
                    m.Errors.Add("StartDate", "invalid");
            if (m.EndDateVisible && m.EndDate.HasValue())
                if (!DateTime.TryParse(m.EndDate, out dt) || dt.Year <= 1900 || dt.Year >= 2200)
                    m.Errors.Add("EndDate", "invalid");
            int i = 0;
            if (m.DaysVisible && !int.TryParse(m.Days, out i))
                m.Errors.Add("Days", "must be integer");
            if (i > 10000)
                m.Errors.Add("Days", "days > 1000");
            if (m.AgeVisible && !int.TryParse(m.Age, out i))
                m.Errors.Add("Age", "must be integer");

            if (m.TagsVisible && string.Join(",", m.Tags).Length > 500)
                m.Errors.Add("tagvalues", "too many tags selected");

            if (m.CodesVisible && m.CodeValues.Length == 0)
                m.Errors.Add("CodeValues", "must select item(s)");

            if (m.NumberVisible && !m.NumberValue.HasValue())
                m.Errors.Add("NumberValue", "must have a number value");
            else
            {
                float f;
                if (m.NumberVisible && m.NumberValue.HasValue())
                    if (!float.TryParse(m.NumberValue, out f))
                        m.Errors.Add("NumberValue", "must have a valid number value (no decoration)");
            }

            if (m.DateVisible && !m.Comparison.EndsWith("Equal"))
                if (!DateTime.TryParse(m.DateValue, out dt) || dt.Year <= 1900 || dt.Year >= 2200)
                    m.Errors.Add("DateValue", "need valid date");

            if (m.Comparison == "Contains")
                if (!m.TextValue.HasValue())
                    m.Errors.Add("TextValue", "cannot be empty");

            return m.Errors.Count == 0;
        }
コード例 #6
0
 public ContentResult UnTagAll()
 {
     var m = new QueryModel();
     m.LoadScratchPad();
     m.UnTagAll();
     var c = new ContentResult();
     c.Content = "Add";
     return c;
 }
コード例 #7
0
 public ContentResult TagAll(string tagname, bool? cleartagfirst)
 {
     if (!tagname.HasValue())
         return Content("error: no tag name");
     var m = new QueryModel();
     m.LoadScratchPad();
     if (Util2.CurrentTagName == tagname && !(cleartagfirst ?? false))
     {
         m.TagAll();
         return Content("Remove");
     }
     var tag = DbUtil.Db.FetchOrCreateTag(tagname, Util.UserPeopleId, DbUtil.TagTypeId_Personal);
     if (cleartagfirst ?? false)
         DbUtil.Db.ClearTag(tag);
     m.TagAll(tag);
     Util2.CurrentTag = tagname;
     DbUtil.Db.TagCurrent();
     return Content("Manage");
 }
コード例 #8
0
 public JsonResult GetCodes(string Comparison, string ConditionName)
 {
     var m = new QueryModel { Comparison = Comparison, ConditionName = ConditionName };
     m.SetCodes();
     return Json(new
     {
         CodesVisible = m.CodesVisible,
         CodeVisible = m.CodeVisible,
         CodeData = m.CodeData,
         SelectMultiple = m.SelectMultiple
     });
 }
コード例 #9
0
 public JsonResult SavedQueries()
 {
     var m = new QueryModel();
     return Json(m.SavedQueries()); ;
 }
コード例 #10
0
 public ActionResult Results()
 {
     var cb = new SqlConnectionStringBuilder(Util.ConnectionString);
     cb.ApplicationName = "qb";
     DbUtil.Db = new CMSDataContext(cb.ConnectionString);
     var m = new QueryModel();
     try
     {
         UpdateModel<IQBUpdateable>(m);
     }
     catch (Exception ex)
     {
         return Content("Something went wrong<br><p>" + ex.Message + "</p>");
     }
     m.LoadScratchPad();
     var starttime = DateTime.Now;
     try
     {
         m.PopulateResults();
     }
     catch (Exception ex)
     {
         var ex2 = new Exception("SearchBuilder error:\n" + m.GetTopClause().ToXml(), ex);
         ErrorLog errorLog = ErrorLog.GetDefault(null);
         errorLog.Log(new Error(ex2));
         return Content("Something went wrong<br><p>" + ex.Message + "</p>");
     }
     DbUtil.LogActivity("QB Results ({0:N1}, {1})".Fmt(DateTime.Now.Subtract(starttime).TotalSeconds, m.QueryId));
     return View(m);
 }
コード例 #11
0
 public JsonResult Remove()
 {
     var m = new QueryModel();
     UpdateModel<IQBUpdateable>(m);
     m.LoadScratchPad();
     m.DeleteCondition();
     return Json(m);
 }
コード例 #12
0
 public ActionResult Main(int? id, int? run)
 {
     if (DbUtil.Db.UserPreference("newlook3", "false").ToBool()
         && DbUtil.Db.UserPreference("advancedsearch", "false").ToBool())
         return Redirect(Request.RawUrl.ToLower().Replace("querybuilder", "search/advanced"));
     ViewData["Title"] = "QueryBuilder";
     ViewData["OnQueryBuilder"] = "true";
     ViewData["TagAction"] = "/QueryBuilder/TagAll/";
     ViewData["UnTagAction"] = "/QueryBuilder/UnTagAll/";
     ViewData["AddContact"] = "/QueryBuilder/AddContact/";
     ViewData["AddTasks"] = "/QueryBuilder/AddTasks/";
     var m = new QueryModel { QueryId = id };
     DbUtil.LogActivity("QueryBuilder");
     if (run.HasValue)
         m.ShowResults = true;
     m.LoadScratchPad();
     ViewData["queryid"] = m.QueryId;
     ViewBag.AutoRun = (bool?)(TempData["AutoRun"]) == true;
     return View(m);
 }
コード例 #13
0
 public ActionResult InsGroupAbove(int id)
 {
     var m = new QueryModel { SelectedId = id };
     m.LoadScratchPad();
     m.InsertGroupAbove();
     var c = new ContentResult();
     c.Content = m.QueryId.ToString();
     return c;
 }
コード例 #14
0
 public JsonResult GetOrganizations(int id)
 {
     var m = new QueryModel();
     return Json(m.Organizations(id));
 }
コード例 #15
0
 public JsonResult GetDivisions(int id)
 {
     var m = new QueryModel();
     return Json(new { Divisions = m.Divisions(id), Organizations = m.Organizations(0) });
 }
コード例 #16
0
 public ActionResult SaveQuery()
 {
     var m = new QueryModel();
     UpdateModel(m);
     m.LoadScratchPad();
     var ret = m.SaveQuery();
     if (ret.HasValue())
         return Content(ret);
     return Content(m.Description);
 }
コード例 #17
0
 public ActionResult Conditions()
 {
     var m = new QueryModel();
     return View(m);
 }
コード例 #18
0
        public JsonResult SelectCondition(int id, string ConditionName)
        {
            var m = new QueryModel { ConditionName = ConditionName, SelectedId = id };
            m.LoadScratchPad();
            m.SetVisibility();

            m.TextValue = "";
            m.Comparison = "";
            m.IntegerValue = "";
            m.DateValue = "";
            m.CodeValue = "";
            m.CodeValues = new string[0];
            m.Days = "";
            m.Age = "";
            m.Program = 0;
            m.Quarters = "";
            m.StartDate = "";
            m.EndDate = "";

            return Json(m);
        }
コード例 #19
0
 public JsonResult EditCondition(int id)
 {
     var m = new QueryModel { SelectedId = id };
     m.LoadScratchPad();
     m.EditCondition();
     return Json(m);
 }
コード例 #20
0
 public ActionResult Export()
 {
     var m = new QueryModel();
     m.LoadScratchPad();
     return new QBExportResult(m.QueryId.Value);
 }