Ejemplo n.º 1
0
/// <summary>
/// SelectWithCriteria
/// </summary>
/// <param name="criteria"></param>
/// <returns></returns>

        public static List <AfsLibrary> SelectWithCriteria(string criteria)
        {
            MetaTreeNode  tempMtn = new MetaTreeNode(MetaTreeNodeType.Library);
            StringBuilder sb      = new StringBuilder(64);

            string sql = @"
				select
					p.proj_id, 
					p.mbs_project_code,
					proj_name, 
					p.mbs_dht_folder_code,
					dht_folder_name, 
					platform_name, 
					lib_id, 
					lib_name, 
					lib_use
				from
					<mbs_owner>.afs_project p,
					<mbs_owner>.afs_lib l
				where
					p.afs_current = 1
					and p.mbs_project_code is not null
					and l.afs_current = 1
					and l.proj_id = p.proj_id
					and <criteria>
				order by upper(dht_folder_name), upper(proj_name), upper(lib_name)
				"                ;

            sql = Lex.Replace(sql, "<mbs_owner>", AfsProject.AfsTableSchema);
            sql = Lex.Replace(sql, "<criteria>", criteria);

            List <AfsLibrary> libs = new List <AfsLibrary>();

            DbCommandMx dao = new DbCommandMx();

            dao.Prepare(sql);
            dao.ExecuteReader();

            string fileName = MetaTableFactory.MetaTableXmlFolder + @"\LibraryStats.txt";
            Dictionary <string, MetaTableStats> libStats = new Dictionary <string, MetaTableStats>();
            int libCount = MetaTableFactory.LoadMetaTableStats(fileName, libStats);

            while (dao.Read())
            {
                AfsLibrary l = new AfsLibrary();
                l.ProjId           = dao.GetInt(0);
                l.MbsProjectName   = dao.GetString(1).ToUpper();
                l.ProjectLabel     = dao.GetString(2);
                l.MbsDhtFolderName = dao.GetString(3).ToUpper();
                l.DhtFolderLabel   = dao.GetString(4).ToUpper();
                l.Platform         = dao.GetString(5).ToUpper();
                l.LibId            = dao.GetInt(6);
                l.LibName          = dao.GetString(7);
                l.LibUse           = dao.GetString(8).ToUpper();

                string nodeName = "LIBRARY_" + l.LibId;

                sb.Length = 0;
                sb.Append(l.LibName);

                sb.Append(" (");
                if (!Lex.IsNullOrEmpty(l.LibUse))
                {
                    sb.Append(l.LibUse);
                    sb.Append(", ");
                }
                sb.Append("Id: ");
                sb.Append(l.LibId);

                if (libStats.ContainsKey(nodeName))
                {
                    tempMtn.Size           = (int)libStats[nodeName].RowCount;
                    tempMtn.UpdateDateTime = libStats[nodeName].UpdateDateTime;                             // really create date
                    sb.Append(", ");
                    sb.Append(MetaTreeNode.FormatStatistics(tempMtn));
                }

                sb.Append(")");
                l.LibLabel = sb.ToString();

                libs.Add(l);
            }

            dao.CloseReader();
            return(libs);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the description for a project in HTML format
        /// </summary>
        /// <param name="projIdString"></param>
        /// <returns></returns>

        public static string GetProjectHtmlDescription(string projIdString)
        {
            string html = "";

            AfsProject p = AfsProject.SelectMetaData(projIdString);

            try
            {
                string       templateFile = ServicesDirs.MetaDataDir + @"\MiscConfig\AFSProjectTemplate.htm";
                StreamReader sr           = new StreamReader(templateFile);
                html = sr.ReadToEnd();
                sr.Close();
            }
            catch (Exception ex) { return(ex.Message); }

            html = Lex.Replace(html, "[Project]", p.ProjectLabel);
            html = Lex.Replace(html, "[Platform]", p.PlatformName);
            html = Lex.Replace(html, "[Description]", p.Description);

            string targets = "";

            foreach (AfsTarget t in p.Targets)
            {
                if (Lex.IsNullOrEmpty(t.TargetName))
                {
                    continue;
                }

                if (targets != "")
                {
                    targets += " ,";
                }
                targets += t.TargetName;
                if (!Lex.IsNullOrEmpty(t.TargetType))
                {
                    targets += " (" + t.TargetType + ")";
                }
            }

            html = Lex.Replace(html, "[Targets]", targets);

            if (!Lex.IsNullOrEmpty(p.ProjectFlowScheme))
            {
                html = Lex.Replace(html, "[LinkText]", "Link");
                html = Lex.Replace(html, "[LinkArg]", p.ProjId.ToString());
            }

            else
            {
                html = Lex.Replace(html, "[LinkText]", "Not Available");
            }

// Project metadata

            string currentCat = "";
            string vals       = "";
            string metaHtml   = "";

            for (int i1 = 0; i1 < p.ProjMeta.Count; i1++)
            {
                AfsProjMeta m = p.ProjMeta[i1];
                if (Lex.IsNullOrEmpty(m.CategoryName) || Lex.IsNullOrEmpty(m.CategoryValue))
                {
                    continue;
                }

                if (m.CategoryName != currentCat)       // going to new category
                {
                    if (vals != "")                     // add any vals for current category
                    {
                        metaHtml += "<strong>" + currentCat + " : </strong>" + vals + "<br>";
                    }

                    currentCat = m.CategoryName;
                    vals       = "";
                }

                if (vals != "")
                {
                    vals += ", ";
                }
                vals += m.CategoryValue;
            }

            if (vals != "")             // last one
            {
                metaHtml += "<strong>" + currentCat + " : </strong>" + vals + "<br>";
            }

            html = Lex.Replace(html, "[ProjMeta]", metaHtml);

// Assays

            metaHtml = "";
            for (int i1 = 0; i1 < p.Assays.Count; i1++)
            {
                AfsAssay a = p.Assays[i1];

                string       target = a.AssayDb + "_" + a.AssayId;
                string       label  = a.AssayLabel;
                MetaTreeNode mtn    = MetaTree.GetNodeByTarget(target);              // try to get better label from contents tree
                if (mtn != null)
                {
                    label = mtn.Label + " (";

                    if (!Lex.IsNullOrEmpty(a.AssayUse) && !Lex.Contains(label, a.AssayUse))                     // append any assay use
                    {
                        label += "Use: " + a.AssayUse + ", ";
                    }

                    label += "Id: " + mtn.Target + ", ";

                    label += MetaTreeNode.FormatStatistics(mtn);
                    label += ")";
                }

                metaHtml += "&nbsp; &nbsp;" + label + "<br>";
            }

            html = Lex.Replace(html, "[AssayMeta]", metaHtml);

// Libraries

            metaHtml = "";
            for (int i1 = 0; i1 < p.Libraries.Count; i1++)
            {
                AfsLibrary l = p.Libraries[i1];
                metaHtml += "&nbsp; &nbsp;" + l.LibLabel + "<br>";
            }

            html = Lex.Replace(html, "[LibraryMeta]", metaHtml);

// Flowscheme if any

            if (!Lex.IsNullOrEmpty(p.ProjectFlowScheme))
            {
                html += "\v" + p.ProjectFlowScheme;
            }

            return(html);
        }