Beispiel #1
0
 /// <summary>
 /// 父类的构造函数
 /// </summary>
 public BasePage()
 {
     //是否关闭网站
     if (config.webstatus == 0)
     {
         HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode(config.webclosereason)));
         return;
     }
     //取得站点信息
     site = GetSiteModel();
     //抛出一个虚方法给继承重写
     ShowPage();
 }
Beispiel #2
0
 /// <summary>
 /// 父类的构造函数
 /// </summary>
 public BasePage()
 {
     //是否关闭网站
     if (config.webstatus == 0)
     {
         HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode(config.webclosereason)));
         return;
     }
     //取得站点信息
     site = GetSiteModel();
     //抛出一个虚方法给继承重写
     ShowPage();
 }
Beispiel #3
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.channel_site   bll   = new BLL.channel_site();
            Model.channel_site model = bll.GetModel(_id);

            model.title      = txtTitle.Text.Trim();
            model.build_path = txtBuildPath.Text.Trim();
            model.domain     = txtDomain.Text.Trim();
            model.sort_id    = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            if (cbIsDefault.Checked == true)
            {
                model.is_default = 1;
            }
            else
            {
                model.is_default = 0;
            }
            if (cbIsMobile.Checked == true)
            {
                model.is_mobile = 1;
            }
            else
            {
                model.is_mobile = 0;
            }
            model.name            = txtName.Text.Trim();
            model.logo            = txtLogo.Text.Trim();
            model.company         = txtCompany.Text.Trim();
            model.address         = txtAddress.Text.Trim();
            model.tel             = txtTel.Text.Trim();
            model.fax             = txtFax.Text.Trim();
            model.email           = txtEmail.Text.Trim();
            model.crod            = txtCrod.Text.Trim();
            model.seo_title       = txtSeoTitle.Text.Trim();
            model.seo_keyword     = txtSeoKeyword.Text.Trim();
            model.seo_description = Utils.DropHTML(txtSeoDescription.Text);
            model.copyright       = txtCopyright.Text.Trim();

            if (bll.Update(model))
            {
                //更新一下域名缓存
                CacheHelper.Remove(DTKeys.CACHE_SITE_HTTP_DOMAIN);
                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改站点:" + model.title); //记录日志
                result = true;
            }

            return(result);
        }
Beispiel #4
0
        private bool DoAdd()
        {
            Model.channel_site model = new Model.channel_site();
            BLL.channel_site bll = new BLL.channel_site();

            model.title = txtTitle.Text.Trim();
            model.build_path = txtBuildPath.Text.Trim();
            model.domain = txtDomain.Text.Trim();
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            if (cbIsDefault.Checked == true)
            {
                model.is_default = 1;
            }
            else
            {
                model.is_default = 0;
            }
            if (cbIsMobile.Checked == true)
            {
                model.is_mobile = 1;
            }
            else
            {
                model.is_mobile = 0;
            }
            model.name = txtName.Text.Trim();
            model.logo = txtLogo.Text.Trim();
            model.company = txtCompany.Text.Trim();
            model.address = txtAddress.Text.Trim();
            model.tel = txtTel.Text.Trim();
            model.fax = txtFax.Text.Trim();
            model.email = txtEmail.Text.Trim();
            model.crod = txtCrod.Text.Trim();
            model.seo_title = txtSeoTitle.Text.Trim();
            model.seo_keyword = txtSeoKeyword.Text.Trim();
            model.seo_description = Utils.DropHTML(txtSeoDescription.Text);
            model.copyright = txtCopyright.Text.Trim();

            if (bll.Add(model) > 0)
            {
                //更新一下域名缓存
                CacheHelper.Remove(DTKeys.CACHE_SITE_HTTP_DOMAIN);
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加站点:" + model.title); //记录日志
                return true;
            }

            return false;
        }
        private void CreateIndexHtml(string lang, string aspx_filename, string catalogue)
        {
            try
            {
                if (File.Exists(Utils.GetMapPath(config.webpath + aspx_filename.Substring(0, aspx_filename.IndexOf(".aspx") + 5))))
                {
                    string urlPath  = config.webpath + aspx_filename.Replace("^", "&"); //文件相对路径
                    string htmlPath = config.webpath + catalogue;                       //保存相对路径
                    if (htmlPath.IndexOf(".") < 0)
                    {
                        htmlPath = htmlPath + "index." + config.staticextension;
                    }
                    //检查目录是否存在
                    string directorystr = HttpContext.Current.Server.MapPath(htmlPath.Substring(0, htmlPath.LastIndexOf("/")));
                    if (!Directory.Exists(directorystr))
                    {
                        Directory.CreateDirectory(directorystr);
                    }
                    string linkwebsite = HttpContext.Current.Request.Url.Authority;

                    Model.channel_site modelchannelsite = objchannel_site.GetModel(lang);
                    if (modelchannelsite != null && !string.IsNullOrEmpty(modelchannelsite.domain))
                    {
                        linkwebsite = modelchannelsite.domain;
                    }
                    System.Net.WebRequest  request      = System.Net.WebRequest.Create("http://" + linkwebsite + urlPath);
                    System.Net.WebResponse response     = request.GetResponse();
                    System.IO.Stream       stream       = response.GetResponseStream();
                    System.IO.StreamReader streamreader = new System.IO.StreamReader(stream, System.Text.Encoding.GetEncoding("utf-8"));
                    string content = streamreader.ReadToEnd();
                    using (StreamWriter sw = new StreamWriter(Utils.GetMapPath(htmlPath), false, Encoding.UTF8))
                    {
                        sw.WriteLine(content);
                        sw.Flush();
                        sw.Close();
                    }
                }
                else
                {
                    HttpContext.Current.Response.Write("1");//找不到生成的模版!
                }
            }
            catch (Exception ex)
            {
                RPoney.Log.LoggerManager.Error(GetType().Name, "生产模版错误", ex);
            }
        }
