Go Back   EN World D&D / RPG News > Blogs

Old

ASP.Net reminders

Posted 16th April 2009 at 12:45 PM by Plane Sailing
This is some code I'm pruning from an object but which I want to keep around

Code:
		private static int EntryIdToFind;
		public List<DiaryEntry> FindByEntryId(int entry_id)
		{
			EntryIdToFind = entry_id;
			List<DiaryEntry> list = new List<DiaryEntry>();
			list.Add(DiaryEntries.Find(FindByEntryId));
			return list;
		}

		public int FindIndexOfEntryId(int entry_id)
		{
			EntryIdToFind = entry_id;
			return DiaryEntries.FindIndex(FindByEntryId);
		}

		// Search predicate returns true if 
		private static bool FindByEntryId(DiaryEntry de)
		{
			if (EntryIdToFind == de.Entry_Id) {
				return true;
			} else {
				return false;
			}
		}

		public List<DiaryEntry> SortedDiaryList(DiarySortCriteria dsc)
		{
			switch (dsc) {
				case DiarySortCriteria.Date:
					//m_DiaryEntries.Sort(delegate(DiaryEntry de1, DiaryEntry de2) { return de1.ActivityDate.CompareTo(de2.ActivityDate); });
					m_DiaryEntries.Sort(CompareByDate);
					break;
				case DiarySortCriteria.Title:
					m_DiaryEntries.Sort(delegate(DiaryEntry de1, DiaryEntry de2) { return de1.Title.CompareTo(de2.Title); });
					break;
				case DiarySortCriteria.ActivityClass:
					m_DiaryEntries.Sort(CompareByClass);
					break;
				case DiarySortCriteria.ActivityCategory:
					m_DiaryEntries.Sort(CompareByCategory);
					break;
				case DiarySortCriteria.ActivityType:
					m_DiaryEntries.Sort(CompareByType);
					break;
				case DiarySortCriteria.DiaryStatus:
					m_DiaryEntries.Sort(CompareByStatus);
					break;
				default:
					break;
			}
			return m_DiaryEntries;
		}

		private static int CompareByDate(DiaryEntry de1, DiaryEntry de2)
		{
			if (de1 == null)
				if (de2 == null)
					return 0;
				else
					return -1;
			else {
				if (de2 == null)
					return 1;
				else {
					int retval = de1.ActivityDate.CompareTo(de2.ActivityDate);
					if (retval != 0)
						return retval;
					else
						return de1.Title.CompareTo(de2.Title);
				}
			}
		}


		private static int CompareByClass(DiaryEntry de1, DiaryEntry de2)
		{
			if (de1 == null)
				if (de2 == null)
					return 0;
				else
					return -1;
			else {
				if (de2 == null)
					return 1;
				else {
					int retval = de1.DiaryClassDescription.CompareTo(de2.DiaryClassDescription);
					if (retval != 0)
						return retval;
					else {
						int retval2 = de1.ActivityDate.CompareTo(de2.ActivityDate);
						if (retval2 != 0)
							return retval2;
						else
							return de1.Title.CompareTo(de2.Title);
					}
				}
			}
		}

		private static int CompareByCategory(DiaryEntry de1, DiaryEntry de2)
		{
			if (de1 == null)
				if (de2 == null)
					return 0;
				else
					return -1;
			else {
				if (de2 == null)
					return 1;
				else {
					int retval = de1.Activity.ActivityCategory.CompareTo(de2.Activity.ActivityCategory);
					if (retval != 0)
						return retval;
					else {
						int retval2 = de1.ActivityDate.CompareTo(de2.ActivityDate);
						if (retval2 != 0)
							return retval2;
						else
							return de1.Title.CompareTo(de2.Title);
					}
				}
			}
		}

		private static int CompareByType(DiaryEntry de1, DiaryEntry de2)
		{
			if (de1 == null)
				if (de2 == null)
					return 0;
				else
					return -1;
			else {
				if (de2 == null)
					return 1;
				else {
					int retval = de1.Activity.ActivityType.CompareTo(de2.Activity.ActivityType);
					if (retval != 0)
						return retval;
					else {
						int retval2 = de1.ActivityDate.CompareTo(de2.ActivityDate);
						if (retval2 != 0)
							return retval2;
						else
							return de1.Title.CompareTo(de2.Title);
					}
				}
			}
		}

		private static int CompareByStatus(DiaryEntry de1, DiaryEntry de2)
		{
			if (de1 == null)
				if (de2 == null)
					return 0;
				else
					return -1;
			else {
				if (de2 == null)
					return 1;
				else {
					int retval = de1.DiaryEntryStatus.CompareTo(de2.DiaryEntryStatus);
					if (retval != 0)
						return retval;
					else {
						int retval2 = de1.ActivityDate.CompareTo(de2.ActivityDate);
						if (retval2 != 0)
							return retval2;
						else
							return de1.Title.CompareTo(de2.Title);
					}
				}
			}
		}
