Word.Shape.Name taking maximum 18 characters - c#

I am using Word.Interop library. If I assign less than 18 characters to 'Word.Shape.Name' then it work perfect but when I assign more than 18 characters then 'Word.Shape.Name' throw exception.
e.g
Word.Shape.Name = "This is a test value to assign";
throw exception
"System.UnauthorizedAccessException: Access is denied.
(Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))".
What I should do to resolve this problem?
Whole method is
objTargetDocument, ref Scripting.Dictionary dicMarkers, ref Alias.Document objSourceDocument)
{
bool blnRetVal = false;
string strModel = ndModel.Name;
int lngModel = 0;
int lngNextModel = 0;
int lngStart;
int lngEnd;
Alias.Document objTemp;
Microsoft.Office.Interop.Word.Range objRange;
Shape objShape;
Object[] astr;
int n;
bool bLastModel;
/*'--------------------------------------------------------------------------------------------------
' 1. Find model's model marker and the next marker (if any)
'--------------------------------------------------------------------------------------------------*/
astr = dicMarkers.Keys();
for (n = astr.GetLowerBound(0); n <= astr.GetUpperBound(0); n++)
{
if (string.Compare(astr[n].ToString(), strModel, true) == 0)
{
lngModel = (int)dicMarkers.get_Item(astr[n]); //PNDC //dicMarkers.Item(astr(n))
if (n < astr.GetUpperBound(0))
{
if (string.Compare(astr[n + 1].ToString(), "#end", true) == 0)
{
lngNextModel = 0;
bLastModel = true;
}
else
{
lngNextModel = (int)dicMarkers.get_Item(astr[n + 1]);
bLastModel = false;
}
}
else
{
lngNextModel = 0;
}
break;
}
}
/*'--------------------------------------------------------------------------------------------------
' 2. Copy model from original document to new document
'--------------------------------------------------------------------------------------------------*/
if (lngModel > 0)
{
lngStart = objSourceDocument.Sections[lngModel].Range.Start;
if (lngNextModel == 0)
{
var key = "#end";
var value = dicMarkers.get_Item(key);
lngEnd = value;
}
else
lngEnd = objSourceDocument.Sections[lngNextModel].Range.Start; //objSourceDocument.Sections.Last.Index;
//--------------------------------------------------------------------------------------------------
//copy original
objSourceDocument.ActiveWindow.Selection.SetRange(lngStart, lngEnd);
objSourceDocument.ActiveWindow.Selection.Copy();
bool bInsertSection = false;
//paste (append) copied model to the document
if (objTargetDocument.Sections.First.Index == objTargetDocument.Sections.Last.Index)
{
//Target document only has 1 (default) section
bInsertSection = true;
}
else
{
if (objTargetDocument.Sections.Last.PageSetup.SectionStart == WdSectionStart.wdSectionNewPage)
{
//Last section is a nextpage section
if ((objTargetDocument.Sections.Last.Range.End - (objTargetDocument.Sections.Last.Range.Start) <= 1))
//Empty section
bInsertSection = false;
else
bInsertSection = true;
}
else
{
//Last section isn't a nextpage
bInsertSection = true;
}
}
objTargetDocument.ActiveWindow.Selection.Start = objTargetDocument.Range().End;
if (bInsertSection)
{
objTargetDocument.ActiveWindow.Selection.InsertBreak(WdBreakType.wdSectionBreakNextPage);
objTargetDocument.ActiveWindow.Selection.Start = objTargetDocument.Range().End;
}
objTargetDocument.ActiveWindow.Selection.Collapse();
objRange = objTargetDocument.ActiveWindow.Selection.Range.Duplicate; //remember range for model marker anchor
objTargetDocument.ActiveWindow.Selection.Paste();
objTargetDocument.Variables.Add(m_strModelMarker + strModel);
// .TextFrame.ContainingRange
//place model marker (so that we can find our model again)
objShape = objTargetDocument.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationUpward, 0, 0, 0, 0, objRange);
objShape.Name = m_strModelMarker + strModel; // This Line Trowing Exception
objShape.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
UpdateFields(ref objTargetDocument, ref ndModel);
blnRetVal = true;
}
else
new Modules.Globals().MsgBoxEx("Kan het bestaande model '" + strModel + "' niet kopieren.", MessageBoxButtons.OK);
return blnRetVal;
}

