Beispiel #1
0
 public void WriteWebInfo(WebInfo webinfo)
 {
     string insertQuery = String.Format("insert into [{0}] ({1},{2}) values(@name,@host)",
         ConstPR.webInfoName, ConstPR.name, ConstPR.host);
     SQLiteParameter[] parameters = new SQLiteParameter[2];
     parameters[0] = new SQLiteParameter("@name", webinfo.Name);
     parameters[1] = new SQLiteParameter("@host", webinfo.Host);
     try
     {
         sqliteHelper.Execute(insertQuery, parameters);
         log.Info(String.Format("insert {0} record into DB success.",ConstPR.webInfoName));
     }
     catch (Exception ex)
     {
         log.ErrorException(String.Format("insert {0} record into DB failed.",ConstPR.webInfoName), ex);
     }
 }
Beispiel #2
0
        public List<WebInfo> LoadWebInfo()
        {
            string QueryWebInfo = QueryHelper.GetInstance().GetQueryCommand("", "QueryWebInfo");
            try
            {
                DataSet ds = sqliteHelper.GetDs(QueryWebInfo);
                if (ds != null && ds.Tables != null && ds.Tables.Count > 0)
                {
                    List<WebInfo> webList = new List<WebInfo>();
                    foreach (DataRow record in ds.Tables[0].Rows)
                    {
                        WebInfo webinfo = new WebInfo();
                        webinfo.Id = record[ConstPR.ID].ToString();
                        webinfo.Name = record[ConstPR.name].ToString();
                        webinfo.Host = record[ConstPR.host].ToString();
                        webinfo.GroupName = record[ConstPR.groupName].ToString();

                        WebHeaders headers = new WebHeaders();
                        headers.Accept = record[ConstPR.accept].ToString();
                        headers.AcceptEncoding = record[ConstPR.acceptEncoding].ToString();
                        headers.AcceptLanguage = record[ConstPR.acceptLanguage].ToString();
                        headers.UserAgent = record[ConstPR.userAgent].ToString();
                        headers.ContentType = record[ConstPR.contentType].ToString();
                        headers.ContentLength = record[ConstPR.contentLength].ToString();
                        headers.Connection = record[ConstPR.connection].ToString();
                        headers.Cookie = record[ConstPR.cookie].ToString();

                        webinfo.Headers = headers;
                        webList.Add(webinfo);
                    }
                    return webList;
                }
            }
            catch (Exception ex)
            {
                log.ErrorException(String.Format("Load {0} failed", ConstPR.webInfoName), ex);
            }
            return null;
        }