示例#1
0
文件: Help.cs 项目: lulzzz/Pisces
        private static void Print(Dictionary <string, string> d, string cgi, string header)
        {
            DataTable t = new DataTable();

            t.Columns.Add("name");
            t.Columns.Add("example");

            if (CgiUtility.IsRemoteRequest())
            {
                cgi += ".pl?";
            }
            else
            {
                cgi += "?";
            }

            foreach (var item in d)
            {
                var example = "<a href=\"" + cgi + item.Value + "\">" + item.Value + "</a>";
                t.Rows.Add(item.Key, example);
            }
            var s = DataTableOutput.ToHTML(t, true, header);

            Console.WriteLine(s);
        }
示例#2
0
        private void PrintHtmlInventory(string siteID, TimeInterval interval, bool ui)
        {
            var parms = db.GetParameters(siteID, interval);
            var desc  = db.GetSiteDescription(siteID);

            WriteLine("<!DOCTYPE html>");
            WriteLine("<html>");



            DataTable tbl = new DataTable();

            tbl.Columns.Add("parameter");
            tbl.Columns.Add("available records");
            tbl.Columns.Add("description");
            int firstYear = DateTime.Now.Year;
            int minYr = 0, maxYr = 0;
            int min = 0, max = 0;

            for (int i = 0; i < parms.Length; i++)
            {
                string por = db.GetPeriodOfRecord(siteID, parms[i], interval, out minYr, out maxYr);
                if (i == 0)
                {
                    min = minYr;
                    max = maxYr;
                }
                if (minYr < min)
                {
                    min = minYr;
                }
                if (maxYr > max)
                {
                    max = maxYr;
                }

                if (ui)
                {
                    var cb = " <input type=\"checkbox\" name=\"pcode\" value=\"" + parms[i] + "\" id=\"" + parms[i] + "\">" + parms[i].ToUpper();
                    tbl.Rows.Add(cb, db.GetParameterDescription(parms[i], interval), por);
                }
                else
                {
                    tbl.Rows.Add(parms[i], db.GetParameterDescription(parms[i], interval), por);
                }
            }

            if (ui)
            {
                string cgiTag = "";
                if (CgiUtility.IsRemoteRequest())
                {
                    cgiTag = ".pl";
                }
                if (interval == TimeInterval.Daily)
                {
                    WriteLine("<form name=\"Form\" action=\"/pn-bin/daily" + cgiTag + "\" method=\"get\" >");
                }
                else
                {
                    WriteLine("<form name=\"Form\" action=\"/pn-bin/instant" + cgiTag + "\" method=\"get\" >");
                }

                WriteLine("<input name=station type=\"hidden\" value=\"" + siteID + "\">");
                WriteLine("<input name=format type=\"hidden\" value=\"html\">");

                WriteTimeSelector(siteID, min, max);
            }
            var s = DataTableOutput.ToHTML(tbl, false, desc);

            WriteLine(s);

            WriteLine("<p><input type=\"submit\" value=\"Retrieve Daily Data\">");

            if (ui)
            {
                WriteLine("</form>");
            }
            //WriteLine("<\\html>");
        }