I haven't been able to find any reference to a 18-character limitation in the Name property. Also, after a quick test, it seems to work fine (even by inputting a much longer length):
Word.Shape oShape = oDoc.Shapes.AddLine(0, 0, 0, 0);
oShape.Name = "This is a test value to assign - This is a test value to assign";
Thus, the error you are mentioning is most likely provoked by a different part of your code.
In any case, I am not sure that you understand the exact meaning of the Name property. This is not something you would be seeing in the Word document at all; this is something for "internal reference purposes". The Shapes array is actually a Dictionary which can be accessed by typing either the index or the name of the given shape; that is, if oShape, as defined above, is the first shape in the document, I can access it by using any of the folowing options:
Word.Shape oShape2 = oDoc.Shapes[1];
Word.Shape oShape2 = oDoc.Shapes["This is a test value to assign - This is a test value to assign"];
For this reason, writing too long names is not necessary anyway.

There is an old discussion here about Word 2003 which seems to be similar.
In that discussion, it suggests storing the name in a document variable object (as in Document.Variables).
Something like:
Variables vars = Doc.Variables;
var = vars.Add("myShapeName", "This is a test value to assign");
and then assign var.Value to Word.Shape.Name somehow.
Edit
On re-reading that linked discussion, there is no way of directly assigning a Doc.Variable to the Name property. What you can set the shape's Name to a short unique identifier and use it to retrieve your long string from the Variables wherever you need it.
void SetLongName(Shape shape, string uniqueId, string longName)
{
shape.Name = uniqueId;
Variables vars = Doc.Variables;
var = vars.Add(uniqueId, longName);
}
string GetLongNameOfShape(Shape shape)
{
return GetLongNameById(shape.Name);
}
string GetLongNameById(string uniqueId)
{
Variables vars = Doc.Variables;
return vars.get_Item(uniqueId).Value;
}

Related

Can't properly rebuild a string with Replacement values from Dictionary

I am trying to build a file using a template. I am processing the file in a while loop line by line. The first section of the file, first 35 lines are header information. The infromation is surrounded by # signs. Take this string for example:
Field InspectionStationID 3 {"PVA TePla #WSM#", "sw#data.tool_context.TOOL_SOFTWARE_VERSION#", "#data.context.TOOL_ENTITY#"}
The expected output should be:
Field InspectionStationID 3 {"PVA TePla", "sw0.2.002", "WSM102"}
This header section uses a different mapping than the rest of the file so I wanted to parse the file line by line from top to bottom and use a different logic for each section so that I don't waste time parsing the entire file at once multiple times for different sections.
The logic uses two dictionaries populated from an xml file. Because the file has mutliple tables, I combined them in the two dictionaries like so:
var headerCdataIndexKeyVals = Dictionary<string, int>(){
{"data.tool_context.TOOL_SOFTWARE_VERSION", 1},
{"data.context.TOOL_ENTITY",0}
};
var headerCdataArrayKeyVals = new Dictionary<string, List<string>>();
var tool_contextCdataList = new list <string>{"HM654", "sw0.2.002"};
var contextCdataList = new List<string>{"WSM102"}
headerCdataArrayKeyVals.add("tool_context", tool_contextCdataList);
headerCdataArrayKeyVals.add("context", contextCdataList);
To help me map the values to their respective positions in the string in one go and without having to loop through multiple dictionaries.
I am using the following logic:
public static string FindSubsInDelimetersAndReturn(string str, char openDelimiter, char closeDelimiter, HeaderMapperData mapperData )
{
string newString = string.Empty;
// Stores the indices of
Stack <int> dels = new Stack <int>();
for (int i = 0; i < str.Length; i++)
{
var let = str[i];
// If opening delimeter
// is encountered
if (str[i] == openDelimiter && dels.Count == 0)
{
dels.Push(i);
}
// If closing delimeter
// is encountered
else if (str[i] == closeDelimiter && dels.Count > 0)
{
// Extract the position
// of opening delimeter
int pos = dels.Peek();
dels.Pop();
// Length of substring
int len = i - 1 - pos;
// Extract the substring
string headerSubstring = str.Substring(pos + 1, len);
bool hasKey = mapperData.HeaderCdataIndexKeyVals.TryGetValue(headerSubstring.ToUpper(), out int headerCdataIndex);
string[] headerSubstringSplit = headerSubstring.Split('.');
string headerCDataVal = string.Empty;
if (hasKey)
{
if (headerSubstring.Contains("CONTAINER.CONTEXT", StringComparison.OrdinalIgnoreCase))
{
headerCDataVal = mapperData.HeaderCdataArrayKeyVals[headerSubstringSplit[1].ToUpper() + '.' + headerSubstringSplit[2].ToUpper()][headerCdataIndex];
//mapperData.HeaderCdataArrayKeyVals[]
}
else
{
headerCDataVal = mapperData.HeaderCdataArrayKeyVals[headerSubstringSplit[1].ToUpper()][headerCdataIndex];
}
string strToReplace = openDelimiter + headerSubstring + closeDelimiter;
string sub = str.Remove(i + 1);
sub = sub.Replace(strToReplace, headerCDataVal);
newString += sub;
}
else if (headerSubstring == "WSM" && closeDelimiter == '#')
{
string sub = str.Remove(len + 1);
newString += sub.Replace(openDelimiter + headerSubstring + closeDelimiter, "");
}
else
{
newString += let;
}
}
}
return newString;
}
}
But my output turns out to be:
"\tFie\tField InspectionStationID 3 {\"PVA TePla#WSM#\", \"sw0.2.002\tField InspectionStationID 3 {\"PVA TePla#WSM#\", \"sw#data.tool_context.TOOL_SOFTWARE_VERSION#\", \"WSM102"
Can someone help understand why this is happening and how I can go about correcting it so I get the output:
Field InspectionStationID 3 {"PVA TePla", "sw0.2.002", "WSM102"}
Am i even trying to solve this the right way or is there a better cleaner way to do it? Btw if the key is not in the dictionary I replace it with empty string

