示例#1
0
        public string GetRegionIdByPersonID(string PersonID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select [RegionID]=stuff((select ','+convert(varchar(64),RegionID) from dbo.PersonRegion t where PersonID=dbo.PersonRegion.PersonID for xml path('')), 1, 1, '') from dbo.PersonRegion ");
            strSql.Append(" where PersonID=@PersonID ");
            strSql.Append(" group by PersonID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PersonID", SqlDbType.Int, 4)
            };
            parameters[0].Value = PersonID;

            SM.YuQing.Model.Regions model = new SM.YuQing.Model.Regions();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(ds.Tables[0].Rows[0][0].ToString());
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();
            int id = Convert.ToInt32(context.Request.QueryString["id"]);

            SM.YuQing.BLL.Regions   bll    = new SM.YuQing.BLL.Regions();
            SM.YuQing.Model.Regions region = bll.GetModel(id);
            context.Response.Write(JsonConvert.SerializeObject(region));
        }
示例#3
0
        private DataTable GetDataRow(DataTable dt, SM.YuQing.Model.Regions region, string reg, string strWhere)
        {
            int positive = 0, negative = 0, neutral = 0, empty = 0;

            try
            {
                DataRow dr = dt.NewRow();
                dr["Region"] = region == null?reg:region.Mall;

                SM.YuQing.BLL.MonitorInfos          monitorInfoBll  = new SM.YuQing.BLL.MonitorInfos();
                List <SM.YuQing.Model.MonitorInfos> monitorInfoList = monitorInfoBll.GetModelList(strWhere + " and Keyword like \'SM\'");
                foreach (SM.YuQing.Model.MonitorInfos monitorInfo in monitorInfoList)
                {
                    switch (monitorInfo.Property)
                    {
                    case "正面":
                        positive++;
                        break;

                    case "负面":
                        negative++;
                        break;

                    case "中性":
                        neutral++;
                        break;

                    case "":
                        empty++;
                        break;
                    }
                }
                dr["Positive"] = positive.ToString();
                dr["Negative"] = negative.ToString();
                dr["Neutral"]  = neutral.ToString();
                dr["Empty"]    = empty.ToString();
                dr["Total"]    = (positive + negative + neutral + empty).ToString();
                dt.Rows.Add(dr);
            }
            catch (Exception ex)
            {
                DataRow dr = dt.NewRow();
                dr["Region"]   = "Error in GetDataRow():" + ex.Message;;
                dr["Positive"] = "";
                dr["Negative"] = "";
                dr["Neutral"]  = "";
                dr["Empty"]    = "";
                dr["Total"]    = "";
                dt.Rows.Add(dr);
            }
            return(dt);
        }
示例#4
0
        public void ProcessRequest(HttpContext context)
        {
            string id = context.Request.Form["id"];

            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            SM.YuQing.Accounts.SiteIdentity identity = (SM.YuQing.Accounts.SiteIdentity)(new SM.YuQing.Accounts.AccountsPrincipal(context.User.Identity.Name)).Identity;
            int personid = identity.FID;

            SM.YuQing.BLL.Regions   bll    = new SM.YuQing.BLL.Regions();
            SM.YuQing.Model.Regions region = bll.GetModel(Convert.ToInt32(id));
            string mall = region.Mall;

            bool success;

            SM.YuQing.BLL.MonitorWebs  webBll  = new SM.YuQing.BLL.MonitorWebs();
            SM.YuQing.BLL.MonitorInfos infoBll = new SM.YuQing.BLL.MonitorInfos();
            if (!bll.ExistRegion(Convert.ToInt32(id), personid) && !webBll.ExistRegion(Convert.ToInt32(id)) && !infoBll.ExistRegion(Convert.ToInt32(id)))
            {
                bll.Delete(Convert.ToInt32(id));
                bll.DeletePersonRegion(personid, Convert.ToInt32(id));
                success = true;
            }
            else
            {
                success = false;
            }

            Hashtable ht = new Hashtable();

            if (success)
            {
                SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                log.LogType    = "操作";
                log.Message    = context.User.Identity.Name + " 删除了区域 " + mall;
                log.IP         = context.Request.UserHostAddress;
                log.MenuID     = 0;
                log.PersonID   = personid;
                log.CreateTime = DateTime.Now;
                SM.YuQing.BLL.Log logBll = new SM.YuQing.BLL.Log();
                logBll.Add(log);

                ht.Add("success", true);
            }
            else
            {
                ht.Add("errorMsg", "该区域已有关联监测数据,不允许删除");
            }
            context.Response.Write(JsonConvert.SerializeObject(ht));
        }
