/// <summary> /// Build assay nodes /// </summary> /// <param name="projectNodeName"></param> /// <param name="pNodes"></param> public void BuildAfsAssayNodes( string projectNodeName, Dictionary <string, MetaTreeNode> pNodes) { MetaTreeNode projNode, assayNode; List <AfsAssay> assays = AfsAssay.Select(projectNodeName); foreach (AfsAssay a in assays) { if (!pNodes.ContainsKey(a.MbsProjectName)) { continue; } projNode = pNodes[a.MbsProjectName]; assayNode = new MetaTreeNode(MetaTreeNodeType.MetaTable); assayNode.Name = a.MbsProjectName + "_" + a.AssayDb + "_" + a.AssayId; // assign unique name for project so label with assay use gets passed through assayNode.Target = a.AssayDb + "_" + a.AssayId; // target must match a metatable name assayNode.Label = a.AssayLabel; if (!Lex.IsNullOrEmpty(a.AssayUse)) // append any assay use { assayNode.Label += " (" + a.AssayUse + ")"; } assayNode.Owner = "AFS"; projNode.Nodes.Add(assayNode); } return; }
/// <summary> /// /// </summary> /// <param name="criteria"></param> /// <returns></returns> public static List <AfsAssay> SelectWithCriteria(string criteria) { MetaTreeNode mtn; string sql = @" select p.proj_id, p.mbs_project_code, proj_name, p.mbs_dht_folder_code, dht_folder_name, platform_name, assay_id, assay_name, assay_db, assay_use from <mbs_owner>.afs_project p, <mbs_owner>.afs_assay a where p.afs_current = 1 and p.mbs_project_code is not null and a.afs_current = 1 and a.proj_id = p.proj_id and <criteria> order by upper(dht_folder_name), upper(proj_name), upper(assay_name) " ; sql = Lex.Replace(sql, "<mbs_owner>", AfsProject.AfsTableSchema); sql = Lex.Replace(sql, "<criteria>", criteria); List <AfsAssay> assays = new List <AfsAssay>(); DbCommandMx dao = new DbCommandMx(); dao.Prepare(sql); dao.ExecuteReader(); while (dao.Read()) { AfsAssay a = new AfsAssay(); a.ProjId = dao.GetInt(0); a.MbsProjectName = dao.GetString(1).ToUpper(); a.ProjectLabel = dao.GetString(2); a.MbsDhtFolderName = dao.GetString(3).ToUpper(); a.DhtFolderLabel = dao.GetString(4).ToUpper(); a.Platform = dao.GetString(5).ToUpper(); a.AssayId = dao.GetInt(6); a.AssayLabel = dao.GetString(7); a.AssayDb = dao.GetString(8).ToUpper(); a.AssayUse = dao.GetString(9).ToUpper(); assays.Add(a); } dao.CloseReader(); return(assays); }
/// <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); }
/// <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 += " " + 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 += " " + l.LibLabel + "<br>"; } html = Lex.Replace(html, "[LibraryMeta]", metaHtml); // Flowscheme if any if (!Lex.IsNullOrEmpty(p.ProjectFlowScheme)) { html += "\v" + p.ProjectFlowScheme; } return(html); }