How can I call this method for retrieved data in C#?

I'm working on a program that allows you to select a customer ID from a dropdown box. Once the customer ID is selected, the customer's information is pulled from a CSV file and displayed in textboxes.
The phone number information is unformatted, but I want it to be displayed formatted (ex. (800)674-3452). I have written a method for this, but I'm not sure how to call it. Can you please help?
-Sorry if this is a dumb question. I'm still learning.
private void idBox_SelectedIndexChanged(object sender, EventArgs e)
{
try // catch errors
{
string selectedCustomer; // variable to hold chosen customer ID
selectedCustomer = idBox.Text; // retrieve the customer number selected
chosenIndex = 0;
bool found = false; // variable if customer ID was found
while (!found && chosenIndex < allData.Length) // loop through the 2D array
{
if (allData[chosenIndex, 0] == selectedCustomer) // make sure it's the right customer
{
found = true; // Yes (true) found the correct customer
}
chosenIndex++; // add one row
}
chosenIndex -= 1; // subtract one because add 1 before exiting while
/* 0 = customer ID
* 1 = name
* 2 = address
* 3 = city
* 4 = state
* 5 = zip
* 6 = phone
* 7 = email
* 8 = charge account - yes/no
* 9 = good standing - yes/no
*/
nameBox.Text = allData[chosenIndex, 1]; // put name in nameBox
addressBox.Text = allData[chosenIndex, 2]; // put address in addressBox
cityBox.Text = allData[chosenIndex, 3]; // put city in cityBox
stateBox.Text = allData[chosenIndex, 4]; //puts state in stateBox
zipBox.Text = allData[chosenIndex, 5]; // puts zip in zipBox
phoneBox.Text = allData[chosenIndex, 6]; // puts phone number in phoneBox
emailBox.Text = allData[chosenIndex, 7]; // puts email in emailBox
if (allData[chosenIndex, 8] == "Yes") // check if charge account
{
yesChargeRadio.Checked = true; // true if Yes
}
else // otherwise
{
noChargeRadio.Checked = true; // true if No
}
if (allData[chosenIndex, 9] == "Yes") // check for good standing
{
yesStandingRadio.Checked = true; // true if Yes
}
else // otherwise
{
noStandingRadio.Checked = true; // true if No
}
}
catch (Exception errorInfo) // catch error
{
MessageBox.Show("errors: " + errorInfo, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error); // error message
}
}
Here is the method(s) to check the length and format:
private bool numberCheck(string str)
{
const int NUMBER_LENGTH = 10;
bool valid = true;
if (str.Length == NUMBER_LENGTH)
{
foreach (char ch in str)
{
if (!char.IsDigit(ch))
{
valid = false;
}
}
}
else
{
valid = false;
}
return valid;
}
private void formatPhone(ref string str)
{
str = str.Insert(0, "(");
str = str.Insert(4, ")");
str = str.Insert(8, "-");
}
You are almost done with your code. What you need to do is, before you set your phoneBox.Text you can call the method as below:
if(numberCheck(allData[chosenIndex, 6]))
{
formatPhone(ref allData[chosenIndex, 6]);
}
phoneBox.Text = allData[chosenIndex, 6];
As you have your method with ref parameter, the formatted text will be updated in your arary and you can then assign it to your phoneBox
I hope I understand what part specifically you're asking about: you call methods you define just like the static methods IsDigit or MessageBox.Show, except you do not need to prefix the method name with a name and then a period because the method is part of the object calling it.
So, for example if I had a method:
public void ShowSomething()
{
MessageBox.Show("stuff");
}
From within the class, I could call it like this:
ShowSomething();
To pass parameters, I would list them in the parenthesis, as you do with MessageBox.Show, for example.
You can use the value a method like numberCheck returns as any other boolean, so you could do any of these:
bool b = numberCheck(someString);
if (numberCheck(someString))
{
//Do something, like displaying the phone number
}
This MSDN document might help you: http://msdn.microsoft.com/en-us/library/ms173114.aspx
Is this what you're looking for? :
.......
phoneBox.Text = numberCheck(allData[chosenIndex, 6]) ?
formatPhone(allData[chosenIndex, 6]) :
allData[chosenIndex, 6];
.......
private string formatPhone(string str)
{
str = str.Insert(0, "(");
str = str.Insert(4, ")");
str = str.Insert(8, "-");
return str;
}
Codes above will check validity of phone data, if it is valid set phoneBox.Text to formatted phone number, else set phoneBox.Text to raw unformatted phone data.
For reference in case you're not familiar with ternary operator (?).

