Uncategorized

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&quot;);

}

}

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&quot;);

}

}//end conditional logic

 

}

 

The only thing required is an HHTP CMSPosting Mudule , enrolled in web.config.

 

Advertisements

One thought on “MCMS Restrict Posting only during 9am to 5pm

  1. <a href="http://www.rmt-wm.com">RMT-WM</a&gt; <a href="http://rmtvip.jp">rmtvip</a>The baby eagle liked the nest. 「<a href="http://www.rmt-wm.com/games/aion.html">-aion rmt</a>」It was the only world he had ever known. <a href="http://www.rmtvip.jp/game/aion.html">aion RMT</a> It was warm and comfortable, had a great view, 「<a href="http://www.rmt-wm.com/games/0003.html"&gt; リネージュ2 rmt</a> and even better, he had all the food and love and attention that a great mother eagle could provide. <a href="http://www.rmtvip.jp/game/Lineage2_リネージュ2_RMT.html">リネージュ2 RMT</a> Many times each day the mother would swoop down from the sky and land in the nest and feed the baby eagle delicious morsels of food. She was like a god to him, he had no where she came from or how she worked her magic. <a href="http://www.rmt-wm.com/games/A004.html">アラド戦記 rmt</a>The baby eagle was hungry all the time, but the mother eagle would always come just in time with the food and love and attention he craved. The baby eagle grew strong. <a href="http://www.rmtvip.jp/game/アラド戦記_RMT.html">アラド戦記 RMT</a>His vision grew very sharp. He felt good all the time. <a href="http://www.rmt-wm.com/games/0005.html">ff11 rmt</a>Until one day, the mother stopped coming to the nest. <a href="http://www.rmtvip.jp/game/FF11_FFXI_RMT.html">FF11 RMT</a>Thelooked up at the mother and cried "Why did you abandon me? I’m going to die any minute. How could you do faster. He screamed. "I’m dying I’m dying," he cried. He picked up more speed. <a href="http://www.replica-watches-mall.com">Replica Watche</a>He looked up at his mother. "How could you do this to me?" He looked down. Something strange happens.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s