So, I have a Row Rule and I added code to change the background color to Orange instead of using one of the Setting Styles. Everything works fine except when I go back into the Customization screen. Every time I open it I get the following error.
Application Error
Exception caught in: mscorlib
Error Detail
============
Message: Length cannot be less than zero.
Parameter name: length
Program: CommonLanguageRuntimeLibrary
Method: Substring
Client Stack Trace
==================
at System.String.Substring(Int32 startIndex, Int32 length)
at Ice.Lib.Customization.CustomCodeParseManager.ParseRuleActionCode(CustomizationLanguage custLanguage, String raCodeLine, RuleActionInfo raInfo)
Should I be concerned that this might cause an issue down the road? Everything compiles fine and the rows are highlighting orange. I just don’t want to mess up the system in some unknown way. Here is the code that (I think) is causing the error.
private void CreateRowRuleCurrentWorkCheckBox03Equals_true()
{
// Description: CWFAI
// **** begin autogenerated code ****
ControlSettings controlSettings = new ControlSettings();
controlSettings.IsReadOnly = false;
controlSettings.BackColor = System.Drawing.Color.Orange;
controlSettings.ForeColor = System.Drawing.Color.Black;
RuleAction errorCurrentWork_RowAction = RuleAction.AddRowSettings(this.oTrans, "CurrentWork", true, controlSettings);
RuleAction[] ruleActions = new RuleAction[] {
errorCurrentWork_RowAction};
// Create RowRule and add to the EpiDataView.
RowRule rrCreateRowRuleCurrentWorkCheckBox03Equals_true = new RowRule("CurrentWork.CheckBox03", RuleCondition.Equals, true, ruleActions);
((EpiDataView)(this.oTrans.EpiDataViews["CurrentWork"])).AddRowRule(rrCreateRowRuleCurrentWorkCheckBox03Equals_true);
// **** end autogenerated code ****
}
This here is where I have seen things go sideways when you start messing with row rules manually. If going that route I don’t use the wizard at all to stop the parser from freaking out.
Something concise on these lines
private void PromiseDatePast_Rule()
{
var action = RuleAction.AddControlSettings(this.oTrans, "V_WCI_Dispatch_1View.JobHead_PromiseDate_c", SettingStyle.Error);
var rr = new RowRule("V_WCI_Dispatch_1View.JobHead_PromiseDate_c", new RowRuleConditionDelegate2(PromiseDatePast_Condition), "Check", new RuleAction[] { action });
edvV_WCI_Dispatch_1View.AddRowRule(rr);
}
private bool PromiseDatePast_Condition(Ice.Lib.ExtendedProps.RowRuleDelegateArgs args)
{
return (!string.IsNullOrEmpty(args.Arg1.ToString()) && DateTime.Parse(args.Arg1.ToString()) < (DateTime)args.Row["JobHead_DueDate"]);
}
After fixing that, it compiles and runs as expected. Or does it always work when launching in developer mode, and only fails when that customization runs in normal mode?