How do you find out if PDF Textbox field is multi-line using ABCpdf?

I can loop through all the fields in a PDF using ABCpdf using the GetFieldNames() collection and get their properties but the one I can't seem to get is whether or not the field is multi-line text field or not. Is there any example out there of how to find this property? My code is below if it's helpful but it's probably unnecessary.
....
foreach (string fieldName in doc.Form.GetFieldNames())
{
WebSupergoo.ABCpdf9.Objects.Field f = doc.Form[fieldName];
dt = GetFieldInstances(dt,f);
}
....
private static DocumentTemplate GetFieldInstances(DocumentTemplate dt, WebSupergoo.ABCpdf9.Objects.Field f)
{
Field field;
Instance inst = new Instance();
int instanceCount = 0;
bool fieldAlreadyExists = dt.Fields.Any(currentField => currentField.Name == f.Name);
if (!fieldAlreadyExists)
{
field = new Field();
field.Name = f.Name;
field.Value = f.Value;
field.Format = f.Format == null ? null : f.Format;
field.PartialName = f.PartialName;
field.TypeID = (int)f.FieldType;
//field.IsMultiline =
//field.IsRequired =
}
else
{
field = (from currentField in dt.Fields where currentField.Name == f.Name select currentField).SingleOrDefault();
instanceCount = field.Instances.Count();
}
if ((Field.FieldTypes)f.FieldType == Field.FieldTypes.Radio || (Field.FieldTypes)f.FieldType == Field.FieldTypes.Checkbox)
{
inst.ExportValue = f.Options[instanceCount];
}
if (f.Kids.Count() > 0)
{
f = f.Kids[instanceCount];
}
inst.Bottom = (int)f.Rect.Bottom;
inst.Height = (int)f.Rect.Height;
inst.Left = (int)f.Rect.Left;
inst.Width = (int)f.Rect.Width;
inst.PageNumber = f.Page.PageNumber;
field.Instances.Add(inst);
if (!fieldAlreadyExists)
{
dt.Fields.Add(field);
}
return dt;
}
I figured it out:
public bool GetIsMultiLine(WebSupergoo.ABCpdf9.Objects.Field field)
{
var flags = Atom.GetInt(Atom.GetItem(field.Atom, "Ff"));
var isMultiLine = GetIsBitFlagSet(flags, 13);
return isMultiLine;
}
public bool GetIsRequired(WebSupergoo.ABCpdf9.Objects.Field field)
{
var flags = Atom.GetInt(Atom.GetItem(field.Atom, "Ff"));
var isRequired = GetIsBitFlagSet(flags, 2);
return isRequired;
}
public bool GetIsReadOnly(WebSupergoo.ABCpdf9.Objects.Field field)
{
var flags = Atom.GetInt(Atom.GetItem(field.Atom, "Ff"));
var isReadOnly = GetIsBitFlagSet(flags, 1);
return isReadOnly;
}
private static bool GetIsBitFlagSet(int b, int pos)
{
return (b & (1 << (pos - 1))) != 0;
}
In case your not familiar with unsigned integer / binary conversions, I found this site really helpful to understand.
For example, let's say that the integer returned for a field's flags equals 4096. If you enter that into the online coversion tool in that website, it will show you that the 13th bit position is turned on (1 instead of a 0 in the 13th position starting from the right).
In the ABCPdf guide, it says that Multi-Line is bit position 13 so you know that field is a Multi-Line field.
Likewise for the 2nd position for Required and the 1st position for Read-only.