Beispiel #6
0
        private void ShowInfo(int _id)
        {
            BLL.channel_site   bll   = new BLL.channel_site();
            Model.channel_site model = bll.GetModel(_id);

            txtTitle.Text     = model.title;
            txtBuildPath.Text = model.build_path;
            txtBuildPath.Attributes.Add("ajaxurl", "../../tools/admin_ajax.ashx?action=channel_site_validate&old_build_path=" + Utils.UrlEncode(model.build_path));
            txtBuildPath.Focus(); //设置焦点,防止JS无法提交
            txtDomain.Text = model.domain;
            txtSortId.Text = model.sort_id.ToString();
            if (model.is_default == 1)
            {
                cbIsDefault.Checked = true;
            }
            else
            {
                cbIsDefault.Checked = false;
            }
            if (model.is_mobile == 1)
            {
                cbIsMobile.Checked = true;
            }
            else
            {
                cbIsMobile.Checked = false;
            }
            txtName.Text           = model.name;
            txtLogo.Text           = model.logo;
            txtCompany.Text        = model.company;
            txtAddress.Text        = model.address;
            txtTel.Text            = model.tel;
            txtFax.Text            = model.fax;
            txtEmail.Text          = model.email;
            txtCrod.Text           = model.crod;
            txtSeoTitle.Text       = model.seo_title;
            txtSeoKeyword.Text     = model.seo_keyword;
            txtSeoDescription.Text = model.seo_description;
            txtCopyright.Text      = model.copyright;
        }
Beispiel #7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.channel_site model)
        {
            string old_build_path = dal.GetBuildPath(model.id);

            if (string.IsNullOrEmpty(old_build_path))
            {
                return(false);
            }
            if (dal.Update(model, old_build_path))
            {
                if (old_build_path.ToLower() != model.build_path.ToLower())
                {
                    //更改频道分类对应的目录名称
                    Utils.MoveDirectory(siteConfig.webpath + DTKeys.DIRECTORY_REWRITE_ASPX + "/" + old_build_path,
                                        siteConfig.webpath + DTKeys.DIRECTORY_REWRITE_ASPX + "/" + model.build_path);
                    Utils.MoveDirectory(siteConfig.webpath + DTKeys.DIRECTORY_REWRITE_HTML + "/" + old_build_path,
                                        siteConfig.webpath + DTKeys.DIRECTORY_REWRITE_HTML + "/" + model.build_path);
                }
                return(true);
            }
            return(false);
        }
