コード例 #1
0
/// <summary>
/// Select
/// </summary>
/// <param name="projId"></param>
/// <returns></returns>

        public static List <AfsProjMeta> Select(int projId)
        {
            List <AfsProjMeta> l = new List <AfsProjMeta>();

            string sql = @"
				select *
				from <mbs_owner>.afs_proj_meta 
				where afs_current = 1 and proj_id = "                 + projId +
                         " order by upper(category_name)";;

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

            DbCommandMx dao = new DbCommandMx();

            dao.Prepare(sql);
            dao.ExecuteReader();
            while (dao.Read())
            {
                AfsProjMeta m = new AfsProjMeta();
                m.ProjId        = dao.GetIntByName("PROJ_ID");
                m.CategoryName  = dao.GetStringByName("CATEGORY_NAME");
                m.CategoryValue = dao.GetStringByName("CATEGORY_VALUE");
                l.Add(m);
            }

            dao.CloseReader();

            return(l);
        }
コード例 #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);
        }
コード例 #3
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);
        }