Exemplo n.º 1
0
        ///// <summary>
        ///// Isolated=true indicates that the module should behave normally, that is,
        ///// an initial module instance is automatically saved by EnsureModule().
        ///// Isolated=false indicates that this module is a child of a
        ///// MasterDetail List module; in this case, the module will not be saved
        ///// until the user clicks the save button.
        ///// </summary>
        //public bool Isolated
        //{
        //    get { return (bool)(ViewState["Isolated"] ?? true); }
        //    set { ViewState["Isolated"] = value; }
        //}

        /// <summary>
        /// Checks that the custom module data exists. If the custom module
        /// object cannot be retrieved (e.g., this is the initial creation of
        /// the module), then a new module object is created using the module
        /// id assigned by the CMS.
        /// </summary>
        override protected void EnsureModule()
        {
            MasterDetailItem module = MasterDetailItem.GetResource(this.ModuleId);

            if (null == module)
            {
                module          = new MasterDetailItem();
                module.ModuleId = this.ModuleId;
                module.Culture  = WM.CultureCode.Current;
                module.Save();
            }
        }
        public static MasterDetailItem GetSafeResource(int moduleId, string cultureCode)
        {
            MasterDetailItem itemRes = MasterDetailItem.GetResource(moduleId, cultureCode);

            if (null == itemRes)
            {
                //try default culture
                WM.CultureCode defaultCultureCode = WM.CultureCode.GetDefaultCulture();
                if (null != defaultCultureCode && WM.CultureCode.Current != defaultCultureCode.Name)
                {
                    itemRes = MasterDetailItem.GetResource(moduleId, defaultCultureCode.Name);
                }
            }

            return(itemRes);
        }