예제 #1
0
        public string GetRegionID()
        {
            SM.YuQing.Accounts.SiteIdentity identity = (SM.YuQing.Accounts.SiteIdentity)(new SM.YuQing.Accounts.AccountsPrincipal(HttpContext.Current.User.Identity.Name)).Identity;
            string personid = identity.FID.ToString();

            SM.YuQing.BLL.Regions regbll = new SM.YuQing.BLL.Regions();
            return(regbll.GetRegionIdByPersonID(personid));
        }
예제 #2
0
        public void ExportToExcel(DataTable dt, string fileName, string menuName)
        {
            try
            {
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", fileName));
                HttpContext.Current.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++)
                    {
                        dt.Rows.Add(dt.NewRow());
                    }
                }

                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);
                HttpContext.Current.Response.BinaryWrite(ms.ToArray());
                HttpContext.Current.Response.Flush();

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

                SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                log.LogType    = "操作";
                log.Message    = HttpContext.Current.User.Identity.Name + " 在 " + menuName + " 导出了Excel";
                log.IP         = HttpContext.Current.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);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
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));
        }
예제 #4
0
        public void ProcessRequest(HttpContext context)
        {
            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;
            string personid = identity.FID.ToString();

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

            SM.YuQing.BLL.Regions bll = new SM.YuQing.BLL.Regions();
            //DataTable dt = bll.GetAllList().Tables[0];
            List <SM.YuQing.Model.Regions> lst = bll.GetModelList(" ID in (" + regionid + ")");

            context.Response.Write(JsonConvert.SerializeObject(lst));
        }
예제 #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            string id       = context.Request.QueryString["id"];
            string property = context.Request.Form["property"];
            bool   success;

            SM.YuQing.BLL.MonitorInfos   bll         = new SM.YuQing.BLL.MonitorInfos();
            SM.YuQing.Model.MonitorInfos monitorInfo = bll.GetModel(Convert.ToInt32(id));
            string oldProperty = monitorInfo.Property;

            monitorInfo.Property     = property;
            monitorInfo.UpdatePerson = context.User.Identity.Name;
            monitorInfo.UpdateTime   = DateTime.Now;

            success = bll.Update(monitorInfo);

            Hashtable ht = new Hashtable();

            if (success)
            {
                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.Model.Log log = new SM.YuQing.Model.Log();
                log.LogType    = "操作";
                log.Message    = context.User.Identity.Name + " 保存了ID=" + id + "的监测记录的性质为 " + property + " (原性质为 " + (oldProperty == "" ? "空" : oldProperty) + " )";
                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", "Some errors occured.");
            }
            context.Response.Write(JsonConvert.SerializeObject(ht));
        }
예제 #6
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.MonitorWebs   bll = new SM.YuQing.BLL.MonitorWebs();
            SM.YuQing.Model.MonitorWebs web = bll.GetModel(Convert.ToInt32(id));
            string url = web.Url, name = web.Name;

            bool      success = bll.Delete(Convert.ToInt32(id));
            Hashtable ht = new Hashtable();

            if (success)
            {
                SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                log.LogType    = "操作";
                log.Message    = context.User.Identity.Name + " 删除了网站 " + url + "(" + name + ")";;
                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", "Some errors occured.");
            }
            context.Response.Write(JsonConvert.SerializeObject(ht));
        }
예제 #7
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));
        }
예제 #8
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));
        }
예제 #9
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;
            }
        }
예제 #10
0
        public void ProcessRequest(HttpContext context)
        {
            string id       = context.Request.QueryString["id"];
            string Url      = context.Request.Form["Url"];
            string Name     = context.Request.Form["Name"];
            string RegionID = context.Request.Form["RegionID"];
            string Status   = context.Request.Form["Status"];
            string errMsg   = "";
            bool   success;

            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;

            if (id == null) //新增
            {
                SM.YuQing.BLL.MonitorWebs bll = new SM.YuQing.BLL.MonitorWebs();
                if (!bll.ExistWeb(Convert.ToInt32(RegionID), Url, Status))
                {
                    SM.YuQing.Model.MonitorWebs web = new SM.YuQing.Model.MonitorWebs();
                    web.Url          = Url;
                    web.Name         = Name;
                    web.RegionID     = Convert.ToInt32(RegionID);
                    web.Status       = Status;
                    web.CreatePerson = context.User.Identity.Name;
                    web.CreateTime   = DateTime.Now;
                    web.UpdatePerson = context.User.Identity.Name;
                    web.UpdateTime   = DateTime.Now;

                    success = bll.Add(web);
                    if (success)
                    {
                        SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                        log.LogType    = "操作";
                        log.Message    = context.User.Identity.Name + " 新增了网站 " + Url + "(" + Name + ")";
                        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.BLL.MonitorWebs   bll = new SM.YuQing.BLL.MonitorWebs();
                SM.YuQing.Model.MonitorWebs web = bll.GetModel(Convert.ToInt32(id));
                string oldUrl = web.Url, oldName = web.Name, oldRegionID = web.RegionID.ToString(), oldStatus = web.Status;

                web.Url      = Url;
                web.Name     = Name;
                web.RegionID = Convert.ToInt32(RegionID);
                web.Status   = Status;

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

                if (oldUrl == Url && oldName == Name && oldRegionID == RegionID && oldStatus == Status)
                {
                    success = false;
                    errMsg  = "您未修改任何信息";
                }
                else if (oldUrl == Url && oldName != Name && oldRegionID == RegionID && oldStatus == Status)
                {
                    success = bll.Update(web);
                }
                else if (!bll.ExistWeb(Convert.ToInt32(RegionID), Url, Status))
                {
                    success = bll.Update(web);
                }
                else
                {
                    success = false;
                    errMsg  = "该网址已存在于此区域中!";
                }

                if (success)
                {
                    SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                    log.LogType    = "操作";
                    log.Message    = context.User.Identity.Name + " 修改了ID=" + id + "的网站信息" + " | " + (oldUrl == Url ? "" : (oldUrl + " -> " + Url + " | ")) + (oldName == Name ? "" : (oldName + " -> " + Name + " | ")) + (oldRegionID == RegionID ? "" : ("RegionID: " + oldRegionID + " -> " + RegionID + " | ")) + (oldStatus == Status ? "" : (oldStatus + " -> " + Status + " | "));
                    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 if (!success && errMsg == "")
                {
                    errMsg = "some error occured.";
                }
            }

            Hashtable ht = new Hashtable();

            if (success)
            {
                ht.Add("success", true);
            }
            else
            {
                ht.Add("errorMsg", errMsg);
            }
            context.Response.Write(JsonConvert.SerializeObject(ht));
        }