示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Buffer = true;
            Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
            Response.Expires = 0;
            Response.CacheControl = "no-cache";
            /*          if (Session["Photo"] != null && Session["PhotoType"] != null)
            {*/
            int id = Convert.ToInt32(Request.QueryString.Get("ID"));
            if (id != 0)
            {
                CQGJEntities CQGJ = new CQGJEntities();
                Teacher teacher = (from c in CQGJ.Teacher
                                   where c.TeacherID == id
                                   select c).First();
                if (teacher.PhotoType != null || teacher.Photo != null)
                {
                    Response.ContentType = teacher.PhotoType;
                    byte[] PhotoArray = (byte[])teacher.Photo;
                    Response.BinaryWrite(PhotoArray);
                    Response.End();
                }
                else
                {

                }
            }
            else
            {
                byte[] PhotoArray = (byte[])Session["Photo"];
                string strPhotoType = Session["PhotoType"].ToString();
                Response.ContentType = strPhotoType;
                Response.BinaryWrite(PhotoArray);
                Response.End();
            }
            /*
                byte[] PhotoArray = (byte[])Session["Photo"];
                string strPhotoType = Session["PhotoType"].ToString();
                Response.ContentType = strPhotoType;
                Response.BinaryWrite(PhotoArray);*/

               //         }
        }
示例#2
0
            public override void OnActionExecuting(FilterExecutingContext filterContext)
            {
                CQGJEntities CQGJ = new CQGJEntities();
                if (filterContext.Controller is ControllerBase)
                {
                    var b = filterContext.Controller as ControllerBase;
                    if (b != null)
                    {
                        string ip = b.HttpContext.Request.UserHostAddress;
                        string url = b.HttpContext.Request.RawUrl;
                        string refer = b.HttpContext.Request.UrlReferrer.OriginalString;

                        //Uri u = b.HttpContext.Request.UrlReferrer;
                        DateTime temp = DateTime.Now.AddDays(-1);
                        var query = from s in CQGJ.Statistic
                                    where s.IP == ip && s.AddTime.Value >= temp
                                    select s;
                        if (query.Count() >= 1)
                        {
                            Statistic statistic = query.First();
                            statistic.LocalUrl = url;
                            statistic.ReferingUrl = refer;
                            statistic.UpdateTime = DateTime.Now;
                            CQGJ.SaveChanges();
                        }
                        else
                        {
                            Statistic statistic = new Statistic();
                            statistic.Hits = 1;
                            statistic.ReferingUrl = refer;
                            statistic.LocalUrl = url;
                            statistic.IP = ip;
                            statistic.AddTime = DateTime.Now;
                            CQGJ.AddToStatistic(statistic);
                            CQGJ.SaveChanges();
                        }
                    }
                }
                base.OnActionExecuting(filterContext);
            }
示例#3
0
        public void SetFlashPic()
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(System.AppDomain.CurrentDomain.BaseDirectory + "/content/bcastr.xml");

            XmlNodeList nodeList = xmlDoc.SelectSingleNode("bcaster").ChildNodes;
            XmlNode xmldocSelect = xmlDoc.SelectSingleNode("bcaster");
            XmlNode Father = xmlDoc.SelectSingleNode("bcaster");
            Father.RemoveAll();

            CQGJEntities cqgje = new CQGJEntities();
            var qurrey = from n in cqgje.News where n.Content.Contains("<img ") select n;
            List<News> newslisttemp = new List<News>();
            if (qurrey != null)
            {
                newslisttemp = qurrey.ToList();
                List<News> newslisttemp2 = qurrey.ToList();
                for (int j = 0; j < qurrey.Count(); ++j)
                {

                    string str = GetImageSRC(newslisttemp2[j].Content);
                    if (str.Contains("http://"))
                    {
                        if (!str.Contains(Request.Url.Host))
                        {
                            newslisttemp.Remove(newslisttemp2[j]);
                        }
                    }
                }
                List<News> newslist = newslisttemp;
                for (int i = 0; i < newslist.Count; ++i)
                {
                    try
                    {
                        string strContent = newslist[i].Content;
                        string strImgSRC = GetImageSRC(strContent);
                        string strURL = "/home/Article/" + newslist[i].NewsID.ToString();
                        string strTitle = newslist[i].Title;
                        if (strTitle.Length > 14)
                        {
                            strTitle = strTitle.Substring(0, 12) + "...";
                        }
                        XmlElement el = xmlDoc.CreateElement("item");
                        el.SetAttribute("item_url", strImgSRC);
                        el.SetAttribute("link", strURL);
                        el.SetAttribute("itemtitle", strTitle);
                        xmldocSelect.AppendChild(el);
                    }
                    catch
                    {
                    }
                }
                xmlDoc.Save(System.AppDomain.CurrentDomain.BaseDirectory + "/content/bcastr.xml");
            }
        }