Esempio n. 1
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("search/advanced", "querybuilder")));
            }
            ViewData["Title"]          = "QueryBuilder";
            ViewData["OnQueryBuilder"] = "true";
            ViewData["TagAction"]      = "/Search/Advanced/TagAll/";
            ViewData["UnTagAction"]    = "/Search/Advanced/UnTagAll/";
            ViewData["AddContact"]     = "/Search/Advanced/AddContact/";
            ViewData["AddTasks"]       = "/Search/Advanced/AddTasks/";
            var m = new AdvancedModel {
                QueryId = id
            };

            DbUtil.LogActivity("QueryBuilder");
            if (run.HasValue)
            {
                m.ShowResults = true;
            }
            m.LoadScratchPad();
            ViewData["queryid"] = m.QueryId;
            ViewBag.AutoRun     = (bool?)(TempData["AutoRun"]) == true;
            var newsearchid = (int?)TempData["newsearch"];

            if (newsearchid.HasValue)
            {
                ViewBag.NewSearch = true;
                m.SelectedId      = newsearchid.Value;
            }
            return(View(m));
        }
Esempio n. 2
0
        public ActionResult SelectCondition(int id, string conditionName)
        {
            var m = new AdvancedModel {
                SelectedId = id
            };

            m.LoadScratchPad();
            m.ConditionName = conditionName;
            m.SetVisibility();
            m.TextValue    = "";
            m.IntegerValue = "";
            m.DateValue    = "";
            m.CodeValue    = "";
            m.CodeValues   = new string[0];
            m.Days         = "";
            m.Age          = "";
            m.Program      = 0;
            m.Quarters     = "";
            m.StartDate    = "";
            m.EndDate      = "";
            m.Comparison   = "Equal";
            m.UpdateCondition();
            m.SelectedId = id;
            return(View("Conditions", m));
        }
Esempio n. 3
0
        public ActionResult Export()
        {
            var m = new AdvancedModel();

            m.LoadScratchPad();
            return(new QBExportResult(m.QueryId.Value));
        }
Esempio n. 4
0
        public ActionResult Reload()
        {
            var m = new AdvancedModel();

            m.LoadScratchPad();
            return(View("Conditions", m));
        }
Esempio n. 5
0
        public ContentResult AddContact()
        {
            var m = new AdvancedModel();

            m.LoadScratchPad();
            var cid = CmsData.Contact.AddContact(m.QueryId.Value);

            return(Content("/Contact.aspx?id=" + cid));
        }
Esempio n. 6
0
        public ActionResult DuplicateCondition(int id)
        {
            var m = new AdvancedModel();

            m.LoadScratchPad();
            m.EditCondition();
            m.CopyCurrentCondition(id);
            return(View("Conditions", m));
        }
Esempio n. 7
0
        public ActionResult AddTasks()
        {
            var m = new AdvancedModel();

            m.LoadScratchPad();
            var c = new ContentResult();

            c.Content = Task.AddTasks(m.QueryId.Value).ToString();
            return(c);
        }
Esempio n. 8
0
 public ActionResult SaveCondition(AdvancedModel m)
 {
     m.LoadScratchPad();
     if (m.Validate(ModelState))
     {
         m.UpdateCondition();
         DbUtil.Db.SubmitChanges();
     }
     return(View("Conditions", m));
 }
Esempio n. 9
0
        public ActionResult EditCondition(int id)
        {
            var m = new AdvancedModel {
                SelectedId = id
            };

            m.LoadScratchPad();
            m.EditCondition();
            return(View("Conditions", m));
        }
Esempio n. 10
0
        public ActionResult RemoveCondition(int id)
        {
            var m = new AdvancedModel {
                SelectedId = id
            };

            m.LoadScratchPad();
            m.DeleteCondition();
            m.SelectedId = null;
            return(View("Conditions", m));
        }
Esempio n. 11
0
        public ContentResult UnTagAll()
        {
            var m = new AdvancedModel();

            m.LoadScratchPad();
            m.UnTagAll();
            var c = new ContentResult();

            c.Content = "Add";
            return(c);
        }
Esempio n. 12
0
        public ActionResult SaveQuery()
        {
            var m = new AdvancedModel();

            UpdateModel(m);
            m.LoadScratchPad();
            m.SaveQuery();
            var c = new ContentResult();

            c.Content = m.Description;
            return(c);
        }
Esempio n. 13
0
        public ActionResult InsGroupAbove(int id)
        {
            var m = new AdvancedModel {
                SelectedId = id
            };

            m.LoadScratchPad();
            m.InsertGroupAbove();
            var c = new ContentResult();

            c.Content = m.QueryId.ToString();
            return(c);
        }
Esempio n. 14
0
        public ActionResult CopyAsNew(int id)
        {
            var m = new AdvancedModel {
                SelectedId = id
            };

            m.LoadScratchPad();
            m.CopyAsNew();
            var c = new ContentResult();

            c.Content = m.QueryId.ToString();
            return(c);
        }
Esempio n. 15
0
        public ActionResult AddNewCondition(int id)
        {
            var m = new AdvancedModel {
                SelectedId = id
            };

            m.LoadScratchPad();
            m.EditCondition();
            if (m.ConditionName == "Group")
            {
                m.AddConditionToGroup();
            }
            else
            {
                m.AddNewConditionAfterCurrent(id);
            }
            return(View("Conditions", m));
        }
Esempio n. 16
0
        public ContentResult TagAll(string tagname, bool cleartagfirst)
        {
            var m = new AdvancedModel();

            m.LoadScratchPad();
            if (Util2.CurrentTagName == tagname && !cleartagfirst)
            {
                m.TagAll();
                return(Content("Remove"));
            }
            var tag = DbUtil.Db.FetchOrCreateTag(tagname, Util.UserPeopleId, DbUtil.TagTypeId_Personal);

            if (cleartagfirst)
            {
                DbUtil.Db.ClearTag(tag);
            }
            m.TagAll(tag);
            Util2.CurrentTag = tagname;
            DbUtil.Db.TagCurrent();
            return(Content("Manage"));
        }
Esempio n. 17
0
        public ActionResult Results()
        {
            var cb = new SqlConnectionStringBuilder(Util.ConnectionString);

            cb.ApplicationName = "qb";
            DbUtil.Db          = new CMSDataContext(cb.ConnectionString);
            var m = new AdvancedModel();

            try
            {
                UpdateModel(m);
            }
            catch (Exception ex)
            {
                return(Content("Something went wrong<br><p>" + ex.Message + "</p>"));
            }
            m.LoadScratchPad();

            var starttime = DateTime.Now;

            m.PopulateResults();
            DbUtil.LogActivity("QB Results ({0:N1}, {1})".Fmt(DateTime.Now.Subtract(starttime).TotalSeconds, m.QueryId));
            return(View(m));
        }