Ejemplo n.º 1
0
        /// <summary>
        /// 返回节点,内容,内容附表数据
        /// </summary>
        public DataSet PackSiteToDS(int siteID)
        {
            B_Design_Node nodeBll = new B_Design_Node();
            DataSet       ds      = new DataSet();
            string        nids    = nodeBll.SelToIDS(siteID, "all");
            DataTable     nodeDT  = nodeBll.SelBy(siteID);
            DataTable     conDT   = DBCenter.Sel("ZL_CommonModel", "NodeID IN(" + nids + ")");
            DataTable     artDT   = DBCenter.Sel("ZL_C_Article", "ID IN (SELECT ItemID FROM ZL_CommonModel WHERE NodeID IN (" + nids + "))");
            DataTable     sfDT    = DBCenter.Sel("ZL_Design_SiteInfo", "ID=" + siteID);

            nodeDT.TableName = "ZL_Node";
            conDT.TableName  = "ZL_CommonModel";
            artDT.TableName  = "ZL_C_Article";
            sfDT.TableName   = "ZL_Design_SiteInfo";
            ds.Tables.Add(nodeDT.Copy());
            ds.Tables.Add(conDT.Copy());
            ds.Tables.Add(artDT.Copy());
            ds.Tables.Add(sfDT.Copy());
            return(ds);
        }
Ejemplo n.º 2
0
        //----------Logical
        ////用户无微站信息,则自动创建
        //public M_Design_MBSite AutoCreate(M_UserInfo mu)
        //{
        //    if (mu == null || mu.IsNull) { return null; }
        //    if (DBCenter.IsExist(TbName, "UserID=" + mu.UserID)) { return null; }
        //    M_Design_MBSite mbMod = new M_Design_MBSite();
        //    mbMod.UserID = mu.UserID;
        //    mbMod.TlpID = 1;
        //    mbMod.SiteID = mu.SiteID;
        //    mbMod.ID = Insert(mbMod);
        //    return mbMod;
        //}
        /// <summary>
        /// 根据用户与模板信息,创建站点
        /// </summary>
        public M_Design_MBSite CreateSite(M_UserInfo mu, M_Design_MBSite mbMod, out string err)
        {
            B_Design_Node desNodeBll = new B_Design_Node();
            B_Node        nodeBll    = new B_Node();
            B_Product     proBll     = new B_Product();
            //int mbsitecount = SiteConfig.SiteOption.DN_MBSiteCount;
            int mbsitecount = 10000;//取消数量限制

            if (mu == null || mu.IsNull)
            {
                err = "用户不存在"; return(null);
            }
            else if (mbMod.TlpID < 1 || mbMod.TlpID > 8)
            {
                err = "未指定模板或模板[" + mbMod.TlpID + "]不存在"; return(null);
            }
            else if (GetSiteCount(mu.UserID) >= mbsitecount)
            {
                err = "用户只能创建" + mbsitecount + "个微站"; return(null);
            }
            if (string.IsNullOrEmpty(mbMod.SiteName))
            {
                mbMod.SiteName = B_User.GetUserName(mu.HoneyName, mu.UserName) + "的微站" + DBCenter.Count(TbName, "UserID=" + mu.UserID) + 1;
            }
            mbMod.UserID = mu.UserID;
            mbMod.ID     = Insert(mbMod);
            //-----建立微站节点信息,从指定的模板处拷节点数据,父节点需要自建
            M_Node pnode = desNodeBll.GetUserRootNode(mu);

            if (pnode.IsNull)
            {
                pnode = desNodeBll.CreateUserRootNode(mu);
            }
            M_Node nodeMod = new M_Node();

            nodeMod.NodeName   = "微建站";
            nodeMod.NodeDir    = function.GetRandomString(6);
            nodeMod.CUser      = mu.UserID;
            nodeMod.CUName     = mu.UserName;
            nodeMod.NodeBySite = mbMod.ID;
            nodeMod.NodeType   = 1;//标识自身为主栏目
            nodeMod.ParentID   = pnode.NodeID;
            nodeMod.NodeID     = nodeBll.Insert(nodeMod);
            //---导入对应的模板节点数据
            string    nodename = "微建站" + mbMod.TlpID;
            DataTable nodeDT   = SelNodeByPName(nodename);

            CopyNodeAndContent(nodeDT, nodeMod);
            //---如果有商品数据,则导入商品
            DataTable proDT = SelProByPName(nodename);

            foreach (DataRow dr in proDT.Rows)
            {
                M_Product proMod = new M_Product().GetModelFromReader(dr);
                proMod.ID         = 0;
                proMod.ParentID   = mbMod.ID;//所属哪个站点
                proMod.UserID     = mu.UserID;
                proMod.AddUser    = mu.UserName;
                proMod.Nodeid     = UserShopNodeID;
                proMod.AddTime    = DateTime.Now;
                proMod.UpdateTime = DateTime.Now;
                proBll.Insert(proMod);
            }
            err = "";
            return(mbMod);
        }