Example #1
0
 public void Save(Song.Entities.Columns entity)
 {
     using (DbTrans trans = Gateway.Default.BeginTrans())
     {
         try
         {
             trans.Save <Columns>(entity);
             //新闻,产品,图片,视频,下载
             trans.Update <Article>(new Field[] { Article._.Col_Name }, new object[] { entity.Col_Name }, Article._.Col_Id == entity.Col_ID);
             trans.Update <Product>(new Field[] { Product._.Col_Name }, new object[] { entity.Col_Name }, Product._.Col_Id == entity.Col_ID);
             trans.Update <Picture>(new Field[] { Picture._.Col_Name }, new object[] { entity.Col_Name }, Picture._.Col_Id == entity.Col_ID);
             trans.Update <Video>(new Field[] { Video._.Col_Name }, new object[] { entity.Col_Name }, Video._.Col_Id == entity.Col_ID);
             trans.Update <Download>(new Field[] { Download._.Col_Name }, new object[] { entity.Col_Name }, Download._.Col_Id == entity.Col_ID);
             trans.Commit();
         }
         catch (Exception ex)
         {
             trans.Rollback();
             throw ex;
         }
         finally
         {
             trans.Close();
         }
     }
 }
Example #2
0
        /// <summary>
        /// 添加栏目信息
        /// </summary>
        /// <param name="result"></param>
        private void _Add(string result)
        {
            if (result == "" || result == null)
            {
                return;
            }
            XmlDocument resXml = new XmlDocument();

            try
            {
                resXml.LoadXml(result, false);
                XmlNode node             = resXml.SelectSingleNode("node");
                int     id               = Convert.ToInt32(((XmlElement)node).Attributes["id"].Value);
                Song.Entities.Columns nc = new Song.Entities.Columns();
                nc.Col_Name   = ((XmlElement)node.SelectSingleNode("name")).InnerText;
                nc.Col_ByName = ((XmlElement)node.SelectSingleNode("byname")).InnerText;
                //父id
                int pid = 0;
                int.TryParse(((XmlElement)node.SelectSingleNode("pid")).InnerText, out pid);
                nc.Col_PID      = pid;
                nc.Col_Type     = ((XmlElement)node.SelectSingleNode("type")).InnerText;
                nc.Col_Title    = ((XmlElement)node.SelectSingleNode("title")).InnerText;
                nc.Col_Keywords = ((XmlElement)node.SelectSingleNode("keywords")).InnerText;
                nc.Col_Descr    = ((XmlElement)node.SelectSingleNode("desc")).InnerText;
                nc.Col_Intro    = ((XmlElement)node.SelectSingleNode("intro")).InnerText;
                nc.Col_IsUse    = Convert.ToBoolean(((XmlElement)node.SelectSingleNode("IsUse")).InnerText);
                nc.Col_IsNote   = Convert.ToBoolean(((XmlElement)node.SelectSingleNode("IsNote")).InnerText);
                //添加
                Business.Do <IColumns>().Add(nc);
            }
            catch
            {
            }
        }