Beispiel #8
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.channel_site GetModel(string build_path)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select " + this.column + " from [" + databaseprefix + "channel_site] where build_path=@build_path");
            SqlParameter[] parameters =
            {
                new SqlParameter("@build_path", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = build_path;

            Model.channel_site model = new Model.channel_site();
            DataSet            ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #9
0
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("sys_site_manage", DTEnums.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.channel_site bll = new BLL.channel_site();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    //检查该分类下是否还有频道
                    int channelCount = new BLL.channel().GetCount("site_id=" + id);
                    if (channelCount > 0)
                    {
                        errorCount += 1;
                        continue;
                    }
                    Model.channel_site model = bll.GetModel(id);
                    //删除成功后对应的目录及文件
                    if (bll.Delete(id))
                    {
                        sucCount += 1;
                        Utils.DeleteDirectory(siteConfig.webpath + DTKeys.DIRECTORY_REWRITE_ASPX + "/" + model.build_path);
                        Utils.DeleteDirectory(siteConfig.webpath + DTKeys.DIRECTORY_REWRITE_HTML + "/" + model.build_path);
                    }
                    else
                    {
                        errorCount += 1;
                    }
                }
            }
            AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除站点成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("site_list.aspx", "keywords={0}", this.keywords), "parent.loadMenuTree");
        }
Beispiel #10
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.channel_site GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 id,title,build_path,templet_path,[domain],[name],logo,company,address,tel,fax,email,crod,copyright,seo_title,seo_keyword,seo_description,is_default,sort_id");
            strSql.Append(" from " + databaseprefix + "channel_site");
            strSql.Append(" where id=@id");
            OleDbParameter[] parameters = {
                    new OleDbParameter("@id", OleDbType.Integer,4)};
            parameters[0].Value = id;

            Model.channel_site model = new Model.channel_site();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Beispiel #11
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.channel_site model)
 {
     return(dal.Add(model));
 }
Beispiel #12
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.channel_site model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        //添加主表信息
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into " + databaseprefix + "channel_site(");
                        strSql.Append("title,build_path,templet_path,domain,name,logo,company,address,tel,fax,email,crod,copyright,seo_title,seo_keyword,seo_description,is_mobile,is_default,sort_id)");
                        strSql.Append(" values (");
                        strSql.Append("@title,@build_path,@templet_path,@domain,@name,@logo,@company,@address,@tel,@fax,@email,@crod,@copyright,@seo_title,@seo_keyword,@seo_description,@is_mobile,@is_default,@sort_id)");
                        strSql.Append(";select @@IDENTITY");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@title",           SqlDbType.NVarChar, 100),
                            new SqlParameter("@build_path",      SqlDbType.NVarChar, 100),
                            new SqlParameter("@templet_path",    SqlDbType.NVarChar, 100),
                            new SqlParameter("@domain",          SqlDbType.NVarChar, 255),
                            new SqlParameter("@name",            SqlDbType.NVarChar, 255),
                            new SqlParameter("@logo",            SqlDbType.NVarChar, 255),
                            new SqlParameter("@company",         SqlDbType.NVarChar, 255),
                            new SqlParameter("@address",         SqlDbType.NVarChar, 255),
                            new SqlParameter("@tel",             SqlDbType.NVarChar,  30),
                            new SqlParameter("@fax",             SqlDbType.NVarChar,  30),
                            new SqlParameter("@email",           SqlDbType.NVarChar,  50),
                            new SqlParameter("@crod",            SqlDbType.NVarChar, 100),
                            new SqlParameter("@copyright",       SqlDbType.Text),
                            new SqlParameter("@seo_title",       SqlDbType.NVarChar, 255),
                            new SqlParameter("@seo_keyword",     SqlDbType.NVarChar, 255),
                            new SqlParameter("@seo_description", SqlDbType.NVarChar, 500),
                            new SqlParameter("@is_mobile",       SqlDbType.TinyInt,    1),
                            new SqlParameter("@is_default",      SqlDbType.TinyInt,    1),
                            new SqlParameter("@sort_id",         SqlDbType.Int, 4)
                        };
                        parameters[0].Value  = model.title;
                        parameters[1].Value  = model.build_path;
                        parameters[2].Value  = model.templet_path;
                        parameters[3].Value  = model.domain;
                        parameters[4].Value  = model.name;
                        parameters[5].Value  = model.logo;
                        parameters[6].Value  = model.company;
                        parameters[7].Value  = model.address;
                        parameters[8].Value  = model.tel;
                        parameters[9].Value  = model.fax;
                        parameters[10].Value = model.email;
                        parameters[11].Value = model.crod;
                        parameters[12].Value = model.copyright;
                        parameters[13].Value = model.seo_title;
                        parameters[14].Value = model.seo_keyword;
                        parameters[15].Value = model.seo_description;
                        parameters[16].Value = model.is_mobile;
                        parameters[17].Value = model.is_default;
                        parameters[18].Value = model.sort_id;
                        object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务
                        model.id = Convert.ToInt32(obj);

                        //如果非移动站点则添加导航菜单
                        if (model.is_mobile == 0)
                        {
                            new DAL.navigation(databaseprefix).Add(conn, trans, "sys_contents", "channel_" + model.build_path, model.title, "", model.sort_id, 0, "Show");
                        }
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(0);
                    }
                }
            }
            return(model.id);
        }
