Exemple #1
0
        public ActionResult Save(string name, string value, SavedQueryInfo m)
        {
            var query    = CurrentDatabase.LoadQueryById2(m.QueryId);
            var previous = (from p in CurrentDatabase.Queries
                            where p.Owner == m.Owner
                            where p.Name == name
                            orderby p.LastRun
                            select p).FirstOrDefault();

            if (previous != null)
            {
                // copying over a previous query with same name and owner
                m.CopyPropertiesTo(previous);
                previous.Text = query.Text;
                if (previous.Name.Equal(Util.ScratchPad2))
                {
                    previous.Ispublic = false;
                }

                CurrentDatabase.SubmitChanges();
                return(Redirect("/Query/" + previous.QueryId));

                //                m.CopyPropertiesTo(previous);
                //                var pc = previous.ToClause();
                //                pc.Reset(CurrentDatabase);
                //                pc = Condition.Import(query.Text, name, newGuids: true, topguid: previous.QueryId);
                //                previous.Text = pc.ToXml();
                //                CurrentDatabase.SubmitChanges();
                //                return Redirect("/Query/" + previous.QueryId);
            }
            // saving to a new query
            m.CopyPropertiesTo(query);
            if (query.Name.Equal(Util.ScratchPad2))
            {
                query.Ispublic = false;
            }

            CurrentDatabase.SubmitChanges();
            return(Redirect("/Query/" + m.QueryId));
        }
Exemple #2
0
        public ActionResult Save(string name, string value, SavedQueryInfo m)
        {
            var query    = CurrentDatabase.LoadQueryById2(m.QueryId);
            var previous = (from p in CurrentDatabase.Queries
                            where p.Owner == m.Owner
                            where p.Name == name
                            orderby p.LastRun
                            select p).FirstOrDefault();

            if (previous != null)
            {
                // copying over a previous query with same name and owner
                m.CopyPropertiesTo(previous);
                if (previous.Name.Equal(Util.ScratchPad2))
                {
                    previous.Text     = query.Text;
                    previous.Ispublic = false;
                }
                else // saved search, not a scratchpad query
                {
                    // remove DisableOnScratchpad attributes from saved search
                    previous.Text = query.Text.Replace(" DisableOnScratchpad=\"True\"", "");
                }
                CurrentDatabase.SubmitChanges();
                return(Redirect("/Query/" + previous.QueryId));
            }
            // saving to a new query
            m.CopyPropertiesTo(query);
            if (query.Name.Equal(Util.ScratchPad2))
            {
                query.Ispublic = false;
            }

            CurrentDatabase.SubmitChanges();
            return(Redirect("/Query/" + m.QueryId));
        }