Exemple #1
0
        protected void Save_Btn_Click(object sender, EventArgs e)
        {
            M_UserInfo      mu    = buser.GetLogin();
            M_Design_MBSite mbMod = new M_Design_MBSite();

            if (Mid > 0)
            {
                mbMod = mbBll.SelReturnModel(Mid);
            }
            mbMod.SiteName = SiteName_T.Text;
            mbMod.SiteImg  = SiteImg_Hid.Value;
            mbMod.TlpID    = DataConvert.CLng(Tlp_DP.SelectedValue);
            if (Mid > 0)
            {
                mbBll.UpdateByID(mbMod);
            }
            else
            {
                string err = "";
                mbMod.UserID = mu.UserID;
                mbMod        = mbBll.CreateSite(mu, mbMod, out err);
                if (!string.IsNullOrEmpty(err))
                {
                    function.WriteErrMsg("创建微站失败,原因:" + err);
                }
            }
            Response.Redirect("default.aspx?id=" + mbMod.ID);
        }
Exemple #2
0
        //加载指定模板页,如不存在,则加载公用模板页(内容|商品详情)
        private string ReadHtml(M_Design_MBSite mbMod)
        {
            string vpath = "/design/mobile/tlp/" + mbMod.TlpID + "/" + PageName + ".html";
            string ppath = Server.MapPath(vpath);

            if (!File.Exists(ppath))
            {
                vpath = "/design/mobile/tlp/common/" + PageName + ".html";
            }
            return(SafeSC.ReadFileStr(vpath));
        }
Exemple #3
0
        public void MyBind()
        {
            M_Design_MBSite msMod = msBll.SelReturnModel(Mid);

            if (msMod == null)
            {
                function.WriteErrMsg("微站不存在!");
            }
            SiteName_T.Text    = msMod.SiteName;
            SiteImg_UP.FileUrl = msMod.SiteImg;
            TlpName_L.Text     = GetTlpName(msMod.TlpID);
            CUser_L.Text       = "<a href='javascript:;' onclick='showuser(" + msMod.UserID + ")'>" + buser.SelReturnModel(msMod.UserID).UserName + "</a>";
            CDate_L.Text       = msMod.CDate.ToString("yyyy-MM-dd");
            SiteCfg_L.Text     = msMod.SiteCfg;
        }
Exemple #4
0
        private void MyBind()
        {
            M_UserInfo mu = buser.GetLogin();

            Tlp_DP.DataSource = mbBll.GetTlpDT();
            Tlp_DP.DataBind();
            Tlp_DP.Enabled = false;
            if (Mid > 0)
            {
                M_Design_MBSite mbMod = mbBll.SelReturnModel(Mid);
                if (mbMod.UserID != mu.UserID)
                {
                    function.WriteErrMsg("你无权管理该微站");
                }
                SiteName_T.Text      = mbMod.SiteName;
                SiteImg_Hid.Value    = mbMod.SiteImg;
                Tlp_DP.SelectedValue = mbMod.TlpID.ToString();
                if (!string.IsNullOrEmpty(mbMod.SiteImg))
                {
                    siteimg.Src = mbMod.SiteImg;
                }
                Head_L.Text = Title_L.Text = "修改微站";
            }
            else//新建
            {
                //取消数量限制
                //int mbcount = mbBll.GetSiteCount(mu.UserID);
                //if (mbcount >= SiteConfig.SiteOption.DN_MBSiteCount)
                //{
                //    function.Script(this, "NoMoreSite('你已经拥有了" + mbcount + "个微站,不能再继续创建');");
                //    Save_Btn.Visible = false;
                //}
                M_Design_MBSite mbMod = mbBll.SelModelByTlpID(mu.UserID, TlpID);
                if (mbMod != null)
                {
                    Response.Redirect("/design/mobile/default.aspx?id=" + mbMod.ID);
                }
                Tlp_DP.SelectedValue = TlpID.ToString();
                Head_L.Text          = Title_L.Text = "新建微站";
            }
        }
