MCMS Restrict Posting only during 9am to 5pm
Check out the follwoing code sample , it shows how to allow posting in MCMS2002 only during 9am to 5pm
this is a classic example of how bussiness rules can be applied.
protected void CmsPosting_Submitted( Object sender, ChangedEventArgs e )
{
//get the posting
Posting post = e.Target
as Posting;
//Get the current time of server
String now = DateTime.Now.ToShortTimeString();
String []hr = now.Split(‘:’);
String []min = hr[1].Split(‘ ‘);
String amPm = min[1];
Int32 allowedStartHour = 9;
Int32 allowedEndHour = 5;
String allowedZone = “am”;
if(“am”.Equals(amPm.ToLower()))
{
//check for 9 – 12 am (12 pm exclusive)
if(Int32.Parse(hr[0]) >= allowedStartHour && Int32.Parse(hr[0])<=11)
{
//allowed
Response.Write(“The Posting is submitted sucessfully”);
}
else
{
//delete
Response.Write(“The Posting can only submitted at 9am to 5pm ”);
CmsHttpContext.Current.CommitAll();
post.AcquireOwnership();
post.Delete();
CmsHttpContext.Current.CommitAll();
Response.Redirect(“http://localhost/MCMS/McmsHomeport/McmsHomeport.aspx");
}
}
else if(“pm”.Equals(amPm.ToLower()))
{
//check for 12 – 5 pm
if(Int32.Parse(hr[0])>= 12 && Int32.Parse(hr[0])<=allowedEndHour-1)
{
//allowed
Response.Write(“The Posting is submitted sucessfully”);
}
else
{
Response.Write(“The Posting can only submitted at 9am to 5pm ”);
CmsHttpContext.Current.CommitAll();
post.AcquireOwnership();
post.Delete();
CmsHttpContext.Current.CommitAll();
Response.Redirect(“http://localhost/MCMS/McmsHomeport/McmsHomeport.aspx");
}
}//end conditional logic
}
The only thing required is an HHTP CMSPosting Mudule , enrolled in web.config.
Originally published on WordPress on 2005-10-25.
Read next
-
MCMS 2002 & WWF (Architecture Overview)
Well one thing that i love about CMS 2002 workflow (yes if you dont know that ,this may be surprising to you ) is that its simple ( 3 step at most ) , secondly we have all the Events with much…
-
MVP SharePoint Chat — Wednesday May 25th at 9am PDT
When: 9 AM PDT, 25th May 2011 (PDT? Convert to your time zone here) Where: Online | Enter Chat Room Do you have tough technical questions regarding SharePoint for which you're seeking answers? Do…
-
How to fix SharePoint Online (403) Forbidden Error while downloading files using Client Object Model
Recently I was working on a project that requires to programmatically access and download files from SharePoint Online (part of Office 365) document library. Currently remote authentication (SP…
Worth reading again?
Get the next one in your inbox.