Show HandwrittenStoryCard.cs syntax highlighted
using System;
using System.Collections;
using System.Xml;
namespace Whiteboard
{
/// <summary>
/// Summary description for HandwrittenStoryCard.
/// </summary>
public class HandwrittenStoryCard
{
#region member declarations
private int projectID;
private String storyName;
private int processTypeID;
private String processTypeName;
private int iterationID;
private String iterationName;
private String description;
private String activityType;
private String effort;
private ArrayList programmerList = new ArrayList();
private XmlDocument xml;
#endregion
// Business Logic
public void addProgrammer(String programmerID, String programmerName)
{
String[] programmer = new String[2];
programmer[0] = programmerID;
programmer[1] = programmerName;
programmerList.Add(programmer);
}
private void removeElement(String tagName)
{
XmlNodeList myNodeList = xml.GetElementsByTagName(tagName);
myNodeList[0].RemoveAll();
myNodeList[0].ParentNode.RemoveChild(myNodeList[0]);
}
// Setters
#region Setters
public void setProjectID(int id)
{
projectID = id;
}
public void setStoryName(String name)
{
storyName = name;
}
public void setProcessTypeID(int id)
{
processTypeID = id;
}
public void setProcessTypeName(String name)
{
processTypeName = name;
}
public void setIterationID(int id)
{
iterationID = id;
}
public void setIterationName(String name)
{
iterationName = name;
}
public void setDescription(String desc)
{
description = desc;
}
public void setActivityType(String type)
{
activityType = type;
}
public void setEffort(String effortRequired)
{
effort = effortRequired;
}
public void setXML(String xmlSource)
{
xml = new XmlDocument();
xml.LoadXml(xmlSource);
// Delete the three nodes we don't want namely:
// This is because they are the base 64 strings and they take up a lot of space
removeElement("storyName");
removeElement("description");
removeElement("effort");
// Uncomment the next line if you want to dump the entire xml to screen
//xml.Save(Console.Out);
}
#endregion
// Getters
#region Getters
// Getters
public String getElement(String tagName)
{
try
{
XmlNodeList myNodeList = xml.GetElementsByTagName(tagName);
return myNodeList[0].InnerText;
}
catch(System.NullReferenceException)
{
return null;
}
}
public String XmlStoryName
{
get{return getElement("storyName_trans");}
}
public int ProjectID
{
get{return projectID;}
}
public String StoryName
{
get{return storyName;}
}
public int ProcessTypeID
{
get{return processTypeID;}
}
public String ProcessTypeName
{
get{return processTypeName;}
}
public int IterationID
{
get{return iterationID;}
}
public String IterationName
{
get{return iterationName;}
}
public String Description
{
get{return description;}
}
public String ActivityType
{
get{return activityType;}
}
public String Effort
{
get{return effort;}
}
public ArrayList ProgrammerList
{
get{return programmerList;}
}
public String[] getProgrammer(int index)
{
String[] result = new String[2];
try
{
result = (String[])programmerList[index];
}
catch(System.ArgumentOutOfRangeException)
{
// There was a bogus index given to us
// Just return null for now
result = null;
}
return result;
}
#endregion
// Additional Methods
public void populateStory()
{
Boolean done = false;
String tempString = "";
String tempID = "";
String[] programmer = new String[2];
int i = 0;
setProjectID(int.Parse(getElement("projectID")));
setStoryName(getElement("storyName_trans"));
setProcessTypeID(int.Parse(getElement("ebProcessTypeID")));
setProcessTypeName(getElement("ebProcessTypeName"));
setIterationID(int.Parse(getElement("iterationID")));
setIterationName(getElement("iterationName"));
setDescription(getElement("description_trans"));
while(!done)
{
i++;
tempString = getElement("programmer"+i+"Name");
if (null != tempString)
{
tempID = getElement("programmer"+i+"ID");
addProgrammer(tempID, tempString);
}
else
{
done = true;
}
}
setActivityType(getElement("activityType"));
setEffort(getElement("effort_trans"));
}
public void printCardToConsole()
{
Console.Out.WriteLine("Story Name =\t" + StoryName);
Console.Out.WriteLine("Project ID =\t" + projectID);
Console.Out.WriteLine("Process Type =\t" + processTypeID);
Console.Out.WriteLine("Process Type Name = \t" + processTypeName);
Console.Out.WriteLine("Iteration ID =\t"+iterationID);
Console.Out.WriteLine("Iteration Name =\t"+iterationName);
Console.Out.WriteLine("Description =\t"+description);
for (int i =0; i<programmerList.Count; i++)
{
Console.Out.WriteLine("Programmer = " + getProgrammer(i));
}
xml.Save(Console.Out);
}
}
}
See more files for this project here