Beispiel #13
0
 /// <summary>
 /// 将对象转换为实体
 /// </summary>
 public Model.channel_site DataRowToModel(DataRow row)
 {
     Model.channel_site model = new Model.channel_site();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["build_path"] != null)
         {
             model.build_path = row["build_path"].ToString();
         }
         if (row["templet_path"] != null)
         {
             model.templet_path = row["templet_path"].ToString();
         }
         if (row["domain"] != null)
         {
             model.domain = row["domain"].ToString();
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
         if (row["logo"] != null)
         {
             model.logo = row["logo"].ToString();
         }
         if (row["company"] != null)
         {
             model.company = row["company"].ToString();
         }
         if (row["address"] != null)
         {
             model.address = row["address"].ToString();
         }
         if (row["tel"] != null)
         {
             model.tel = row["tel"].ToString();
         }
         if (row["fax"] != null)
         {
             model.fax = row["fax"].ToString();
         }
         if (row["email"] != null)
         {
             model.email = row["email"].ToString();
         }
         if (row["crod"] != null)
         {
             model.crod = row["crod"].ToString();
         }
         if (row["copyright"] != null)
         {
             model.copyright = row["copyright"].ToString();
         }
         if (row["seo_title"] != null)
         {
             model.seo_title = row["seo_title"].ToString();
         }
         if (row["seo_keyword"] != null)
         {
             model.seo_keyword = row["seo_keyword"].ToString();
         }
         if (row["seo_description"] != null)
         {
             model.seo_description = row["seo_description"].ToString();
         }
         if (row["is_mobile"] != null && row["is_mobile"].ToString() != "")
         {
             model.is_mobile = int.Parse(row["is_mobile"].ToString());
         }
         if (row["is_default"] != null && row["is_default"].ToString() != "")
         {
             model.is_default = int.Parse(row["is_default"].ToString());
         }
         if (row["sort_id"] != null && row["sort_id"].ToString() != "")
         {
             model.sort_id = int.Parse(row["sort_id"].ToString());
         }
     }
     return(model);
 }
