Schneider Electric GIS Tech Support

Forum discussion for Schneider Electric GIS products, including ArcFM, ArcFM Viewer, Designer, Responder, and others.
It is currently Tue May 21, 2013 8:35 pm

All times are UTC - 7 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How to display warning when custom validation rule fails?
PostPosted: Thu Feb 17, 2011 5:38 am 
Offline

Joined: Thu Feb 10, 2011 4:45 am
Posts: 2
Dear All,

I have written a custom validation rule by implementing IMMValidationRule, IMMExtObject.
But I am not able to display warning instead of error when QA/QC tool is run.

I have used below piece of code to show error.

MMValidationError pWarning = new MMValidationErrorClass();
pWarning.Severity =1;
pWarning.ErrorMessage = "Rule Failed";
result.Add(pWarning as ID8ListItem);

Even if I give Severity any value from 1 to 10, it is not showing as warning but it is showing as Error.

Kindly let me know how to display warnings are QA/QC is run.

Thank you.


Regards
Muzammil


Top
 Profile  
 
 Post subject: Re: How to display warning when custom validation rule fails
PostPosted: Mon Oct 24, 2011 10:55 pm 
Offline

Joined: Wed Oct 06, 2010 10:05 pm
Posts: 13
Can you please tell which validation rule you have implemented.
please tell me how to implement custom validation rule.

If possible please suggest me how to do this for connectivity checking like HTLine cannot connect to LTLine etc...


Thanks & Regards
Janardhan Gangineni


Top
 Profile  
 
 Post subject: Re: How to display warning when custom validation rule fails
PostPosted: Wed Nov 23, 2011 11:28 pm 
Offline

Joined: Fri Oct 22, 2010 5:11 am
Posts: 15
Location: Bangalore, India
You have to implement IMMValidationRule to your class.

Check the below an example from ArFM Resource centre, guess this helps you.

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Esri.ArcGIS.Geodatabase;
using Esri.ArcGIS.esriSystem;
using Miner.Interop;
using Miner.ComCategories;
namespace Miner.Samples.ValidationRules
{
[ComponentCategory(ComCategory.MMValidationRules)]
[ComVisible(true)]
[Guid("04B41DC9-4122-427c-9E58-93A759219C5D")]
public class RatedKVARule : IMMExtObject, IMMValidationRule
{
#region Private fields
private const string _transformer = "Transformer";
private const string _transUnit = "TransformerUnit";
private const string _kvaFieldModelName = "RatedKVA";
// private Resourcer _resourcer;
private IMMModelNameManager _modelNameManager;
#endregion
#region Constructor
public RatedKVARule()
{

}
#endregion
#region IMMExtObject Members
public stdole.IPictureDisp Bitmap
{
get
{
return null;
}
}
public bool get_Enabled(ref object pvarValues)
{
bool enabled = false;
try
{
IObjectClass objClass = pvarValues as IObjectClass;
if(pvarValues == null || objClass == null)
{
return enabled;
}
if(_modelNameManager == null)
{
_modelNameManager = QASampleUtilities.GetIMMModelNameManager();
if(_modelNameManager != null)
{
enabled = _modelNameManager.ContainsClassModelName(
objClass, _transformer);
}
}
}
catch(Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message,
this.GetType() + ".IMMExtObject.Enabled",
System.Windows.Forms.MessageBoxButtons.OK);
}
return enabled;
}
public string Name
{
get
{
return "Sample Rated KVA on Transformer (C#)";
}
}
#endregion

#region IMMValidationRule Members
public ID8List IsValid(IRow pRow)
{
ID8List d8List = null;
try
{
if(pRow == null)
{
return d8List;
}
if(_modelNameManager == null)
{
_modelNameManager = QASampleUtilities.GetIMMModelNameManager();
}
d8List = new D8ListClass();

IObject obj = pRow as IObject;
if(obj != null)
{
IObjectClass objClass = obj.Class;
if(! _modelNameManager.ContainsClassModelName(objClass, _transformer))
{
return d8List;
}
object objKVA = QASampleUtilities.GetRowValueByFieldModelName(
obj, _kvaFieldModelName, _modelNameManager);
if(IsValidKVAValue(objKVA))
{
IRelationshipClass relationShipCls
= QASampleUtilities.GetRelatedClassByModelName(objClass,
esriRelRole.esriRelRoleOrigin, _transUnit);
if(relationShipCls != null)
{
ISet objSet =
relationShipCls.GetObjectsRelatedToObject(obj);
if(objSet == null)
{
return d8List;
}
IObject objRelation;
object objUnitKVA;
double totalUnitKVA = 0.0;
objSet.Reset();
do
{
objRelation = objSet.Next() as IObject;
if(objRelation == null)
{
break;
}
objUnitKVA =
QASampleUtilities.GetRowValueByFieldModelName(
objRelation, _kvaFieldModelName,
_modelNameManager);
if(IsValidKVAValue(objUnitKVA))
{
totalUnitKVA += ConvertDB2ActualKVA(Convert.ToDouble(objUnitKVA));
}
}while(true);
if(totalUnitKVA > 0)
{
if(totalUnitKVA != (double) objKVA)
{
string s = "value of Rated KVA of transformer (Rated JVA: " +
((double) objKVA).ToString() + ") is not equal to the total " +
"Rated KVA of related Transformer Units (Rated KVA: " +
totalUnitKVA.ToString() + ".";
QASampleUtilities.CreateNewError(ref d8List, 8, s, 0);
}
}
}
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,
GetType() + ".IMMValidationRule.IsValid",
MessageBoxButtons.OK);
}
return d8List;;
}
#endregion
#region Private methods
private static double ConvertDB2ActualKVA(double databaseKVA)
{
double d = databaseKVA;
if(databaseKVA == 38)
{
d = 37.5;
}

return d;
}
private static bool IsValidKVAValue(object objKVA)
{
bool bValid = false;
try
{
if(objKVA != null)
{
if(IsNumeric(objKVA))
{
// bValid = ((double) objKVA > 0);
bValid = (double.Parse(objKVA.ToString()) > 0);
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,
"ValidationRule.IsValidKVAValue",
MessageBoxButtons.OK);
}
return bValid;
}
private static bool IsNumeric(object value)
{
try
{
Convert.ToDouble(value.ToString());
return true;
}
catch (FormatException)
{
return false;
}
}
#endregion
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group