Plane Sailing's Avatar
Astral Admin - Mwahahaha!
Posted in Uncategorized
Views 220 Comments 0 Plane Sailing is offline
Old

ASP.Net Gotchas

Posted 25th July 2008 at 11:54 AM by Plane Sailing
Just jotting a few notes down here as I've resolved another annoying little asp.net 2.0 'gotcha', in this case relating to the calendar control.

I'm using a calendar control in a gridview when a row is in update mode. My database contains some null dates for 'PaperworkReceived', but the calendar control chokes on null dates so I transform them into 1/1/1900 dates so I can give them special programatic handling.

I'm connecting to an objectdatasource which provides my interface to the database.

When 'null' dates are present, I set the selected date to 1/1/1900, but I set the visible date to todays date so that the calendar is in the correct position for someone who wants to select the date if the paperwork has just been received.

The strange thing is that even if you obtain a reference to the calendar object in the _RowUpdating procedure and set the parameter to the value of the selected date, it still passes the current date to the objectdatasource (!).

I resolved this by checking in the _RowUpdating procedure and if the selectedDate is 1/1/1900 I programatically set the view date to that just before I assign the parameters. (I've also changed the Bind() to an Eval() in the gridview code).

Code:
DateTime defaultdate = new DateTime(1900, 1, 1);
Calendar c = (Calendar)gvAuditees.Rows[e.RowIndex].FindControl("calPaperwork");
if (c.SelectedDate == defaultdate) {
	c.VisibleDate = c.SelectedDate;
} 
ObjectDataSource2.UpdateParameters.Clear();
...
ObjectDataSource2.UpdateParameters.Add("PaperworkReceived", c.SelectedDate.ToLongDateString());


I also use ToLongDateString to ensure that SQL server reliably parses the date - otherwise I get faux US mmddyy conversions happening on some installations.

Cheers
Plane Sailing's Avatar
Astral Admin - Mwahahaha!
Posted in Uncategorized
Views 340 Comments 0 Plane Sailing is offline
Old

Keep on the Shadowfell - Part 2

Posted 7th July 2008 at 02:23 PM by Plane Sailing
I do plan to come back and write these accounts up in more detail (really I do!) but here is the bare bones of the adventure from last night.

Because of various players away, we had the Dragon Paladin and Eladrin Warlock from last adventure who have been joined by a halfling rogue and human cleric of the raven queen.

They went to assault the kobold stronghold, and managed to take out all the kobolds outside (although they nearly lost the cleric in the process because he was left on his own and a bunch of minions ran over and ganged up on him!)

They then took a short rest (and were spied on by the kobolds, who prepared a couple of traps) and assaulted the kobolds behind the waterfall.

All were taken down to dying except the rogue, who surrendered. The dying were patched up and imprisoned, ready to be sold off as slaves to the hobgoblins.

In come party #2, comprising the Tiefling warlord of the original party, an elven ranger and an eladrin wizard.

It was a knock down and drag out fight, not least because of the appalling rolling by the PCs. The one saving grace was that all the dailys hit. The wizards Frost Fog (?) ended up killing a minion and bloodying the wyrmpriest, a skirmisher and a soldier. The rangers Split the Tree rolled a 1 and a 3... "Elven Accuracy!" rerolled and got a 20! 24 damage to the bloodied wyrmpriest and dragonshield wiped them out. Finally, the warlords 'lead the charge' against Irontooth, providing +5 to hit him for everyone was instrumental in their final victory.

Come the end, the warlord was down and dying (and died), the ranger ran away and the wizard was ray-of-frosting the bloodied Irontooth as he struggled through the difficult terrain (water) to get to him... and Irontooth didn't make it!

The earlier heroes were rescued, the warlord was mourned, the kobold horde was ransacked, alarming letters discovered and payment received for a job well done.

Phew!
Plane Sailing's Avatar
Astral Admin - Mwahahaha!
Posted in Storyhour , 4e Rules
Views 306 Comments 0 Plane Sailing is offline
Old

Keep on the Shadowfell - house rules

Posted 3rd July 2008 at 09:42 PM by Plane Sailing
Updated 3rd July 2008 at 09:49 PM by Plane Sailing
I've got a few house rules at the moment, to keep things fitting better with the 'heroic tier' as I envisage it for this game.

1) Dragonborn don't start off with a breath weapon. Gaining a breath weapon is a paragon tier feat for them. In its place they gain an elemental resistance (same rate as the tiefling). Should they get a breath weapon in the future, its type is the same as the energy resistance they've had since they were a shell.