Beispiel #14
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.channel_site model, string old_build_path)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        //修改主表信息
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update " + databaseprefix + "channel_site set ");
                        strSql.Append("title=@title,");
                        strSql.Append("build_path=@build_path,");
                        strSql.Append("templet_path=@templet_path,");
                        strSql.Append("domain=@domain,");
                        strSql.Append("name=@name,");
                        strSql.Append("logo=@logo,");
                        strSql.Append("company=@company,");
                        strSql.Append("address=@address,");
                        strSql.Append("tel=@tel,");
                        strSql.Append("fax=@fax,");
                        strSql.Append("email=@email,");
                        strSql.Append("crod=@crod,");
                        strSql.Append("copyright=@copyright,");
                        strSql.Append("seo_title=@seo_title,");
                        strSql.Append("seo_keyword=@seo_keyword,");
                        strSql.Append("seo_description=@seo_description,");
                        strSql.Append("is_mobile=@is_mobile,");
                        strSql.Append("is_default=@is_default,");
                        strSql.Append("sort_id=@sort_id");
                        strSql.Append(" where id=@id");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@title",           SqlDbType.NVarChar, 100),
                            new SqlParameter("@build_path",      SqlDbType.NVarChar, 100),
                            new SqlParameter("@templet_path",    SqlDbType.NVarChar, 100),
                            new SqlParameter("@domain",          SqlDbType.NVarChar, 255),
                            new SqlParameter("@name",            SqlDbType.NVarChar, 255),
                            new SqlParameter("@logo",            SqlDbType.NVarChar, 255),
                            new SqlParameter("@company",         SqlDbType.NVarChar, 255),
                            new SqlParameter("@address",         SqlDbType.NVarChar, 255),
                            new SqlParameter("@tel",             SqlDbType.NVarChar,  30),
                            new SqlParameter("@fax",             SqlDbType.NVarChar,  30),
                            new SqlParameter("@email",           SqlDbType.NVarChar,  50),
                            new SqlParameter("@crod",            SqlDbType.NVarChar, 100),
                            new SqlParameter("@copyright",       SqlDbType.Text),
                            new SqlParameter("@seo_title",       SqlDbType.NVarChar, 255),
                            new SqlParameter("@seo_keyword",     SqlDbType.NVarChar, 255),
                            new SqlParameter("@seo_description", SqlDbType.NVarChar, 500),
                            new SqlParameter("@is_mobile",       SqlDbType.TinyInt,    1),
                            new SqlParameter("@is_default",      SqlDbType.TinyInt,    1),
                            new SqlParameter("@sort_id",         SqlDbType.Int,        4),
                            new SqlParameter("@id",              SqlDbType.Int, 4)
                        };
                        parameters[0].Value  = model.title;
                        parameters[1].Value  = model.build_path;
                        parameters[2].Value  = model.templet_path;
                        parameters[3].Value  = model.domain;
                        parameters[4].Value  = model.name;
                        parameters[5].Value  = model.logo;
                        parameters[6].Value  = model.company;
                        parameters[7].Value  = model.address;
                        parameters[8].Value  = model.tel;
                        parameters[9].Value  = model.fax;
                        parameters[10].Value = model.email;
                        parameters[11].Value = model.crod;
                        parameters[12].Value = model.copyright;
                        parameters[13].Value = model.seo_title;
                        parameters[14].Value = model.seo_keyword;
                        parameters[15].Value = model.seo_description;
                        parameters[16].Value = model.is_mobile;
                        parameters[17].Value = model.is_default;
                        parameters[18].Value = model.sort_id;
                        parameters[19].Value = model.id;
                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters);

                        //检查旧导航是否存在
                        if (new DAL.navigation(databaseprefix).GetModel(conn, trans, "channel_" + old_build_path) != null)
                        {
                            //如果非移动站点则修改导航菜单,是移动站点则删除旧导航
                            if (model.is_mobile == 0)
                            {
                                new DAL.navigation(databaseprefix).Update(conn, trans, "channel_" + old_build_path, "channel_" + model.build_path, model.title, model.sort_id);
                            }
                            else
                            {
                                new DAL.navigation(databaseprefix).Delete(conn, trans, "channel_" + old_build_path);
                            }
                        }
                        else if (model.is_mobile == 0) //没有旧菜单而非移动站需要添加新导航菜单
                        {
                            new DAL.navigation(databaseprefix).Add(conn, trans, "sys_contents", "channel_" + model.build_path, model.title, "", model.sort_id, 0, "Show");
                        }

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #15
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.channel_site   bll   = new BLL.channel_site();
            Model.channel_site model = bll.GetModel(_id);

            model.title      = txtTitle.Text.Trim();
            model.build_path = txtBuildPath.Text.Trim();
            model.domain     = txtDomain.Text.Trim();
            model.sort_id    = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            if (cbIsDefault.Checked == true)
            {
                model.is_default = 1;
            }
            else
            {
                model.is_default = 0;
            }
            if (cbIsMobile.Checked == true)
            {
                model.is_mobile = 1;
            }
            else
            {
                model.is_mobile = 0;
            }
            model.inherit_id      = int.Parse(ddlSiteId.SelectedValue);
            model.name            = txtName.Text.Trim();
            model.company         = txtCompany.Text.Trim();
            model.address         = txtAddress.Text.Trim();
            model.tel             = txtTel.Text.Trim();
            model.fax             = txtFax.Text.Trim();
            model.email           = txtEmail.Text.Trim();
            model.crod            = txtCrod.Text.Trim();
            model.seo_title       = txtSeoTitle.Text.Trim();
            model.seo_keyword     = txtSeoKeyword.Text.Trim();
            model.seo_description = Utils.DropHTML(txtSeoDescription.Text);
            model.copyright       = txtCopyright.Text.Trim();
            //判断上传图片
            if (this.imgUpload.HasFile)
            {
                //上传前先删除原图片
                if (!string.IsNullOrEmpty(model.logo))
                {
                    Utils.DeleteFile(model.logo);
                }
                Model.upLoad upfile = new Web.UI.UpLoad().fileSaveAs(this.imgUpload.PostedFile, 0, false, false);
                if (upfile.status > 0)
                {
                    model.logo = upfile.path;
                }
            }
            else
            {
                //判断是否需要删除原图
                if (txtLogo.Text.Trim() == "" && !string.IsNullOrEmpty(model.logo))
                {
                    Utils.DeleteFile(model.logo);
                }
                model.logo = txtLogo.Text.Trim();
            }
            //百度推送
            if (bdSend.Checked == true)
            {
                model.bdsend = 1;
            }
            else
            {
                model.bdsend = 0;
            }
            model.bdtoken = bdToken.Text.Trim();

            if (bll.Update(model))
            {
                //更新一下域名缓存
                CacheHelper.Remove(DTKeys.CACHE_SITE_HTTP_DOMAIN);
                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改站点:" + model.title); //记录日志
                result = true;
            }

            return(result);
        }
