Exemple #1
0
        private bool DoEdit(int _id)
        {
            bool result = false;

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

            model.parent_id  = int.Parse(ddlParentId.SelectedValue);
            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 (cbIsLock.Checked == true)
            {
                model.is_lock = 0;
            }
            else
            {
                model.is_lock = 0;
            }
            model.site_type       = int.Parse(rblSiteType.SelectedValue);
            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);
        }
Exemple #2
0
        private string CreateIndexHtml(string lang, string aspx_filename, string catalogue)
        {
            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.sites modelchannelsite = objchannel_site.GetModel("build_path='" + lang + "'", string.Empty, string.Empty);
                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();
                }
                return("0");
            }
            else
            {
                return("1");
                //HttpContext.Current.Response.Write("1");//找不到生成的模版!
            }
        }
Exemple #3
0
        private void ShowInfo(int _id)
        {
            BLL.sites   bll   = new BLL.sites();
            Model.sites model = bll.GetModel(_id);

            txtTitle.Text     = model.title;
            txtBuildPath.Text = model.build_path;
            txtBuildPath.Attributes.Add("ajaxurl", "../../tools/admin_ajax.ashx?action=site_path_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_lock == 0)
            {
                cbIsLock.Checked = true;
            }
            else
            {
                cbIsLock.Checked = false;
            }
            ddlParentId.SelectedValue = model.parent_id.ToString();
            rblSiteType.SelectedValue = model.site_type.ToString();
            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;
        }
Exemple #4
0
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("sys_site_manage", DTEnums.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.sites bll = new BLL.sites();
            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.site_channel().GetCount("site_id=" + id);
                    if (channelCount > 0)
                    {
                        errorCount += 1;
                        continue;
                    }
                    Model.sites model = bll.GetModel(id);
                    //删除成功后对应的目录及文件
                    if (bll.Delete(id))
                    {
                        sucCount += 1;
                        FileHelp.DeleteDirectory(sysConfig.webpath + DTKeys.DIRECTORY_REWRITE_ASPX + "/" + model.build_path);
                        FileHelp.DeleteDirectory(sysConfig.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");
        }