2) Eladrin don't get 'Fey step' teleportation. Instead, they all get a wizard cantrip of their choice as a per-encounter ability. This reflects their innate magical ability well for my campaign, while teleporting 1st level characters doesn't fit my theme at all well!

If any more come up, I'll include them here too.
Plane Sailing's Avatar
Astral Admin - Mwahahaha!
Posted in Storyhour , 4e Rules
Views 1065 Comments 12 Plane Sailing is offline
Old

Keep on the Shadowfell - part 1

Posted 3rd July 2008 at 02:58 PM by Plane Sailing
Updated 3rd July 2008 at 09:49 PM by Plane Sailing
It is a hundred years since the empire of Nerath fell. The ripples of that fall are still spreading out across the many lands that once looked to the seat of the empire for protection and rule.

Now only points of light glimmering in the darkness remain. Yet in the hearts of heroes the desire to stand up for all that once made Nerath great still beats strongly. The Nerath Foreign Legion, comprising people from all walks of life and all species under the sun still exists out in the borderlands, and it sends teams of legionnaires to the outlying remnants of civilisation - a reminder that help is still at hand in time of need.

A small team of legionnaires has been sent to Winterhaven, to check on rumours of death cultists and to look for another legionary who went missing there a month or so ago. They expect to be joined by their friends soon, but their first visit is on their own:

Cast

Shamash, Dragonborn Paladin of Bahamut 1
Thoradin, Dwarf Cleric of Moradin 1
Bethrynna, Eladrin Fey Warlock 1
Damakos, Tiefling Warlord 1
Plane Sailing's Avatar
Astral Admin - Mwahahaha!
Posted in Storyhour
Views 626 Comments 3 Plane Sailing is offline
Old

My first blog entry

Posted 27th June 2008 at 12:31 PM by Plane Sailing
Somehow it seems appropriate that it will be on ENworld

My plan is to have some storyhour elements here, some campaign discussions, perhaps some game design thoughts.

Still, all to come after the current moderation checks, eh?

Cheers
Plane Sailing's Avatar
Astral Admin - Mwahahaha!
Posted in Uncategorized
Views 1035 Comments 4 Plane Sailing is offline
And yet another word from our sponsors
Visit Our Sponsors
Visit Our Sponsors... Again
Powered by vBadvanced CMPS v3.0.1

All times are GMT +1. The time now is 12:00 PM.


Site Contents © 2008 ENWorld
PHP Ajax Multimedia Web Framework © 2008 Digital Media Graphix
Powered by vBulletin® Version 3.8.0 Beta 1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

"Vault Data" powered by VaultWiki v2.5.1.
Copyright © 2008 - 2009, Cracked Egg Studios.