示例#5
0
        public DataTable GetData(DataTable dt, string website, string keyword, SM.YuQing.Model.Regions region, SM.YuQing.Model.MonitorWebs web)
        {
            //DataTable dt = new DataTable();
            //dt.Columns.Add("Title");
            //dt.Columns.Add("PublishDate");
            //dt.Columns.Add("ViewsCounts");
            //dt.Columns.Add("Region");
            //dt.Columns.Add("RegionID");
            //dt.Columns.Add("MonitorUrl");
            //dt.Columns.Add("Keyword");
            //dt.Columns.Add("Url");

            DataTable dtUrl = new DataTable();

            dtUrl.Columns.Add("Title");
            dtUrl.Columns.Add("PublishDate");
            dtUrl.Columns.Add("ViewsCounts");
            dtUrl.Columns.Add("Region");
            dtUrl.Columns.Add("RegionID");
            dtUrl.Columns.Add("MonitorUrl");
            dtUrl.Columns.Add("Keyword");
            dtUrl.Columns.Add("Url");

            //int searchLevel = 1;

            try
            {
                //get all urls
                dtUrl = RemoveCommonUrl(GetUrls(website));

                //一级页面
                dt = GetDataRows(dt, website, keyword, null, null);

                //二级页面
                int count = dtUrl.Rows.Count;
                for (int i = 0; i < count; i++)
                {
                    string site = dtUrl.Rows[i]["Url"].ToString();
                    dt = GetDataRows(dt, site, keyword, null, null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(dt);
        }
示例#6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SM.YuQing.Model.Regions model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Regions set ");
            strSql.Append("Region=@Region,");
            strSql.Append("Mall=@Mall,");
            strSql.Append("Keyword=@Keyword,");
            strSql.Append("Description=@Description,");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("CreatePerson=@CreatePerson,");
            strSql.Append("UpdateTime=@UpdateTime,");
            strSql.Append("UpdatePerson=@UpdatePerson");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",           SqlDbType.Int,         4),
                new SqlParameter("@Region",       SqlDbType.NVarChar,   50),
                new SqlParameter("@Mall",         SqlDbType.NVarChar,   50),
                new SqlParameter("@Keyword",      SqlDbType.NVarChar,  500),
                new SqlParameter("@Description",  SqlDbType.NVarChar,  500),
                new SqlParameter("@CreateTime",   SqlDbType.DateTime),
                new SqlParameter("@CreatePerson", SqlDbType.NVarChar,   50),
                new SqlParameter("@UpdateTime",   SqlDbType.DateTime),
                new SqlParameter("@UpdatePerson", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.Region;
            parameters[2].Value = model.Mall;
            parameters[3].Value = model.Keyword;
            parameters[4].Value = model.Description;
            parameters[5].Value = model.CreateTime;
            parameters[6].Value = model.CreatePerson;
            parameters[7].Value = model.UpdateTime;
            parameters[8].Value = model.UpdatePerson;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#7
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SM.YuQing.Model.Regions DataRowToModel(DataRow row)
 {
     SM.YuQing.Model.Regions model = new SM.YuQing.Model.Regions();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["Region"] != null)
         {
             model.Region = row["Region"].ToString();
         }
         if (row["Mall"] != null)
         {
             model.Mall = row["Mall"].ToString();
         }
         if (row["Keyword"] != null)
         {
             model.Keyword = row["Keyword"].ToString();
         }
         if (row["Description"] != null)
         {
             model.Description = row["Description"].ToString();
         }
         if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
         {
             model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
         }
         if (row["CreatePerson"] != null)
         {
             model.CreatePerson = row["CreatePerson"].ToString();
         }
         if (row["UpdateTime"] != null && row["UpdateTime"].ToString() != "")
         {
             model.UpdateTime = DateTime.Parse(row["UpdateTime"].ToString());
         }
         if (row["UpdatePerson"] != null)
         {
             model.UpdatePerson = row["UpdatePerson"].ToString();
         }
     }
     return(model);
 }
示例#8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(SM.YuQing.Model.Regions model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Regions(");
            strSql.Append("Region,Mall,Keyword,Description,CreateTime,CreatePerson,UpdateTime,UpdatePerson)");
            strSql.Append(" values (");
            strSql.Append("@Region,@Mall,@Keyword,@Description,@CreateTime,@CreatePerson,@UpdateTime,@UpdatePerson)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Region",       SqlDbType.NVarChar,   50),
                new SqlParameter("@Mall",         SqlDbType.NVarChar,   50),
                new SqlParameter("@Keyword",      SqlDbType.NVarChar,  500),
                new SqlParameter("@Description",  SqlDbType.NVarChar,  500),
                new SqlParameter("@CreateTime",   SqlDbType.DateTime),
                new SqlParameter("@CreatePerson", SqlDbType.NVarChar,   50),
                new SqlParameter("@UpdateTime",   SqlDbType.DateTime),
                new SqlParameter("@UpdatePerson", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Region;
            parameters[1].Value = model.Mall;
            parameters[2].Value = model.Keyword;
            parameters[3].Value = model.Description;
            parameters[4].Value = model.CreateTime;
            parameters[5].Value = model.CreatePerson;
            parameters[6].Value = model.UpdateTime;
            parameters[7].Value = model.UpdatePerson;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            //List<SM.YuQing.Model.MonitorWebs> lst = bll.GetModelList("");
            //context.Response.Write(JsonConvert.SerializeObject(lst));

            SM.YuQing.Accounts.SiteIdentity identity = (SM.YuQing.Accounts.SiteIdentity)(new SM.YuQing.Accounts.AccountsPrincipal(context.User.Identity.Name)).Identity;
            string personid = identity.FID.ToString();

            SM.YuQing.BLL.Regions regbll = new SM.YuQing.BLL.Regions();
            string regionid = regbll.GetRegionIdByPersonID(personid);

            SM.YuQing.BLL.MonitorWebs bll = new SM.YuQing.BLL.MonitorWebs();
            DataTable dt = bll.GetList(" RegionID in (" + regionid + ")").Tables[0], retDt = new DataTable();

            retDt.Columns.Add("ID");
            retDt.Columns.Add("Region");
            retDt.Columns.Add("Name");
            retDt.Columns.Add("Url");
            retDt.Columns.Add("Status");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                SM.YuQing.BLL.Regions   regionBll = new SM.YuQing.BLL.Regions();
                SM.YuQing.Model.Regions region    = regionBll.GetModel(Convert.ToInt32(dt.Rows[i]["RegionID"]));
                DataRow dr = retDt.NewRow();
                dr["ID"]     = dt.Rows[i]["ID"];
                dr["Region"] = region.Region;
                dr["Name"]   = dt.Rows[i]["Name"];
                dr["Url"]    = dt.Rows[i]["Url"];
                dr["Status"] = dt.Rows[i]["Status"];
                retDt.Rows.Add(dr);
            }
            context.Response.Write(JsonConvert.SerializeObject(retDt));
        }
示例#10
0
        public int GetMaxRegionID(string CreatePerson)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Max(ID) from dbo.Regions ");
            strSql.Append(" where CreatePerson=@CreatePerson ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CreatePerson", SqlDbType.NChar, 50)
            };
            parameters[0].Value = CreatePerson;

            SM.YuQing.Model.Regions model = new SM.YuQing.Model.Regions();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(Convert.ToInt32(ds.Tables[0].Rows[0][0]));
            }
            else
            {
                return(0);
            }
        }