Example #3
0
 public void ProductSave(Product entity)
 {
     Song.Entities.Columns nc = Business.Do <IColumns>().Single((int)entity.Col_Id);
     if (nc != null)
     {
         entity.Col_Name = nc.Col_Name;
     }
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Save <Product>(entity);
             //当更改产品信息时,同步更改产品留言的产品名称
             tran.Update <ProductMessage>(new Field[] { ProductMessage._.Pd_Name }, new object[] { entity.Pd_Name }, ProductMessage._.Pd_Id == entity.Pd_Id);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Example #4
0
 public void VideoSave(Video entity)
 {
     Song.Entities.Columns nc = Business.Do <IColumns>().Single((int)entity.Col_Id);
     if (nc != null)
     {
         entity.Col_Name = nc.Col_Name;
     }
     Gateway.Default.Save <Video>(entity);
 }
Example #5
0
 public void DownloadSave(Download entity)
 {
     if (entity.Col_Name == "")
     {
         Song.Entities.Columns nc = Business.Do <IColumns>().Single((int)entity.Col_Id);
         if (nc != null)
         {
             entity.Col_Name = nc.Col_Name;
         }
     }
     Gateway.Default.Save <Download>(entity);
 }
Example #6
0
        //获取单个栏目信息
        public string ColumnJson(int id)
        {
            Song.Entities.Columns nc = Business.Do <IColumns>().Single(id);
            Type info = nc.GetType();

            PropertyInfo[] properties = info.GetProperties();
            string         node       = "var node={";

            for (int i = 0; i < properties.Length; i++)
            {
                PropertyInfo pi = properties[i];
                //当前属性的值
                object obj = info.GetProperty(pi.Name).GetValue(nc, null);
                node += pi.Name + ":";
                if (obj == null)
                {
                    node += "\"\"";
                }
                else
                {
                    string type = obj.GetType().Name;
                    switch (obj.GetType().Name)
                    {
                    case "Boolean":
                        node += obj.ToString().ToLower();
                        break;

                    case "String":
                        node += "\"" + obj.ToString() + "\"";
                        break;

                    case "DateTime":
                        node += "\"" + obj.ToString() + "\"";
                        break;

                    default:
                        node += obj.ToString();
                        break;
                    }
                }
                if (i != properties.Length - 1)
                {
                    node += ",";
                }
                node += "\n";
            }
            node += "};";
            return(node);
        }
Example #7
0
 public int DownloadAdd(Download entity)
 {
     Song.Entities.Columns nc = Business.Do <IColumns>().Single((int)entity.Col_Id);
     if (nc != null)
     {
         entity.Col_Name = nc.Col_Name;
     }
     //所在机构
     Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent();
     if (org != null)
     {
         entity.Org_ID   = org.Org_ID;
         entity.Org_Name = org.Org_Name;
     }
     return(Gateway.Default.Save <Download>(entity));
 }
Example #8
0
 public int Add(Song.Entities.Columns entity)
 {
     entity.Col_CrtTime = DateTime.Now;
     //如果没有排序号,则自动计算
     if (entity.Col_Tax < 1)
     {
         object obj = Gateway.Default.Max <Columns>(Columns._.Col_Tax, Columns._.Col_PID == entity.Col_PID);
         entity.Col_Tax = obj is int?(int)obj + 1 : 0;
     }
     Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent();
     if (org != null)
     {
         entity.Org_ID   = org.Org_ID;
         entity.Org_Name = org.Org_Name;
     }
     return(Gateway.Default.Save <Columns>(entity));
 }
Example #9
0
        public int VideoAdd(Video entity)
        {
            //设置新对象的排序号
            object obj = Gateway.Default.Max <Video>(Video._.Vi_Tax, Video._.Vi_Tax > -1);

            entity.Vi_Tax = obj is int?(int)obj + 1 : 1;
            Song.Entities.Columns nc = Business.Do <IColumns>().Single((int)entity.Col_Id);
            if (nc != null)
            {
                entity.Col_Name = nc.Col_Name;
            }
            //所在机构
            Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent();
            if (org != null)
            {
                entity.Org_ID   = org.Org_ID;
                entity.Org_Name = org.Org_Name;
            }
            return(Gateway.Default.Save <Video>(entity));
        }
Example #10
0
        public int PictureAdd(Picture entity)
        {
            //设置新对象的排序号
            object obj = Gateway.Default.Max <Picture>(Picture._.Pic_Tax, Picture._.Col_Id == entity.Col_Id);

            entity.Pic_Tax = obj is int?(int)obj + 1 : 1;
            Song.Entities.Columns nc = Business.Do <IColumns>().Single((int)entity.Col_Id);
            if (nc != null)
            {
                entity.Col_Name = nc.Col_Name;
            }
            //所在机构
            Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent();
            if (org != null)
            {
                entity.Org_ID   = org.Org_ID;
                entity.Org_Name = org.Org_Name;
            }
            return(Gateway.Default.Save <Picture>(entity));
        }
Example #11
0
 public void SaveOrder(string xml)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             XmlDocument resXml = new XmlDocument();
             resXml.XmlResolver = null;
             resXml.LoadXml(xml, false);
             XmlNodeList nodeList = resXml.SelectSingleNode("nodes").ChildNodes;
             //取rootid
             XmlNode    nodes   = resXml.SelectSingleNode("nodes");
             XmlElement xenodes = (XmlElement)nodes;
             //遍历所有子节点
             foreach (XmlNode xn in nodeList)
             {
                 XmlElement            xe  = (XmlElement)xn;
                 int                   id  = Convert.ToInt32(xe.Attributes["id"].Value);
                 int                   pid = Convert.ToInt32(xe.Attributes["pid"].Value);
                 int                   tax = Convert.ToInt32(xe.Attributes["tax"].Value);
                 Song.Entities.Columns nc  = this.Single(id);
                 if (nc != null)
                 {
                     nc.Col_PID = pid;
                     nc.Col_Tax = tax;
                     tran.Save <Columns>(nc);
                 }
             }
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Example #12
0
        public int ProductAdd(Product entity)
        {
            //创建时间
            entity.Pd_CrtTime = DateTime.Now;
            Song.Entities.Columns nc = Business.Do <IColumns>().Single((int)entity.Col_Id);
            if (nc != null)
            {
                entity.Col_Name = nc.Col_Name;
            }
            //添加对象,并设置排序号
            object obj = Gateway.Default.Max <Product>(Product._.Pd_Tax, Product._.Col_Id == entity.Col_Id);

            entity.Pd_Tax = obj is int?(int)obj + 1 : 0;
            //所在机构
            Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent();
            if (org != null)
            {
                entity.Org_ID   = org.Org_ID;
                entity.Org_Name = org.Org_Name;
            }
            return(Gateway.Default.Save <Product>(entity));
        }
Example #13
0
        public void ArticleSave(Article entity)
        {
            entity.Art_LastTime = DateTime.Now;
            if (entity.Art_PushTime < DateTime.Now.AddYears(-100))
            {
                entity.Art_PushTime = entity.Art_CrtTime;
            }
            Song.Entities.Columns nc = Business.Do <IColumns>().Single((int)entity.Col_Id);
            if (nc != null)
            {
                entity.Col_Name = nc.Col_Name;
            }
            //如果是置顶新闻
            if (entity.Art_IsTop)
            {
                int topNumber = Business.Do <ISystemPara>()["NewsMaxTop"].Int16 ?? 10;
                int count     = Gateway.Default.Count <Article>(Article._.Art_IsTop == true);
                //如果置顶信息过多
                if (count >= topNumber)
                {
                    Song.Entities.Article[] tna = Gateway.Default.From <Article>().Where(Article._.Art_IsTop == true).OrderBy(Article._.Art_CrtTime.Asc).ToArray <Article>(count - topNumber + 1);
                    if (tna != null)
                    {
                        foreach (Article na in tna)
                        {
                            na.Art_IsTop = false;
                            Gateway.Default.Save <Article>(na);
                        }
                    }
                }
            }
            //如果是推荐的新闻
            if (entity.Art_IsRec)
            {
                int recNumber = Business.Do <ISystemPara>()["NewsMaxRec"].Int16 ?? 10;
                int reccount  = Gateway.Default.Count <Article>(Article._.Art_IsRec == true);
                //如果置顶信息过多
                if (reccount >= recNumber)
                {
                    Song.Entities.Article[] tna = Gateway.Default.From <Article>().Where(Article._.Art_IsRec == true).OrderBy(Article._.Art_CrtTime.Asc).ToArray <Article>(reccount - recNumber + 1);
                    if (tna != null)
                    {
                        foreach (Article na in tna)
                        {
                            na.Art_IsRec = false;
                            Gateway.Default.Save <Article>(na);
                        }
                    }
                }
            }
            //如果不需要审核
            bool isveri = Business.Do <ISystemPara>()["NewsIsReVeri"].Boolean ?? true;

            if (!isveri)
            {
                entity.Art_IsVerify = true;
            }
            //如果修改后需要重新审核
            bool isrevi = Business.Do <ISystemPara>()["NewsIsReVeri"].Boolean ?? true;

            if (isveri)
            {
                entity.Art_IsVerify = false;
            }
            Gateway.Default.Save <Article>(entity);
        }
Example #14
0
        public int ArticleAdd(Article entity)
        {
            //创建时间
            entity.Art_CrtTime = DateTime.Now;
            if (entity.Art_PushTime < DateTime.Now.AddYears(-100))
            {
                entity.Art_PushTime = entity.Art_CrtTime;
            }
            //所在机构
            Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent();
            if (org != null)
            {
                entity.Org_ID   = org.Org_ID;
                entity.Org_Name = org.Org_Name;
            }
            //所属栏目
            Song.Entities.Columns nc = Business.Do <IColumns>().Single((int)entity.Col_Id);
            if (nc != null)
            {
                entity.Col_Name = nc.Col_Name;
            }
            //如果是置顶新闻
            if (entity.Art_IsTop)
            {
                int topNumber = Business.Do <ISystemPara>()["NewsMaxTop"].Int16 ?? 10;
                int count     = Gateway.Default.Count <Article>(Article._.Art_IsTop == true);
                //如果置顶信息过多
                if (count >= topNumber)
                {
                    Song.Entities.Article[] tna = Gateway.Default.From <Article>().Where(Article._.Art_IsTop == true).OrderBy(Article._.Art_CrtTime.Asc).ToArray <Article>(count - topNumber + 1);
                    if (tna != null)
                    {
                        foreach (Article na in tna)
                        {
                            na.Art_IsTop = false;
                            Gateway.Default.Save <Article>(na);
                        }
                    }
                }
            }
            //如果是推荐的新闻
            if (entity.Art_IsRec)
            {
                int recNumber = Business.Do <ISystemPara>()["NewsMaxRec"].Int16 ?? 10;
                int reccount  = Gateway.Default.Count <Article>(Article._.Art_IsRec == true);
                //如果置顶信息过多
                if (reccount >= recNumber)
                {
                    Song.Entities.Article[] tna = Gateway.Default.From <Article>().Where(Article._.Art_IsRec == true).OrderBy(Article._.Art_CrtTime.Asc).ToArray <Article>(reccount - recNumber + 1);
                    if (tna != null)
                    {
                        foreach (Article na in tna)
                        {
                            na.Art_IsRec = false;
                            Gateway.Default.Save <Article>(na);
                        }
                    }
                }
            }
            //如果不需要审核
            bool isveri = Business.Do <ISystemPara>()["NewsIsVerify"].Boolean ?? true;

            if (!isveri)
            {
                entity.Art_IsVerify = true;
            }
            entity.Art_IsUse = true;
            return(Gateway.Default.Save <Article>(entity));
        }