Exemple #5
0
        protected void Save_Btn_Click(object sender, EventArgs e)
        {
            M_Design_MBSite msMod = msBll.SelReturnModel(Mid);

            msMod.SiteName     = SiteName_T.Text;
            SiteImg_UP.SaveUrl = "/UploadFiles/User/" + buser.SelReturnModel(msMod.UserID).UserName + "/";
            string oldimg = msMod.SiteImg;

            if (SiteImg_UP.HasFile)
            {
                HttpPostedFile file  = SiteImg_UP.Request.Files[0];
                var            image = System.Drawing.Image.FromStream(file.InputStream);
                SiteImg_UP.SaveFile();
                msMod.SiteImg = SiteImg_UP.FileUrl;
            }
            else
            {
                msMod.SiteImg = SiteImg_UP.FVPath;
            }

            msBll.UpdateByID(msMod);
            function.WriteSuccessMsg("修改成功", "MBSiteList.aspx");
        }
Exemple #6
0
 public bool UpdateByID(M_Design_MBSite model)
 {
     return(DBCenter.UpdateByID(model, model.ID));
 }
Exemple #7
0
 public int Insert(M_Design_MBSite model)
 {
     return(DBCenter.Insert(model));
 }
Exemple #8
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);
        }
Exemple #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         M_UserInfo mu = buser.GetLogin();
         if (Mid < 1 && mu.IsNull)
         {
             function.WriteErrMsg("你尚未指定站点信息");
         }
         else if (Mid < 1)//未指定但已登录,进入用户自己的站点
         {
             mbMod = mbBll.SelModelByUid(mu.UserID);
             if (mbMod == null)
             {
                 Response.Redirect("newsite.aspx");
             }
             else
             {
                 Response.Redirect("/design/mobile/default.aspx?id=" + mbMod.ID);
             }
         }
         else //正常浏览站点
         {
             mbMod = mbBll.SelReturnModel(Mid);
             if (mbMod == null)
             {
                 function.WriteErrMsg("站点不存在");
             }
             //----用于微信分享
             Title_L.Text       = mbMod.SiteName + "-来自[" + mu.TrueName + "]的微站";
             Share_Img.ImageUrl = string.IsNullOrEmpty(mbMod.SiteImg) ? "/design/mobile/tlp/" + mbMod.TlpID + "/view.jpg" : mbMod.SiteImg;
             //----需要加载的通用页面资源,版本更新刷新缓存
             string version = DateTime.Now.Millisecond.ToString();
             string cssres  = "<link href=\"/design/JS/mobile/tools.css?v=" + version + "\" rel=\"stylesheet\" />"
                              + "<link href=\"/design/JS/sui/css/sm.min.css\" rel=\"stylesheet\" />";
             string jsres = "<script src=\"/JS/Plugs/angular.min.js\"></script>"
                            + "<script src=\"/JS/Controls/ZL_Webup.js?v=" + version + "\"></script>"
                            + "<script src=\"/JS/Modal/APIResult.js\"></script>"
                            + "<script src=\"/design/h5/js/zepto.min.js\"></script>"
                            + "<script src=\"/design/JS/sui/js/sm.js\"></script>"
                            + "<script src=\"/design/JS/mobile/tools.js?v=" + version + "\"></script>";
             //----根据网站绑定的模板,加载指定页面
             string html = ReadHtml(mbMod);
             html          = html.Replace("{$site}", Mid.ToString()).Replace("{$gid}", Gid.ToString());
             html          = cssres + jsres + html;//资源置顶
             Html_Lit.Text = html;
             //----配置信息,后期可扩展其他功能
             SiteCfg cfg = new SiteCfg();
             cfg.mid = Mid;
             //直接进入,并且未强制指定为编辑模式
             if (Request.UrlReferrer == null && !(Request["action"] ?? "").Equals("edit"))
             {
             }
             else if (mbMod.UserID == mu.UserID)
             {
                 cfg.edit = true; btns_wrap.Visible = true; pop_div.Visible = true;
             }
             sitecfg_hid.Value = JsonConvert.SerializeObject(cfg);
         }
     }
 }