Ejemplo n.º 1
0
        /// <summary>
        /// BindData()
        /// </summary>
        void BindData()
        {
            Action = We7Request.GetString("t").ToLower();
            if (Action == "widget")

            {
                List <string>           displayFields = new List <string>();
                We7DataColumnCollection dcs           = new We7DataColumnCollection();
                foreach (We7DataColumn col in ModelInfo.DataSet.Tables[0].Columns)
                {
                    if (col.Direction == ParameterDirection.ReturnValue || (col.IsSystem && !displayFields.Contains(col.Name)))
                    {
                        continue;
                    }
                    dcs.Add(col);
                }

                chklstWidgetList.DataSource     = dcs;
                chklstWidgetList.DataTextField  = "Label";
                chklstWidgetList.DataValueField = "Name";

                chklstWidgetView.DataSource     = dcs;
                chklstWidgetView.DataTextField  = "Label";
                chklstWidgetView.DataValueField = "Name";

                chklstWidgetList.DataBind();
                chklstWidgetView.DataBind();
            }

            if (ModelInfo.Layout != null && ModelInfo.Layout.UCContrl != null)
            {
                foreach (ListItem item in chklstWidgetView.Items)
                {
                    item.Attributes["mvalue"] = item.Value;
                    if (ModelInfo.Layout.UCContrl.WidgetDetailFieldArray != null)
                    {
                        item.Selected = Array.Exists(ModelInfo.Layout.UCContrl.WidgetDetailFieldArray,
                                                     s => s == item.Value);
                    }
                }

                foreach (ListItem item in chklstWidgetList.Items)
                {
                    item.Attributes["mvalue"] = item.Value;
                    if (ModelInfo.Layout.UCContrl.WidgetListFieldArray != null)
                    {
                        item.Selected = Array.Exists(ModelInfo.Layout.UCContrl.WidgetListFieldArray, s => s == item.Value);
                    }
                }
            }

            Exist(Action);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// ProcessRequest
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string action = We7Request.GetQueryString("action");
            string result = "";

            switch (action)
            {
            case "DeleteModel": result = DeleteModel();
                break;
            }
            context.Response.Write(result);
        }