how do i pass a single char value to a string variable after increment from a linQ record data

internal char SubMeasurement = 'a';
internal string GetLast;
private void CreateSub()
{
SFCDataContext SFC = new SFCDataContext();
try
{
var CheckRecordSub = SFC.Systems_SettingsMeasurements.Where(r => r.RelationData == txtNO.Text)
.Select(t => new { CODE = t.No });
int count = 0; int total = 0;
string[] row = new string[CheckRecordSub.Count()];
foreach (var r in CheckRecordSub)
{
row[count] = r.CODE;
GetLast = r.CODE;
count++;
total = count;
}
if (txtNO.Text == GetLast)
{
MessageBox.Show(SubMeasurement.ToString()); <-- Msg Box doesn't Work
}
else
{
SubMeasurement = Convert.ToChar(GetLast);
SubMeasurement++; <-- Error
MessageBox.Show(SubMeasurement.ToString()); <-- Msg Box doesn't Work
}
}
catch (Exception) { }
}
I have a record data which is when a user tries to pick a "Sub" option instead of a "Header" the process tries to check for a record last sub record and takes that record put it in a char and increment it and then place it back to a string variable at this code i just use messagebox to check if i get the last record and if it increments it if its a Header it just take the default value of the "SubMeasurement" 'a' for a start. but its not working that way please help.
It's error of course it is. Because char can not increase in normal, if you really need it let try some kind of difference:
int asciiCode = ((int)SubMeasurement) + 1;
SubMeasurement = (char)asciiCode;

Read cell Items from data grid in SysListView32 of another application using C#