示例#11
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SM.YuQing.Model.Regions GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,Region,Mall,Keyword,Description,CreateTime,CreatePerson,UpdateTime,UpdatePerson from Regions ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            SM.YuQing.Model.Regions model = new SM.YuQing.Model.Regions();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#12
0
        public DataTable GetDataRows(DataTable dt, string website, string keyword, SM.YuQing.Model.Regions region, SM.YuQing.Model.MonitorWebs web)
        {
            try
            {
                string html = GetHtmlString(website, "utf-8");
                if (html.IndexOf("charset") < 0)
                {
                    html = GetHtmlString(website, "gb2312");
                    if (html.IndexOf("charset") < 0)
                    {
                        html = GetHtmlString(website, "gbk");
                    }
                }

                //string html = GetHtmlString(website, "UTF-8");
                //string str = html.Substring(0, html.IndexOf("charset=") + 64);  //报错点???

                //if (str.ToLower().Contains("gb2312"))
                //{
                //    html = GetHtmlString(website, "GB2312");
                //}
                //else if (str.ToLower().Contains("gbk"))
                //{
                //    html = GetHtmlString(website, "GBK");
                //}

                ////将获取的内容写入文本
                //using (StreamWriter sw = new StreamWriter("c:\\html.html"))
                //{
                //    sw.Write(html);
                //}

                //string regex = @">.*" + keyword + @".*<";
                //string regex = @">((.*|\s*))?" + keyword + @"((.*|\s*)<)?";


                if (html.IndexOf("charset=") >= 0)
                {
                    string regex = @">[^<>]*" + keyword + @"[^<>]*<";
                    if (keyword.ToLower() == "sm")
                    {
                        regex = @">[^<>]*" + keyword + @"[^a-zA-Z][^<>]*<";
                    }
                    Regex           re      = new Regex(regex, RegexOptions.IgnoreCase);
                    MatchCollection matches = re.Matches(html);
                    if (matches != null)
                    {
                        IEnumerator enu = matches.GetEnumerator();
                        while (enu.MoveNext() && enu.Current != null)
                        {
                            Match match = (Match)(enu.Current);
                            if (html.LastIndexOf(match.Value) > html.Length)
                            {
                                continue;
                            }

                            string url = GetUrlFromHtml(html.Substring(0, html.LastIndexOf(match.Value)));
                            SM.YuQing.BLL.MonitorInfos bll = new MonitorInfos();
                            //if (bll.Exists(url, region == null ? 0 : region.ID))  //存在此Url+RegionID
                            //    continue;

                            string tmpHtml = GetHtmlString(url, "UTF-8");
                            if (tmpHtml.IndexOf("charset=") < 0)
                            {
                                tmpHtml = GetHtmlString(url, "GB2312");
                                if (tmpHtml.IndexOf("charset=") < 0)
                                {
                                    tmpHtml = GetHtmlString(url, "GBK");
                                }
                            }
                            string title = match.Value.Replace(">", "").Replace("<", "").Trim();                                                                               //去掉头尾的“>”和“<”

                            if (Regex.IsMatch(match.Value, @"[\u4e00-\u9fa5]") && !Regex.IsMatch(match.Value, @";|function") && url != "" && !url.ToLower().Contains("error")) //包含中文,去除js代码、空url && tmpHtml.Contains(title) && Regex.IsMatch(title, @"\p{ASCII}")
                            {
                                DataRow dr = dt.NewRow();
                                //dr["Title"] = match.Value.Substring(1, match.Value.Length - 2).Trim();  //去掉头尾的“>”和“<”
                                //if (isLastLevel)
                                //    dr["Title"] = GetHtmlTitle(html);
                                //else

                                dr["Title"]       = title.Length > 100 ? (title.Substring(0, 97) + "...") : title;
                                dr["PublishDate"] = "";
                                dr["ViewsCounts"] = "";
                                dr["Region"]      = region == null ? "" : region.Mall;
                                dr["RegionID"]    = region == null ? "" : region.ID.ToString();
                                dr["MonitorUrl"]  = web == null ? website : web.Url;
                                dr["Keyword"]     = keyword;
                                dr["Url"]         = url;
                                dt.Rows.Add(dr);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
                //DataRow dr = dt.NewRow();
                //dr["Title"] = "Error in GetDataRows():" + ex.Message;
                //dr["PublishDate"] = "";
                //dr["ViewsCounts"] = "";
                //dr["Region"] = "";
                //dr["RegionID"] = "";
                //dr["MonitorUrl"] = "";
                //dr["Keyword"] = "";
                //dr["Url"] = "";
                //dt.Rows.Add(dr);
            }
            return(dt);
        }
示例#13
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            string regionid = context.Request.QueryString["regionid"], reg = "";
            string beginDate = context.Request.QueryString["beginDate"];
            string endDate   = context.Request.QueryString["endDate"];
            string property  = context.Request.QueryString["property"];
            string func      = context.Request.QueryString["func"];

            if (regionid == "" || regionid.Contains("-1"))
            {
                GetRegionIdHelper grih = new GetRegionIdHelper();
                regionid = grih.GetRegionID();
            }

            DataTable dt = new DataTable();

            dt.Columns.Add("ID");
            dt.Columns.Add("Title");
            dt.Columns.Add("PublishDate");
            dt.Columns.Add("ViewsCounts");
            dt.Columns.Add("Region");
            dt.Columns.Add("Property");
            dt.Columns.Add("Url");

            try
            {
                string    strWhere     = "";
                ArrayList strWhereList = new ArrayList();

                strWhereList.Add(" RegionID in (" + regionid + ")");
                strWhereList.Add(" Keyword like \'SM\'");

                if (beginDate != "" && endDate != "")
                {
                    strWhereList.Add(" PublishDate>=\'" + beginDate + "\' and PublishDate<=\'" + endDate + " 23:59:59.999\'");
                }
                if (property != "" && !property.Contains("全部"))
                {
                    //strWhereList.Add(" Property=N\'" + (property == "空" ? "" : property) + "\'");
                    //" (Property=N\'" + (p == "空" ? "" : p) + "\' or Property=N\'" + p + "\'")
                    string[] props  = property.Split(',');
                    string   tmpSql = "";
                    foreach (string p in props)
                    {
                        tmpSql += " or Property=N\'" + (p == "空" ? "" : p) + "\'";
                    }
                    tmpSql = tmpSql.Substring(tmpSql.IndexOf("or") + 2, tmpSql.Length - 3);
                    strWhereList.Add(" (" + tmpSql + ") ");
                }

                switch (strWhereList.Count)
                {
                case 2:
                    strWhere = strWhereList[0].ToString() + " and " + strWhereList[1].ToString();
                    break;

                case 3:
                    strWhere = strWhereList[0].ToString() + " and " + strWhereList[1].ToString() + " and " + strWhereList[2].ToString();
                    break;

                case 4:
                    strWhere = strWhereList[0].ToString() + " and " + strWhereList[1].ToString() + " and " + strWhereList[2].ToString() + " and " + strWhereList[3].ToString();
                    break;

                default:
                    break;
                }

                SM.YuQing.BLL.MonitorInfos          monitorInfoBll  = new SM.YuQing.BLL.MonitorInfos();
                List <SM.YuQing.Model.MonitorInfos> monitorInfoList = monitorInfoBll.GetModelList(strWhere);
                foreach (SM.YuQing.Model.MonitorInfos monitorInfo in monitorInfoList)
                {
                    DataRow dr = dt.NewRow();
                    dr["ID"]          = monitorInfo.ID;
                    dr["Title"]       = monitorInfo.Title;
                    dr["PublishDate"] = monitorInfo.PublishDate.ToString("yyyy-MM-dd");
                    dr["ViewsCounts"] = monitorInfo.ViewsCounts;
                    if (monitorInfo.RegionID > 0)
                    {
                        SM.YuQing.BLL.Regions   regionBll = new SM.YuQing.BLL.Regions();
                        SM.YuQing.Model.Regions region    = regionBll.GetModel(Convert.ToInt32(monitorInfo.RegionID));
                        reg = region.Mall;
                    }
                    else
                    {
                        reg = "";
                    }
                    dr["Region"]   = reg;
                    dr["Property"] = monitorInfo.Property;
                    dr["Url"]      = monitorInfo.Url;
                    dt.Rows.Add(dr);
                }

                if (dt.Rows.Count == 0)
                {
                    DataRow dr = dt.NewRow();
                    dr["ID"]          = "";
                    dr["Title"]       = "未查询到数据";
                    dr["PublishDate"] = "";
                    dr["ViewsCounts"] = "";
                    dr["Region"]      = "";
                    dr["Property"]    = "";
                    dr["Url"]         = "";
                    dt.Rows.Add(dr);
                }

                //context.Response.Write("<script>lert(\'ManageInfos.DoSearch\');</script>");
            }
            catch (Exception ex)
            {
                throw ex;
                //DataRow dr = dt.NewRow();
                //dr["ID"] = "";
                //dr["Title"] = "Error in ProcessRequest():" + ex.Message;
                //dr["PublishDate"] = "";
                //dr["ViewsCounts"] = "";
                //dr["Region"] = "";
                //dr["Property"] = "";
                //dr["Url"] = "";
                //dt.Rows.Add(dr);
            }

            if (func == "1")  //导出excel
            {
                ExportToExcelHelper eteh = new ExportToExcelHelper();
                eteh.ExportToExcel(dt, "ManageInfoResult.xls", "[监测管理] -> [监测数据管理]");
            }
            else
            {
                context.Response.Write(JsonConvert.SerializeObject(dt));
            }
        }
示例#14
0
        public void ProcessRequest(HttpContext context)
        {
            string    id      = context.Request.QueryString["id"];
            string    Region  = context.Request.Form["Region"];
            string    Mall    = context.Request.Form["Mall"];
            string    Keyword = context.Request.Form["Keyword"];
            string    errMsg  = "";
            bool      success;
            Hashtable ht = new Hashtable();

            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            SM.YuQing.Accounts.SiteIdentity identity = (SM.YuQing.Accounts.SiteIdentity)(new SM.YuQing.Accounts.AccountsPrincipal(context.User.Identity.Name)).Identity;
            int personid = identity.FID;

            SM.YuQing.BLL.Regions bll = new SM.YuQing.BLL.Regions();
            if (id == null)
            {
                if (!bll.ExistRegion(Region.Trim(), Mall.Trim(), Keyword.Trim()))
                {
                    SM.YuQing.Model.Regions region = new SM.YuQing.Model.Regions();
                    region.Region       = Region;
                    region.Mall         = Mall;
                    region.Keyword      = Keyword;
                    region.CreatePerson = context.User.Identity.Name;
                    region.CreateTime   = DateTime.Now;
                    region.UpdatePerson = context.User.Identity.Name;
                    region.UpdateTime   = DateTime.Now;

                    success = bll.Add(region);

                    if (success)
                    {
                        int maxRegionID = bll.GetMaxRegionID(context.User.Identity.Name);
                        bll.AddPersonRegion(personid, maxRegionID);

                        SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                        log.LogType    = "操作";
                        log.Message    = context.User.Identity.Name + " 新增了区域 " + Mall;
                        log.IP         = context.Request.UserHostAddress;
                        log.MenuID     = 0;
                        log.PersonID   = personid;
                        log.CreateTime = DateTime.Now;
                        SM.YuQing.BLL.Log logBll = new SM.YuQing.BLL.Log();
                        logBll.Add(log);
                    }
                    else
                    {
                        success = false;
                        errMsg  = "some error occured.";
                    }
                }
                else
                {
                    success = false;
                    errMsg  = "此区域已存在";
                }
            }
            else
            {
                SM.YuQing.Model.Regions region = bll.GetModel(Convert.ToInt32(id));
                string oldRegion = region.Region, oldMall = region.Mall, oldKeyword = region.Keyword;

                if (oldRegion == Region && oldMall == Mall && oldKeyword == Keyword)
                {
                    success = false;
                    errMsg  = "您未修改任何信息";
                }
                else if (!bll.ExistRegion(Region.Trim(), Mall.Trim(), Keyword.Trim()))
                {
                    region.Region  = Region;
                    region.Mall    = Mall;
                    region.Keyword = Keyword;

                    region.UpdatePerson = context.User.Identity.Name;
                    region.UpdateTime   = DateTime.Now;

                    success = bll.Update(region);

                    if (success)
                    {
                        SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                        log.LogType    = "操作";
                        log.Message    = context.User.Identity.Name + " 修改了ID=" + id + "的区域信息" + " | " + (oldRegion == Region ? "" : (oldRegion + " -> " + Region + " | ")) + (oldMall == Mall ? "" : (oldMall + " -> " + Mall + " | ")) + (oldKeyword == Keyword ? "" : ("关键字 | "));
                        log.IP         = context.Request.UserHostAddress;
                        log.MenuID     = 0;
                        log.PersonID   = personid;
                        log.CreateTime = DateTime.Now;
                        SM.YuQing.BLL.Log logBll = new SM.YuQing.BLL.Log();
                        logBll.Add(log);
                    }
                    else
                    {
                        success = false;
                        errMsg  = "some error occured.";
                    }
                }
                else
                {
                    success = false;
                    errMsg  = "此区域已存在";
                }
            }
            //if (!bll.ExistRegion(Region.Trim(), Mall.Trim(), Keyword.Trim()))
            //{

            //}
            //else
            //{
            //    success = false;
            //    errMsg = "此区域已存在";
            //}

            if (success)
            {
                ht.Add("success", true);
            }
            else
            {
                ht.Add("errorMsg", errMsg);
            }

            context.Response.Write(JsonConvert.SerializeObject(ht));
        }
示例#15
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            string regionid = context.Request.QueryString["regionid"], reg = "";
            string beginDate = context.Request.QueryString["beginDate"];
            string endDate   = context.Request.QueryString["endDate"];
            string keyword   = context.Request.QueryString["keyword"];
            string func      = context.Request.QueryString["func"];

            if (regionid == "" || regionid.Contains("-1"))
            {
                GetRegionIdHelper grih = new GetRegionIdHelper();
                regionid = grih.GetRegionID();
            }

            DataTable dt = new DataTable();

            dt.Columns.Add("ID");
            dt.Columns.Add("Title");
            dt.Columns.Add("PublishDate");
            dt.Columns.Add("ViewsCounts");
            dt.Columns.Add("Keyword");
            dt.Columns.Add("Region");
            dt.Columns.Add("Url");

            try
            {
                string    strWhere     = "";
                ArrayList strWhereList = new ArrayList();

                if (beginDate != "" && endDate != "")
                {
                    strWhereList.Add(" PublishDate>=\'" + beginDate + "\' and PublishDate<=\'" + endDate + " 23:59:59.999\'");
                }
                if (regionid != "")
                {
                    strWhereList.Add(" RegionID in (" + regionid + ")");
                }
                if (keyword != "")
                {
                    strWhereList.Add(" Keyword like N\'%" + keyword + "%\'");
                }

                switch (strWhereList.Count)
                {
                case 1:
                    strWhere = strWhereList[0].ToString();
                    break;

                case 2:
                    strWhere = strWhereList[0].ToString() + " and " + strWhereList[1].ToString();
                    break;

                case 3:
                    strWhere = strWhereList[0].ToString() + " and " + strWhereList[1].ToString() + " and " + strWhereList[2].ToString();
                    break;

                default:
                    break;
                }

                SM.YuQing.BLL.MonitorInfos          monitorInfoBll  = new SM.YuQing.BLL.MonitorInfos();
                List <SM.YuQing.Model.MonitorInfos> monitorInfoList = monitorInfoBll.GetModelList(strWhere);
                foreach (SM.YuQing.Model.MonitorInfos monitorInfo in monitorInfoList)
                {
                    DataRow dr = dt.NewRow();
                    dr["ID"]          = monitorInfo.ID;
                    dr["Title"]       = monitorInfo.Title;
                    dr["PublishDate"] = monitorInfo.PublishDate.ToString("yyyy-MM-dd");
                    dr["ViewsCounts"] = monitorInfo.ViewsCounts;
                    dr["Keyword"]     = monitorInfo.Keyword;
                    if (monitorInfo.RegionID > 0)
                    {
                        SM.YuQing.BLL.Regions   regionBll = new SM.YuQing.BLL.Regions();
                        SM.YuQing.Model.Regions region    = regionBll.GetModel(Convert.ToInt32(monitorInfo.RegionID));
                        reg = region.Mall;
                    }
                    else
                    {
                        reg = "";
                    }
                    dr["Region"] = reg;
                    dr["Url"]    = monitorInfo.Url;
                    dt.Rows.Add(dr);
                }

                if (dt.Rows.Count == 0)
                {
                    DataRow dr = dt.NewRow();
                    dr["ID"]          = "";
                    dr["Title"]       = "未查询到数据";
                    dr["PublishDate"] = "";
                    dr["ViewsCounts"] = "";
                    dr["Keyword"]     = "";
                    dr["Region"]      = "";
                    dr["Url"]         = "";
                    dt.Rows.Add(dr);
                }
            }
            catch (Exception ex)
            {
                throw ex;
                //DataRow dr = dt.NewRow();
                //dr["Title"] = "Error in ProcessRequest():" + ex.Message;
                //dr["PublishDate"] = "";
                //dr["ViewsCounts"] = "";
                //dr["Keyword"] = "";
                //dr["Region"] = "";
                //dr["Url"] = "";
                //dt.Rows.Add(dr);
            }

            if (func == "1")  //导出excel
            {
                ExportToExcelHelper eteh = new ExportToExcelHelper();
                eteh.ExportToExcel(dt, "IndustryResult.xls", "[监测管理] -> [行业监测]");
            }
            else
            {
                context.Response.Write(JsonConvert.SerializeObject(dt));
            }
        }
示例#16
0
        public DataTable RealTimeMonitor(HttpContext context, int level)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            string regionid    = context.Request.QueryString["regionid"];
            string keyword     = context.Request.QueryString["keyword"];
            string website     = context.Request.QueryString["website"];
            string searchLevel = context.Request.QueryString["sl"];
            string func        = context.Request.QueryString["func"];

            if (regionid == "" || regionid.Contains("-1"))
            {
                GetRegionIdHelper grih = new GetRegionIdHelper();
                regionid = grih.GetRegionID();
            }

            //keyword = System.Web.HttpUtility.UrlDecode(keyword);
            DataTable dt = new DataTable();

            dt.Columns.Add("Title");
            dt.Columns.Add("PublishDate");
            dt.Columns.Add("ViewsCounts");
            dt.Columns.Add("Region");
            dt.Columns.Add("RegionID");
            dt.Columns.Add("MonitorUrl");
            dt.Columns.Add("Keyword");
            dt.Columns.Add("Url");

            SM.YuQing.BLL.RealTimeMonitorHelper rtmh = new SM.YuQing.BLL.RealTimeMonitorHelper();

            try
            {
                if (website != "")
                {
                    //dt = RemoveCommonRecord(rtmh.GetDataRows(dt, website, keyword, null, null));

                    //searchLevel 搜索级别
                    if (searchLevel == "1")
                    {
                        dt = rtmh.GetDataRows(dt, website, keyword, null, null);
                    }
                    else if (searchLevel == "2")
                    {
                        dt = rtmh.GetData(dt, website, keyword, null, null);
                    }
                }
                else
                {
                    string[] regs = regionid.Split(',');
                    foreach (string reg in regs)
                    {
                        SM.YuQing.BLL.Regions   regionBll = new SM.YuQing.BLL.Regions();
                        SM.YuQing.Model.Regions region    = regionBll.GetModel(Convert.ToInt32(reg.Trim()));

                        SM.YuQing.BLL.MonitorWebs          webBll  = new SM.YuQing.BLL.MonitorWebs();
                        List <SM.YuQing.Model.MonitorWebs> webList = webBll.GetModelList("RegionID=" + reg.Trim());
                        foreach (SM.YuQing.Model.MonitorWebs web in webList)
                        {
                            if (web.Status == "启用")
                            {
                                if (searchLevel == "1")
                                {
                                    dt = rtmh.GetDataRows(dt, web.Url, keyword, region, web);
                                }
                                else if (searchLevel == "2")
                                {
                                    dt = rtmh.GetData(dt, web.Url, keyword, region, web);
                                }
                            }
                        }
                    }
                }

                if (dt.Rows.Count == 0)
                {
                    DataRow dr = dt.NewRow();
                    dr["Title"]       = "未匹配到关键字“" + keyword + "”";
                    dr["PublishDate"] = "";
                    dr["ViewsCounts"] = "";
                    dr["Region"]      = "";
                    dr["RegionID"]    = "";
                    dr["MonitorUrl"]  = "";
                    dr["Keyword"]     = "";
                    dr["Url"]         = "";
                    dt.Rows.Add(dr);
                }
                else
                {
                    //DataTable去重
                    int rowsCount = dt.Rows.Count;
                    for (int i = 0; i < rowsCount - 1; i++)
                    {
                        for (int j = i + 1; j < rowsCount;)
                        {
                            if (dt.Rows[i]["Url"].ToString() == dt.Rows[j]["Url"].ToString())
                            {
                                dt.Rows.RemoveAt(j);
                                rowsCount--;
                                dt.AcceptChanges();
                            }
                            else
                            {
                                j++;
                            }
                        }
                    }

                    if (func != "1")
                    {
                        //写入数据库
                        rtmh.RecordToDatabase(dt, context.User.Identity.Name);

                        //写入日志Log
                        SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                        log.LogType    = "实时监测";
                        log.Message    = "本次共新增 " + dt.Rows.Count.ToString() + " 条数据";
                        log.IP         = context.Request.UserHostAddress;
                        log.MenuID     = 0;
                        log.PersonID   = 0;
                        log.CreateTime = DateTime.Now;
                        SM.YuQing.BLL.Log logBll = new SM.YuQing.BLL.Log();
                        logBll.Add(log);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
                //DataRow dr = dt.NewRow();
                //dr["Title"] = "Error in ProcessRequest():" + ex.Message;
                //dr["PublishDate"] = "";
                //dr["ViewsCounts"] = "";
                //dr["Region"] = "";
                //dr["RegionID"] = "";
                //dr["MonitorUrl"] = "";
                //dr["Keyword"] = "";
                //dr["Url"] = "";
                //dt.Rows.Add(dr);
            }

            if (func == "1")  //导出excel
            {
                ExportToExcelHelper eteh = new ExportToExcelHelper();
                eteh.ExportToExcel(dt, "RealTimeResult.xls", "[监测管理] -> [实时监测]");
            }
            else
            {
                context.Response.Write(JsonConvert.SerializeObject(dt));
            }
            return(dt);
        }
示例#17
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            string regionid  = context.Request.QueryString["RegionId"];
            string beginDate = context.Request.QueryString["beginDate"];
            string endDate   = context.Request.QueryString["endDate"];
            string func      = context.Request.QueryString["func"];

            if (regionid == "" || regionid.Contains("-1"))
            {
                GetRegionIdHelper grih = new GetRegionIdHelper();
                regionid = grih.GetRegionID();
            }

            DataTable dt = new DataTable();

            dt.Columns.Add("Region");
            dt.Columns.Add("Positive");
            dt.Columns.Add("Negative");
            dt.Columns.Add("Neutral");
            dt.Columns.Add("Empty");
            dt.Columns.Add("Total");

            try
            {
                string    strWhere     = "";
                ArrayList strWhereList = new ArrayList();

                //strWhereList.Add(" RegionID in (" + regionid + ")");
                //strWhereList.Add(" Keyword like \'SM\'");

                if (beginDate != "" && endDate != "")
                {
                    if (regionid != "")
                    {
                        string[] regs = regionid.Split(',');
                        foreach (string regid in regs)
                        {
                            strWhere = " PublishDate>=\'" + beginDate + "\' and PublishDate<=\'" + endDate + " 23:59:59.999\'" + " and RegionID=" + regid;
                            SM.YuQing.BLL.Regions   regionBll = new SM.YuQing.BLL.Regions();
                            SM.YuQing.Model.Regions region    = regionBll.GetModel(Convert.ToInt32(regid));
                            dt = GetDataRow(dt, null, region.Mall, strWhere);
                        }
                    }
                    else
                    {
                        SM.YuQing.BLL.Regions          regionBll  = new SM.YuQing.BLL.Regions();
                        List <SM.YuQing.Model.Regions> regionList = regionBll.GetModelList("");
                        foreach (SM.YuQing.Model.Regions region in regionList)
                        {
                            strWhere = " PublishDate>=\'" + beginDate + "\' and PublishDate<=\'" + endDate + " 23:59:59.999\'" + " and RegionID=" + region.ID;
                            dt       = GetDataRow(dt, region, "", strWhere);
                        }
                    }
                }
                else
                {
                    if (regionid != "")
                    {
                        string[] regs = regionid.Split(',');
                        foreach (string regid in regs)
                        {
                            SM.YuQing.BLL.Regions   regionBll = new SM.YuQing.BLL.Regions();
                            SM.YuQing.Model.Regions region    = regionBll.GetModel(Convert.ToInt32(regid));
                            dt = GetDataRow(dt, null, region.Mall, " RegionID=" + regid);
                        }
                    }
                    else
                    {
                        SM.YuQing.BLL.Regions          regionBll  = new SM.YuQing.BLL.Regions();
                        List <SM.YuQing.Model.Regions> regionList = regionBll.GetModelList("");
                        foreach (SM.YuQing.Model.Regions region in regionList)
                        {
                            dt = GetDataRow(dt, region, "", " RegionID=" + region.ID.ToString());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
                //DataRow dr = dt.NewRow();
                //dr["Region"] = "Error in ProcessRequest():" + ex.Message; ;
                //dr["Positive"] = "";
                //dr["Negative"] = "";
                //dr["Neutral"] = "";
                //dr["Empty"] = "";
                //dr["Total"] = "";
                //dt.Rows.Add(dr);
            }

            if (func == "1")  //导出excel
            {
                ExportToExcelHelper eteh = new ExportToExcelHelper();
                eteh.ExportToExcel(dt, "StatisticsResult.xls", "[监测管理] -> [监测性质统计表]");
            }
            else
            {
                context.Response.Write(JsonConvert.SerializeObject(dt));
            }
        }
示例#18
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            string regionid = context.Request.QueryString["regionid"];
            string status   = context.Request.QueryString["status"];

            DataTable dt = new DataTable();

            dt.Columns.Add("ID");
            dt.Columns.Add("Url");
            dt.Columns.Add("Name");
            dt.Columns.Add("Region");
            dt.Columns.Add("Status");

            try
            {
                string    strWhere     = "";
                ArrayList strWhereList = new ArrayList();

                if (regionid != "" && regionid != null)
                {
                    strWhereList.Add("  RegionID=" + regionid);
                }
                else
                {
                    SM.YuQing.Accounts.SiteIdentity identity = (SM.YuQing.Accounts.SiteIdentity)(new SM.YuQing.Accounts.AccountsPrincipal(context.User.Identity.Name)).Identity;
                    string personid = identity.FID.ToString();
                    SM.YuQing.BLL.Regions regbll = new SM.YuQing.BLL.Regions();
                    regionid = regbll.GetRegionIdByPersonID(personid);
                    strWhereList.Add(" RegionID in (" + regionid + ")");
                }
                if (status != "" && status != null)
                {
                    strWhereList.Add(" Status=N\'" + status + "\'");
                }

                switch (strWhereList.Count)
                {
                case 1:
                    strWhere = strWhereList[0].ToString();
                    break;

                case 2:
                    strWhere = strWhereList[0].ToString() + " and " + strWhereList[1].ToString();
                    break;

                default:
                    break;
                }

                SM.YuQing.BLL.MonitorWebs          webBll  = new SM.YuQing.BLL.MonitorWebs();
                List <SM.YuQing.Model.MonitorWebs> webList = webBll.GetModelList(strWhere);
                foreach (SM.YuQing.Model.MonitorWebs web in webList)
                {
                    DataRow dr = dt.NewRow();
                    dr["ID"]   = web.ID;
                    dr["Url"]  = web.Url;
                    dr["Name"] = web.Name;
                    SM.YuQing.BLL.Regions   regionBll = new SM.YuQing.BLL.Regions();
                    SM.YuQing.Model.Regions region    = regionBll.GetModel(web.RegionID);
                    dr["Region"] = region.Region;
                    dr["Status"] = web.Status;
                    dt.Rows.Add(dr);
                }

                if (dt.Rows.Count == 0)
                {
                    DataRow dr = dt.NewRow();
                    dr["ID"]     = "";
                    dr["Url"]    = "未查询到数据";
                    dr["Name"]   = "";
                    dr["Region"] = "";
                    dr["Status"] = "";
                    dt.Rows.Add(dr);
                }

                context.Response.Write(JsonConvert.SerializeObject(dt));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#19
0
        public void ExportToExcel()
        {
            string beginDate = Request.QueryString["beginDate"];
            string endDate   = Request.QueryString["endDate"];
            string regionid  = Request.QueryString["RegionId"];

            DataTable dt = new DataTable();

            dt.Columns.Add("Region");
            dt.Columns.Add("Positive");
            dt.Columns.Add("Negative");
            dt.Columns.Add("Neutral");
            dt.Columns.Add("Empty");
            dt.Columns.Add("Total");

            try
            {
                string strWhere = "";

                if (beginDate != "" && endDate != "")
                {
                    strWhere = " PublishDate>=\'" + beginDate + "\' and PublishDate<=\'" + endDate + " 23:59:59.999\'";
                    if (regionid != "")
                    {
                        string[] regs = regionid.Split(',');
                        foreach (string regid in regs)
                        {
                            strWhere += " and RegionID=" + regid;
                            SM.YuQing.BLL.Regions   regionBll = new SM.YuQing.BLL.Regions();
                            SM.YuQing.Model.Regions region    = regionBll.GetModel(Convert.ToInt32(regid));
                            dt = GetDataRow(dt, null, region.Mall, strWhere);
                        }
                    }
                    else
                    {
                        SM.YuQing.BLL.Regions          regionBll  = new SM.YuQing.BLL.Regions();
                        List <SM.YuQing.Model.Regions> regionList = regionBll.GetModelList("");
                        foreach (SM.YuQing.Model.Regions region in regionList)
                        {
                            strWhere += " and RegionID=" + region.ID;
                            dt        = GetDataRow(dt, region, "", strWhere);
                        }
                    }
                }
                else
                {
                    if (regionid != "")
                    {
                        string[] regs = regionid.Split(',');
                        foreach (string regid in regs)
                        {
                            SM.YuQing.BLL.Regions   regionBll = new SM.YuQing.BLL.Regions();
                            SM.YuQing.Model.Regions region    = regionBll.GetModel(Convert.ToInt32(regid));
                            dt = GetDataRow(dt, null, region.Mall, " RegionID=" + regid);
                        }
                    }
                    else
                    {
                        SM.YuQing.BLL.Regions          regionBll  = new SM.YuQing.BLL.Regions();
                        List <SM.YuQing.Model.Regions> regionList = regionBll.GetModelList("");
                        foreach (SM.YuQing.Model.Regions region in regionList)
                        {
                            dt = GetDataRow(dt, region, "", " RegionID=" + region.ID.ToString());
                        }
                    }
                }

                Response.Clear();
                Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", "StatisticsResult.xls"));
                Response.ContentType = "application/ms-excel";

                MemoryStream ms        = new MemoryStream();
                Workbook     workbook  = new Workbook();
                Worksheet    worksheet = new Worksheet("Sheet1");

                if (dt.Rows.Count < 30)
                {
                    for (int i = 0; i < 30; i++)
                    {
                        DataRow dr = dt.NewRow();
                        dr["Region"]   = "";
                        dr["Positive"] = "";
                        dr["Negative"] = "";
                        dr["Neutral"]  = "";
                        dr["Empty"]    = "";
                        dr["Total"]    = "";
                        dt.Rows.Add(dr);
                    }
                }

                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    worksheet.Cells[0, i] = new Cell(dt.Columns[i].ColumnName);
                }

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        worksheet.Cells[i + 1, j] = new Cell(dt.Rows[i][j].ToString());
                    }
                }

                workbook.Worksheets.Add(worksheet);
                workbook.SaveToStream(ms);
                Response.BinaryWrite(ms.ToArray());
                Response.Flush();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }