Esempio n. 1
0
/// <summary>
/// Build the basic projects nodes without assay, library or other assoc info
/// </summary>
/// <param name="projectNodeName"></param>
/// <param name="pNodes"></param>

        public void BuildAfsProjectNodes(
            string projectNodeName,
            Dictionary <string, MetaTreeNode> pNodes)
        {
            MetaTreeNode projNode, assayNode;

            List <AfsProject> projects = AfsProject.Select(projectNodeName);

            foreach (AfsProject p in projects)
            {
                if (!pNodes.ContainsKey(p.MbsProjectName))                 // add project node
                {
                    projNode                 = new MetaTreeNode(MetaTreeNodeType.Project);
                    projNode.Name            = projNode.Target = p.MbsProjectName;
                    projNode.Label           = p.ProjectLabel;
                    projNode.Owner           = "AFS";
                    pNodes[p.MbsProjectName] = projNode;

                    if (Nodes.ContainsKey(p.MbsDhtFolderName))                     // link to project parent if exists
                    {
                        projNode.Parent = Nodes[p.MbsDhtFolderName];
                    }
                }
            }

            return;
        }
Esempio n. 2
0
        /// <summary>
        /// Select basic project info with criteria
        /// </summary>
        /// <param name="criteria"></param>
        /// <returns></returns>

        public static List <AfsProject> SelectWithCriteria(string criteria)
        {
            MetaTreeNode mtn;

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

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

            List <AfsProject> projects = new List <AfsProject>();

            DbCommandMx dao = new DbCommandMx();

            dao.Prepare(sql);
            dao.ExecuteReader();
            while (dao.Read())
            {
                AfsProject p = new AfsProject();
                p.ProjId = dao.GetInt(0);

                p.MbsProjectName = dao.GetString(1).ToUpper();
                p.ProjectLabel   = dao.GetString(2);
                if (Lex.IsNullOrEmpty(p.ProjectLabel))
                {
                    p.ProjectLabel = p.MbsProjectName;
                }

                p.MbsDhtFolderName = dao.GetString(3).ToUpper();
                p.DhtFolderLabel   = dao.GetString(4).ToUpper();
                if (Lex.IsNullOrEmpty(p.DhtFolderLabel))
                {
                    p.DhtFolderLabel = p.MbsDhtFolderName;
                }

                p.PlatformName = dao.GetString(5).ToUpper();

                projects.Add(p);
            }

            dao.CloseReader();

            return(projects);
        }
Esempio n. 3
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);
        }
Esempio 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);
        }
Esempio n. 5
0
        /// <summary>
        /// Return true if node name is a mobius AFS project node name
        /// </summary>
        /// <param name="projNodeName"></param>
        /// <returns></returns>

        public static bool IsAfsNodeName(string projNodeName)
        {
            int id = AfsProject.GetAfsProjectId(projNodeName);

            return(id > 0 ? true : false);
        }