Esempio n. 1
0
        public static string getSql(string sql, DMClient dmc)
        {
            string retValue = null;

            QTIUtility.RequesterAsync rr = new QTIUtility.RequesterAsync(sql, dmc.origUrl, dmc.token, true);
            DataTable     dt             = rr.execute();
            StringBuilder sb             = new StringBuilder();

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataColumn dc in dt.Columns)
                {
                    sb.Append(dc.ColumnName + "\t");
                }
                sb.Append(Environment.NewLine);
                foreach (DataRow dr in dt.Rows)
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        sb.Append(dr[dc].ToString() + "\t");
                    }
                    sb.Append(Environment.NewLine);
                }
            }
            retValue = sb.ToString() + Environment.NewLine;
            return(retValue);
        }
Esempio n. 2
0
        public string getUser(string firstname, string lastname)
        {
            string retvalue = null;
            string token    = null;

            if (this.token != null)
            {
                token = this.token;
            }
            else
            {
                token = getToken();
            }
            string sql = "select firstname as Firstname,lastname as Lastname,user_id as Username, email ";

            sql += " from users ";
            sql += " where UPPER(firstname)  = '" + firstname.ToUpper() + "'";
            sql += " and UPPER(lastname) = '" + lastname.ToUpper() + "'";
            QTIUtility.RequesterAsync rr = new QTIUtility.RequesterAsync(sql, this.origUrl, token, true);
            DataTable     dt             = rr.execute();
            StringBuilder sb             = new StringBuilder();

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        sb.Append(dc.ColumnName + " = " + dr[dc].ToString() + Environment.NewLine);
                    }
                }
            }
            retvalue = sb.ToString() + Environment.NewLine;
            return(retvalue);
        }
Esempio n. 3
0
        public DataTable getSqldt(string sql, DMClient dmc)
        {
            DataTable retValue;

            QTIUtility.RequesterAsync rr = new QTIUtility.RequesterAsync(sql, dmc.origUrl, dmc.token, true);
            retValue = rr.execute();
            return(retValue);
        }
Esempio n. 4
0
        public bool getOracle()
        {
            string sql = "select sysdate from dual";

            QTIUtility.RequesterAsync rr = new QTIUtility.RequesterAsync(sql, this.origUrl, this.token, true);
            DataTable dt = rr.execute();

            if (dt == null || dt.Rows.Count == 0)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 5
0
        public static string getSqlHTML(string sql, DMClient dmc)
        {
            string retValue   = null;
            bool   compressed = ((dmc.origUrl.Contains(".php") && dmc.origUrl.Contains("cc1")) || dmc.origUrl.ToLower().Contains("postgres")) ? false : true;

            QTIUtility.RequesterAsync rr = new QTIUtility.RequesterAsync(sql, dmc.origUrl, dmc.token, compressed);
            DataTable dt = rr.execute();

            if (dt.Columns.Contains("qdecode") || dt.Columns.Contains("QDECODE"))
            {
                foreach (DataRow dr in dt.Rows)
                {
                    string data = QTIUtility.BbQuery.getStringFromData(dr["qdecode"].ToString());
                    System.Xml.Linq.XElement qd = System.Xml.Linq.XElement.Parse(data);
                    var qs = qd.Descendants(XName.Get("mat_formattedtext"));
                    if (qs.Count() > 0)
                    {
                        dr["qdecode"] = QTIUtility.Utilities.StripTags(qs.FirstOrDefault().Value);
                    }
                }
            }
            if (dt.Columns.Contains("qrscore") || dt.Columns.Contains("QRSCORE"))
            {
                foreach (DataRow dr in dt.Rows)
                {
                    string data = QTIUtility.BbQuery.getStringFromData(dr["qrscore"].ToString());
                    System.Xml.Linq.XElement qd = System.Xml.Linq.XElement.Parse(data);
                    string sc = "";
                    var    qs = qd.Descendants(XName.Get("score_value"));
                    if (qs.Count() > 0)
                    {
                        foreach (string v in qs)
                        {
                            sc += ":" + v;
                        }
                    }
                    qs = qd.Descendants(XName.Get("score_maximum"));
                    if (qs.Count() > 0)
                    {
                        foreach (string v in qs)
                        {
                            sc += ":" + v;
                        }
                    }
                    dr["qrscore"] = sc.Substring(1);
                }
            }

            StringBuilder sb = new StringBuilder("<table style=\"font-family: Tahoma, Arial, sans-serif;font-size:12px\" >");

            sb.Append("<tr>");
            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataColumn dc in dt.Columns)
                {
                    sb.Append("<th>" + dc.ColumnName + "</th>");
                }
                sb.Append("</tr>");
                foreach (DataRow dr in dt.Rows)
                {
                    sb.Append("<tr>");
                    foreach (DataColumn dc in dt.Columns)
                    {
                        sb.Append("<td>" + dr[dc].ToString() + "</td>");
                    }
                    sb.Append("</tr>");
                }
                sb.Append("</table>");
            }
            retValue = sb.ToString();
            return(retValue);
        }