Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Webmethod for IWebCS not working as expectedWebmethod for IWebCS not working as expected
Previous
 
Next
New Post
7/30/2009 7:55 AM
 

Hi all

I have written a webmethod for the IWebCS module. The purpose of the webmethod is to add pages, and each new page should contain the HTML module.

While it does add a new page, with a HTML module, it seems that the new module always has the same moduleID, so that when it is added all other previously added pages, and their respective modules get updated.

 

I have tried clearing various caches, tried hard coding the module id but nothing seems to work. Does anyone have any ideas? here is my code:

 

[WebMethod(Description = "Creates a new page")]
        public int CreatePage(string pageName, string content, string title, string lang)
        {

            //Create page (tab)
            //TODO: set public read permissions for pages(hopefully the module will inheirate the permissions).
            //TODO: new module is created with old module id. Why?
            DotNetNuke.Entities.Tabs.TabController controller = new DotNetNuke.Entities.Tabs.TabController();
            DotNetNuke.Entities.Tabs.TabInfo newTab = new DotNetNuke.Entities.Tabs.TabInfo();
            //newTab.LocalizedTabName = lang; //read only.
            //DotNetNuke.Security.Permissions.TabPermissionCollection tp = new DotNetNuke.Security.Permissions.TabPermissionCollection();
            //tp.
           
            //newTab.TabPermissions = new
            newTab.PortalID = 0;
            newTab.TabName = pageName;
            newTab.Title = pageName;
            newTab.Description = pageName;
            newTab.KeyWords = pageName;
            newTab.IsDeleted = false;
            newTab.IsSuperTab = false;
            newTab.IsVisible = true;
            newTab.DisableLink = false;
            newTab.IconFile = "";
            newTab.Url = "";
           

            int newTabId = controller.AddTab(newTab); //add new page.
            controller.ClearCache(0);
           
            // clear cache
            DataCache.ClearModuleCache(newTab.TabID);
          
            ///Add module to newTab
            DotNetNuke.Entities.Modules.ModuleInfo modInfo = new DotNetNuke.Entities.Modules.ModuleInfo();
            DotNetNuke.Entities.Modules.ModuleController mc = new DotNetNuke.Entities.Modules.ModuleController();
            modInfo.DisplayTitle = true;
            modInfo = mc.GetModuleByDefinition(0, "Text/HTML");   
            modInfo.Header = "header string";
            //modInfo.IsDefaultModule = true;//do we need this?
            modInfo.PaneName = "ContentPane";
            modInfo.TabID = newTabId;
            modInfo.ModuleTitle = title;
            modInfo.Header = title;
            //modInfo.DesktopModuleID = 68; //HTML text module
            //modInfo.ModuleID = 68;
            modInfo.PortalID = 0;
            modInfo.EndDate = System.DateTime.Now.AddYears(10);
            modInfo.InheritViewPermissions = true;
            modInfo.IsDefaultModule = true;
            modInfo.ModuleOrder = 1;
            modInfo.AllTabs = false;
           
            int newModuleID=mc.AddModule(modInfo); //add module to the page       

            DotNetNuke.Modules.HTML.HtmlTextInfo htmlinfo = new DotNetNuke.Modules.HTML.HtmlTextInfo();
            DotNetNuke.Modules.HTML.HtmlTextController htmlcont = new DotNetNuke.Modules.HTML.HtmlTextController();
            htmlinfo.ModuleID = newModuleID;
            htmlinfo.Content = content;
            htmlinfo.PortalID = 0;
            htmlinfo.IsPublished = true;
            htmlinfo.StateID = 1;
            modInfo.ModuleTitle = title;
           
            //htmlinfo.WorkflowID = 1;
            //htmlinfo.WorkflowName = "Direct Publish";
            //htmlinfo.Approved = true;
            //htmlcont.UpdateWorkflowID(modInfo.ModuleID, 0, 1);

            //htmlcont.GetWorkflowID(newModuleID, 0);
            //htmlcont.DeleteHtmlText(newModuleID, 0);
            //htmlcont.UpdateHtmlText(htmlinfo, htmlcont.GetMaximumVersionHistory(0));
            //htmlcont.
            mc.UpdateModule(modInfo);
           
           
            // clear cache
            DataCache.ClearModuleCache(newTab.TabID);
            DataCache.ClearTabsCache(0);
            DataCache.ClearCache();
            controller.ClearCache(0);
           
            return newTabId;  

        }

 
New Post
7/30/2009 9:15 PM
 

for support on 3rd party extensions like IWeb, please use the developers/vendors support options, Thank you.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
7/30/2009 9:26 PM
 

This actually has nothing really to do with IWeb because there are no calls at all to the IWeb code in the code sample (also there is no IWebCS only IWeb and IWebCF).

As to the problem, the process to create a new module, if you set either of these two lines to a non existant ModuleID, did it create the module using that ID?

modInfo.DesktopModuleID = 68; //HTML text module
modInfo.ModuleID = 68;
 



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
7/31/2009 9:55 AM
 

When I run it with those two lines uncommented I get the following:

System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_ModuleSettings_Modules". The conflict occurred in database "DNN2", table "dbo.Modules", column 'ModuleID'.
The statement has been terminated.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(SqlConnection connection, CommandType commandType, String commandText, SqlParameter[] commandParameters)
   at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters)
   at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, String spName, Object[] parameterValues)
   at DotNetNuke.Data.SqlDataProvider.AddModuleSetting(Int32 ModuleId, String SettingName, String SettingValue, Int32 createdByUserID)
   at DotNetNuke.Entities.Modules.ModuleController.UpdateModuleSetting(Int32 ModuleId, String SettingName, String SettingValue)
   at DotNetNuke.Modules.HTML.HtmlTextController.UpdateWorkflowID(Int32 ModuleID, Int32 PortalID, Int32 WorkflowID) in C:\Documents and Settings\ANH\My Documents\Projects\EPRTRsrc\DNN2\DotNetNuke_Community_05.01.00_Install\App_Code\HTML\HtmlTextController.vb:line 445
   at DotNetNuke.Modules.IWebCSharp.WebService.CreatePage(String pageName, String content, String title, String lang) in c:\Documents and Settings\ANH\my documents\projects\eprtrsrc\dnn2\dotnetnuke_community_05.01.00_install\App_Code\IWebCSharp\IWebMethods\IWebMisc.cs:line 137

Its crazy. I just cant seem to get a unique module to be inserted onto the page. This is truly driving me crazy!

 
New Post
7/31/2009 6:52 PM
 

Yeah this is a tough one and I have no code samples to offer because I have never tried this.

The good news is you know it can be done because the Core DotNetNuke code is clearly doing this.

You will have to download the source version of DotNetNuke and run it using a debugger to trace the path and see exactly what it's doing when you do it normally through the UI.

When you figure it out it would be great if you posted your working code.



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Webmethod for IWebCS not working as expectedWebmethod for IWebCS not working as expected


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out