Exemple #1
0
        /// <summary>
        /// Add a query and it's result list to session query history
        /// </summary>
        /// <param name="query"></param>
        /// <param name="cnList"></param>

        public static void AddToHistoryList(
            Query query,
            CidList cnList)
        {
            HistoryItem hi = new HistoryItem();

            hi.DateTime = DateTime.Now;

            Query  q2      = query.Clone();                                   // clone for possible name change
            string name    = q2.UserObject.Name;
            string pattern = @" - [0-9]+\:[0-9]+\:[0-9]+ (AM|PM)$";           // capture long time

            name = Regex.Replace(name, pattern, "", RegexOptions.IgnoreCase); // and remove if present

            q2.UserObject.Name = name;

            hi.QueryName     = q2.UserObject.Name;
            hi.QueryFileName = TempFile.GetTempFileName(ClientDirs.TempDir, ".qry");
            StreamWriter sw        = new StreamWriter(hi.QueryFileName);
            string       queryText = q2.Serialize();

            sw.Write(queryText);
            sw.Close();

            hi.ListFileName = TempFile.GetTempFileName(ClientDirs.TempDir, ".lst");
            sw = new StreamWriter(hi.ListFileName);
            string listText = cnList.ToMultilineString();

            sw.Write(listText);
            sw.Close();
            hi.ListCount = cnList.Count;

            SS.I.History.Add(hi);
        }
Exemple #2
0
        /// <summary>
        /// Write a compound number list
        /// </summary>
        /// <returns></returns>

        public static int Write(
            CidList list,
            UserObject uo)
        {
            string fileName;

            string content = list.ToMultilineString();

            uo.Type  = UserObjectType.CnList;
            uo.Owner = Security.UserName;             // assume current user

            if (!uo.HasDefinedParentFolder &&
                (Lex.Eq(uo.Name, "Current") || Lex.Eq(uo.Name, "Previous") || Lex.Eq(uo.Name, "Criteria List")))
            {
                uo.ParentFolder     = UserObject.TempFolderName;
                uo.ParentFolderType = FolderTypeEnum.None;
                uo.Owner            = Security.UserName;
            }

            else if (!uo.HasDefinedParentFolder)
            {
                throw new Exception("No parent folder for list");
            }

            uo.Content = content;
            uo.Count   = list.Count;
            UserObjectDao.Write(uo);

            return(list.Count);
        }
Exemple #3
0
/// <summary>
/// Process a database subset command
/// </summary>
/// <param name="arg"></param>
/// <returns></returns>

        static string SubsetDatabase(
            string arg)
        {
            string  statusMsg = "", returnMsg = "";
            CidList newList = new CidList();

            if (Lex.Eq(arg, "Current"))
            {
                newList = Read("Current", QbUtil.CurrentQueryRoot);
                if (newList == null || newList.Count == 0)
                {
                    return("Current list does not exist or is empty");
                }

                SS.I.DatabaseSubsetListName = "Current";
                SS.I.DatabaseSubsetListSize = newList.Count;

                returnMsg =
                    "Queries will now be limited to the " + newList.Count.ToString() +
                    " compound identifiers in the Current list.";
            }

            else if (Lex.Eq(arg, "List"))
            {
                UserObject uo = SelectListDialog("Database Subset");
                if (uo == null)
                {
                    return("");
                }
                newList = Read(uo.InternalName, QbUtil.CurrentQueryRoot);
                if (newList == null || newList.Count == 0)
                {
                    return("List " + uo.Name + " is empty or could not be read");
                }

                SS.I.DatabaseSubsetListName = uo.Name;
                SS.I.DatabaseSubsetListSize = newList.Count;

                returnMsg =
                    "Queries will now be limited to the " + newList.Count.ToString() +
                    " compound identifiers in list " + uo.Name + ".";
            }

            else if (Lex.Eq(arg, "All"))
            {
                SS.I.DatabaseSubsetListName = "";
                SS.I.DatabaseSubsetListSize = -1;
                returnMsg = "The complete database will now be searched.";
            }

            SessionManager.Instance.StatusBarManager.DisplaySearchDomain();

            QueryEngine.SetParameter("DatabaseSubset", newList.ToMultilineString());

            return(returnMsg);
        }
Exemple #4
0
        /// <summary>
        /// Write a compound number list
        /// </summary>
        /// <returns></returns>

        public static int Write(
            CidList list,
            UserObject uo)
        {
            string fileName;

            string content = list.ToMultilineString();

            uo.Type = UserObjectType.CnList;
            if (Lex.IsNullOrEmpty(uo.Owner))             // set current user as owner if owner not defined
            {
                uo.Owner = SS.I.UserName;
            }

            if (Lex.IsNullOrEmpty(uo.ParentFolder))
            {
                throw new Exception("No parent folder for list");
            }

            uo.Content = content;
            uo.Count   = list.Count;
            UserObjectDao.Write(uo, uo.Id);

            if (uo.IsCurrentObject)
            {
                SessionManager.CurrentResultKeys = list.ToStringList();
                SessionManager.DisplayCurrentCount();
            }

            if (uo.HasDefinedParentFolder)
            {
                MainMenuControl.UpdateMruList(uo.InternalName);
            }

            return(list.Count);
        }