Ejemplo n.º 1
0
/// <summary>
/// Read assay information
/// </summary>
/// <param name="projectNodeName"></param>
/// <param name="pNodes"></param>

        public void BuildAfsLibraryNodes(
            string projectNodeName,
            Dictionary <string, MetaTreeNode> pNodes)
        {
            MetaTreeNode  projNode, libFolderNode, libNode;
            StringBuilder sb = new StringBuilder(64);

            List <AfsLibrary> libs = AfsLibrary.Select(projectNodeName);

            string fileName = MetaTableFactory.MetaTableXmlFolder + @"\LibraryStats.txt";

            foreach (AfsLibrary l in libs)
            {
                if (!pNodes.ContainsKey(l.MbsProjectName))
                {
                    continue;
                }

                projNode = pNodes[l.MbsProjectName];

                List <MetaTreeNode> projNodes = projNode.Nodes;

                if (projNodes.Count == 0 || projNodes[projNodes.Count - 1].Label != "Libraries")
                {                 // add libraries folder if doesn't exist
                    libFolderNode       = new MetaTreeNode(MetaTreeNodeType.SystemFolder);
                    libFolderNode.Name  = projNode.Name + "_LIBRARIES";
                    libFolderNode.Label = "Libraries";
                    libFolderNode.Owner = "AFS";
                    projNodes.Add(libFolderNode);
                }
                else
                {
                    libFolderNode = projNodes[projNodes.Count - 1];
                }

                libNode      = new MetaTreeNode(MetaTreeNodeType.Library);            // add node for library
                libNode.Name = libNode.Target = "LIBRARY_" + l.LibId;

                libNode.Label = l.LibLabel;
                libNode.Owner = "AFS";
                libFolderNode.Nodes.Add(libNode);
            }

            return;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// GetProjectMetaDataWithCriteria
        /// </summary>
        /// <param name="criteria"></param>
        /// <returns></returns>

        public static AfsProject SelectMetaDataWithCriteria(string criteria)
        {
            string sql = @"
				select *
				from <mbs_owner>.afs_project 
				where afs_current = 1 and <criteria>"                ;

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

            DbCommandMx dao = new DbCommandMx();

            dao.Prepare(sql);
            dao.ExecuteReader();
            if (!dao.Read())
            {
                dao.CloseReader();
                return(null);
            }

            AfsProject p = new AfsProject();

            p.ProjId            = dao.GetIntByName("PROJ_ID");
            p.ProjectLabel      = dao.GetStringByName("PROJ_NAME");
            p.PlatformName      = dao.GetStringByName("PLATFORM_NAME");
            p.Description       = dao.GetStringByName("DESCRIPTION");
            p.ProjectFlowScheme = dao.GetClobByName("PROJ_FLOW_SCHEME");
            p.MbsDhtFolderName  = dao.GetStringByName("MBS_DHT_FOLDER_CODE");
            p.MbsProjectName    = dao.GetStringByName("MBS_PROJECT_CODE");

            dao.CloseReader();

            p.ProjMeta  = AfsProjMeta.Select(p.ProjId);
            p.Targets   = AfsTarget.Select(p.ProjId);
            p.Assays    = AfsAssay.Select(p.ProjId);
            p.Libraries = AfsLibrary.Select(p.ProjId);

            return(p);
        }
Ejemplo n.º 3
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.º 4
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);
        }