08-23-05 10:53 PM
Hi,
never use datasource.rawcontent to update a placeholder!
See here for details:
http://blogs.technet.com/stefan_gos.../24/119546.aspx
Please replace these references with the correctly casted placeholder
references.
If the problem still occurs, please attach VS.NET as debugger to the process
and step through the routine to see which of the placeholders is causing the
problem.
Btw: the posting object is not initialized in this method. Where do you set
this object?
Which mode is the CmsContext in when this code is being executed?
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
<hemlata_shah@yahoo.com> wrote in message
news:1124821941.498973.224460@g44g2000cwa.googlegroups.com...
> private void btnTopSaveforPreview_Click(object sender, System.EventArgs
> e)
> {
> try
> {
>
> string historychannels =
> posting.Placeholders["htmlSelectedChannelsHistory"].Datasource.RawCont
ent;
> string selectedchannels =
> posting.Placeholders["htmlSelectedChannels"].Datasource.RawContent;
>
> // Creating he XML for Channel Tree
>
> TreeNodeCollection nodes = ChannelTree.Nodes;
> this.SelectedChannels = null;
> this.SelectedChannels = new StringCollection();
>
> foreach(TreeNode node in nodes)
> {
> this.getAllSelectedChannels(node);
> }
>
>
> // You now have the set of selected channels in the collection
> // SelectedChannels
>
> // Save the channels in the XMLPlaceHolderControl
> XmlDocument xmlChannels = new XmlDocument();
> XmlNode xmlnode;
> XmlElement element;
>
> // Creating the XML Structure
> xmlChannels.LoadXml("<Channels></Channels>");
>
> foreach(string chSelectedChannels in SelectedChannels)
> {
> xmlnode = xmlChannels.CreateNode(XmlNodeType.Element, "Channel",""
> );
> xmlnode.InnerText = chSelectedChannels;
> element = xmlChannels.DocumentElement;
> element.AppendChild(xmlnode);
>
> }
>
> // Persisting SelectedChannelsHistory in SelectedChannels
>
> historychannels =
> posting.Placeholders["htmlSelectedChannelsHistory"].Datasource.RawCont
ent;
> selectedchannels =
> posting.Placeholders["htmlSelectedChannels"].Datasource.RawContent;
>
> posting.Placeholders["htmlSelectedChannels"].Datasource.RawContent
> = "<Channels></Channels>";
> posting.Placeholders["htmlSelectedChannels"].Datasource.RawContent
> = xmlChannels.InnerXml;
>
> posting.Placeholders["htmlSelectedChannelsHistory"].Datasource.RawCont
ent
> = "<Channels></Channels>";
> if(selectedchannels.Length>0)
> posting.Placeholders["htmlSelectedChannelsHistory"].Datasource.RawCont
ent
> = selectedchannels;
>
>
> // Setting the Posting Status to Saved. Production/ContentTypes
> posting.CustomProperties["ProcessStatus"].Value = "Saved";
> posting.CustomProperties["IsInPreview"].Value = "1";
> posting.CustomProperties["IsInProduction"].Value = "0";
>
> // Setting the Posting Status to Saved. Initial Setup Properties
> initposting.CustomProperties["ProcessStatus"].Value = "Saved";
> initposting.CustomProperties["IsInPreview"].Value = "1";
> initposting.CustomProperties["IsInProduction"].Value = "0";
>
> // Call procedure for Admin and Saved
> this.EnableForAdmin_Saved();
>
> posting.Approve();
> initposting.Approve();
>
> AppContext.CommitAll();
> posting.ReleaseOwnership();
> initposting.ReleaseOwnership();
> AppContext.CommitAll();
>
> // Showing message to the user
> string message =
> context.SystemMessages. GetMessage(SystemMessagesCustomizationPa
rameters.Me
ssageEnum.MR31);
> base.SetMessage(message) ;
>
> }
> catch(Exception excep)
> {
> // Handle Exception here
> base.SetError(excep);
> }
>
> # region Posting in Site Map
> // From here
>
> try
> {
> // Call getAllSelectedChannels
> // All Selected channels can be accessed by calling the
> getAllSelectedChannels()
> string selectedChannelList =
> posting.Placeholders["htmlSelectedChannels"].Datasource.RawContent ;
>
> string currentHistorychannels =
> posting.Placeholders["htmlSelectedChannelsHistory"].Datasource.RawCont
ent;
>
> if(selectedChannelList.Length==0)
> {
> selectedChannelList = "<channels></channels>";
> }
>
> if(currentHistorychannels.Length==0)
> {
> currentHistorychannels = "<channels></channels>";
> }
>
> StringCollection deSelectedChannels = new StringCollection();
>
> Template tTemplate = (Template)
> AppContext.Searches.GetByPath("/Templates/lol/sec/en/Shared/Template1H");
>
> string prodarticleguid = posting.Guid;
>
> XmlDocument xmlChannels = new XmlDocument();
> xmlChannels.LoadXml(selectedChannelList);
>
> XmlDocument xmlHistoryChannels = new XmlDocument();
> xmlHistoryChannels.LoadXml(currentHistorychannels);
>
> string channel = string.Empty ;
> Channel prodChannel = null;
>
> CopyPostingDao copyDao = (CopyPostingDao)
> base.GetDao(typeof(CopyPostingDao));
>
> bool channelDeselected = true;
>
> foreach(XmlElement historyElement in
> xmlHistoryChannels.GetElementsByTagName("Channel"))
> {
> channelDeselected = true;
> foreach(XmlElement selectedElement in
> xmlChannels.GetElementsByTagName("Channel"))
> {
> if(selectedElement.InnerText == historyElement.InnerText)
> {
> channelDeselected = false;
> break;
> }
> }
>
> if (channelDeselected)
> {
> // This element was deselected
> deSelectedChannels.Add(historyElement.InnerXml);
> channel = historyElement.InnerText;
> prodChannel = (Channel) AppContext.Searches.GetByPath(channel);
>
> prodPosting = (Posting)
> AppContext.Searches.GetByPath(channel+posting.Name);
> if(prodPosting!=null)
> {
> prodPosting.Delete();
> AppContext.CommitAll();
> }
> }
>
> }
>
> channel = null;
>
> foreach(XmlElement element in
> xmlChannels.GetElementsByTagName("Channel"))
> {
> // Create Posting using Template1h in the selected Channels
> channel = element.InnerText;
> prodChannel = (Channel) AppContext.Searches.GetByPath(channel);
> // Checking if the Posting exists already, if so, we dont make any
> changes
> // Otherwise, we create a New Posting using Template1h
> prodPosting = (Posting)
> AppContext.Searches.GetByPath(channel+posting.Name);
> if(prodPosting==null)
> {
> prodPosting = prodChannel.CreatePosting(tTemplate);
>
> }
> else
> {
> prodPosting.Delete();
> AppContext.CommitAll();
>
> prodPosting = prodChannel.CreatePosting(tTemplate);
>
>
> }
>
> // Name the posting same as the Preview/Article Posting Name
> prodPosting.Name = posting.Name;
> prodPosting.DisplayName =
> RemoveHtmlSUPTags(posting.Placeholders["htmlTitle"].Datasource.RawCont
ent.ToString());
> string enddate = posting.CustomProperties["EndDate"].Value;
> if(enddate.Length>0)
> {
> prodPosting.ExpiryDate = DateTime.Parse(enddate);
> }
>
> // Set the Prod Posting Object name as the Posting Object name
> prodPosting.CustomProperties["ObjectName"].Value =
> posting.CustomProperties["ObjectName"].Value;
>
> // Setting the Page ID of the Posting
> if(prodPosting.Path.IndexOf("/SiteMap/ProductsandPlanning/") <= 0)
> prodPosting.CustomProperties["PageID"].Value =
> "og/Online/ContentManagement/Articles/Standard";
> else
> prodPosting.CustomProperties["PageID"].Value =
> "og/Online/ContentManagement/Articles/ProdPlanArticle";
>
>
> // Set IsInProduction Property
> prodPosting.CustomProperties["IsInProduction"].Value = "0";
>
> // Set IsInPreview Property
> prodPosting.CustomProperties["IsInPreview"].Value = "1";
>
> // Set the Article GUID Custom Property
>
> // for enabling the Article Conroller to pickup the correct GUID
> // and for solving the issues about inconsistent GUIDs during
> replications
> // prodPosting.CustomProperties["ArticleGUID"].Value =
> posting.Guid ;
> prodPosting.CustomProperties["ArticleGUID"].Value =
> posting.CustomProperties["SourceGUID"].Value;
>
> // Approve, Commit and release ownership
> // Possiblity of multi-object commit - can show up here -
> prodPosting.Approve();
> AppContext.CommitAll();
> prodPosting.ReleaseOwnership();
> AppContext.CommitAll();
>
> }
> }
> catch(Exception excep)
> {
> // Handle Exception here
> base.SetError(excep);
> }
>
> # endregion
>
>
> }
>
[ Post a follow-up to this message ]
|