Ejemplo n.º 3
0
        string GetTags()
        {
            int         pageIndex = We7Request.GetInt("pi", 1);
            int         pageSize  = We7Request.GetInt("ps", 10);
            List <Tags> list      = TagsHelper.GetTags(pageIndex, pageSize);

            if (list != null && list.Count > 0)
            {
                string json = JavaScriptConvert.SerializeObject(list).Replace("null", "\"\"");

                return("{\"success\":true,\"msg\":\"操作成功!\",\"Data\":" + json + "}");
            }
            else
            {
                return("{\"success\":true,\"msg\":\"无数据!\"}");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// ProcessRequest
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string action = We7Request.GetQueryString("action");
            string result = "";

            switch (action)
            {
            case "DeleteModel": result = DeleteModel();
                break;

            case "CheckModelName":
                string groupname = We7Request.GetQueryString("group").Trim();
                string file      = We7Request.GetQueryString("file").Trim();
                string modelname = We7Request.GetQueryString("model").Trim();
                bool   isEdit    = Convert.ToBoolean(We7Request.GetQueryString("isedit"));
                result = CheckModelName(isEdit, groupname, file, modelname);
                break;
            }
            context.Response.Write(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 删除模型
        /// </summary>
        /// <returns></returns>
        public string DeleteModel()
        {
            string modelName = We7Request.GetQueryString("model");
            string msg       = "";
            bool   success   = true;
            //2011-10-10 取消生成控件
            //ModelHelper.CreateControls(modelInf);


            /*
             * TODO:
             * 以下这些代码应该集成到ModelHelper.DeleteContentModel中,但是下列代码中需要一些方法是调用We7.CMS.WebControls.Core.BaseControlHelper中的方法,这个类物理文件存储在We7.CMS.UI里面.
             */

            ModelInfo modelInf = ModelHelper.GetModelInfo(modelName);

            //反馈模型删除前需要解除类型的绑定
            if (modelInf.Type.ToString().ToLower().Equals("advice"))
            {
                Criteria          c          = new Criteria(CriteriaType.Equals, "ModelName", modelInf.ModelName);
                List <AdviceType> adviceList = Assistant.List <AdviceType>(c, null);

                if (adviceList != null && adviceList.Count > 0)
                {
                    success = false;
                    msg     = "当前模型尚有绑定的反馈类型,请先解除绑定再进行删除!";
                    return("{\"success\":" + success.ToString().ToLower() + ",\"msg\":\"" + msg + "\"}");
                }
            }
            //布局控件
            string layoutPath = ModelHelper.GetModelLayoutDirectory(modelInf.ModelName);
            //部件
            int    widgetCount  = 0;
            string viewPath     = ModelHelper.GetWidgetDirectory(modelInf, "View");
            string listPath     = ModelHelper.GetWidgetDirectory(modelInf, "List");
            string pageListPath = ModelHelper.GetWidgetDirectory(modelInf, "PagedList");

            try
            {
                if (Directory.Exists(layoutPath))
                {
                    Directory.Delete(layoutPath, true);
                }
                if (Directory.Exists(viewPath))
                {
                    Directory.Delete(viewPath, true);
                    widgetCount++;
                }
                if (Directory.Exists(listPath))
                {
                    Directory.Delete(listPath, true);
                    widgetCount++;
                }
                if (Directory.Exists(pageListPath))
                {
                    Directory.Delete(pageListPath, true);
                    widgetCount++;
                }
                if (widgetCount > 0)
                {
                    //重建部件索引
                    BaseControlHelper ctrHelper = new BaseControlHelper();
                    ctrHelper.CreateIntegrationIndexConfig();
                    ctrHelper.CreateWidegetsIndex();
                }
            }
            catch
            {
                msg    += "部分文件夹删除失败,请手动删除以下文件夹:\r\n";
                msg    += "1:" + layoutPath + "\r\n";
                msg    += "2:" + viewPath + "\r\n";
                msg    += "3:" + listPath + "\r\n";
                msg    += "4:" + pageListPath + "\r\n";
                success = false;
            }

            //删除数据库表
            try
            {
                DataBaseHelperFactory.Create().DeleteTable(modelInf);
            }
            catch
            {
            }
            //检查左侧菜单
            MenuHelper MenuHelper = HelperFactory.Instance.GetHelper <MenuHelper>();
            MenuItem   item       = MenuHelper.GetMenuItemByTitle(modelInf.Label + "管理");

            if (item != null && !string.IsNullOrEmpty(item.ID))
            {
                try
                {
                    MenuHelper.DeleteMenuItem(item.ID);
                }
                catch
                {
                    success = false;
                    msg    += "左侧菜单删除失败,请在【后台菜单管理里手动删除】";
                }
            }
            //检查是否关联了Channel
            List <Channel> channelList = HelperFactory.Instance.GetHelper <ChannelHelper>().
                                         GetChannelByModelName(modelInf.ModelName);

            if (channelList != null && channelList.Count > 0)
            {
                try
                {
                    foreach (Channel c in channelList)
                    {
                        c.ModelName = "";
                        HelperFactory.Instance.GetHelper <ChannelHelper>().UpdateChannel(c);
                    }
                }
                catch (Exception ex)
                {
                    success = false;
                    msg    += "内容模型已关联栏目,取消关联失败,请手动取消栏目和内容模型的绑定关系!错误消息:" + ex.Message;
                }
            }

            //删除XML节点及文件
            success = !ModelHelper.DeleteContentModel(modelName, ref msg) ? false : success;
            string strResult = "{\"success\":" + success.ToString().ToLower() + ",\"msg\":\"" + Utils.JsonCharFilter(msg) + "\"}";

            //return JsonConvert.SerializeObject(strResult).Replace("null", "\"\""); ;
            return(strResult);
        }
Ejemplo n.º 6
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            #region 保存设置信息

            //if (this.CheckCookie())
            //{

            //    Hashtable ht = new Hashtable();
            //    ht.Add("图片附件文字水印大小", watermarkfontsize.Text);
            //    ht.Add("JPG图片质量", attachimgquality.Text);
            //    ht.Add("图片最大高度", attachimgmaxheight.Text);
            //    ht.Add("图片最大宽度", attachimgmaxwidth.Text);

            //    foreach (DictionaryEntry de in ht)
            //    {
            //        if (!Utils.IsInt(de.Value.ToString()))
            //        {
            //            base.RegisterStartupScript("", "<script>alert('输入错误," + de.Key.ToString() + "只能是0或者正整数');window.location.href='global_attach.aspx';</script>");
            //            return;
            //        }

            //    }



            if (Convert.ToInt16(attachimgquality.Text) > 100 || (Convert.ToInt16(attachimgquality.Text) < 0))
            {
                this.Page.RegisterStartupScript("", "<script>alert('JPG图片质量只能在0-100之间');window.location.href='global_attach.aspx';</script>");
                return;
            }

            if (Convert.ToInt16(watermarktransparency.Text) > 10 || Convert.ToInt16(watermarktransparency.Text) < 1)
            {
                this.Page.RegisterStartupScript("", "<script>alert('图片水印透明度取值范围1-10');window.location.href='global_attach.aspx';</script>");
                return;
            }

            if (Convert.ToInt16(watermarkfontsize.Text) <= 0)
            {
                this.Page.RegisterStartupScript("", "<script>alert('图片附件添加文字水印的大小必须大于0');window.location.href='global_attach.aspx';</script>");
                return;
            }


            //if (Convert.ToInt16(attachimgmaxheight.Text) < 0)
            //{
            //    this.Page.RegisterStartupScript("", "<script>alert('图片最大高度必须大于或等于0');window.location.href='global_attach.aspx';</script>");
            //    return;
            //}

            //if (Convert.ToInt16(attachimgmaxwidth.Text) < 0)
            //{
            //    this.Page.RegisterStartupScript("", "<script>alert('图片最大宽度必须大于或等于0');window.location.href='global_attach.aspx';</script>");
            //    return;
            //}

            string            configFile   = Server.MapPath("~/Config/general.config");
            GeneralConfigInfo __configinfo = new GeneralConfigInfo();
            if (File.Exists(configFile))
            {
                __configinfo = GeneralConfigs.Deserialize(configFile);
            }
            //GeneralConfigInfo __configinfo = GeneralConfigs.Deserialize(Server.MapPath("~/Config/general.config"));
            __configinfo.WaterMarkStatus            = We7Request.GetInt("watermarkstatus", 0);
            __configinfo.WaterMarkType              = Convert.ToInt16(watermarktype.SelectedValue);
            __configinfo.WaterMarkText              = watermarktext.Text;
            __configinfo.WaterMarkPic               = watermarkpic.Text;
            __configinfo.WaterMarkFontName          = watermarkfontname.SelectedValue;
            __configinfo.WaterMarkFontSize          = Convert.ToInt32(watermarkfontsize.Text);
            __configinfo.WaterMarkTransparency      = Convert.ToInt16(watermarktransparency.Text);
            __configinfo.MaxWidthOfUploadedImg      = Convert.ToInt32(MaxWidthOfUploadedImgTextbox.Text);
            __configinfo.CutToMaxWidthOfUploadedImg = CuttoMaxCheckBox.Checked ? 1 : 0;

            GeneralConfigs.Serialiaze(__configinfo, Server.MapPath("~/Config/general.config"));

            Response.Redirect("system.aspx");
            //this.Page.RegisterStartupScript("PAGE", "window.location.href='sytem.aspx';");
            #endregion
        }
Ejemplo n.º 7
0
        private string DeleteFiles()
        {
            string result = "";

            string fileStr = We7Request.GetString("delFiles");

            if (fileStr.Length > 0)
            {
                string[] filePathList = Utils.SplitString(fileStr, ",");
                int      totalCount   = 0;
                int      errorCount   = 0;
                foreach (string filePath in filePathList)
                {
                    bool   exist        = false;
                    bool   isFile       = false;
                    string physicalPath = "";
                    if (filePath.Length > 0)
                    {
                        totalCount++;
                        try
                        {
                            physicalPath = Server.MapPath(filePath);
                            isFile       = (Path.GetExtension(physicalPath).Length > 0 ? true : false);
                            if (isFile)
                            {
                                exist = File.Exists(physicalPath);
                            }
                            else
                            {
                                exist = Directory.Exists(physicalPath);
                            }
                        }
                        catch
                        {
                        }
                        if (exist)
                        {
                            try
                            {
                                if (isFile)
                                {
                                    File.Delete(physicalPath);
                                }
                                else
                                {
                                    Directory.Delete(physicalPath, true);
                                }
                            }
                            catch (Exception ex)
                            {
                                result += "<br/>“" + physicalPath + "” 删除失败,原因:" + ex.Message;


                                errorCount++;
                            }
                        }
                    }
                }
                result = "升级文件异常:总文件数:" + totalCount + ",其中删除失败:" + errorCount + ",详细信息:" + result;
                if (errorCount > 0)
                {
                    We7.Framework.LogHelper.WriteLog(typeof(upgrade), result);
                }
            }

            return(result);
        }