public JsonResult GetInfo(string ID)
        {
            Sys_AdvertisingXmlHelper xh     = new Sys_AdvertisingXmlHelper(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/"));
            Sys_Advertising          Rmodel = xh.GetItemById(ID);

            //  groupsBiz.Add(rol);
            return(Json(Rmodel, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public JsonResult GetInfo(string ID)
        {
            var             mql2   = Sys_AdvertisingSet.SelectAll().Where(Sys_AdvertisingSet.Id.Equal(ID));
            Sys_Advertising Rmodel = OPBiz.GetEntity(mql2);

            //  groupsBiz.Add(rol);
            return(MyJson(Rmodel, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public JsonResult EditInfo(Sys_Advertising Sys_AdvertisingModle)
        {
            HttpReSultMode ReSultMode = new HttpReSultMode();
            bool           IsAdd      = false;

            Sys_AdvertisingModle.UpdateTime = DateTime.Now;
            if (Sys_AdvertisingModle.Id == 0)//id为空,是添加
            {
                IsAdd = true;
                Sys_AdvertisingModle.AddTime = DateTime.Now;
            }
            if (IsAdd)
            {
                Sys_AdvertisingModle.isDeleted = false;
                try
                {
                    OPBiz.Add(Sys_AdvertisingModle);

                    ReSultMode.Code = 11;
                    ReSultMode.Data = Sys_AdvertisingModle.Id.ToString();
                    ReSultMode.Msg  = "添加成功";
                }
                catch (Exception e)
                {
                    ReSultMode.Code = -11;
                    ReSultMode.Data = e.ToString();
                    ReSultMode.Msg  = "添加失败";
                }
            }
            else
            {
                Sys_AdvertisingModle.WhereExpression = Sys_AdvertisingSet.Id.Equal(Sys_AdvertisingModle.Id);
                Sys_AdvertisingModle.ChangedMap.Remove("id");//移除主键值
                if (OPBiz.Update(Sys_AdvertisingModle) > 0)
                {
                    ReSultMode.Code = 11;
                    ReSultMode.Data = "";
                    ReSultMode.Msg  = "修改成功";
                }
                else
                {
                    ReSultMode.Code = -13;
                    ReSultMode.Data = "";
                    ReSultMode.Msg  = "修改失败";
                }
            }

            return(Json(ReSultMode, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 根据分类获取
        /// </summary>
        /// <returns></returns>
        public List <Sys_Advertising> GetByCategory(string Category)
        {
            List <Sys_Advertising> list = new List <Sys_Advertising>();

            if (xmlDoc != null && root != null)
            {
                XmlNodeList nodeList = xmlDoc.SelectSingleNode("root").ChildNodes;

                // 遍历根节点下所有子节点
                foreach (XmlNode node in nodeList)
                {
                    if (node["Category"].InnerText == Category)
                    {
                        Sys_Advertising item = new Sys_Advertising();
                        item.Id       = int.Parse(node["Id"].InnerText);
                        item.ImageUrl = node["ImageUrl"].InnerText;
                        item.Title    = node["Title"].InnerText;
                        item.Category = node["Category"].InnerText;
                        if (node["UpdateTime"].InnerText != "")
                        {
                            item.UpdateTime = Convert.ToDateTime(node["UpdateTime"].InnerText);
                        }
                        else
                        {
                            item.UpdateTime = DateTime.Now;
                        }
                        if (node["AddTime"].InnerText != "")
                        {
                            item.AddTime = Convert.ToDateTime(node["AddTime"].InnerText);
                        }
                        else
                        {
                            item.AddTime = DateTime.Now;
                        }
                        item.Details = node["Details"].InnerText;
                        item.Url     = node["Url"].InnerText;
                        if (node["States"].InnerText != "")
                        {
                            item.States = Convert.ToInt32(node["States"].InnerText);
                        }
                        list.Add(item);
                    }
                }
            }

            return(list);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="item"></param>
        public int Update(Sys_Advertising item)
        {
            int rs = 0;

            if (xmlDoc != null && root != null)
            {
                try
                {
                    XmlNodeList nodeList = xmlDoc.SelectSingleNode("root").ChildNodes;

                    for (int i = nodeList.Count - 1; i >= 0; i--)
                    {
                        XmlNode node = nodeList[i];
                        if (node["Id"].InnerText == item.Id.ToString().Trim())
                        {
                            node["ImageUrl"].InnerText   = item.ImageUrl;
                            node["Title"].InnerText      = item.Title;
                            node["Category"].InnerText   = item.Category;
                            node["UpdateTime"].InnerText = item.UpdateTime.ToString();
                            node["Details"].InnerText    = item.Details;
                            node["Url"].InnerText        = item.Url;
                            node["States"].InnerText     = item.States.ToString();
                            node["UpdateTime"].InnerText = item.UpdateTime.ToString();
                            //保存文件
                            xmlDoc.Save(filePath);
                            rs = 1;
                            break;
                        }
                    }
                }
                catch
                {
                    rs = -1;
                }
            }

            return(rs);
        }
        public JsonResult EditInfo(Sys_Advertising Sys_AdvertisingModle)
        {
            Sys_AdvertisingXmlHelper xh = new Sys_AdvertisingXmlHelper(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/"));
            bool IsAdd = false;

            if (Sys_AdvertisingModle.Details != null)
            {
                Sys_AdvertisingModle.Details = Sys_AdvertisingModle.Details.Replace("&lt", "<").Replace("&gt", ">");
            }
            if (Sys_AdvertisingModle.States == null)
            {
                Sys_AdvertisingModle.States = 1;
            }
            if (Sys_AdvertisingModle.Id == 0)//id为空,是添加
            {
                IsAdd = true;
            }
            if (IsAdd)
            {
                Sys_AdvertisingModle.UpdateTime = DateTime.Now;
                Sys_AdvertisingModle.AddTime    = DateTime.Now;
                xh.Add(Sys_AdvertisingModle);
                return(Json("ok", JsonRequestBehavior.AllowGet));
            }
            else
            {
                Sys_AdvertisingModle.UpdateTime = DateTime.Now;
                if (xh.Update(Sys_AdvertisingModle) > 0)
                {
                    return(Json("ok", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json("Nok", JsonRequestBehavior.AllowGet));
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 添加一条信息
        /// </summary>
        /// <param name="item"></param>
        /// <returns>1添加成功  否则添加失败</returns>
        public int Add(Sys_Advertising item)
        {
            int rs = 0;

            if (xmlDoc != null && root != null)
            {
                try
                {
                    //创建一个节点
                    XmlNode node = xmlDoc.CreateElement("Data");

                    //创建各元素
                    XmlElement Id = xmlDoc.CreateElement("Id");
                    Id.InnerText = item.Id.ToString();
                    node.AppendChild(Id);
                    XmlElement ImageUrl = xmlDoc.CreateElement("ImageUrl");
                    ImageUrl.InnerText = item.ImageUrl;
                    node.AppendChild(ImageUrl);

                    XmlElement Category = xmlDoc.CreateElement("Category");
                    Category.InnerText = item.Category;
                    node.AppendChild(Category);

                    XmlElement Title = xmlDoc.CreateElement("Title");
                    Title.InnerText = item.Title;
                    node.AppendChild(Title);

                    XmlElement Details = xmlDoc.CreateElement("Details");
                    Details.InnerText = item.Details;
                    node.AppendChild(Details);

                    XmlElement Url = xmlDoc.CreateElement("Url");
                    Url.InnerText = item.Url;
                    node.AppendChild(Url);

                    XmlElement AddTime = xmlDoc.CreateElement("AddTime");
                    AddTime.InnerText = item.AddTime.ToString();
                    node.AppendChild(AddTime);


                    XmlElement UpdateTime = xmlDoc.CreateElement("UpdateTime");
                    UpdateTime.InnerText = item.UpdateTime.ToString();
                    node.AppendChild(UpdateTime);

                    XmlElement States = xmlDoc.CreateElement("States");
                    States.InnerText = item.States.ToString();
                    node.AppendChild(States);

                    //将节点添加到根节点
                    root.AppendChild(node);

                    //保存文件
                    xmlDoc.Save(filePath);
                    rs = 1;
                }
                catch
                {
                    rs = -1;
                }
            }

            return(rs);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取一条记录
        /// </summary>
        /// <returns></returns>
        public Sys_Advertising GetItemById(string Id)
        {
            Sys_Advertising item = null;

            try
            {
                if (xmlDoc != null && root != null)
                {
                    XmlNodeList nodeList = xmlDoc.SelectSingleNode("root").ChildNodes;

                    foreach (XmlNode node in nodeList)
                    {
                        if (string.IsNullOrEmpty(Id))
                        {
                            item          = new Sys_Advertising();
                            item.Id       = int.Parse(node["Id"].InnerText);
                            item.ImageUrl = node["ImageUrl"].InnerText;
                            item.Title    = node["Title"].InnerText;
                            item.Category = node["Category"].InnerText;
                            if (node["UpdateTime"].InnerText != "")
                            {
                                item.UpdateTime = Convert.ToDateTime(node["UpdateTime"].InnerText);
                            }
                            else
                            {
                                item.UpdateTime = DateTime.Now;
                            }
                            if (node["AddTime"].InnerText != "")
                            {
                                item.AddTime = Convert.ToDateTime(node["AddTime"].InnerText);
                            }
                            else
                            {
                                item.AddTime = DateTime.Now;
                            }
                            item.Details = node["Details"].InnerText;
                            item.Url     = node["Url"].InnerText;
                            if (node["States"].InnerText != "")
                            {
                                item.States = Convert.ToInt32(node["States"].InnerText);
                            }
                            break;
                        }
                        else if (node["Id"].InnerText == Id)
                        {
                            item          = new Sys_Advertising();
                            item.Id       = int.Parse(node["Id"].InnerText);
                            item.ImageUrl = node["ImageUrl"].InnerText;
                            item.Title    = node["Title"].InnerText;
                            item.Category = node["Category"].InnerText;
                            if (node["UpdateTime"].InnerText != "")
                            {
                                item.UpdateTime = Convert.ToDateTime(node["UpdateTime"].InnerText);
                            }
                            else
                            {
                                item.UpdateTime = DateTime.Now;
                            }
                            if (node["AddTime"].InnerText != "")
                            {
                                item.AddTime = Convert.ToDateTime(node["AddTime"].InnerText);
                            }
                            else
                            {
                                item.AddTime = DateTime.Now;
                            }
                            item.Details = node["Details"].InnerText;
                            item.Url     = node["Url"].InnerText;
                            if (node["States"].InnerText != "")
                            {
                                item.States = Convert.ToInt32(node["States"].InnerText);
                            }
                            break;
                        }
                    }
                }
            }
            catch
            { }

            return(item);
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            // context.Response.Write("Hello World");
            //  /httpSever/AdvertisingHandler.ashx?json={"jsonEntity":{"Category":"0201"},"action":"GetByCategory"}
            HttpReSultMode     resultMode = new HttpReSultMode();
            Sys_AdvertisingBiz OPBiz      = new Sys_AdvertisingBiz();

            try
            {
                JObject httpObject = JsonHelper.FromJson(context.Request["json"]);
                switch (httpObject["action"].ToString())
                {
                case "GetByCategory":
                    #region
                    List <Sys_Advertising> list = new List <Sys_Advertising>();
                    if (httpObject["jsonEntity"]["Category"] != null)    //分类
                    {
                        string Category = FilterTools.FilterSpecial(httpObject["jsonEntity"]["Category"].ToString());
                        var    sqlm     = Sys_AdvertisingSet.SelectAll().Where(Sys_AdvertisingSet.Category.Equal(Category).And(Sys_AdvertisingSet.States.Equal(1)).And(Sys_AdvertisingSet.isDeleted.Equal(0)));
                        list = OPBiz.GetEntities(sqlm);
                    }
                    else
                    {
                        var sqlm = Sys_AdvertisingSet.SelectAll().Where(Sys_AdvertisingSet.States.Equal(1).And(Sys_AdvertisingSet.isDeleted.Equal(0)));
                        list = OPBiz.GetEntities(sqlm);
                    }
                    if (list.Count > 0)
                    {
                        resultMode.Code = 11;
                        resultMode.Msg  = "获取成功";
                        resultMode.Data = JsonHelper.ToJson(list, true);
                    }
                    else
                    {
                        resultMode.Code = 0;
                        resultMode.Msg  = "没有数据";
                        resultMode.Data = "[]";
                    }
                    #endregion
                    break;


                case "GetById":
                    #region
                    string          IdG    = httpObject["jsonEntity"]["Id"].ToString();
                    var             sqlO   = Sys_AdvertisingSet.SelectAll().Where(Sys_AdvertisingSet.Id.Equal(IdG));
                    Sys_Advertising modelG = OPBiz.GetEntity(sqlO);
                    if (modelG != null)
                    {
                        resultMode.Code = 11;
                        resultMode.Msg  = "获取成功";
                        resultMode.Data = JsonHelper.ToJson(modelG, true);
                    }
                    else
                    {
                        resultMode.Code = -13;
                        resultMode.Msg  = "数据不存在";
                        resultMode.Data = "";
                    }
                    #endregion
                    break;
                }
            }
            catch (Exception ex)
            {
                resultMode.Code = -11;
                resultMode.Data = ex.ToString();
            }
            context.Response.Write(JsonHelper.ToJson(resultMode, true));
            context.Response.End();
        }