예제 #1
0
        public string GetModuleHtml(int moduleId)
        {
            string ret = "";

            try
            {
                Domain.Modules module;
                using (var session = new Data.DataSession())
                {
                    var repo = new Data.ModulesRepository(session.UnitOfWork);
                    module = repo.GetSingle(moduleId);
                }

                var control = ModulesManager.GetControlFromModuleData(module);

                var single = (Module.SingleModule) new DefaultModuleFactory("~/Module/SingleModule.ascx").GetControl(module);

                single.Control = control;

                single.Initialize(true);
                var children = ModulesHelper.FlattenChildren(single);

                var enumerator = children.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var child = enumerator.Current;

                    if (child is ModuleUserControl)
                    {
                        var moduleChild = (ModuleUserControl)child;
                        moduleChild.Initialize(true);
                    }
                }

                ret = RenderControlToHtml(single);
            }
            catch (Exception ex)
            {
                ret = ex.ToString();
            }

            return(ret);
        }