Beispiel #16
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.channel_site model)
 {
     using (OleDbConnection conn = new OleDbConnection(DbHelperOleDb.connectionString))
     {
         conn.Open();
         using (OleDbTransaction trans = conn.BeginTransaction())
         {
             try
             {
                 //添加主表信息
                 StringBuilder strSql = new StringBuilder();
                 strSql.Append("insert into " + databaseprefix + "channel_site(");
                 strSql.Append("title,build_path,templet_path,[domain],[name],logo,company,address,tel,fax,email,crod,copyright,seo_title,seo_keyword,seo_description,is_default,sort_id)");
                 strSql.Append(" values (");
                 strSql.Append("@title,@build_path,@templet_path,@domain,@name,@logo,@company,@address,@tel,@fax,@email,@crod,@copyright,@seo_title,@seo_keyword,@seo_description,@is_default,@sort_id)");
                 OleDbParameter[] parameters =
                 {
                     new OleDbParameter("@title",           OleDbType.VarChar,  100),
                     new OleDbParameter("@build_path",      OleDbType.VarChar,  100),
                     new OleDbParameter("@templet_path",    OleDbType.VarChar,  100),
                     new OleDbParameter("@domain",          OleDbType.VarChar,  255),
                     new OleDbParameter("@name",            OleDbType.VarChar,  255),
                     new OleDbParameter("@logo",            OleDbType.VarChar,  255),
                     new OleDbParameter("@company",         OleDbType.VarChar,  255),
                     new OleDbParameter("@address",         OleDbType.VarChar,  255),
                     new OleDbParameter("@tel",             OleDbType.VarChar,   30),
                     new OleDbParameter("@fax",             OleDbType.VarChar,   30),
                     new OleDbParameter("@email",           OleDbType.VarChar,   50),
                     new OleDbParameter("@crod",            OleDbType.VarChar,  100),
                     new OleDbParameter("@copyright",       OleDbType.VarChar),
                     new OleDbParameter("@seo_title",       OleDbType.VarChar,  255),
                     new OleDbParameter("@seo_keyword",     OleDbType.VarChar,  255),
                     new OleDbParameter("@seo_description", OleDbType.VarChar,  500),
                     new OleDbParameter("@is_default",      OleDbType.Integer,    4),
                     new OleDbParameter("@sort_id",         OleDbType.Integer, 4)
                 };
                 parameters[0].Value  = model.title;
                 parameters[1].Value  = model.build_path;
                 parameters[2].Value  = model.templet_path;
                 parameters[3].Value  = model.domain;
                 parameters[4].Value  = model.name;
                 parameters[5].Value  = model.logo;
                 parameters[6].Value  = model.company;
                 parameters[7].Value  = model.address;
                 parameters[8].Value  = model.tel;
                 parameters[9].Value  = model.fax;
                 parameters[10].Value = model.email;
                 parameters[11].Value = model.crod;
                 parameters[12].Value = model.copyright;
                 parameters[13].Value = model.seo_title;
                 parameters[14].Value = model.seo_keyword;
                 parameters[15].Value = model.seo_description;
                 parameters[16].Value = model.is_default;
                 parameters[17].Value = model.sort_id;
                 DbHelperOleDb.ExecuteSql(conn, trans, strSql.ToString(), parameters);
                 //取得新插入的ID
                 model.id = GetMaxId(conn, trans);
                 //添加导航菜单
                 new DAL.navigation(databaseprefix).Add(conn, trans, "sys_contents", "channel_" + model.build_path, model.title, "", model.sort_id, 0, "Show");
                 trans.Commit();
             }
             catch
             {
                 trans.Rollback();
                 return(0);
             }
         }
     }
     return(model.id);
 }