I am trying to read data grid items in SysListView32 of another process using C# .net ui-automation and winapi
C# code using ui-automation
http://pastebin.com/6x7rXMiW
C# code using winapi
http://pastebin.com/61RjXZuK
using this code you just have to place your Mouse pointer on SysListView32 on screen and press Enter.
now both code returns empty on the cell item which have following properties
pastebin.com/Rw9FGkYC
but both code works on following properties
pastebin.com/L51T4PLu
the only difference i noted that the name property contains the same data as in cell but problem occurs when name property is empty.
Is there any other way to read the cell ? or any changes I can make, Please elaborate.
I would also suggest the Inspect tool. If you see this:
IsLegacyIAccessiblePatternAvailable: true
you can use the LegacyIAccessiblePattern. Other posts seem to indicate that it is not yet in the Client UI Automation Api, but it is in the core. You can use the core in .NET by wrapping it. I added this into my build to begin using it:
"%PROGRAMFILES%\Microsoft SDKs\Windows\v7.0A\bin\tlbimp.exe" %windir%\system32\UIAutomationCore.dll /out:..\interop.UIAutomationCore.dll"
I can add more details if this pattern is indeed supported.
Well, then you are probably good.
Here is some sample code:
// C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\UIAutomationClient.h
public const int UIA_LegacyIAccessibleNamePropertyId = 30092;
public const int UIA_LegacyIAccessibleValuePropertyId = 30093;
public const int UIA_IsTextPatternAvailablePropertyId = 30040;
public const int UIA_IsItemContainerPatternAvailablePropertyId = 30108;
public const int UIA_AutomationIdPropertyId = 30011;
public const int UIA_NamePropertyId = 30005;
public const int UIA_IsInvokePatternAvailablePropertyId = 30031;
public const int UIA_ItemContainerPatternId = 10019;
public const int UIA_TextPatternId = 10014;
public const int UIA_LegacyIAccessiblePatternId = 10018;
public const int UIA_ValuePatternId = 10002;
public const int UIA_InvokePatternId = 10000;
public const int UIA_ButtonControlTypeId = 50000;
uiAutomationCore = new UiAutomationCore();
cacheRequest = UiAuto.CreateCacheRequest();
cacheRequest.AddPattern(WindowsConstants.UIA_LegacyIAccessiblePatternId);
cacheRequest.AddProperty(WindowsConstants.UIA_LegacyIAccessibleNamePropertyId);
cacheRequest.AddProperty(WindowsConstants.UIA_LegacyIAccessibleValuePropertyId);
cacheRequest.TreeFilter = UiAuto.ContentViewCondition;
trueCondition = UiAuto.CreateTrueCondition();
// A Pinvoke GetChildWindows call because it is
// the fastest way to traverse down to a handle
foreach (var child in GetChildWindows(someIUIAutomationElement.GetMainWindowHandle()))
{
var sb = new StringBuilder(100);
// get the name of each window & see if it is an ultragrid
// (get the name because the getchildwindows call only gets the handles
User32.GetClassName(child, sb, sb.Capacity);
var foundProperGrid = false;
if (Win32Utils.GetText(child) != "UltraGrid1")
continue;
// if this is an ultragrid, create a core automation object
var iuiae = UiCore.AutoElementFromHandle(child);
// get the children of the grid
var outerArayOfStuff =
iuiae.FindAllBuildCache(interop.UIAutomationCore.TreeScope.TreeScope_Children,
trueCondition,
cacheRequest.Clone());
var countOuter = outerArayOfStuff.Length;
// loop through the grid children
for (var counterOuter = 0; counterOuter < countOuter; counterOuter++)
{
// make a core automation object from each
var uiAutomationElement = outerArayOfStuff.GetElement(counterOuter);
// hacky - see if this grid has a GroupBy Box as first 'row'
// - if so, this is the proper grid
// - ignore other grids
if (!foundProperGrid && uiAutomationElement.CurrentName.Equals("GroupBy Box"))
{
foundProperGrid = true;
}
else if (foundProperGrid)
{
// 'cast' the object to a core 'legacy msaa' object
IUIAutomationLegacyIAccessiblePattern outerLegacyPattern =
uiAutomationElement.GetCachedPattern(WindowsConstants.UIA_LegacyIAccessiblePatternId);
Log.Info("OUTER, CachedName = " + outerLegacyPattern.CachedName);
try
{
// select the 'row' to give visual feedback
outerLegacyPattern.Select(3);
}
catch (Exception exc)
{
Log.Info(exc.Message);
}
// get the cells in a row
var arrayOfStuff =
uiAutomationElement.FindAllBuildCache(TreeScope.TreeScope_Children,
trueCondition,
cacheRequest.Clone());
// loop over the cells in a row
var count = arrayOfStuff.Length;
for (var counter = 0; counter < count; counter++)
{
// get a cell
var currIUIA = arrayOfStuff.GetElement(counter);
// 'cast' cell to a core 'legacy msaa' object
IUIAutomationLegacyIAccessiblePattern legacyPattern =
currIUIA.GetCachedPattern(WindowsConstants.UIA_LegacyIAccessiblePatternId);
// dump cell name & value for reference
var name = legacyPattern.CachedName;
Log.Info(counter + ") CachedName = " + name);
var value = legacyPattern.CachedValue;
Log.Info("CachedValue = " + value);
// check if cell name corresponds to what is being checked
if (name.Equals("Date"))
{
//if (!value.StartsWith("5/23/2012"))
if (!value.StartsWith("5/25/2012"))
errorList.AppendLine("Bad Date = " + value);
}
if (name.Equals("XXX"))
{
if (!(value.Equals("1") || value.Equals("2")))
errorList.AppendLine("Bad XXX= " + value);
}
if (name.Equals("YYY"))
{
if (!value.Equals("ZZZ"))
errorList.AppendLine("Bad YYY = " + value);
}
}
}
}
foundProperGrid = false;
}
var stopTime = DateTime.Now;
var duration = stopTime - startTime;
Log.Info("duration = " + duration);
if (!"".Equals(errorList.ToString()))
{
Log.Info("errorList = " + errorList);
Assert.Fail("Test errors");
}
}

Categories