コード例 #1
0
        /// <summary>
        /// Save list of hits and optional reference to a results file from a background query
        /// </summary>
        /// <param name="qm"></param>
        /// <param name="listOwner"></param>
        /// <returns></returns>

        public static UserObject SaveBackgroundQueryResultsReferenceObject(
            QueryManager qm,
            string listOwner,
            string resultsFileName)
        {
            Query            q   = qm.Query;
            DataTableManager dtm = qm.DataTableManager;

            UserObject cidListUo = new UserObject(UserObjectType.CnList);

            cidListUo.Owner       = listOwner;
            cidListUo.Id          = UserObjectDao.GetNextId();
            cidListUo.Name        = "List " + cidListUo.Id;            // assign unique name
            cidListUo.Description = q.UserObject.Id + "\t" +           // store query id
                                    DateTimeUS.ToString(DateTime.Now); // and a time stamp
            if (!Lex.IsNullOrEmpty(resultsFileName))
            {
                cidListUo.Description += "\t" + resultsFileName;
            }

            SortOrder sortDirection = (q.KeySortOrder > 0) ? SortOrder.Ascending : SortOrder.Descending;

            ResultsSorter.SortKeySet(dtm.ResultsKeys, sortDirection);             // sort properly

            StringBuilder sb = new StringBuilder();

            foreach (string s in dtm.ResultsKeys)
            {             // build comma separated list of numbers
                if (sb.Length > 0)
                {
                    sb.Append("\r\n");
                }
                sb.Append(s);
            }

            cidListUo.Content = sb.ToString();
            cidListUo.Count   = dtm.ResultsKeys.Count;
            UserObjectDao.Write(cidListUo, cidListUo.Id);             // write list with supplied id
            return(cidListUo);
        }
コード例 #2
0
        /// <summary>
        /// Utility routine to load a file of stats for a single broker type
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="metaTableStats"></param>
        /// <returns></returns>

        public static int LoadMetaTableStats(
            string fileName,
            Dictionary <string, MetaTableStats> metaTableStats)
        {
            if (!File.Exists(fileName))
            {
                return(0);
            }
            StreamReader sr  = new StreamReader(fileName);
            int          cnt = 0;

            while (true)
            {
                string rec = sr.ReadLine();
                if (Lex.IsUndefined(rec))
                {
                    break;
                }
                string[] sa = rec.Split('\t');
                if (sa.Length < 3)
                {
                    continue;
                }
                string         table = sa[0].ToUpper();
                MetaTableStats mts   = new MetaTableStats();
                mts.RowCount       = long.Parse(sa[1]);
                mts.UpdateDateTime = DateTimeUS.ParseDate(sa[2]);

                metaTableStats[table] = mts;

                cnt++;
            }

            sr.Close();
            return(cnt);
        }