Beispiel #17
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.channel_site GetModel(string build_path)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 id,title,build_path,templet_path,domain,name,logo,company,address,tel,fax,email,crod,copyright,seo_title,seo_keyword,seo_description,is_mobile,is_default,sort_id");
            strSql.Append(" from " + databaseprefix + "channel_site");
            strSql.Append(" where build_path=@build_path");
            SqlParameter[] parameters = {
                    new SqlParameter("@build_path", SqlDbType.NVarChar,50)};
            parameters[0].Value = build_path;

            Model.channel_site model = new Model.channel_site();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Beispiel #18
0
 /// <summary>
 /// 将对象转换为实体
 /// </summary>
 public Model.channel_site DataRowToModel(DataRow row)
 {
     Model.channel_site model = new Model.channel_site();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["build_path"] != null)
         {
             model.build_path = row["build_path"].ToString();
         }
         if (row["templet_path"] != null)
         {
             model.templet_path = row["templet_path"].ToString();
         }
         if (row["domain"] != null)
         {
             model.domain = row["domain"].ToString();
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
         if (row["logo"] != null)
         {
             model.logo = row["logo"].ToString();
         }
         if (row["company"] != null)
         {
             model.company = row["company"].ToString();
         }
         if (row["address"] != null)
         {
             model.address = row["address"].ToString();
         }
         if (row["tel"] != null)
         {
             model.tel = row["tel"].ToString();
         }
         if (row["fax"] != null)
         {
             model.fax = row["fax"].ToString();
         }
         if (row["email"] != null)
         {
             model.email = row["email"].ToString();
         }
         if (row["crod"] != null)
         {
             model.crod = row["crod"].ToString();
         }
         if (row["copyright"] != null)
         {
             model.copyright = row["copyright"].ToString();
         }
         if (row["seo_title"] != null)
         {
             model.seo_title = row["seo_title"].ToString();
         }
         if (row["seo_keyword"] != null)
         {
             model.seo_keyword = row["seo_keyword"].ToString();
         }
         if (row["seo_description"] != null)
         {
             model.seo_description = row["seo_description"].ToString();
         }
         if (row["is_mobile"] != null && row["is_mobile"].ToString() != "")
         {
             model.is_mobile = int.Parse(row["is_mobile"].ToString());
         }
         if (row["is_default"] != null && row["is_default"].ToString() != "")
         {
             model.is_default = int.Parse(row["is_default"].ToString());
         }
         if (row["sort_id"] != null && row["sort_id"].ToString() != "")
         {
             model.sort_id = int.Parse(row["sort_id"].ToString());
         }
     }
     return model;
 }