public VelocityHelper(basePortalModule _bpm, EffectDBEntity _Theme)
        {
            Theme = _Theme;
            bpm   = _bpm;

            Init(_bpm);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取Form传值
        /// </summary>
        /// <param name="fieldItem"></param>
        /// <returns></returns>
        public static String GetWebFormValue(SettingEntity fieldItem, basePortalModule bpm)
        {
            String WebFormValue = String.Empty;

            //创建控件的Name和ID
            ControlHelper ControlItem = new ControlHelper(bpm.ModuleId);
            String        ControlName = ControlItem.ViewControlName(fieldItem);
            String        ControlID   = ControlItem.ViewControlID(fieldItem);

            if (fieldItem.ControlType == EnumControlType.CheckBox.ToString())
            {
                WebFormValue = WebHelper.GetStringParam(HttpContext.Current.Request, ControlName, "");
                WebFormValue = !String.IsNullOrEmpty(WebFormValue) && WebFormValue == "on" ? "true" : "false";
            }
            else if (fieldItem.ControlType == EnumControlType.FileUpload.ToString())
            {
                HttpPostedFile hpFile = HttpContext.Current.Request.Files[ControlName];
                if (hpFile != null && hpFile.ContentLength > 0)
                {
                    WebFormValue = String.Format("Url://{0}", FileSystemUtils.UploadFile(hpFile, bpm));                                                            //存放到目录中,并返回
                }
            }
            else
            {
                WebFormValue = WebHelper.GetStringParam(HttpContext.Current.Request, ControlName, "");
            }
            return(WebFormValue);
        }
        /// <summary>
        /// 绑定控件到容器
        /// </summary>
        public void BindContainer()
        {
            MenuTabItem _MenuTabItem = InitMenuTabCollection.ContainsKey(Token) ? InitMenuTabCollection[Token] : new MenuTabItem();

            if (_MenuTabItem != null && !String.IsNullOrEmpty(_MenuTabItem.Token) && !this.DesignMode)
            {
                //判断是否为管理员菜单,当前用户是否为管理员
                if (_MenuTabItem.IsAdministrator && !IsAdministrator)
                {
                    phContainer.Visible = false;
                    mTips.MsgType       = EnumTips.Warning;
                    mTips.Content       = ViewResourceText("HasModuleAccess", "You are not permitted to access this page! :(");
                    mTips.Put();
                }
                else
                {
                    //加载相应的控件
                    basePortalModule ManageContent = new basePortalModule();
                    string           ContentSrc    = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, _MenuTabItem.Src));

                    if (System.IO.File.Exists(MapPath(ContentSrc)))
                    {
                        ManageContent = (basePortalModule)LoadControl(ContentSrc);
                        ManageContent.ModuleConfiguration = ModuleConfiguration;
                        ManageContent.ID = _MenuTabItem.Token;
                        ManageContent.LocalResourceFile = Localization.GetResourceFile(this, string.Format("{0}.resx", _MenuTabItem.Src));
                        phContainer.Controls.Add(ManageContent);
                    }
                }

                //标题
                Page.Title = String.Format("{0} - {1} - {2}", ViewMenuText(_MenuTabItem), ModuleConfiguration.ModuleTitle, PortalSettings.ActiveTab.LocalizedTabName);
            }
            else if (!String.IsNullOrEmpty(Token) && Token.ToLower() == "error")
            {
                //加载相应的控件
                basePortalModule ManageContent = new basePortalModule();
                string           ContentSrc    = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, "Manager_ErrorCatch.ascx"));

                if (System.IO.File.Exists(MapPath(ContentSrc)))
                {
                    ManageContent = (basePortalModule)LoadControl(ContentSrc);
                    ManageContent.ModuleConfiguration = ModuleConfiguration;
                    ManageContent.ID = "ErrorCatch";
                    ManageContent.LocalResourceFile = Localization.GetResourceFile(this, string.Format("{0}.resx", "Manager_ErrorCatch.ascx"));
                    phContainer.Controls.Add(ManageContent);
                }
                //标题
                Page.Title = String.Format("{0} - {1}", "Error", ModuleConfiguration.ModuleTitle);
            }

            //首页地址
            hlHome.NavigateUrl = Globals.NavigateURL(TabId);
        }
        /// <summary>
        /// 载入模块
        /// </summary>
        /// <param name="ModuleSrc"></param>
        /// <param name="phContainer"></param>
        public void LoadModule(String ModuleSrc, ref PlaceHolder phContainer)
        {
            basePortalModule ManageContent = new basePortalModule();

            ManageContent.ID = ModuleSrc.Replace(".ascx", "");
            String ContentSrc = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, ModuleSrc));

            ManageContent = (basePortalModule)LoadControl(ContentSrc);
            ManageContent.ModuleConfiguration = this.ModuleConfiguration;
            ManageContent.LocalResourceFile   = Localization.GetResourceFile(this, string.Format("{0}.resx", ModuleSrc));
            phContainer.Controls.Add(ManageContent);
        }
        /// <summary>
        /// 绑定列表数据到容器
        /// </summary>
        private void BindContainer()
        {
            //加载相应的控件
            basePortalModule ManageContent = new basePortalModule();
            String           ModuleSrc     = "View_Info.ascx";

            ManageContent.ID = Token;
            String ContentSrc = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, ModuleSrc));

            ManageContent = (basePortalModule)LoadControl(ContentSrc);
            ManageContent.ModuleConfiguration = this.ModuleConfiguration;
            ManageContent.LocalResourceFile   = Localization.GetResourceFile(this, string.Format("{0}.resx", ModuleSrc));
            phContainer.Controls.Add(ManageContent);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 保存XML到文件
        /// </summary>
        /// <param name="XmlName">XML文件名</param>
        /// <param name="XmlContent">XML内容</param>
        /// <param name="pmb"></param>
        /// <returns></returns>
        public static String SaveXmlToFile(String XmlName, String XmlContent, basePortalModule pmb)
        {
            String FileFullName = String.Format("{0}LayerGallery\\Export\\{1}", pmb.PortalSettings.HomeDirectoryMapPath, XmlName);

            FileInfo XmlFile = new FileInfo(FileFullName);

            if (!XmlFile.Directory.Exists)
            {
                XmlFile.Directory.Create();
            }

            using (StreamWriter sw = new StreamWriter(FileFullName))
            {
                sw.Write(XmlContent);
                sw.Flush();
                sw.Close();

                return(FileFullName);
            }
        }
        /// <summary>
        /// 初始话CNVelocity模块
        /// </summary>
        public void Init(basePortalModule _bpm)
        {
            //创建VelocityEngine实例对象
            velocity = new VelocityEngine();


            //使用设置初始化VelocityEngine
            ExtendedProperties props = new ExtendedProperties();

            props.AddProperty(RuntimeConstants.RESOURCE_LOADER, "file");
            props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, HttpContext.Current.Server.MapPath(String.Format("{0}Effects/{1}/", _bpm.ModulePath, _bpm.Settings_EffectName)));
            //props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, Path.GetDirectoryName(HttpContext.Current.Request.PhysicalPath));
            props.AddProperty(RuntimeConstants.INPUT_ENCODING, "utf-8");
            props.AddProperty(RuntimeConstants.OUTPUT_ENCODING, "utf-8");

            //模板的缓存设置
            props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, false);              //是否缓存
            props.AddProperty("file.resource.loader.modificationCheckInterval", (Int64)600);    //缓存时间(秒)

            velocity.Init(props);

            //为模板变量赋值
            context = new VelocityContext();
        }
Exemplo n.º 8
0
 /// <summary>
 /// 获取资源文件夹中的内容
 /// </summary>
 /// <param name="PathName">文件夹名</param>
 /// <param name="FileName">文件名</param>
 /// <param name="pmb">当前模块对象</param>
 /// <returns></returns>
 public static String Resource(String PathName, String FileName, basePortalModule pmb)
 {
     return(String.Format("{0}{1}/{2}", pmb.ModulePath, PathName, FileName));
 }
Exemplo n.º 9
0
 public TemplateFormat(basePortalModule _bpm)
 {
     bpm = _bpm;
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="pmb">集成模块的对象</param>
 public VelocityHelper(basePortalModule _bpm)
 {
     bpm = _bpm;
     Init(_bpm);
 }