using System.Collections;
using System.Collections.Generic;
using System.Web.SessionState;
using System.Globalization;
namespace gm_AddIndividualAssignments_class
class gm_AddIndividualAssignments_class : Item
public gm_AddIndividualAssignments_class() : base(null) { }
public Item gm_AddIndividualAssignments()
Aras.Server.Core.CallContext CCO = ((Aras.Server.Core.IOMConnection)serverConnection).CCO;
Aras.Server.Core.IContextState RequestState = CCO.RequestState;
if(System.Diagnostics.Debugger.Launch()) System.Diagnostics.Debugger.Break();
Innovator inn = this.getInnovator();
string thisType = this.getAttribute("type");
if (thisType != "Activity") {
string activityID = this.getID();
string activityName = this.getProperty("name", "");
if (this.getProperty("is_auto", "") == "1") {
Item ecr = this.apply("GM Get Controlled Item");
if (ecr.isError() || ecr.isEmpty()) {
return inn.newError("gm_AddIndividualAssignments: Cannot retrieve controlled item.");
Item delAssign = inn.newItem("Activity Assignment", "delete");
delAssign.setAttribute("where", "[ACTIVITY_ASSIGNMENT].source_id = '" + activityID + "'");
delAssign = delAssign.apply();
ecr.fetchRelationships("gm_Work Order Distribution");
Item distroRels = ecr.getRelationships("gm_Work Order Distribution");
for (int i = 0; i < distroRels.getItemCount(); i++) {
Item thisDistro = distroRels.getItemByIndex(i);
string thisName = thisDistro.getProperty("_activity", "");
if (thisName != activityName) {
string thisRole = thisDistro.getProperty("_assigned", "");
Item addAssign = inn.newItem("Activity Assignment", "add");
addAssign.setProperty("source_id", activityID);
addAssign.setProperty("related_id", thisRole);
addAssign = addAssign.apply();
using System.Collections;
using System.Collections.Generic;
using System.Web.SessionState;
using System.Globalization;
namespace gm_WF_EvaluateConditionalLogic_class
class gm_WF_EvaluateConditionalLogic_class : Item
public gm_WF_EvaluateConditionalLogic_class() : base(null) { }
public Item gm_WF_EvaluateConditionalLogic()
Aras.Server.Core.CallContext CCO = ((Aras.Server.Core.IOMConnection)serverConnection).CCO;
Aras.Server.Core.IContextState RequestState = CCO.RequestState;
#region gm_WF_EvaluateConditionalLogic
string MethodName = "gm_WF_EvaluateConditionalLogic";
grantIdentityPrivileges("Aras PLM");
IDataAccessLayer dataAccessLayer = new DataAccessLayer(this.inn);
BusinessLogic businessLogic = new BusinessLogic(dataAccessLayer, inn);
result = businessLogic.EvaluateConditionalLogic(this);
catch (System.ArgumentException argex)
result = inn.newError(argex.Message);
catch (System.ApplicationException appex)
result = inn.newError(string.Format("<b>ERROR in method {0}</b><br>{1}", MethodName, appex.Message));
revokeIdentityPrivileges();
_inn = this.getInnovator();
#region "Identity Privileges"
private string AssignedIdentity;
public void grantIdentityPrivileges(string assignedIdent)
if (!string.IsNullOrEmpty(AssignedIdentity))
revokeIdentityPrivileges();
Aras.Server.Security.Identity secIdentity = Aras.Server.Security.Identity.GetByName(assignedIdent);
if (Aras.Server.Security.Permissions.GrantIdentity(secIdentity))
AssignedIdentity = assignedIdent;
public void revokeIdentityPrivileges()
if (AssignedIdentity != null)
Aras.Server.Security.Permissions.RevokeIdentity(Aras.Server.Security.Identity.GetByName(AssignedIdentity));
public class BusinessLogic
private IDataAccessLayer dataAccessLayer;
private static class CONSTANTS
internal static class Parenthisis
internal const string Open = "(";
internal const string Close = ")";
private Innovator inn { get; set; }
public BusinessLogic(IDataAccessLayer dataAccessLayer, Innovator inn)
this.dataAccessLayer = dataAccessLayer;
public Item EvaluateConditionalLogic(Item contextItem)
string context_item_id = contextItem.getID();
var res = inn.applyMethod("gm_GetDLRunStatus","<ecr_id>" + context_item_id + "</ecr_id>");
var isFinal = res.getResult();
string submittoworkflow = contextItem.getProperty("_is_submittoworkflow");
isFinal = GetStatusforPWODesignStudy(contextItem, submittoworkflow, isFinal);
ConditionalLogic logic = new ConditionalLogic(inn);
List<Activity> activityList = logic.getActivityConfiguration(contextItem);
Item allData = logic.GetAllRequiredProperties(activityList, context_item_id);
EvaluateConditions(activityList, allData,inn);
ParseConditionExpression(activityList);
FindDistListUsers(contextItem, logic, activityList);
var dlList = logic.DistributionListToList(contextItem);
var isFinalDistributionList = contextItem.getProperty("_finaliseddistributionlist");
var assignedNames = AreThereNamesInDistributionList(activityList, dlList, isFinal,contextItem);
DisableActivities(activityList, contextItem,isFinalDistributionList,submittoworkflow);
if (submittoworkflow != null && submittoworkflow == "0" && contextItem.getProperty("state") != "New")
assignedNames = AdhocCoAuthorPrompts(context_item_id, activityList, logic, assignedNames);
if (assignedNames.isError()) return assignedNames;
private Item AdhocCoAuthorPrompts(string contextItemId, List<Activity> activityList, ConditionalLogic logic, Item assignedNames)
"SELECT is_co_author_adhoc_req, is_app_engr_adhoc_req FROM GM_WORK_ORDER_CHANGE_CRITERIA where source_id='" +
bool is_coauthor_prompt_req = false;
bool is_app_engr_prompt_req = false;
if (!adHocPromptFlags.isError())
is_coauthor_prompt_req = (adHocPromptFlags.getProperty("is_co_author_adhoc_req", "0") == "1");
is_app_engr_prompt_req = (adHocPromptFlags.getProperty("is_app_engr_adhoc_req", "0") == "1");
if (!is_coauthor_prompt_req && !is_app_engr_prompt_req) return assignedNames;
var co_author_app_eng_act_names = activityList.Where(c =>
c.HasRequiredRole && (c.AssignedRole == "4F4F389AD9814540BA2C01F62EB06543" ||
c.AssignedRole == "1ED8F56AD0634C32AF1CCFF465B920DD")).ToList();
if (co_author_app_eng_act_names.Count <= 0) return assignedNames;
warMsg = new StringBuilder();
warMsg.Append("</b> <div style=\"overflow:auto; width: 600px; max-height:350px;\">");
"<ul><u>You have made changes that now require an Application Engineer or Co-Author. Those activities have already passed, so please Adhoc in the appropriate participants in the distribution list.</u><ul>");
bool is_warn_req = false;
for (int i1 = 0; i1 < co_author_app_eng_act_names.Count; i1++)
bool is_compl_by_auto = logic.IsActivityCompleted(co_author_app_eng_act_names[i1].ActivityName,
contextItemId, inn, true);
if (!is_compl_by_auto) continue;
is_warn_req = IsWarnReq(contextItemId, is_coauthor_prompt_req, co_author_app_eng_act_names[i1], warMsg, is_app_engr_prompt_req);
if (assignedNames.isError() && is_warn_req)
assignedNames.setErrorDetail(assignedNames.getErrorDetail() + "-Warning-" + warMsg.ToString());
if (!is_warn_req) return assignedNames;
assignedNames = inn.newError("Warning");
assignedNames.setErrorDetail(warMsg.ToString());
private bool IsWarnReq(string contextItemId, bool is_coauthor_prompt_req, Activity co_author_app_eng_act_names,StringBuilder warMsg, bool is_app_engr_prompt_req)
if (is_coauthor_prompt_req &&
co_author_app_eng_act_names.AssignedRole == "4F4F389AD9814540BA2C01F62EB06543")
warMsg.Append("<li><p> " + co_author_app_eng_act_names.ActivityName + " - Generic - Co-Author" +
"UPDATE GM_WORK_ORDER_CHANGE_CRITERIA set is_co_author_adhoc_req = '0' where source_id = '" +
if (is_app_engr_prompt_req &&
co_author_app_eng_act_names.AssignedRole == "1ED8F56AD0634C32AF1CCFF465B920DD")
warMsg.Append("<li><p> " + co_author_app_eng_act_names.ActivityName +
" - Application Engineer" + " </p></li> ");
"UPDATE GM_WORK_ORDER_CHANGE_CRITERIA set is_app_engr_adhoc_req = '0' where source_id = '" +
private static void FindDistListUsers(Item contextItem, ConditionalLogic logic, List<Activity> activityList)
string submittoworkflow = contextItem.getProperty("_is_submittoworkflow");
string context_item_id = contextItem.getID();
if (submittoworkflow == null || submittoworkflow != "0") return;
if (contextItem.getProperty("_draftdistributionlist") != "1" &&
contextItem.getProperty("_finaliseddistributionlist") != "0") return;
logic.AddRolesToDistributionList(activityList, contextItem);
var results = contextItem.getInnovator().applyMethod("gm_IdentifyDistributionListUsers", "<id>" + context_item_id + "</id>");
private static string GetStatusforPWODesignStudy(Item contextItem, string submittoworkflow, string isFinal)
if (submittoworkflow != null || isFinal != "1") return isFinal;
var gpsind = contextItem.getProperty("_gps_indicator");
var subtype = contextItem.getProperty("_subtype");
var state = contextItem.getProperty("state");
if (string.Equals(gpsind, "1", StringComparison.OrdinalIgnoreCase) &&
string.Equals(subtype, "PWO - Design Study", StringComparison.OrdinalIgnoreCase) &&
!string.Equals(state, "Investigate", StringComparison.OrdinalIgnoreCase))
contextItem.setProperty("_finaliseddistributionlist", "0");
public void EvaluateConditions(List<Activity> activityList, Item allData, Innovator inn)
foreach (var activity in activityList)
activity.HasRequiredRole = true;
bool isAssignedRoleCoAuthor = string.Equals(activity.AssignedRoleName, "Generic - Co-Author", StringComparison.OrdinalIgnoreCase);
if (isAssignedRoleCoAuthor && activity.conditionList.Count == 0)
activity.HasRequiredRole = false;
foreach (var c in activity.conditionList)
c.MatchConditioninItem(c.propertyName, c.value, c.logicalOperator, c.sourceItemName, allData, inn);
if (EvaluateActivityCondition(c, activity)) break;
private static bool EvaluateActivityCondition( Conditions c, Activity activity)
if ((c.propertyName == "_gps_indicator") && (c.logicalOperator == "and") && (!c.isMatch))
activity.IsMatch = false;
if (c.propertyName == "_gps_indicator")
if (c.logicalOperator == null)
activity.ConditionExpression = c.isMatch + "";
activity.ConditionExpression = c.isMatch + c.logicalOperator + CONSTANTS.Parenthisis.Open;
if (c.logicalOperator == null)
activity.ConditionExpression += c.isMatch + CONSTANTS.Parenthisis.Close;
if (string.IsNullOrWhiteSpace(activity.ConditionExpression))
activity.ConditionExpression = c.isMatch + c.logicalOperator + CONSTANTS.Parenthisis.Open;
if (string.IsNullOrWhiteSpace(c.logicalOperator))
activity.ConditionExpression += c.isMatch + CONSTANTS.Parenthisis.Close;
activity.ConditionExpression += c.isMatch + c.logicalOperator;
public void ParseConditionExpression(List<Activity> activityList)
foreach (var activity in activityList.Where(c => c.ConditionExpression != null))
activity.ConditionExpression = activity.ConditionExpression.ToLower();
activity.ConditionExpression = activity.ConditionExpression.Replace("true", "1");
activity.ConditionExpression = activity.ConditionExpression.Replace("false", "0");
activity.ConditionExpression = activity.ConditionExpression.Replace(" ", "");
expression = activity.ConditionExpression;
activity.ConditionExpression = activity.ConditionExpression.Replace("(1)", "1");
activity.ConditionExpression = activity.ConditionExpression.Replace("(0)", "0");
activity.ConditionExpression = activity.ConditionExpression.Replace("0and0", "0");
activity.ConditionExpression = activity.ConditionExpression.Replace("0and1", "0");
activity.ConditionExpression = activity.ConditionExpression.Replace("1and0", "0");
activity.ConditionExpression = activity.ConditionExpression.Replace("1and1", "1");
activity.ConditionExpression = activity.ConditionExpression.Replace("0or0", "0");
activity.ConditionExpression = activity.ConditionExpression.Replace("0or1", "1");
activity.ConditionExpression = activity.ConditionExpression.Replace("1or0", "1");
activity.ConditionExpression = activity.ConditionExpression.Replace("1or1", "1");
while (expression != activity.ConditionExpression);
var value = !((activity.ConditionExpression == "0") || activity.ConditionExpression.Contains("0"));
activity.IsMatch = value;
activity.HasRequiredRole = value;
public Item AreThereNamesInDistributionList(List<Activity> activityList, Dictionary<string, List<RoleNameList>> dlList, string isFinal, Item ecr_Item)
List<string> rolesWithNoUserNames = new List<string>();
List<string> missingRoleNames = new List<string>();
IEnumerable<Activity> filtered_list = null;
var subtype = ecr_Item.getProperty("_subtype");
if(string.Equals(subtype, "VWO - VDS Administration" , StringComparison.OrdinalIgnoreCase) ||
string.Equals(subtype, "VWO - VDS - Create" , StringComparison.OrdinalIgnoreCase))
return inn.newResult("");
filtered_list = activityList.Where(c => c.HasRequiredRole);
filtered_list = activityList.Where(c => c.HasRequiredRole && (c.RoleInInitialWorkflow ??"0") == "1");
foreach (var activityConfigurationItem in filtered_list)
var assignedRoleName = GetMissingRole(activityConfigurationItem,dlList, ecr_Item);
if (!string.IsNullOrEmpty(assignedRoleName))
rolesWithNoUserNames.Add(assignedRoleName);
var distinctRoleNames=rolesWithNoUserNames.Distinct();
var distinctMissingRoleNames = missingRoleNames.Distinct();
return GetMissingRoleErrorsOrNames(distinctRoleNames, distinctMissingRoleNames);
private string GetMissingRole( Activity activityConfigurationItem, Dictionary<string, List<RoleNameList>> dlList,Item ecr_Item)
string assignedRoleName = activityConfigurationItem.AssignedRoleName;
string ecrItemState = ecr_Item != null ? ecr_Item.getProperty("state") : string.Empty;
if (!dlList.ContainsKey(activityConfigurationItem.ActivityName))
var dlValue = dlList[activityConfigurationItem.ActivityName];
var assignedRole = activityConfigurationItem.AssignedRole;
if (dlValue.Count <= 0) return assignedRoleName;
var doesAssigneeExist = dlValue.Where(c => c.AssignedRole == assignedRole).Select(c => string.IsNullOrEmpty(c.Assignee)).FirstOrDefault();
if (ecr_Item != null && ecrItemState != "New" && ecrItemState != "Draft")
string active_actvy_ids_sql = "select related_id from WORKFLOW_PROCESS_ACTIVITY where SOURCE_ID in (select id from WORKFLOW_PROCESS where KEYED_NAME=" +
ecr_Item.getProperty("item_number") + ")" + "and related_id in (select id from ACTIVITY where state='Closed' and NAME='" +
activityConfigurationItem.ActivityName + "')";
var res_item = inn.applySQL(active_actvy_ids_sql);
is_closed = !res_item.isError() && res_item.getItemCount() > 0;
if (!is_closed) return assignedRoleName;
private Item GetMissingRoleErrorsOrNames(IEnumerable<string> distinctRoleNames, IEnumerable<string> distinctMissingRoleNames)
if (!distinctRoleNames.Any() && !distinctMissingRoleNames.Any()) return inn.newResult("");
if (distinctMissingRoleNames.Any())
StringBuilder errorMsg = new StringBuilder();
errorMsg.Append("</b> <div style=\"overflow:auto; width: 600px; max-height:350px;\">");
"<ul><u>Following Roles are missing from the distribution List, Please run the Distribution List action again.</u><ul>");
foreach (var roles in distinctMissingRoleNames)
errorMsg.Append("<li><p> " + roles + " </p></li> ");
var error = inn.newError("Error");
error.setErrorDetail(errorMsg.ToString());
StringBuilder errorMsg = new StringBuilder();
errorMsg.Append("</b> <div style=\"overflow:auto; width: 600px; max-height:350px;\">");
"<ul><u>Could not find the UPM Matches for the following Roles, Please add them manually: </u><ul>");
foreach (var roles in distinctRoleNames)
errorMsg.Append("<li><p> " + roles + " </p></li> ");
var error = inn.newError("Error");
error.setErrorDetail(errorMsg.ToString());
public void DisableActivities(List<Activity> activityList, Item contextItem, string isFinalDistributionList,string submittoworkflow)
var isInitialWorkFlow = isFinalDistributionList ==null? "1" : "0";
var results= activityList.Where(c => c.IsMatch == false || string.Equals(c.AssignedRoleName, "Generic - Co-Author", StringComparison.OrdinalIgnoreCase)).ToList();
var activitiesSql = "select a.id,a.name "+
"from [innovator].[ACTIVITY] a "+
"inner join [innovator].[WORKFLOW_PROCESS_ACTIVITY] p on a.id = p.related_id "+
"inner join [innovator].[WORKFLOW_PROCESS] wa on wa.id= p.source_id "+
"inner join [innovator].[WORKFLOW] wf on wf.related_id = wa.id "+
"inner join [Innovator].[gm_Work_order] g on wf.source_id = g.id "+
"where g.id ='" +contextItem.getID()+"'";
var activities= inn.applySQL(activitiesSql) ;
var activityItemList= ToList(activities);
IEnumerable<Item> filteredActivityList = null;
if (!(isFinalDistributionList == "0" && submittoworkflow == null))
filteredActivityList = (from a in results
join activity in activityItemList on a.ActivityName.Replace(" ","") equals (activity.getProperty("name").Trim().Replace(" ",""))
where a.RoleInInitialWorkflow == isInitialWorkFlow
filteredActivityList = (from a in results
join activity in activityItemList on a.ActivityName.Replace(" ","") equals (activity.getProperty("name").Trim().Replace(" ",""))
foreach(var activityItem in filteredActivityList)
var existsAssigneeForCoAuthorSql = "select d._assigned, d._activity from [gm_work_order_distribution] d " +
"inner join [Identity] i on d._role = i.id " +
"where d.source_id= '" + contextItem.getID() + "'" +
" and i.name ='Generic - Co-Author' and d._activity ='" + activityItem.getProperty("name") + "' and d._assigned is not null";
var dlResults = inn.applySQL(existsAssigneeForCoAuthorSql);
if(dlResults.getItemCount()>0)
Item act = activityItem.getInnovator().newItem("Activity", "get");
act.setAttribute("select", "id,state");
act.setID(activityItem.getID());
if(!(string.Equals(act.getProperty("state"),"Closed", StringComparison.OrdinalIgnoreCase) || string.Equals(act.getProperty("state"),"Active", StringComparison.OrdinalIgnoreCase)))
AML += "<Item type='Activity' action='edit' doGetItem='0' id='" + actID + "'>";
if (isFinalDistributionList != null)
AML+="<icon>../images/Delete.svg</icon>";
AML += "<is_auto>1</is_auto></Item>";
AML += "<Item type='Workflow Process Path' action='edit' doGetItem='0' where=\"[workflow_process_path].source_id='" + actID + "'\">";
AML += "<is_default>1</is_default></Item>";
var varResults= inn.applyAML(AML);
public List<Item> ToList(Item distributionListItem)
List<Item> distributionList= new List<Item>();
int distributionListItemCount = distributionListItem.getItemCount();
for (var i = 0; i < distributionListItemCount; i++)
var distributionItem = distributionListItem.getItemByIndex(i);
distributionList.Add(distributionItem);
public interface IDataAccessLayer
Item newItem(string itemName, string action = "get");
Item getItemById(string itemTypeName, string id);
Item getItemByIdAndSelect(string itemTypeName, string id, string selectProperties);
public class DataAccessLayer : IDataAccessLayer
private Innovator innovator;
internal DataAccessLayer(Innovator innovator)
this.innovator = innovator;
public Item getItemById(string itemTypeName, string id)
return innovator.getItemById(itemTypeName, id);
public Item getItemByIdAndSelect(string itemTypeName, string id, string selectProperties)
Item result = innovator.newItem(itemTypeName, "get");
result.setAttribute("select", selectProperties);
public string getUserID()
return innovator.getUserID();
public Item newItem(string itemName, string action = "get")
return this.innovator.newItem(itemName, action);
public class ConditionalLogic
private static class CONSTANTS
internal static class PropertyNames
internal const string OwnedById = "owned_by_id";
internal const string Owner = "_owner";
internal const string CreatedById = "created_by_id";
internal const string KeyedName = "keyed_name";
internal const string SourceId = "source_id";
internal const string RelatedId = "related_id";
internal const string Company = "company";
internal const string Classification = "classification";
internal const string IncludeRoleinInitialWorkFlow = "_includeroleininitialwf";
internal const string ActivityName = "_activity";
internal const string ActivityTitle = "_activitytitle";
internal const string ActivityType = "_activitytype";
internal const string PlanType = "_plantype";
internal const string Role = "_role";
internal const string Assigned = "_assigned";
internal const string ConfigActivityName = "_activityname";
internal const string ConfigActivityTitle = "_activitytitle";
internal const string ConfigActivityType = "_activitytype";
internal const string ConfigRole = "_assignedrole";
internal const string ConfigPlanType = "_plantype";
private Innovator inn { get; set; }
public ConditionalLogic(Innovator inn)
public List<Activity> getActivityConfiguration(Item contextItem)
var innovator = contextItem.getInnovator();
string configActivitiesQuery = "<AML>";
configActivitiesQuery += "<Item type='gm_WorkflowConfig Activity' action='get' select='related_id'>";
configActivitiesQuery += "<source_id>";
configActivitiesQuery += "<Item type='gm_WorkFlow Configuration' action='get' select='id'>";
configActivitiesQuery += "<classification>" + contextItem.getProperty("classification") + "</classification>";
configActivitiesQuery += "</Item>";
configActivitiesQuery += "</source_id>";
configActivitiesQuery += "<related_id>";
configActivitiesQuery += "<Item type='gm_Activity Configuration' action='get' select='_activityname,_activitytitle,_activitytype, _assignedrole,_plantype,_sortorder,_includeroleininitialwf'>";
string finalDistList = contextItem.getProperty("_finaliseddistributionlist");
if(finalDistList == null )
configActivitiesQuery += "<_includeroleininitialwf>1</_includeroleininitialwf>";
configActivitiesQuery += "<Relationships>";
configActivitiesQuery += "<Item type='gm_ActvityConfig Conditions' select='related_id'>";
configActivitiesQuery += "<related_id>";
configActivitiesQuery += "<Item type='gm_Activity Conditions' action='get' select='_sortorder,_property(keyed_name, source_id),_value,_logical'></Item>";
configActivitiesQuery += "</related_id>";
configActivitiesQuery += "</Item>";
configActivitiesQuery += "</Relationships>";
configActivitiesQuery += " </Item>";
configActivitiesQuery += "</related_id>";
configActivitiesQuery += " </Item>";
configActivitiesQuery += "</AML>";
var configActivities = innovator.applyAML(configActivitiesQuery);
return ToList(configActivities);
public List<Activity> ToList(Item activityConfigurationItem)
List<Activity> activityItems = new List<Activity>();
int activityConfigurationItemCount = activityConfigurationItem.getItemCount();
for (var i = 0; i < activityConfigurationItemCount; i++)
var configactivityItem = activityConfigurationItem.getItemByIndex(i);
var activityItem = configactivityItem.getRelatedItem();
var conditions = activityItem.getItemsByXPath("Relationships/Item/related_id/Item[@type='gm_Activity Conditions']");
List<Conditions> activityConditions = new List<Conditions>();
int conditionsItemCount = conditions.getItemCount();
for (int j = 0; j < conditionsItemCount; j++)
Item conditionsItem = conditions.getItemByIndex(j);
var Source = conditionsItem.getPropertyItem("_property").getPropertyAttribute("source_id", "keyed_name");
activityConditions.Add(new Conditions()
propertyName = conditionsItem.getPropertyAttribute("_property", "keyed_name"),
value = conditionsItem.getProperty("_value"),
logicalOperator = conditionsItem.getProperty("_logical"),
sortorder = conditionsItem.getProperty("_sortorder"),
sourceItemName = string.Equals(Source,"gm_PATSrc")? "gm_Work Order gm_PATSrc" : Source,
activityConditions = activityConditions.OrderBy(x => x.sortorder).ToList();
activityItems.Add(new Activity()
ActivityName = activityItem.getProperty("_activityname"),
ActivityTitle = activityItem.getProperty("_activitytitle"),
ActivityType = activityItem.getProperty("_activitytype"),
SortOrder= activityItem.getProperty("_sortorder"),
AssignedRole = activityItem.getProperty("_assignedrole"),
AssignedRoleName = activityItem.getPropertyAttribute("_assignedrole", "keyed_name"),
PlanType = activityItem.getProperty("_plantype"),
RoleInInitialWorkflow = activityItem.getProperty("_includeroleininitialwf"),
conditionList = activityConditions
public Item getActivityItems(Item parentItem)
query += "<Item type='Activity' action='get' select='id, name'>";
query += "<is_auto>0</is_auto>";
query += "<Item type='Workflow Process Activity' action='get' select='id'>";
query += "<Item type='Workflow Process' action='get' select ='id'>";
query += "<Item type='Workflow' action='get' select='related_id'>";
query += "<source_id>" + parentItem.getID() + "</source_id>";
query += "</related_id>";
var activityItems = parentItem.getInnovator().applyAML(query);
public Item GetAllItems(List<string> SourceItemNameList, List<string> PropertyNamesList, string ecrItemId)
Item activityItems = null;
var ecrItemIndex = SourceItemNameList.IndexOf("gm_Work Order");
properties = PropertyNamesList[ecrItemIndex];
amlQuery += "<Item type='gm_Work Order' action='get' serverEvents='0' select='" + properties + "'>";
amlQuery += "<id>" + ecrItemId + "</id>";
amlQuery += "<Relationships>";
amlQuery += "<Item type='gm_Work Order' serverEvents='0' action='get'>";
amlQuery += "<id>" + ecrItemId + "</id>";
amlQuery += "<Relationships>";
for (int i = 0; i < SourceItemNameList.Count(); i++)
properties = PropertyNamesList[i];
amlQuery += "<Item type='" + SourceItemNameList[i] + "' action='get' serverEvents='0' select='" + properties + "'></Item>";
amlQuery += "</Relationships>";
activityItems = inn.applyAML(amlQuery);
public Item GetAllRequiredProperties(List<Activity> activityList, string ecrItemId)
var conditions = activityList.SelectMany(d => d.conditionList).ToList();
List<string> SourceItemNameList = new List<string>();
List<string> PropertyNameList = new List<string>();
foreach (var t in conditions)
var propertyName = t.propertyName;
var source = t.sourceItemName;
if (SourceItemNameList.IndexOf(source) == -1)
SourceItemNameList.Add(source);
if (source == "gm_Work Order gm_PATSrc")
PropertyNameList.Add("_part_fstnr_ind_cde,_bfo," + propertyName);
PropertyNameList.Add(propertyName);
var sourceFound = SourceItemNameList.IndexOf(source);
if (!PropertyNameList[sourceFound].Contains(propertyName))
PropertyNameList[sourceFound] += ("," + propertyName);
var allItems = GetAllItems(SourceItemNameList, PropertyNameList, ecrItemId);
private void Add_Suppliers(Item DistributionLists)
if (DistributionLists == null || DistributionLists.getItemCount() <= 0) return;
Innovator Inn = DistributionLists.getItemByIndex(0).getInnovator();
string ecr_id = string.Empty;
int DistributionListsItemCount = DistributionLists.getItemCount();
for(int i = 0; i < DistributionListsItemCount; i++)
CurrentItem = DistributionLists.getItemByIndex(i);
ecr_id = CurrentItem.getProperty("source_id", "");
Item user = CurrentItem.getPropertyItem("_user");
if (string.IsNullOrEmpty(ecr_id) || (user == null)) continue;
if (user.isError()) throw new ArgumentException("Error retrieving a user associated with the identity in the distribution list.");
string edge_sec_company_id = user.getProperty("_edge_sec_company_id", "");
if (string.IsNullOrEmpty(edge_sec_company_id)) continue;
Item supplier_list = CurrentItem.newItem("gm_Work Order gm_Company", "get");
supplier_list.setProperty("select", "id");
supplier_list.setProperty("source_id", ecr_id);
supplier_list.setProperty("related_id", edge_sec_company_id);
supplier_list = supplier_list.apply();
if (supplier_list != null && !supplier_list.isError() && supplier_list.getItemCount() > 0) continue;
Item supplier = CurrentItem.newItem();
string aml = string.Format(@"<Item type='gm_Work Order gm_Company' doGetItem='0' action='add'>
<source_id>{0}</source_id>
<related_id>{1}</related_id>
</Item>", ecr_id, edge_sec_company_id);
supplier = supplier.apply();
if (supplier.isError()) throw new ArgumentException("Error creating supplier row for new user on distribution list.");
private void Delete_Suppliers(Item distribution_list, Item newly_added_distribution_list, Item parentItem)
List<string> Related_Ids = new List<string>();
GetSuppliers(newly_added_distribution_list, Related_Ids);
if (distribution_list == null) return;
int Count = distribution_list.getItemCount();
Item current_distribution = null;
for (int i = 0; i < Count; i++)
current_distribution = distribution_list.getItemByIndex(i);
Item curr_user = current_distribution.getPropertyItem("_user");
if (curr_user == null) continue;
if (curr_user.isError()) throw new ArgumentException("Error retrieving a user associated with the identity in the distribution list.");
string curr_edge_sec_company_id = curr_user.getProperty("_edge_sec_company_id", "");
if (string.IsNullOrEmpty(curr_edge_sec_company_id)) continue;
bool canDelete = CanDelete(distribution_list, ii, Count, curr_edge_sec_company_id);
if (!canDelete || Related_Ids.Contains(curr_edge_sec_company_id)) continue;
Item supplier = current_distribution.newItem("gm_Work Order gm_Company", "delete");
supplier.setProperty("source_id", parentItem.getID());
supplier.setAttribute("where", "[GM_WORK_ORDER_GM_COMPANY].source_id='" + parentItem.getID() + "' AND [GM_WORK_ORDER_GM_COMPANY].related_id='" + curr_edge_sec_company_id + "'");
supplier = supplier.apply();
if (supplier.isError()) throw new ArgumentException("Error deleting supplier row for new user on distribution list.");
private static bool CanDelete(Item distribution_list, int ii, int Count, string curr_edge_sec_company_id)
var next_distribution = distribution_list.getItemByIndex(ii);
var next_user = next_distribution.getPropertyItem("_user");
var next_edge_sec_company_id = next_user.getProperty("_edge_sec_company_id", "");
if (!string.IsNullOrEmpty(next_edge_sec_company_id) &&
next_edge_sec_company_id.Equals(curr_edge_sec_company_id))
private static void GetSuppliers(Item newly_added_distribution_list, List<string> Related_Ids)
if (newly_added_distribution_list == null || newly_added_distribution_list.isError() ||
newly_added_distribution_list.getItemCount() <= 0) return;
string edge_company = string.Empty;
int newly_added_distribution_list_item_count = newly_added_distribution_list.getItemCount();
for (int ii = 0; ii < newly_added_distribution_list_item_count; ii++)
_user_item = newly_added_distribution_list.getItemByIndex(ii).getPropertyItem("_user");
if (_user_item == null) continue;
edge_company = _user_item.getProperty("_edge_sec_company_id");
if (!string.IsNullOrEmpty(edge_company) && !Related_Ids.Contains(edge_company))
Related_Ids.Add(edge_company);
public Item AddRolesToDistributionList(List<Activity> ActivitiesCollection, Item parentItem)
var Inn = parentItem.getInnovator();
List<string> DeleteDistributionListIDs = new List<string>();
List<string> DeleteDistributionListQuery = new List<string>();
List<string> CompletedActivities = new List<string>();
List<string> NonDelete_ManuallyDistributionListRole = new List<string>();
Item Delete_DistributionItems = null;
string Query = string.Format("Select id,_activity,_role,_modify_by,_assigned from {0} where [{0}].source_id='{1}'", "gm_Work_Order_Distribution", ECR.getID());
Item AllDistributionListItems = Inn.applySQL(Query);
if (AllDistributionListItems.isError()) return Inn.newError("Error while getting Distribution List");
UpdateDlAndWfActvities(ECR,
AllDistributionListItems,
NonDelete_ManuallyDistributionListRole,
DeleteDistributionListQuery,
DeleteDistributionListIDs);
if (DeleteDistributionListIDs.Count>0)
Delete_DistributionItems = Inn.newItem("gm_Work Order Distribution", "get");
Delete_DistributionItems.setAttribute("select", "id,_user(_edge_sec_company_id)");
Delete_DistributionItems.setProperty("id", string.Join(",", DeleteDistributionListIDs));
Delete_DistributionItems.setPropertyAttribute("id", "condition", "in");
Delete_DistributionItems = Delete_DistributionItems.apply();
string amlQuery = GetNewDlItemsAddAML(ActivitiesCollection, ECR, NonDelete_ManuallyDistributionListRole, CompletedActivities);
if (DeleteDistributionListQuery.Count > 0)
Inn.applySQL(string.Join(";", DeleteDistributionListQuery));
var results = Inn.applyAML(amlQuery);
Item NewlyAddedDistributionItems = Inn.newItem("gm_Work Order Distribution", "get");
NewlyAddedDistributionItems.setAttribute("select", "source_id,_user(_edge_sec_company_id)");
NewlyAddedDistributionItems.setProperty("source_id", ECR.getID());
NewlyAddedDistributionItems = NewlyAddedDistributionItems.apply();
Delete_Suppliers(Delete_DistributionItems, NewlyAddedDistributionItems, parentItem);
Add_Suppliers(NewlyAddedDistributionItems);
private string GetNewDlItemsAddAML(List<Activity> ActivitiesCollection, Item ECR, List<string> NonDelete_ManuallyDistributionListRole, List<string> CompletedActivities)
var Inn = ECR.getInnovator();
string ECRID = ECR.getID();
string Team = ECR.getProperty("team_id");
string AMLQuery = "<AML>";
string manualDLItemsQry = string.Format(
"Select id,_activity,_role,_modify_by,_assigned,_user from {0} where [{0}].source_id='{1}' and [{0}]._assigned is not null and [{0}]._modify_by is not null and [{0}]._assigned_orig is null and [{0}]._assignment_type!='Ad Hoc' and [{0}]._assignment_type!='Surrogate' and [{0}]._assignment_type!='Assigned Self' and [{0}]._assignment_type!='Delegate'",
"gm_Work_Order_Distribution", ECR.getID());
Item manual_dl_items = Inn.applySQL(manualDLItemsQry);
List<Item> manual_dl_item_list = dlToList(manual_dl_items);
string Activity_Role = string.Empty;
foreach (var Activity in ActivitiesCollection)
if (!string.Equals(Activity.AssignedRoleName, "Generic - Co-Author", StringComparison.OrdinalIgnoreCase) &&
!Activity.IsMatch ) continue;
Activity_Role = string.Format("{0}~{1}", Activity.ActivityName, Activity.AssignedRole);
if (NonDelete_ManuallyDistributionListRole.Contains(Activity_Role) ||
CompletedActivities.Contains(Activity_Role)) continue;
List<Item> existingAssignees =
manual_dl_item_list.Where(x => x.getProperty("_role") == Activity.AssignedRole).ToList();
IItemCmparerAssigned Cmparer = new IItemCmparerAssigned();
existingAssignees = existingAssignees.Distinct(Cmparer).ToList();
if (existingAssignees.Count > 0)
foreach (Item existingDl in existingAssignees)
AMLQuery += "<Item type='gm_Work Order Distribution' action='add' doGetItem='0'>" +
"<source_id>" + ECRID + "</source_id>" +
"<_activity>" + Activity.ActivityName + "</_activity>" +
"<_activitytitle>" + HttpUtility.HtmlEncode(Activity.ActivityTitle) + "</_activitytitle>" +
"<_activitytype>" + Activity.ActivityType + "</_activitytype>" +
"<_plantype>" + Activity.PlanType + "</_plantype>" +
"<_role>" + Activity.AssignedRole + "</_role>" +
"<_assigned>" + existingDl.getProperty("_assigned") + "</_assigned>" +
"<_modify_by>" + existingDl.getProperty("_modify_by") + "</_modify_by>" +
"<_user>" + existingDl.getProperty("_user") + "</_user>" +
"<_sortorder>" + Activity.SortOrder + "</_sortorder>" +
"<_assignment_type>Manually Added</_assignment_type>" +
"<team_id>" + Team + "</team_id></Item>";
AMLQuery += "<Item type='gm_Work Order Distribution' action='add' doGetItem='0'>" +
"<source_id>" + ECRID + "</source_id>" +
"<_activity>" + Activity.ActivityName + "</_activity>" +
"<_activitytitle>" + HttpUtility.HtmlEncode(Activity.ActivityTitle) + "</_activitytitle>" +
"<_activitytype>" + Activity.ActivityType + "</_activitytype>" +
"<_plantype>" + Activity.PlanType + "</_plantype>" +
"<_role>" + Activity.AssignedRole + "</_role>" +
"<_sortorder>" + Activity.SortOrder + "</_sortorder>" +
"<team_id>" + Team + "</team_id>";
if (string.Equals(Activity.AssignedRoleName, "Generic - Change Owner", StringComparison.OrdinalIgnoreCase))
AMLQuery += "<_assigned>" + ECR.getProperty(CONSTANTS.PropertyNames.OwnedById) + "</_assigned>";
AMLQuery += "<_user>" + ECR.getProperty(CONSTANTS.PropertyNames.Owner) + "</_user>";
AMLQuery += "<_assignment_type>ECR Owner</_assignment_type>";
private void UpdateDlAndWfActvities(Item ECR,List<Activity> ActivitiesCollection, Item AllDistributionListItems,
List<string> NonDelete_ManuallyDistributionListRole, List<string> CompletedActivities, List<string> DeleteDistributionListQuery, List<string> DeleteDistributionListIDs)
if (AllDistributionListItems == null || AllDistributionListItems.isError() ||
AllDistributionListItems.getItemCount() <= 0) return;
int AllDistributionListItemsCount = AllDistributionListItems.getItemCount();
var Inn = ECR.getInnovator();
string ECRID = ECR.getID();
bool IsWorkflowInitiated = !string.Equals(ECR.getProperty("state"), "New");
for (int i = 0; i < AllDistributionListItemsCount; i++)
DL = AllDistributionListItems.getItemByIndex(i);
ActivityName = DL.getProperty("_activity", string.Empty);
Role = DL.getProperty("_role", string.Empty);
ManuallyModify = !string.IsNullOrEmpty(DL.getProperty("_modify_by", string.Empty));
Assigned = DL.getProperty("_assigned", string.Empty);
CanDelete = GetDeleteFlagforManualDlItem(NonDelete_ManuallyDistributionListRole, ManuallyModify, Assigned, ActivityName, Role);
List<Activity> DlItems2bdeleted = ActivitiesCollection.Where(x => (x.ActivityName == ActivityName && !(x.IsMatch) && !(string.Equals(x.AssignedRoleName, "Generic - Co-Author", StringComparison.OrdinalIgnoreCase)))).ToList();
if (DlItems2bdeleted.Count > 0) CanDelete = true;
IsActivityComplete = CheckIsActivityComplete(IsWorkflowInitiated, ActivityName, ECRID, Inn);
CompletedActivities.Add(string.Format("{0}~{1}", ActivityName, Role));
if (ManuallyModify && !CanDelete) continue;
DeleteDistributionListQuery.Add(string.Format("Delete from gm_Work_Order_Distribution where id='{0}'", ID));
DeleteDistributionListIDs.Add(string.Format("'{0}'", ID));
Assigned = DL.getProperty("_assigned", string.Empty);
if (!IsWorkflowInitiated || string.IsNullOrEmpty(Assigned)) continue;
string body = "<name>" + ActivityName + "</name><ecrId>" + ECRID + "</ecrId><roleId>" + Role +
"</roleId><assignedId>" + Assigned +
"</assignedId ><action>delete</action><delete_assignment_only>" +
false + "</delete_assignment_only>";
inn.applyMethod("gm_ActivityAssignment", body);
private bool CheckIsActivityComplete( bool IsWorkflowInitiated, string ActivityName,
string ECRID, Innovator Inn)
IsActivityComplete = IsWorkflowInitiated ? IsActivityCompleted(ActivityName, ECRID, Inn, false) : false;
private static bool GetDeleteFlagforManualDlItem(List<string> NonDelete_ManuallyDistributionListRole, bool ManuallyModify,
string Assigned, string ActivityName, string Role)
if (!ManuallyModify) return CanDelete;
if (string.IsNullOrEmpty(Assigned)) CanDelete = true;
if (!CanDelete) NonDelete_ManuallyDistributionListRole.Add(string.Format("{0}~{1}", ActivityName, Role));
public bool IsActivityCompleted(string ActivityName,string ECRID, Innovator Inn,bool ConsiderAutoFlag)
string Query = Format_ClosedActivityQuery_Name(ActivityName, ECRID,ConsiderAutoFlag);
Item Results = Inn.applySQL(Query);
if (Results != null && Results.getItemCount() > 0) return true;
private string Format_ClosedActivityQuery_Name(string ActivityName, string ECRID,bool ConsiderAutoFlag)
string select_act_str = "select * from (select a.name " +
"from [innovator].[gm_work_order_distribution] d " +
"inner join [innovator].[ACTIVITY] a on d._activity = a.name " +
"inner join [innovator].[WORKFLOW_PROCESS_ACTIVITY] p on a.id = p.related_id " +
"inner join [innovator].[WORKFLOW_PROCESS] wa on wa.id= p.source_id " +
"inner join [innovator].[WORKFLOW] wf on wf.related_id = wa.id " +
"inner join [Innovator].[gm_Work_order] g on wf.source_id = g.id and d.source_id= g.id ";
return select_act_str + "where g.id ='" + ECRID + "' and a.state in ('Closed') and a.is_auto = '1') R where R.Name='" + ActivityName + "'";
if (string.Equals(ActivityName, "Draft 10.1", StringComparison.OrdinalIgnoreCase)) {
return select_act_str + "where g.id ='" + ECRID + "' and a.state in ('Closed','Active')) R where R.Name='" + ActivityName + "'";
return select_act_str + "where g.id ='" + ECRID + "' and a.state in ('Closed','Active') and a.is_auto = '0') R where R.Name='" + ActivityName + "'";
public Dictionary<string, List<RoleNameList>> DistributionListToList(Item parentItem)
var distributionList = parentItem.getInnovator().newItem("gm_Work Order Distribution", "get");
distributionList.setAttribute("select", "_activity,_role,_assigned");
distributionList.setProperty("source_id", parentItem.getProperty("id"));
distributionList = distributionList.apply();
int distributionListItemCount = distributionList.getItemCount();
Dictionary<string, List<RoleNameList>> dlDictionary =
new Dictionary<string, List<RoleNameList>>();
List<string> dlList= new List<string>();
for (int i = 0; i < distributionListItemCount; i++)
var item = distributionList.getItemByIndex(i);
if (!dlList.Contains(item.getProperty("_activity")))
dlList.Add(item.getProperty("_activity"));
foreach (var activity in dlList)
List<RoleNameList> assigneeRoleandNameList = new List<RoleNameList>();
for (int j = 0; j < distributionListItemCount; j++)
var item2 = distributionList.getItemByIndex(j);
if (activity == item2.getProperty("_activity"))
assigneeRoleandNameList.Add(new RoleNameList()
AssignedRole = item2.getProperty("_role"),
Assignee = item2.getProperty("_assigned")
dlDictionary.Add(activity, assigneeRoleandNameList);
public List<Item> dlToList(Item allDistributionItems)
var distribution = new List<Item>();
int allDistributionItemsCount = allDistributionItems.getItemCount();
for(int i=0; i < allDistributionItemsCount; i++)
var dl = allDistributionItems.getItemByIndex(i);
#region Miscellaneous Classes
public string ActivityName { get; set; }
public string ActivityTitle { get; set; }
public string ActivityType { get; set; }
public string PlanType { get; set; }
public string AssignedRole { get; set; }
public string AssignedRoleName { get; set; }
public string SortOrder {get; set;}
public string ConditionExpression { get; set; }
public bool IsMatch { get; set; }
public bool HasRequiredRole { get; set; }
public string RoleInInitialWorkflow { get; set; }
public List<Conditions> conditionList = new List<Conditions>();
public class RoleNameList
public string AssignedRole { get; set; }
public string AssignedRoleName { get; set; }
public string Assignee{get; set;}
internal string sourceItemName;
public string propertyName { get; set; }
public string value { get; set; }
public string sortorder {get; set;}
public string logicalOperator { get; set; }
public bool isMatch { get; set; }
public bool MatchConditioninItem(string propertyName, string value, string logicaloperator, string sourceName, Item datatoCompare, Innovator inn)
if (sourceName == "gm_Work Order gm_PATSrc" || sourceName == "gm_Work Order gm_PIC" ||
sourceName == "gm_Work Order Build Event" || sourceName == "gm_Work Order TWO Rework")
data = datatoCompare.getRelationships(sourceName);
data = datatoCompare.getItemsByXPath("//Item[@type='" + sourceName + "']");
case "gm_Work Order gm_PATSrc":
var PAT = new PAT(propertyName, value, data);
isMatch = PAT.FindFirstMatch(propertyName, value, data);
case "gm_Work Order gm_PIC":
var PIC = new PIC(propertyName, value, data);
isMatch = PIC.FindFirstMatch(propertyName, value, data);
case "gm_Work Order TWO Rework":
var TWOrework = new TWO_REWORK(propertyName, value, data);
isMatch = TWOrework.FindFirstMatch_TWO(propertyName, value, data, inn);
case "gm_Work Order Build Event":
var Build_Evnt = new TWO_BUILD_EVENT(propertyName, value, data);
isMatch = Build_Evnt.FindFirstMatch(propertyName, value, data);
if(sourceName.Equals("gm_PPAT Pulled Build", StringComparison.OrdinalIgnoreCase) && String.Equals(propertyName, "_build_number", StringComparison.OrdinalIgnoreCase))
var buildCountQuery = string.Format(@"select count(*) from GM_WORK_ORDER_PPPAT p inner join GM_PPAT_PULLED_BUILD pb on p.id = pb.SOURCE_ID where p.SOURCE_ID = '{0}'", datatoCompare.getID());
var result = inn.applySQL(buildCountQuery);
isMatch = !(result.isError() || result.getResult().Equals("0"));
var propertyNode = data.node.SelectSingleNode(propertyName);
if (propertyNode != null &&
Array.IndexOf(propertyNode.InnerText.ToLower().Split(sep,StringSplitOptions.RemoveEmptyEntries),value.ToLower()) != -1)
public Item rows { get; set; }
public bool FindFirstMatch()
public bool FindAllMatches()
public virtual bool FindAllMatchesAndAddtoDistributionList(string criteriaPropertyName, string criteriaPropertyValue, Item datatoCompare)
public List<Item> ToList(Item datatoCompare)
List<Item> ls = new List<Item>();
int datatoCompareItemCount = datatoCompare.getItemCount();
for (int i = 0; i < datatoCompareItemCount; i++)
ls.Add(datatoCompare.getItemByIndex(i));
public class PAT : ItemRows
public string PropertyName { get; set; }
public string PropertyValue { get; set; }
public List<Activity> ActivitiestoAddToDistributionList;
public PAT(string criteriaPropertyName, string criteriaPropertyValue, Item datatoCompare)
PropertyName = criteriaPropertyName;
PropertyValue = criteriaPropertyValue;
public override bool FindAllMatchesAndAddtoDistributionList(string criteriaPropertyName, string criteriaPropertyValue, Item datatoCompare)
var dataList = ToList(datatoCompare);
var jj = dataList.Where(c => c.getProperty(criteriaPropertyName) == criteriaPropertyValue).Select(k => k).ToList();
if (String.Equals(criteriaPropertyName, "_preference_indicator", StringComparison.OrdinalIgnoreCase))
var hh = dataList.Where(c => c.getProperty(criteriaPropertyName) == criteriaPropertyValue).Select(c => new Test()
bfo = c.getProperty("_bfo"),
fastener = c.getProperty("_part_fstnr_ind_cde")
if (String.Equals(c.fastener, "N", StringComparison.OrdinalIgnoreCase))
public bool FindFirstMatch(string criteriaPropertyName, string criteriaPropertyValue, Item datatoCompare)
var dataList = ToList(datatoCompare);
if(criteriaPropertyName == "_fna_desc")
foreach (var dataItem in dataList) {
string getCriteriaPropertyName = dataItem.getProperty(criteriaPropertyName);
if (string.IsNullOrEmpty(getCriteriaPropertyName))
if(getCriteriaPropertyName.ToLower().Contains(criteriaPropertyValue.ToLower()) == true)
matchFound = dataList.Where(c => c.getProperty(criteriaPropertyName) == criteriaPropertyValue).Select(k => k).FirstOrDefault();
return (matchFound == null ? false : matchFound.getItemCount() > 0);
private void GetUserFromUserProfile(string p)
throw new NotImplementedException();
private void GetFromUPM(string p)
throw new NotImplementedException();
public class PIC : ItemRows
public string PropertyName { get; set; }
public string PropertyValue { get; set; }
public List<Activity> ActivitiestoAddToDistributionList;
public PIC(string criteriaPropertyName, string criteriaPropertyValue, Item datatoCompare)
PropertyName = criteriaPropertyName;
PropertyValue = criteriaPropertyValue;
public bool FindFirstMatch(string criteriaPropertyName, string criteriaPropertyValue, Item datatoCompare)
var dataList = ToList(datatoCompare);
if(criteriaPropertyName == "_effective_point_code")
foreach (var dataItem in dataList) {
string getCriteriaPropertyName = dataItem.getPropertyAttribute(criteriaPropertyName, "keyed_name");
if ((!string.IsNullOrEmpty(getCriteriaPropertyName)) && ((getCriteriaPropertyName.ToLower().Contains(criteriaPropertyValue.ToLower()) == true)))
matchFound = dataList.Where(c => c.getProperty(criteriaPropertyName) == criteriaPropertyValue).Select(k => k).FirstOrDefault();
return (matchFound == null ? false : matchFound.getItemCount() > 0);
public class TWO_REWORK : ItemRows
public string PropertyName { get; set; }
public string PropertyValue { get; set; }
public List<Activity> ActivitiestoAddToDistributionList;
public TWO_REWORK(string criteriaPropertyName, string criteriaPropertyValue, Item datatoCompare)
PropertyName = criteriaPropertyName;
PropertyValue = criteriaPropertyValue;
public bool FindFirstMatch_TWO(string criteriaPropertyName, string criteriaPropertyValue, Item datatoCompare, Innovator inn)
var dataList = ToList(datatoCompare);
if(criteriaPropertyName == "_rework_supplier_type")
foreach (var dataItem in dataList) {
string getCriteriaPropertyId = dataItem.getProperty(criteriaPropertyName);
Item getReworkItem = inn.newItem("gm_Rework Supplier Type", "get");
getReworkItem.setAttribute("select", criteriaPropertyName);
getReworkItem.setID(getCriteriaPropertyId);
getReworkItem = getReworkItem.apply();
string getCriteriaPropertyName = getReworkItem.getProperty(criteriaPropertyName);
if (string.IsNullOrEmpty(getCriteriaPropertyName))
if(getCriteriaPropertyName.ToLower().Contains(criteriaPropertyValue.ToLower()) == true)
matchFound = dataList.Where(c => c.getProperty(criteriaPropertyName) == criteriaPropertyValue).Select(k => k).FirstOrDefault();
return (matchFound == null ? false : matchFound.getItemCount() > 0);
public class TWO_BUILD_EVENT : ItemRows
public string PropertyName { get; set; }
public string PropertyValue { get; set; }
public List<Activity> ActivitiestoAddToDistributionList;
public TWO_BUILD_EVENT(string criteriaPropertyName, string criteriaPropertyValue, Item datatoCompare)
PropertyName = criteriaPropertyName;
PropertyValue = criteriaPropertyValue;
public bool FindFirstMatch(string criteriaPropertyName, string criteriaPropertyValue, Item datatoCompare)
var dataList = ToList(datatoCompare);
if(criteriaPropertyName == "_prod_event_code" && !string.IsNullOrEmpty(criteriaPropertyValue))
criteriaPropertyValue = criteriaPropertyValue.ToLower();
string[] criteriaPropVals = criteriaPropertyValue.Split(',');
foreach (var dataItem in dataList) {
string getCriteriaPropertyName = dataItem.getProperty(criteriaPropertyName);
if (string.IsNullOrEmpty(getCriteriaPropertyName)) {
if (Array.IndexOf(criteriaPropVals,getCriteriaPropertyName.ToLower()) > -1) {
matchFound = dataList.Where(c => c.getProperty(criteriaPropertyName) == criteriaPropertyValue).Select(k => k).FirstOrDefault();
return (matchFound == null ? false : matchFound.getItemCount() > 0);
public string bfo { get; set; }
public string fastener { get; set; }
class IItemCmparerAssigned : IEqualityComparer<Item>
public bool Equals(Item x, Item y)
return x.getProperty("_assigned") == y.getProperty("_assigned");
public int GetHashCode(Item obj)
private void EndOfMethod()
using System.Collections;
using System.Collections.Generic;
using System.Web.SessionState;
using System.Globalization;
namespace gm_Wf_HandleInitiallWFSubmission_class
class gm_Wf_HandleInitiallWFSubmission_class : Item
public gm_Wf_HandleInitiallWFSubmission_class() : base(null) { }
public Item gm_Wf_HandleInitiallWFSubmission()
Aras.Server.Core.CallContext CCO = ((Aras.Server.Core.IOMConnection)serverConnection).CCO;
Aras.Server.Core.IContextState RequestState = CCO.RequestState;
#region MethodCode gm_Wf_HandleInitiallWFSubmission
string MethodName = "gm_Wf_HandleInitiallWFSubmission";
IDataAccessLayer dataAccessLayer = new DataAccessLayer(this.inn);
BusinessLogic businessLogic = new BusinessLogic(dataAccessLayer);
result = businessLogic.AddRolesToParticipantList(this);
catch (System.ArgumentException argex)
result = inn.newError(argex.Message);
catch (System.ApplicationException appex)
result = inn.newError(string.Format("<b>ERROR in method {0}</b><br>{1}", MethodName, appex.Message));
_inn = this.getInnovator();
#region "Identity Privileges"
private string AssignedIdentity;
public void grantIdentityPrivileges(string assignedIdent)
if (!string.IsNullOrEmpty(AssignedIdentity))
revokeIdentityPrivileges();
Aras.Server.Security.Identity secIdentity = Aras.Server.Security.Identity.GetByName(assignedIdent);
if (Aras.Server.Security.Permissions.GrantIdentity(secIdentity))
AssignedIdentity = assignedIdent;
public void revokeIdentityPrivileges()
if (AssignedIdentity != null)
Aras.Server.Security.Permissions.RevokeIdentity(Aras.Server.Security.Identity.GetByName(AssignedIdentity));
public class BusinessLogic
private IDataAccessLayer dataAccessLayer;
private Item gmECRItem { get; set; }
private static class CONSTANTS
internal static class ItemTypeNames
internal const string User = "User";
internal const string gmWorkOrder = "gm_Work Order";
internal const string gmWorkflowConfiguration = "gm_WorkFlow Configuration";
internal const string gmDistributionList = "gm_Work Order Distribution";
internal static class PropertyNames
internal const string OwnedById = "owned_by_id";
internal const string CreatedById = "created_by_id";
internal const string KeyedName = "keyed_name";
internal const string SourceId = "source_id";
internal const string RelatedId = "related_id";
internal const string Company = "company";
internal const string Classification = "classification";
internal const string IncludeRoleinInitialWorkFlow = "_includeroleininitialwf";
internal const string ActivityName = "_activity";
internal const string ActivityTitle = "_activitytitle";
internal const string ActivityType = "_activitytype";
internal const string PlanType ="_plantype";
internal const string Role = "_role";
internal const string Assigned = "_assigned";
internal const string ConfigActivityName = "_activityname";
internal const string ConfigActivityTitle = "_activitytitle";
internal const string ConfigActivityType = "_activitytype";
internal const string ConfigRole = "_assignedrole";
internal const string ConfigPlanType ="_plantype";
internal static class Actions
internal const string Add = "add";
internal const string Get = "get";
internal const string Update = "update";
internal const string Select = "select";
internal const string Create = "create";
internal const string Delete = "delete";
public string SourceID { get; set; }
public BusinessLogic(IDataAccessLayer dataAccessLayer)
this.dataAccessLayer = dataAccessLayer;
public Item getActivityConfiguration(Item parentItem)
var activityConfigurationQuery= @"select ac._activityname, ac._activitytitle,ac._activitytype,ac._assignedrole,i.keyed_name as roleName,ac._plantype,ac._reworkuser,ac._includeroleininitialwf from [innovator].[GM_WORKFLOW_CONFIGURATION] wfc
inner join [innovator].[GM_WORKFLOWCONFIG_ACTIVITY] wfca on wfc.id= wfca.source_id
inner join [innovator].[GM_ACTIVITY_CONFIGURATION] ac on wfca.related_id = ac.id
inner join [innovator].[Identity] i on i.id = ac._assignedrole
where wfc.classification ='"+parentItem.getProperty("classification")+"'";
var activityConfiguration = parentItem.getInnovator().applySQL(activityConfigurationQuery);
if(activityConfiguration.isError())
return parentItem.getInnovator().newError("Unable to get Activity Configuration");
return activityConfiguration;
public Item AddRolesToParticipantList(Item contextItem)
var gmECRItem = getECRItem(contextItem);
var configurationItemList = getActivityConfiguration(gmECRItem);
var distributionList= dataAccessLayer.newItem(CONSTANTS.ItemTypeNames.gmDistributionList, CONSTANTS.Actions.Delete);
distributionList.setAttribute("where", "[gm_work_order_distribution].[source_id]='"+ gmECRItem.getID()+"'");
distributionList= distributionList.apply();
for(int i=0; i<configurationItemList.getItemCount();i++)
var configurationItem= configurationItemList.getItemByIndex(i);
distributionList = dataAccessLayer.newItem(CONSTANTS.ItemTypeNames.gmDistributionList, CONSTANTS.Actions.Create);
distributionList.setProperty(CONSTANTS.PropertyNames.SourceId, gmECRItem.getID());
distributionList.setProperty(CONSTANTS.PropertyNames.ActivityName, configurationItem.getProperty(CONSTANTS.PropertyNames.ConfigActivityName));
distributionList.setProperty(CONSTANTS.PropertyNames.ActivityTitle, configurationItem.getProperty(CONSTANTS.PropertyNames.ConfigActivityTitle));
distributionList.setProperty(CONSTANTS.PropertyNames.ActivityType, configurationItem.getProperty(CONSTANTS.PropertyNames.ConfigActivityType));
distributionList.setProperty(CONSTANTS.PropertyNames.PlanType, configurationItem.getProperty(CONSTANTS.PropertyNames.ConfigPlanType));
distributionList.setProperty(CONSTANTS.PropertyNames.Role, configurationItem.getProperty(CONSTANTS.PropertyNames.ConfigRole));
if(string.Equals(configurationItem.getProperty("rolename"), "Owner",StringComparison.OrdinalIgnoreCase))
distributionList.setProperty(CONSTANTS.PropertyNames.Assigned, gmECRItem.getProperty(CONSTANTS.PropertyNames.OwnedById));
distributionList = distributionList.apply();
public bool isParentItemECR(Item contextItem)
var itemType = contextItem.getAttribute("type");
if (itemType == CONSTANTS.ItemTypeNames.gmWorkOrder)
public Item getECRItem(Item contextItem)
if (!isParentItemECR(contextItem))
var parentItem = contextItem.apply("GM Get Controlled Item");
if (parentItem.isError())
throw new ApplicationException(parentItem.getErrorDetail());
public bool isOwnerAndCreatorTheSame(Item contextItem)
var isECR = isParentItemECR(contextItem);
var creator = contextItem.getPropertyAttribute(CONSTANTS.PropertyNames.CreatedById, CONSTANTS.PropertyNames.KeyedName);
var owner = contextItem.getPropertyAttribute(CONSTANTS.PropertyNames.OwnedById, CONSTANTS.PropertyNames.KeyedName);
return String.Equals(creator, owner, StringComparison.OrdinalIgnoreCase);
public bool isSubmitToWorkflow(Item contextItem)
var isSubmitToWorkflow = isParentItemECR(contextItem) ? true : false;
return isSubmitToWorkflow;
public void ValidateEffectivePointsOnPic()
public class WorkFlowSubmission
public WorkFlowSubmission(Item contextItem)
public interface IDataAccessLayer
Item newItem(string itemName, string action);
Item getItemById(string itemTypeName, string id);
public class DataAccessLayer : IDataAccessLayer
private Innovator innovator;
internal DataAccessLayer(Innovator innovator)
this.innovator = innovator;
public Item getItemById(string itemTypeName, string id)
return innovator.getItemById(itemTypeName, id);
public string getUserID()
return innovator.getUserID();
public Item newItem(string itemName, string action = "get")
return this.innovator.newItem(itemName, action);
private void end_of_method_()
using System.Collections;
using System.Collections.Generic;
using System.Web.SessionState;
using System.Globalization;
namespace GMInstantiateWorkFlow_class
class GMInstantiateWorkFlow_class : Item
public GMInstantiateWorkFlow_class() : base(null) { }
public Item GMInstantiateWorkFlow()
Aras.Server.Core.CallContext CCO = ((Aras.Server.Core.IOMConnection)serverConnection).CCO;
Aras.Server.Core.IContextState RequestState = CCO.RequestState;
var innovator= this.getInnovator();
var itemId= this.getProperty("itemId");
var itemTypeID = this.getProperty("itemTypeID");
var itemType = this.getProperty("itemType");
var workflowMapId = this.getProperty("workflowMapId");
var item = innovator.getItemById(itemType, itemId);
var wf_process = item.instantiateWorkflow(workflowMapId);
return innovator.newError("Error instantiating Workflow");
var workflowProcessId= wf_process.getAttribute("id");
wf_process.apply("startWorkflow");
using System.Collections;
using System.Collections.Generic;
using System.Web.SessionState;
using System.Globalization;
namespace gm_ECRPATValidation_class
class gm_ECRPATValidation_class : Item
public gm_ECRPATValidation_class() : base(null) { }
public Item gm_ECRPATValidation()
Aras.Server.Core.CallContext CCO = ((Aras.Server.Core.IOMConnection)serverConnection).CCO;
Aras.Server.Core.IContextState RequestState = CCO.RequestState;
string MethodName = "gm_ECRPATValidation";
IDataAccessLayer dataAccessLayer = new DataAccessLayer(innovator);
BusinessLogic businessLogic = new BusinessLogic(dataAccessLayer, innovator);
if (result.getAttribute("type", "") == "Activity"
&& result.getProperty("is_auto", "") == "1"
&& result.getProperty("name", "") != "Draft 10.1")
result = businessLogic.ValidatePat(this);
catch (ArgumentException argex)
result = innovator.newError(argex.Message);
catch (Aras.Server.Core.InnovatorServerException appex)
result = innovator.newError(appex.Message);
result = innovator.newError(string.Format("<b>SYSTEM EXCEPTION in method {0}</b><br>{1}", MethodName, ex.Message));
#region "Innovator innovator;"
private Innovator _innovator;
public Innovator innovator
_innovator = this.getInnovator();
public class BusinessLogic
private static class Constants
internal static class ItemTypeNames
internal const string workOrder = "gm_Work Order";
internal const string woChangeCriteria = "gm_Work Order Change Criteria";
internal const string woPAT = "gm_Work Order gm_PATSrc";
internal const string woPIC = "gm_Work Order gm_PIC";
internal const string woTooling = "gm_Work Order Tooling";
internal const string woValPlan = "gm_Work Order Validation Plan";
internal const string woAttach = "gm_Work Order File";
internal const string woCostTiming = "gm_Work Order Cost";
internal const string woVPPS = "gm_Work Order VPPS";
internal const string woBuildEvent = "gm_Work Order Build Event";
internal const string woTWORework = "gm_Work Order TWO Rework";
internal const string woPPPAT = "gm_Work Order PPPAT";
internal const string woPPIC = "gm_Work Order PPIC";
internal const string woPPCost = "gm_Work Order PPCost";
internal const string woShippedTo = "gm_Work Order Shipped To";
internal const string woPBreakpoint = "gm_Work Order PPBreakpoint";
internal const string woBSDVerification = "gm_Work Order BSD Verification";
internal const string woPartAndCost = "gm_Work Order Part and Cost";
internal const string woMpdAction = "gm_Work Order MPD";
internal const string woMmoPptShippedTo = "gm_Work Order MP Shipped To";
internal const string woMwoVppsErd = "gm_Work Order VPPS ERD";
internal const string woPpqp = "gm_Work Order PPQP";
internal static class PropertyNames
internal const string Type = "_type";
internal static class EcrTypes
internal const string TempType = "Temporary Type";
internal const string PartType = "Part Type";
internal const string BCR = "BOM Change Request Type";
internal const string BSD = "Build Site Direction Type";
internal const string PPT = "Pre-Prod Tooling Type";
internal const string MMO = "Misc Material Order Type";
private readonly IDataAccessLayer dataAccessLayer;
private readonly Innovator inn;
public BusinessLogic(IDataAccessLayer dataAccessLayer, Innovator inn)
this.dataAccessLayer = dataAccessLayer;
public Item ValidatePat(Item patItem)
PatValidation patValidation = new PatValidation(patItem);
patValidation = PopulateWorkOrderItems(patValidation);
if (patValidation == null) return patItem;
patValidation = ValidateErrorsInAllPatRows(patValidation);
if (!patValidation.IsValid)
throw new Aras.Server.Core.InnovatorServerException(patValidation.ErrorMsg);
private static void SetSearchItem(PatValidation patValidation, Item patErrCondSearchItem)
if (patValidation.IsRequestFromWorkflowBtn)
patErrCondSearchItem.setProperty("_is_validate_submit_to_workflow", "1");
else if (patValidation.IsRequestFromImport)
patErrCondSearchItem.setProperty("_is_validate_on_import", "1");
else if (patValidation.IsRequestFromWorkflowActivity)
patErrCondSearchItem.setProperty("_is_workflow_validation", "1");
patErrCondSearchItem.setProperty("_workflow_activity_names", "*" + patValidation.WorkflowActivityName + "*");
patErrCondSearchItem.setPropertyCondition("_workflow_activity_names", "like");
patErrCondSearchItem.setProperty("_workflow_subtypes", "*" + patValidation.WorkflowSubtype + "*");
patErrCondSearchItem.setPropertyCondition("_workflow_subtypes", "like");
patErrCondSearchItem.setProperty("_is_validate_on_save", "1");
private void PopulateErrorConditions(PatValidation patValidation)
Item patErrCondSearchItem = dataAccessLayer.newItem("gm_PAT_Error_Conditions", "get");
SetSearchItem(patValidation, patErrCondSearchItem);
patErrCondSearchItem.setProperty("_is_validate", "1");
Item patErrCondResults = patErrCondSearchItem.apply();
int patErrCondCount = patErrCondResults.getItemCount();
if (patErrCondCount <= 0) return;
var patErrFields = new Dictionary<string, string>();
for (int i = 0; i < patErrCondCount; i++)
Item patErrCondItem = patErrCondResults.getItemByIndex(i);
var errCriteria = new ErrorCriteria();
errCriteria.ErrPreCondition = patErrCondItem.getProperty("_pre_condition");
errCriteria.ErrPostCondition = patErrCondItem.getProperty("_post_condition");
errCriteria.ErrMsgDflt = patErrCondItem.getProperty("_dflt_err_msg");
errCriteria.Validate = patErrCondItem.getProperty("_is_validate") == "1";
string patErrPropName = patErrCondItem.getProperty("_prop_name");
errCriteria.FieldName = patErrCondItem.getProperty("_prop_name");
string patErrSourceName = patErrCondItem.getProperty("_source_itemtype");
errCriteria.SourceName = patErrCondItem.getProperty("_source_itemtype");
errCriteria.ValidateOnSave = patErrCondItem.getProperty("_is_validate_on_save") == "1";
errCriteria.ValidateOnImport = patErrCondItem.getProperty("_is_validate_on_import") == "1";
errCriteria.ValidateOnSubmitToWorkflow = patErrCondItem.getProperty("_is_validate_submit_to_workflow") == "1";
errCriteria.ValidValueSource = patErrCondItem.getProperty("_is_valid_value_source");
errCriteria.IsWorkflowValidation = patErrCondItem.getProperty("_is_workflow_validation") == "1";
errCriteria.WorkflowActivityNames = patErrCondItem.getProperty("_workflow_activity_names");
errCriteria.WorkflowSubtypes = patErrCondItem.getProperty("_workflow_subtypes");
errCriteria.ErrorCode = patErrCondItem.getProperty("_err_code");
if (string.IsNullOrWhiteSpace(patErrSourceName) || string.IsNullOrWhiteSpace(patErrPropName) || (!string.IsNullOrWhiteSpace(errCriteria.WorkflowSubtypes) && !string.IsNullOrWhiteSpace(patValidation.WorkflowSubtype) && !errCriteria.WorkflowSubtypes.ToUpper().Contains(patValidation.WorkflowSubtype.ToUpper())))
patValidation.ErrorCriteriaList.Add(errCriteria);
if (patErrFields.ContainsKey(patErrSourceName))
string newVal = patErrFields[patErrSourceName] ?? "";
newVal = newVal + "'" + patErrPropName + "',";
patErrFields[patErrSourceName] = newVal;
patErrFields.Add(patErrSourceName, "'" + patErrPropName + "',");
patValidation.PatPropLabelMap = getPATPropertyLabelsMap(patErrFields);
public Dictionary<string, string> getPATPropertyLabelsMap(Dictionary<string, string> patFields)
Dictionary<string, string> propLabelMap = new Dictionary<string, string>();
foreach (KeyValuePair<string, string> entry in patFields)
Item itemType = inn.getItemByKeyedName("ItemType", entry.Key);
if (itemType == null || itemType.isError())
string patItemTypeId = itemType.getID();
string SQL = "select name as property, label from innovator.Property " +
"where source_id='" + patItemTypeId + "' and " +
"name in (" + entry.Value.TrimEnd(',') + ")";
Item propertyItems = dataAccessLayer.applySQL(SQL);
for (int j = 0; j < propertyItems.getItemCount(); j++)
Item propertyItem = propertyItems.getItemByIndex(j);
propLabelMap.Add(entry.Key + "." + propertyItem.getProperty("property"), propertyItem.getProperty("label"));
public PatValidation ValidateErrorsInAllPatRows(PatValidation patValidation)
bool isReqFrmSubmitWorkflow = patValidation.IsRequestFromWorkflowBtn;
bool isReqFrmWorkflowActivity = patValidation.IsRequestFromWorkflowActivity;
var errorCriteriaList = patValidation.ErrorCriteriaList;
StringBuilder errorMessageBuilder = new StringBuilder();
RelValidationInfo[] relValidationInfos = {
new RelValidationInfo(Constants.ItemTypeNames.workOrder, "ECR Validation Errors", patValidation.WorkOrder),
new RelValidationInfo(Constants.ItemTypeNames.woPAT, "Part Action Validation Errors", patValidation.WoPatRels),
new RelValidationInfo(Constants.ItemTypeNames.woPPPAT, "Pre-Prod Part Action Tab Errors", patValidation.WoPppatRels),
new RelValidationInfo(Constants.ItemTypeNames.woPPCost, "Pre-Prod Cost Validation Errors", patValidation.WoPpCostRels),
new RelValidationInfo(Constants.ItemTypeNames.woShippedTo, "Shipped To Errors", patValidation.WoShippedToRels),
new RelValidationInfo(Constants.ItemTypeNames.woBSDVerification, "BSD Verification Errors", patValidation.WoBsdVerificationRels),
new RelValidationInfo(Constants.ItemTypeNames.woPBreakpoint, "Pre-Prod Breakpoint Errors", patValidation.WoPBreakpointRels),
new RelValidationInfo(Constants.ItemTypeNames.woPartAndCost, "Part and Cost Errors", patValidation.WoPartAndCostRels),
new RelValidationInfo(Constants.ItemTypeNames.woMmoPptShippedTo, "MMO & PPT Shipped To Errors", patValidation.WoMmoPptShippedToRels),
ValidateRelationships(patValidation, relValidationInfos, errorCriteriaList,
isReqFrmSubmitWorkflow, isReqFrmWorkflowActivity, errorMessageBuilder);
if (isReqFrmSubmitWorkflow || isReqFrmWorkflowActivity)
ValidateRelsForSubmitToWorkflowAndWorkflowActivity(patValidation, errorCriteriaList,
isReqFrmSubmitWorkflow, isReqFrmWorkflowActivity, errorMessageBuilder);
string errorMessage = errorMessageBuilder.ToString();
SetPatValidationErrorMessage(patValidation, isReqFrmSubmitWorkflow, isReqFrmWorkflowActivity,
private void ValidateRelsForSubmitToWorkflowAndWorkflowActivity(PatValidation patValidation,
List<ErrorCriteria> errorCriteriaList, bool isReqFrmSubmitWorkflow, bool isReqFrmWorkflowActivity,
StringBuilder errorMessageBuilder)
RelValidationInfo[] relValidationInfos =
new RelValidationInfo(Constants.ItemTypeNames.woChangeCriteria, "ECR Change Criteria Validation Errors", patValidation.WoChangeCriteriaRel),
new RelValidationInfo(Constants.ItemTypeNames.woBuildEvent, "Build Event Details Errors", patValidation.WoBuildEventRels),
new RelValidationInfo(Constants.ItemTypeNames.woTooling, "Tooling Validation Errors", patValidation.WoToolingRels),
new RelValidationInfo(Constants.ItemTypeNames.woValPlan, "Validation Plan Validation Errors", patValidation.WoValPlanRels),
new RelValidationInfo(Constants.ItemTypeNames.woAttach, "Attachment Validation Errors", patValidation.WoAttachRels),
new RelValidationInfo(Constants.ItemTypeNames.woCostTiming, "Cost & Timing Validation Errors", patValidation.WoCostRels),
new RelValidationInfo(Constants.ItemTypeNames.woMpdAction, "MPD Action Tab Errors", patValidation.WoMpdActionRels),
new RelValidationInfo(Constants.ItemTypeNames.woMwoVppsErd, "VPPS and ERD Errors", patValidation.WoVppsRels),
new RelValidationInfo(Constants.ItemTypeNames.woPpqp, "PPQP Errors", patValidation.WoPpqpRels)
ValidateRelationships(patValidation, relValidationInfos, errorCriteriaList,
isReqFrmSubmitWorkflow, isReqFrmWorkflowActivity, errorMessageBuilder);
if (isReqFrmWorkflowActivity)
ValidateRelsForIsReqFrmWorkflowActivity(patValidation, errorCriteriaList,
isReqFrmSubmitWorkflow, errorMessageBuilder);
string ecrType = patValidation.WorkOrder.getProperty(Constants.PropertyNames.Type, "");
ValidatePicRelationships(patValidation, errorCriteriaList, isReqFrmSubmitWorkflow,
isReqFrmWorkflowActivity, errorMessageBuilder, ecrType);
ValidatePpicRelationships(patValidation, errorCriteriaList, isReqFrmSubmitWorkflow,
isReqFrmWorkflowActivity, errorMessageBuilder, ecrType);
private void ValidatePicRelationships(PatValidation patValidation, List<ErrorCriteria> errorCriteriaList,
bool isReqFrmSubmitWorkflow, bool isReqFrmWorkflowActivity, StringBuilder errorMessageBuilder,
const string picErrorsTitle = "PIC Validation Errors";
var picRelationshipValidationInfo = new RelValidationInfo(
Constants.ItemTypeNames.woPIC, picErrorsTitle, patValidation.WoPicRels);
bool anypicRelationshipErrors = ValidateRelationship(patValidation, errorCriteriaList,
isReqFrmSubmitWorkflow, isReqFrmWorkflowActivity, errorMessageBuilder, picRelationshipValidationInfo);
if (!anypicRelationshipErrors
&& !ecrType.Equals(Constants.EcrTypes.BCR, StringComparison.OrdinalIgnoreCase)
&& !ecrType.Equals(Constants.EcrTypes.BSD, StringComparison.OrdinalIgnoreCase)
&& !ecrType.Equals(Constants.EcrTypes.PPT, StringComparison.OrdinalIgnoreCase)
&& !ecrType.Equals(Constants.EcrTypes.MMO, StringComparison.OrdinalIgnoreCase))
Item picRels = inn.newItem(Constants.ItemTypeNames.woPIC, "get");
picRels.setAttribute("select", "id");
picRels.setProperty("source_id", patValidation.WorkOrder.getID());
picRels = picRels.apply();
int ppicRelsCount = picRels.getItemCount();
patValidation.SetInvalid();
errorMessageBuilder.AppendFormat("<br><u>{0}</u>", picErrorsTitle);
errorMessageBuilder.Append(
"<ul>\n <li>At least <b>one Product Impact Chart (PIC) row</b> must exist on this ECR.</li> </ul>");
errorMessageBuilder.Append("<br>");
private void ValidatePpicRelationships(PatValidation patValidation, List<ErrorCriteria> errorCriteriaList, bool isReqFrmSubmitWorkflow,
bool isReqFrmWorkflowActivity, StringBuilder errorMessageBuilder, string ecrType)
const string ppicTitle = "Pre-Prod Product Impact Chart (PPIC)";
const string ppicErrorsTitle = ppicTitle + " Validation Errors";
var ppicRelationshipValidationInfo = new RelValidationInfo(
Constants.ItemTypeNames.woPPIC, ppicErrorsTitle, patValidation.WoPpicRels);
bool anyPpicRelationshipErrors = ValidateRelationship(patValidation, errorCriteriaList,
isReqFrmSubmitWorkflow, isReqFrmWorkflowActivity, errorMessageBuilder, ppicRelationshipValidationInfo);
if (!anyPpicRelationshipErrors
&& patValidation.WoPpicRels.getItemCount() == 0
&& (ecrType.Equals(Constants.EcrTypes.BCR, StringComparison.OrdinalIgnoreCase)
|| ecrType.Equals(Constants.EcrTypes.BSD, StringComparison.OrdinalIgnoreCase)
|| ecrType.Equals(Constants.EcrTypes.PPT, StringComparison.OrdinalIgnoreCase)
|| ecrType.Equals(Constants.EcrTypes.MMO, StringComparison.OrdinalIgnoreCase)))
patValidation.SetInvalid();
errorMessageBuilder.AppendFormat("<br><u>{0}</u>", ppicErrorsTitle);
errorMessageBuilder.AppendFormat("<ul>\n <li>At least <b>one {0} row</b> must exist on this ECR.</li> </ul>",
errorMessageBuilder.Append("<br>");
private void ValidateRelationships(PatValidation patValidation,
IEnumerable<RelValidationInfo> relationshipValidationInfos, List<ErrorCriteria> errorCriteriaList,
bool isReqFrmSubmitWorkflow, bool isReqFrmWorkflowActivity, StringBuilder errMsg)
foreach (var relationshipValidationInfo in relationshipValidationInfos)
ValidateRelationship(patValidation, errorCriteriaList, isReqFrmSubmitWorkflow,
isReqFrmWorkflowActivity, errMsg, relationshipValidationInfo);
private class RelValidationInfo
internal string RelationshipItemTypeName { get; private set; }
internal string RelationshipErrorsTitle { get; private set; }
internal Item RelationshipsItem { get; private set; }
public RelValidationInfo(string relationshipItemTypeName,
string relationshipErrorsTitle, Item relationshipsItem)
RelationshipItemTypeName = relationshipItemTypeName;
RelationshipErrorsTitle = relationshipErrorsTitle;
RelationshipsItem = relationshipsItem;
private void ValidateRelsForIsReqFrmWorkflowActivity(PatValidation patValidation,
List<ErrorCriteria> errorCriteriaList, bool isReqFrmSubmitWorkflow, StringBuilder errMsg)
string workOrderSubtype = patValidation.WorkflowSubtype;
if (workOrderSubtype.Contains("STO") || workOrderSubtype.Contains("VDS"))
itemTypeName = Constants.ItemTypeNames.woVPPS;
appndErrMsg = "<br><u>VPPS Validation Errors</u> </br>";
relItem = patValidation.WoVppsRels;
else if (workOrderSubtype.Contains("TWO - Rework"))
itemTypeName = Constants.ItemTypeNames.woTWORework;
appndErrMsg = "<br><u>TWO Rework Errors</u>";
relItem = patValidation.WoTwoReworkRels;
Item patErrConditions = inn.newItem("gm_PAT_Error_Conditions", "get");
patErrConditions.setProperty("_source_itemtype", itemTypeName);
patErrConditions = patErrConditions.apply();
var woRelsErrors = ValidateErrorConditionsForIsReqFrmWorkflowActivitySubMethod(patValidation,
errorCriteriaList, isReqFrmSubmitWorkflow, patErrConditions, workOrderSubtype, itemTypeName,
if (!string.IsNullOrEmpty(woRelsErrors))
patValidation.SetInvalid();
errMsg.Append(appndErrMsg);
errMsg.Append(woRelsErrors);
private string ValidateErrorConditionsForIsReqFrmWorkflowActivitySubMethod(PatValidation patValidation,
List<ErrorCriteria> errorCriteriaList, bool isReqFrmSubmitWorkflow, Item patErrConditions,
string workOrderSubtype, string itemTypeName, Item relItem)
string woRelsErrors = string.Empty;
int patErrConditionsCount = patErrConditions.getItemCount();
for (int i = 0; i < patErrConditionsCount; i++)
woRelsErrors = string.Empty;
Item PatErrCondition = patErrConditions.getItemByIndex(i);
string[] Subtypes = PatErrCondition.getProperty("_workflow_subtypes").Split(',');
string[] ActivityNames = PatErrCondition.getProperty("_workflow_activity_names").Split(',');
string ErrorMessage = PatErrCondition.getProperty("_dflt_err_msg");
string ErrorCode = PatErrCondition.getProperty("_err_code");
string Property = PatErrCondition.getProperty("_prop_name");
string projectActivityName = patValidation.WorkflowActivityName;
if (Array.IndexOf(ActivityNames, projectActivityName) < 0 ||
Array.IndexOf(Subtypes, workOrderSubtype) < 0) continue;
Item rels = inn.newItem(itemTypeName, "get");
rels.setAttribute("select", "id");
rels.setProperty("source_id", patValidation.WorkOrder.getID());
int relsCount = rels.getItemCount();
woRelsErrors = ValidateEachRelationship(patValidation, errorCriteriaList, relItem,
isReqFrmSubmitWorkflow, true, itemTypeName);
if (string.IsNullOrEmpty(woRelsErrors) && relsCount != 0) continue;
patValidation.SetInvalid();
if (relsCount != 0) continue;
if (workOrderSubtype.Contains("TWO - Rework"))
woRelsErrors = "<ul>\n <li>At least <b>one TWO Rework row</b> must exist on this ECR.</li> </ul>";
"Select label from PROPERTY where SOURCE_ID = (select ID from ITEMTYPE where NAME = '" +
itemTypeName + "') AND NAME = '" + Property + "'")
woRelsErrors = "<ul>\n <li><p> " + propertylabel + " (" + ErrorCode + ") : " + ErrorMessage +
private static void SetPatValidationErrorMessage(PatValidation patValidation, bool isReqFrmSubmitWorkflow,
bool isReqFrmWorkflowActivity, string errorMessage)
if (patValidation.IsValid) return;
string blockedActionDescription;
if (isReqFrmSubmitWorkflow)
blockedActionDescription = "submitting to the workflow";
else if (isReqFrmWorkflowActivity)
blockedActionDescription = "submitting";
blockedActionDescription = "Save";
patValidation.ErrorMsg = string.Format(
"<b>Validation Errors On ECR: You must fix the following errors before {0}.</b> <div style=\"overflow:auto; width: 600px; max-height:350px;\">{1}</ul><div>",
blockedActionDescription,
private bool ValidateRelationship(PatValidation patValidation, List<ErrorCriteria> errorCriteriaList,
bool isReqFrmSubmitWorkflow, bool isReqFrmWorkflowActivity, StringBuilder errorMessageBuilder,
RelValidationInfo relToValidate)
string relationshipErrors = ValidateEachRelationship(patValidation, errorCriteriaList,
relToValidate.RelationshipsItem, isReqFrmSubmitWorkflow, isReqFrmWorkflowActivity,
relToValidate.RelationshipItemTypeName);
if (string.IsNullOrEmpty(relationshipErrors)) return false;
patValidation.SetInvalid();
errorMessageBuilder.AppendFormat("<br><u>{0}</u>", relToValidate.RelationshipErrorsTitle);
errorMessageBuilder.Append(relationshipErrors);
errorMessageBuilder.Append("<br>");
private string ValidateEachRelationship(PatValidation patValidation, List<ErrorCriteria> errorCriteriaList,
Item patRels, bool isReqFrmSubmitWorkflow, bool isReqFrmWorkflowActivity, string sourceNameMatch)
if (patRels != null && patRels.getItemCount() > 0)
errorMessage = ValidateEachRelationshipPat(patValidation, errorCriteriaList, patRels,
isReqFrmSubmitWorkflow, isReqFrmWorkflowActivity, sourceNameMatch);
else if (isReqFrmSubmitWorkflow)
errorMessage = ValidateEachRelationshipIsReqFrmSubmitWorkflow(
patValidation, errorCriteriaList, sourceNameMatch);
errorMessage = ValidateEachRelationshipOther(patValidation, errorCriteriaList,
isReqFrmWorkflowActivity, sourceNameMatch);
private string ValidateEachRelationshipPat(PatValidation patValidation,
List<ErrorCriteria> errorCriteriaList, Item patRels, bool isReqFrmSubmitWorkflow,
bool isReqFrmWorkflowActivity, string sourceNameMatch)
var errorMessageBuilder = new StringBuilder();
List<string> distinctErrorMessages = new List<string>();
int patRelCount = patRels.getItemCount();
for (int i = 0; i < patRelCount; i++)
Item patItem = patRels.getItemByIndex(i);
patValidation.PatItem = patItem;
string rowNumber = patItem == null ? "" : patItem.getProperty("_row_number");
bool isFirstRowErr = true;
foreach (ErrorCriteria errorCriteria in errorCriteriaList)
bool isErrValidate = errorCriteria.Validate
&& errorCriteria.SourceName == sourceNameMatch
&& ((isReqFrmSubmitWorkflow && errorCriteria.ValidateOnSubmitToWorkflow)
|| isReqFrmWorkflowActivity == errorCriteria.IsWorkflowValidation);
if (!isErrValidate) continue;
bool isValid = IsValidateErrorCriteria(errorCriteria, patValidation);
PostErrorCriteriaValidation(patValidation, isValid, errorCriteria, errorMessageBuilder,
distinctErrorMessages, rowNumber, ref isFirstRowErr);
errorMessageBuilder.Append("</ul>");
return errorMessageBuilder.ToString();
private static void PostErrorCriteriaValidation(PatValidation patValidation, bool isValid,
ErrorCriteria errorCriteria, StringBuilder errorMessageBuilder, List<string> distinctErrorMessages,
string rowNumber, ref bool isFirstRowErr)
errorCriteria.IsValid = true;
AddErrorMessagesForInvalidErrorCriteria(errorMessageBuilder, distinctErrorMessages, rowNumber,
errorCriteria, patValidation.PatPropLabelMap, ref isFirstRowErr);
private static void AddErrorMessagesForInvalidErrorCriteria(StringBuilder errorMessageBuilder,
List<string> distinctErrorMessages, string rowNumber, ErrorCriteria errorCriteria,
Dictionary<string, string> patValidationPatPropLabelMap, ref bool isFirstRow)
if (string.IsNullOrEmpty(rowNumber))
errorMessageBuilder.Append("<ul>");
errorMessageBuilder.Append("<br><u>Row Number: " + rowNumber + "</u><ul>");
string formattedErrorMessage = GetErrorMsg(errorCriteria, patValidationPatPropLabelMap);
if (!string.IsNullOrEmpty(rowNumber)
|| !distinctErrorMessages.Contains(formattedErrorMessage))
distinctErrorMessages.Add(formattedErrorMessage);
errorMessageBuilder.Append("\n <li><p> " + formattedErrorMessage + " </p></li> ");
private string ValidateEachRelationshipIsReqFrmSubmitWorkflow(PatValidation patValidation,
IEnumerable<ErrorCriteria> errorCriteriaList, string sourceNameMatch)
StringBuilder errorMessageBuilder = new StringBuilder();
foreach (ErrorCriteria errorCriteria in errorCriteriaList)
if (!errorCriteria.Validate
|| errorCriteria.SourceName != sourceNameMatch
|| !errorCriteria.ValidateOnSubmitToWorkflow
|| (!errorCriteria.ErrPostCondition.Contains("~exists~")
&& !errorCriteria.ErrPostCondition.StartsWith("wo."))) continue;
patValidation.PatItem = null;
bool isValid = IsValidateErrorCriteria(errorCriteria, patValidation);
errorCriteria.IsValid = true;
errorMessageBuilder.Append("<ul>\n <li><p> " + GetErrorMsg(errorCriteria, patValidation.PatPropLabelMap) +
return errorMessageBuilder.ToString();
private string ValidateEachRelationshipOther(PatValidation patValidation,
IEnumerable<ErrorCriteria> errorCriteriaList, bool isReqFrmWorkflowActivity, string sourceNameMatch)
StringBuilder errorMessageBuilder = new StringBuilder();
foreach (ErrorCriteria errorCriteria in errorCriteriaList)
if (!errorCriteria.Validate
|| errorCriteria.SourceName != sourceNameMatch
|| !isReqFrmWorkflowActivity
|| !errorCriteria.IsWorkflowValidation
|| (!errorCriteria.ErrPostCondition.Contains("~exists~") &&
!errorCriteria.ErrPostCondition.StartsWith("wo."))) continue;
patValidation.PatItem = null;
bool isValid = IsValidateErrorCriteria(errorCriteria, patValidation);
errorCriteria.IsValid = true;
string errorMsg = GetErrorMsg(errorCriteria, patValidation.PatPropLabelMap);
errorMessageBuilder.AppendFormat("<ul>\n <li><p> {0} </p></li> </ul>", errorMsg);
return errorMessageBuilder.ToString();
private static string GetErrorMsg(ErrorCriteria errorCriteria, Dictionary<string, string> patPropLabelMap)
patPropLabelMap.TryGetValue(errorCriteria.SourceName + "." + errorCriteria.FieldName, out errFieldName)
return errFieldName + " (" + errorCriteria.ErrorCode + ") : " + errorCriteria.ErrMsgDflt;
public PatValidation PopulateWorkOrderItems(PatValidation patValidation)
Item patItem = patValidation.PatItem;
string itemId = patItem.getProperty("itemId");
string validateAction = patItem.getProperty("validateAction");
bool isRequestFromWorkflowBtn = false;
bool isRequestFromImport = false;
bool isRequestFromWorkflowActivity = false;
string workflowActivityName = "";
if (string.IsNullOrEmpty(validateAction))
if (patItem.getAttribute("type") == "Activity")
workflowActivityName = patItem.getProperty("name");
isRequestFromWorkflowActivity = true;
else if (validateAction == "submit_to_workflow")
isRequestFromWorkflowBtn = true;
else if (validateAction == "pat_import")
isRequestFromImport = true;
patValidation.IsRequestFromWorkflowBtn = isRequestFromWorkflowBtn;
patValidation.IsRequestFromImport = isRequestFromImport;
patValidation.IsRequestFromWorkflowActivity = isRequestFromWorkflowActivity;
patValidation.WorkflowActivityName = workflowActivityName;
Item reload = patItem.newItem(Constants.ItemTypeNames.workOrder, "get");
string[] relationshipTypeNames = {
Constants.ItemTypeNames.woChangeCriteria,
Constants.ItemTypeNames.woPAT,
Constants.ItemTypeNames.woPIC,
Constants.ItemTypeNames.woVPPS,
Constants.ItemTypeNames.woBuildEvent,
Constants.ItemTypeNames.woTWORework,
Constants.ItemTypeNames.woTooling,
Constants.ItemTypeNames.woValPlan,
Constants.ItemTypeNames.woAttach,
Constants.ItemTypeNames.woCostTiming,
Constants.ItemTypeNames.woPPPAT,
Constants.ItemTypeNames.woPPIC,
Constants.ItemTypeNames.woPPCost,
Constants.ItemTypeNames.woShippedTo,
Constants.ItemTypeNames.woBSDVerification,
Constants.ItemTypeNames.woPBreakpoint,
Constants.ItemTypeNames.woPartAndCost,
Constants.ItemTypeNames.woMpdAction,
Constants.ItemTypeNames.woMmoPptShippedTo,
Constants.ItemTypeNames.woMwoVppsErd,
Constants.ItemTypeNames.woPpqp
foreach (string relationshipItemTypeName in relationshipTypeNames)
reload.createRelationship(relationshipItemTypeName, "get");
if (isRequestFromWorkflowBtn)
else if (isRequestFromWorkflowActivity)
Item controlled = patItem.apply("GM Get Controlled Item");
reload.setID(controlled.getID());
reload.setID(patItem.getID());
Item ecr = reload.apply();
throw new Aras.Server.Core.InnovatorServerException(ecr.getErrorDetail());
patValidation.WorkflowSubtype = ecr.getProperty("_subtype", "");
patValidation.WorkOrder = ecr;
SetRelationshipsFromEcrOnPatValidation(patValidation, relationshipTypeNames, ecr);
PopulateErrorConditions(patValidation);
private static void SetRelationshipsFromEcrOnPatValidation(PatValidation patValidation,
string[] relationshipTypeNames, Item ecr)
foreach (string relationshipTypeName in relationshipTypeNames)
Item relationshipsFromEcr = GetRelationshipsFromEcr(ecr, relationshipTypeName);
if (relationshipsFromEcr == null) continue;
switch (relationshipTypeName)
case Constants.ItemTypeNames.woChangeCriteria:
int count = relationshipsFromEcr.getItemCount();
Item woChangeCriteriaRel = relationshipsFromEcr.getItemByIndex(0);
if (woChangeCriteriaRel.isError())
throw new Aras.Server.Core.InnovatorServerException(
woChangeCriteriaRel.getErrorDetail());
patValidation.WoChangeCriteriaRel = woChangeCriteriaRel;
case Constants.ItemTypeNames.woPAT:
patValidation.WoPatRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woPIC:
patValidation.WoPicRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woVPPS:
patValidation.WoVppsRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woBuildEvent:
patValidation.WoBuildEventRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woTWORework:
patValidation.WoTwoReworkRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woTooling:
patValidation.WoToolingRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woValPlan:
patValidation.WoValPlanRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woAttach:
patValidation.WoAttachRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woCostTiming:
patValidation.WoCostRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woPPPAT:
patValidation.WoPppatRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woPPIC:
patValidation.WoPpicRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woPPCost:
patValidation.WoPpCostRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woShippedTo:
patValidation.WoShippedToRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woBSDVerification:
patValidation.WoBsdVerificationRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woPBreakpoint:
patValidation.WoPBreakpointRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woPartAndCost:
patValidation.WoPartAndCostRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woMpdAction:
patValidation.WoMpdActionRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woMmoPptShippedTo:
patValidation.WoMmoPptShippedToRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woMwoVppsErd:
patValidation.WoVppsRels = relationshipsFromEcr;
case Constants.ItemTypeNames.woPpqp:
patValidation.WoPpqpRels = relationshipsFromEcr;
private static Item GetRelationshipsFromEcr(Item ecr, string relationshipItemTypeName)
Item relationships = ecr.getRelationships(relationshipItemTypeName);
if (relationships == null) return null;
if (relationships.isError())
throw new Aras.Server.Core.InnovatorServerException(relationships.getErrorDetail());
public bool IsValidateErrorCriteria(ErrorCriteria errorCriteria, PatValidation patValidation)
string preCond = errorCriteria.ErrPreCondition;
string postCond = errorCriteria.ErrPostCondition;
if (!string.IsNullOrEmpty(preCond) && !string.IsNullOrEmpty(postCond))
bool isValidatePreCondition = ParseConditionCriteria(preCond, patValidation, false, " and ");
if (isValidatePreCondition)
return ParseConditionCriteria(postCond, patValidation, false, " and ");
else if (string.IsNullOrEmpty(preCond) && !string.IsNullOrEmpty(postCond))
return ParseConditionCriteria(postCond, patValidation, false, " and ");
private bool ParseConditionCriteria(string conditionStr, PatValidation patValidation, bool isSubCond,
string[] stringSeparators = { condSep };
conditionStr = conditionStr.Replace(Constants.ItemTypeNames.woPartAndCost, "gm_costplaceholder");
string[] errCondArr = conditionStr.Split(stringSeparators, StringSplitOptions.None).Select(x => x.Replace("gm_costplaceholder", Constants.ItemTypeNames.woPartAndCost)).ToArray();
bool isCondCompare = condSep != " or ";
if (errCondArr.Length == 1 && conditionStr.Contains(" or "))
isCondCompare = isCondCompare && ParseConditionCriteria(conditionStr, patValidation, false, " or ");
return GetIsCondCompareFromErrCondArr(errCondArr, isCondCompare, patValidation, condSep);
private bool GetIsCondCompareFromErrCondArr(string[] errCondArr, bool isCondCompare, PatValidation patValidation, string condSep)
foreach (string condition in errCondArr)
if (condition.Contains(" or "))
isCondCompare = isCondCompare && ParseConditionCriteria(condition, patValidation, true, " or ");
isCondCompare = isCondCompare && IsParseCondition(condition, patValidation);
if (!isCondCompare) return false;
else if (condSep == " or ")
isCondCompare = isCondCompare || IsParseCondition(condition, patValidation);
if (isCondCompare) return true;
private bool IsParseCondition(string condition, PatValidation patValidation)
condition = condition.Trim();
string[] stringSepSpace = new string[] { "~" };
string[] subCondition1 = condition.Split(stringSepSpace, StringSplitOptions.None);
if (subCondition1.Length >= 2 && subCondition1.Length <= 3)
string propName = subCondition1[0].Trim();
string operation = subCondition1[1].Trim();
string value = string.Empty;
if (subCondition1.Length == 3)
value = subCondition1[2].Trim();
return CompareProperty(propName, operation, value, patValidation);
private string GetPropValueFromPropName(Item item, string propName, PatValidation patValidation)
string[] strSepPipe = { "|" };
string[] strSepDot = { "." };
string[] propNamePipeArr = propName.Split(strSepPipe, StringSplitOptions.None);
if (propNamePipeArr.Length > 1)
string[] itemPropNameDotArr = propNamePipeArr[0].Split(strSepDot, StringSplitOptions.None);
if (itemPropNameDotArr.Length > 1)
string itemName = itemPropNameDotArr[0];
string itemPropName = itemPropNameDotArr[1];
GetCurrentItemFromPropName(itemPropName, item, patValidation);
string itemPropId = GetPropValueFromItem(itemPropName, item);
Item refItem = dataAccessLayer.getItemById(itemName, itemPropId);
propValue = GetPropValueFromItem(itemPropName, refItem);
string currPropName = propNamePipeArr[0];
Item refItem = GetCurrentItemFromPropName(currPropName, item, patValidation);
propValue = GetPropValueFromItem(currPropName, refItem);
string[] itemPropNameDotArr = propNamePipeArr[0].Split(strSepDot, StringSplitOptions.None);
if (itemPropNameDotArr.Length > 1)
string itemPropName = itemPropNameDotArr[1];
Item refItem = GetCurrentItemFromPropName(propName, item, patValidation);
propValue = GetPropValueFromItem(itemPropName, refItem);
Item refItem = GetCurrentItemFromPropName(propName, item, patValidation);
propValue = GetPropValueFromItem(propName, refItem);
private static string GetPropValueFromItem(string propName, Item item)
if (item == null || string.IsNullOrEmpty(propName))
string propValue = item.getProperty(propName);
return !string.IsNullOrEmpty(propValue) ? propValue.Trim() : "";
private static Item GetCurrentItemFromPropName(string propName, Item item, PatValidation patValidation)
string[] strSepDot = { "." };
string[] propNameDotArr = propName.Split(strSepDot, StringSplitOptions.None);
if (propNameDotArr.Length > 1)
string itemName = propNameDotArr[0];
if (itemName == "changeCriteria")
item = patValidation.WoChangeCriteriaRel;
else if (itemName == "wo")
item = patValidation.WorkOrder;
private bool CompareProperty(string propName, string operation, string compareVal,
PatValidation patValidation)
Item item = patValidation.PatItem;
if (item == null && !propName.Contains(".") && operation != "exists") return false;
string propValue = GetPropValueFromPropName(item, propName, patValidation);
return propValue == compareVal;
return string.Equals(propValue, compareVal, StringComparison.OrdinalIgnoreCase);
return propValue != compareVal;
return !string.IsNullOrEmpty(propValue);
return propValue.Contains(compareVal);
case "containsIgnoreCase":
string noCasePropValue = propValue.ToUpper();
string noCaseCompareValue = compareVal.ToUpper();
return noCasePropValue.Contains(noCaseCompareValue);
decimal decimalComareVal = System.Convert.ToDecimal(compareVal);
return propValue.Length <= decimalComareVal;
decimal decimalComareVal = System.Convert.ToDecimal(compareVal);
return propValue.Length >= decimalComareVal;
return IsCheckRegularExpression(propValue, compareVal);
return IsNumericValue(propValue, compareVal);
return !IsNumericValue(propValue, compareVal);
return IsPositiveNumeric(compareVal, propValue);
return IsCheckDecimalValue(propValue, compareVal);
return ComparePropertyWithCustomOperator(propName, compareVal, patValidation, item, propValue);
return IsCheckValidValues(propValue, compareVal);
return IsExistsValue(propName, compareVal, patValidation);
case "hasASelectedActiveBuild":
return HasASelectedActiveAndOrPulledBuild(item, checkPulledBuilds: false);
case "hasASelectedActiveOrPulledBuild":
return HasASelectedActiveAndOrPulledBuild(item, checkPulledBuilds: true);
case "keyednameContains":
var keyedName = item == null ? "" : item.getPropertyAttribute(propName, "keyed_name", "");
return keyedName.IndexOf(compareVal, StringComparison.OrdinalIgnoreCase) >= 0;
var keyedName = item == null ? "" : item.getPropertyAttribute(propName, "keyed_name", "");
return keyedName.Equals(compareVal, StringComparison.OrdinalIgnoreCase);
return ComparePropertyWithOtherOperation(propName, operation, compareVal, item);
private bool HasASelectedActiveAndOrPulledBuild(Item patItem, bool checkPulledBuilds)
var itemType = patItem.getType();
if (!itemType.Equals(Constants.ItemTypeNames.woPPPAT, StringComparison.OrdinalIgnoreCase)) return false;
var ppatId = patItem.getID();
Func<string, string> getBuildCountQuery = buildTableName => string.Format(
"(SELECT COUNT(*) FROM {0} WHERE _SELECT = '1' AND SOURCE_ID = '{1}')",
string buildCountQuery = string.Format("SELECT {0}{1}",
getBuildCountQuery("GM_PPAT_ACTIVE_BUILD"),
checkPulledBuilds ? " + " + getBuildCountQuery("GM_PPAT_PULLED_BUILD") : "");
var result = inn.applySQL(buildCountQuery);
return !result.isError() && !result.getProperty("column1", "0").Equals("0");
private static bool ComparePropertyWithOtherOperation(string propName, string operation, string compareVal, Item item)
if (operation.StartsWith("delimSepValueCount"))
return CompareDelimSepValueCount(propName, operation, compareVal, item);
if (operation.StartsWith("delimSepValueEqual"))
return CompareDelimSepValueEqual(propName, operation, compareVal, item);
private static bool CompareDelimSepValueEqual(string propName, string operation, string compareVal, Item item)
string[] valueArr = operation.Split('|');
if (valueArr.Length != 3) return false;
var delim1 = valueArr[1];
var delim2 = valueArr[2];
if (item == null) return false;
var compArr = item.getProperty(propName, "").Split(new[] { delim1 }, StringSplitOptions.None);
if (delim2.Equals("ALL", StringComparison.OrdinalIgnoreCase))
return compArr.All(s => s == compareVal);
var splitValues = delim2.Split(',');
foreach (var splitValue in splitValues)
if (int.TryParse(splitValue, out x) && compArr.Length >= x && compArr[x] != compareVal)
private static bool CompareDelimSepValueCount(string propName, string operation, string compareVal, Item item)
string[] valueArr = operation.Split('|');
if (valueArr.Length != 3) return false;
string delim1 = valueArr[1];
string delim2 = valueArr[2];
if (item == null) return false;
string[] prodYr = item.getProperty(propName, "")
.Split(new[] { delim1 }, StringSplitOptions.None);
string[] stkDisp = item.getProperty(compareVal, "")
.Split(new[] { delim2 }, StringSplitOptions.None);
return !string.IsNullOrEmpty(item.getProperty(compareVal, ""))
&& prodYr.Length == stkDisp.Length;
private bool ComparePropertyWithCustomOperator(string propName, string compareVal, PatValidation patValidation, Item item,
return CompareNewPartPlsProperty(item, compareVal, propValue);
return CompareNewPartDlsProperty(item, compareVal, propValue);
case "_new_part_mss_net_qty":
return CompareNewPartMssNetQtyProperty(compareVal, propValue);
return HasRelatedEcrOfGivenType(patValidation, Constants.EcrTypes.TempType);
return HasRelatedEcrOfGivenType(patValidation, Constants.EcrTypes.BSD);
return HasRelatedEcrOfGivenType(patValidation, Constants.EcrTypes.BCR, "'Related','Plant'");
return HasRelatedEcrOfGivenType(patValidation, Constants.EcrTypes.PartType);
return HasRelatedEcrOfGivenType(patValidation, Constants.EcrTypes.BCR);
return HasRelatedEcrOfGivenType(patValidation);
private bool HasRelatedEcrOfGivenType(PatValidation patValidation, string type = null, string classifications = "'Related'")
"SELECT Coord._WORK_ORDER FROM INNOVATOR.GM_COORDINATION Coord WHERE Coord.ID IN (SELECT RELATED_ID FROM INNOVATOR.GM_COORDINATION_ROOTS WHERE SOURCE_ID IN (SELECT SOURCE_ID FROM INNOVATOR.GM_COORDINATION_ROOTS WHERE RELATED_ID IN (SELECT ID FROM INNOVATOR.GM_COORDINATION WHERE _WORK_ORDER = '" +
patValidation.WorkOrder.getID() + "' AND CLASSIFICATION IN (" + classifications + " ))))";
Item relatedEcr = inn.applySQL(sql);
if (relatedEcr.isError() || relatedEcr.getItemCount() <= 0) return false;
if (string.IsNullOrWhiteSpace(type) && relatedEcr.getItemCount() > 0)
for (int i = 0; i < relatedEcr.getItemCount(); i++)
string workOrderId = relatedEcr.getItemByIndex(i).getProperty("_work_order", "");
if (workOrderId.Equals(patValidation.WorkOrder.getID(), StringComparison.OrdinalIgnoreCase))
var ecrSql = "select _type from gm_work_order where gm_work_order.id ='" + workOrderId + "'";
var result = inn.applySQL(ecrSql);
if (result.isError() || result.getItemCount() <= 0) continue;
if (result.getProperty("_type", string.Empty).Equals(type, StringComparison.OrdinalIgnoreCase))
private static bool CompareNewPartMssNetQtyProperty(string compareVal, string propValue)
if (string.IsNullOrEmpty(propValue)) return true;
var newMass = Convert.ToDecimal(propValue);
var newMassMaxValue = Convert.ToDecimal(compareVal);
return newMass < newMassMaxValue;
private bool CompareNewPartPlsProperty(Item item, string compareVal, string propValue)
return System.Text.RegularExpressions.Regex.IsMatch(propValue, @"^[a-zA-Z]+$")
|| string.IsNullOrEmpty(propValue);
private bool CompareNewPartDlsProperty(Item item, string compareVal, string propValue)
return System.Text.RegularExpressions.Regex.IsMatch(propValue, @"^[a-zA-Z]+$")
|| string.IsNullOrEmpty(propValue);
private static bool IsPositiveNumeric(string compareVal, string propValue)
string[] strSepPipe = { "|" };
string[] compareValSplitArr = compareVal.Split(strSepPipe, StringSplitOptions.None);
decimal maxVal = System.Convert.ToDecimal(compareValSplitArr[0]);
if (compareValSplitArr.Length >= 1)
string decimalPosStr = compareValSplitArr[1];
decimalPos = ConvertStringToInt(decimalPosStr);
return IsPositiveNumericValue(propValue, maxVal, decimalPos ?? 0);
public bool IsPlsValid(Item patItem)
var newPartId = patItem.getProperty("_new_part_no");
if (string.IsNullOrEmpty(newPartId))
var pls = patItem.getProperty("_new_part_pls");
if (string.IsNullOrEmpty(pls))
bool isPlsNumeric = int.TryParse(pls, out n);
var patPartRequest = inn.newItem("gm_part", "get");
patPartRequest.setAttribute("select", "id,keyed_name");
patPartRequest.setProperty("id", newPartId);
var patPart = patPartRequest.apply();
var partRequest = inn.newItem("gm_part", "get");
partRequest.setAttribute("select", "_part_pls");
partRequest.setProperty("_part_nbr", patPart.getProperty("keyed_name"));
var parts = partRequest.apply();
var existingPls = ToEnumerable(parts)
.Select(I => I.getProperty("_part_pls", "").Trim())
.Where(A => !string.IsNullOrEmpty(A))
var nextPlsChar = existingPls.Any() ? ((char)(((int)existingPls.First()[0]) + 1)).ToString() : "A";
var isExistingPlsVal = existingPls.Any(I => I.Equals(pls));
return pls.Equals(nextPlsChar) || isExistingPlsVal;
public bool IsDlsValid(Item patItem)
var newPartId = patItem.getProperty("_new_part_no");
if (string.IsNullOrEmpty(newPartId))
var dls = patItem.getProperty("_new_part_dls");
if (string.IsNullOrEmpty(dls))
bool isDlsNumeric = int.TryParse(dls, out n);
var patPartRequest = inn.newItem("gm_part", "get");
patPartRequest.setAttribute("select", "id,keyed_name");
patPartRequest.setProperty("id", newPartId);
var patPart = patPartRequest.apply();
var partRequest = inn.newItem("gm_part", "get");
partRequest.setAttribute("select", "_part_dls");
partRequest.setProperty("_part_nbr", patPart.getProperty("keyed_name"));
var parts = partRequest.apply();
var existingDls = ToEnumerable(parts)
.Select(I => I.getProperty("_part_dls", "").Trim())
.Where(A => !string.IsNullOrEmpty(A))
var nextDlsChar = existingDls.Any() ? ((char)(((int)existingDls.Last()[0]) + 1)).ToString() : "A";
var isExistingDlsVal = existingDls.Any(I => I.Equals(dls));
return string.Equals(nextDlsChar, dls, StringComparison.OrdinalIgnoreCase) || isExistingDlsVal;
private static IEnumerable<Item> ToEnumerable(Item item)
var items = new List<Item>();
for (var i = 0; i < item.getItemCount(); i++)
items.Add(item.getItemByIndex(i));
private static bool IsPositiveNumericValue(string value, decimal maxVal, int decimalPos)
decimalPos = (decimalPos == 0) ? 2 : decimalPos;
string compareVal = "^(?=[0-9]?\\d*(\\.\\d{1," + decimalPos + "})?$)[0-9\\d\\.]+$";
if (IsCheckRegularExpression(value, compareVal))
decimal val = System.Convert.ToDecimal(value);
if (val <= 0 || val >= maxVal)
private static bool IsNumericValue(string value, string compareVal)
string[] strSepPipe = { "|" };
string[] compareValSplitArr = compareVal.Split(strSepPipe, StringSplitOptions.None);
if (compareValSplitArr.Length > 0)
charRange = compareValSplitArr[0];
if (compareValSplitArr.Length > 1)
minValStr = compareValSplitArr[1];
if (compareValSplitArr.Length > 2)
maxValStr = compareValSplitArr[2];
charRange = GetRegExpCharRange(charRange);
bool isCheckNumericVal = IsCheckRegularExpression(value, "[0-9]" + charRange);
if (!isCheckNumericVal) return false;
int? propVal = ConvertStringToInt(value);
int? minVal = ConvertStringToInt(minValStr);
if (propVal == null || minVal == null || propVal < minVal)
if (maxValStr == "") return true;
int? maxVal = ConvertStringToInt(maxValStr);
return propVal != null && maxVal != null && !(propVal > maxVal);
private static string GetRegExpCharRange(string charRange)
if (IsCheckRegularExpression(charRange, "^[0-9]{1,4}[,]{0,1}[0-9]{0,4}$"))
charRange = "{" + charRange + "}";
private bool IsCheckValidValues(string propVal, string validValueSourceName)
string[] strSepValidValSource = { "|" };
string[] validValSourceSplitArr = validValueSourceName.Split(strSepValidValSource, StringSplitOptions.None);
if (validValSourceSplitArr.Length < 2) return false;
bool isList = validValSourceSplitArr[1] == "Y";
string columnNameToSearch = "";
if (validValSourceSplitArr.Length == 3)
columnNameToSearch = validValSourceSplitArr[2];
if (validValSourceSplitArr.Length == 4)
isMultiple = validValSourceSplitArr[3] == "Y";
if (validValSourceSplitArr.Length == 5)
int.TryParse(validValSourceSplitArr[4], out maxMultipleVals);
Item validValSrcItem = dataAccessLayer.newItem("List", "get");
validValSrcItem.setAttribute("select", "name");
validValSrcItem.setProperty("name", "gm_change criteria yes no");
Item validValListItem = dataAccessLayer.newItem("Value", "get");
validValListItem.setAttribute("select", "label, value");
Item listAmlResults = validValListItem.apply();
int validValsCount = listAmlResults.getItemCount();
if (isMultiple) return false;
Item validValItem = dataAccessLayer.newItem(propVal, "get");
validValItem.setAttribute("select", columnNameToSearch);
validValItem.setProperty(columnNameToSearch, propVal);
Item validValResults = validValItem.apply();
int validValsCount = validValResults.getItemCount();
private bool IsExistsValue(string propName, string relValCombo, PatValidation patValidation)
string[] strSepRelVal = { "|" };
string[] relValComboArr = relValCombo.Split(strSepRelVal, StringSplitOptions.None);
if (relValComboArr.Length != 2) return false;
string relationshipName = relValComboArr[0];
string mustExistValue = relValComboArr[1];
switch (relationshipName)
case Constants.ItemTypeNames.woPAT:
rels = patValidation.WoPatRels;
case Constants.ItemTypeNames.woValPlan:
rels = patValidation.WoValPlanRels;
case Constants.ItemTypeNames.woAttach:
rels = patValidation.WoAttachRels;
case Constants.ItemTypeNames.woCostTiming:
rels = patValidation.WoCostRels;
case Constants.ItemTypeNames.woBuildEvent:
rels = patValidation.WoBuildEventRels;
case Constants.ItemTypeNames.woTWORework:
rels = patValidation.WoTwoReworkRels;
case Constants.ItemTypeNames.woPPCost:
rels = patValidation.WoPpCostRels;
case Constants.ItemTypeNames.woShippedTo:
rels = patValidation.WoShippedToRels;
case Constants.ItemTypeNames.woBSDVerification:
rels = patValidation.WoBsdVerificationRels;
case Constants.ItemTypeNames.woPBreakpoint:
rels = patValidation.WoPBreakpointRels;
case Constants.ItemTypeNames.woPartAndCost:
rels = patValidation.WoPartAndCostRels;
case Constants.ItemTypeNames.woMpdAction:
rels = patValidation.WoMpdActionRels;
case Constants.ItemTypeNames.woMmoPptShippedTo:
rels = patValidation.WoMmoPptShippedToRels;
case Constants.ItemTypeNames.woMwoVppsErd:
rels = patValidation.WoVppsRels;
case Constants.ItemTypeNames.woPpqp:
rels = patValidation.WoPpqpRels;
if (rels == null) return false;
if (propName == "id" && mustExistValue == "x")
if (rels.getItemCount() > 0)
returnVal = GetIsExistsReturnVal(propName, rels, mustExistValue);
private bool GetIsExistsReturnVal(string propName, Item rels, string mustExistValue)
for (int c = 0; c < rels.getItemCount(); c++)
Item rel = rels.getItemByIndex(c);
string propertyValueToCheck = rel.getProperty(propName, "");
if (propertyValueToCheck != "" && mustExistValue.Contains("->"))
string[] strSepItemLookup = { "->" };
string[] itemLookupComboArr = mustExistValue.Split(strSepItemLookup, StringSplitOptions.None);
if (itemLookupComboArr.Length != 3) continue;
string itemTypeLookup = itemLookupComboArr[0];
string propNameLookup = itemLookupComboArr[1];
string propValueLookup = itemLookupComboArr[2];
Item lookupQuery = dataAccessLayer.newItem(itemTypeLookup, "get");
lookupQuery.setAttribute("select", propNameLookup);
lookupQuery.setProperty(propNameLookup, propValueLookup);
Item lookupResult = lookupQuery.apply();
returnVal = IsPropertyInLookupResult(lookupResult, propertyValueToCheck);
else if ((mustExistValue == "notblank" && !string.IsNullOrWhiteSpace(propertyValueToCheck))
|| propertyValueToCheck == mustExistValue)
private static bool IsPropertyInLookupResult(Item lookupResult, string propertyValueToCheck)
int itemCount = lookupResult.getItemCount();
for (int i = 0; i < itemCount; i++)
Item thisLookupItem = lookupResult.getItemByIndex(i);
if (propertyValueToCheck == thisLookupItem.getProperty("id"))
private static int? ConvertStringToInt(string str)
private static bool IsCheckDecimalValue(string propVal, string compareVal)
string[] strSepPipe = { "|" };
string[] compareValSplitArr = compareVal.Split(strSepPipe, StringSplitOptions.None);
string preDecimalMaxNumbers = compareValSplitArr[0];
string postDecimalMaxNumbers = compareValSplitArr[1];
string negativeAllowed = compareValSplitArr[2];
string isNegAllowedRegExp = "[+-]";
if (negativeAllowed == "false")
string regExp = "^" + isNegAllowedRegExp + "?\\d{0," + preDecimalMaxNumbers + "}(\\.\\d{1," + postDecimalMaxNumbers + "})?$";
return IsCheckRegularExpression(propVal, regExp);
private static bool IsCheckRegularExpression(string propVal, string compareVal)
bool isRegexCompare = false;
System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex(compareVal);
isRegexCompare = rgx.IsMatch(propVal);
throw new Aras.Server.Core.InnovatorServerException(e.ToString());
public class PatValidation
public PatValidation(Item patItem)
ErrorCriteriaList = new List<ErrorCriteria>();
PatPropLabelMap = new Dictionary<string, string>();
WorkflowActivityName = "";
public bool IsValid { get; private set; }
public List<ErrorCriteria> ErrorCriteriaList { get; set; }
public Dictionary<string, string> PatPropLabelMap { get; set; }
public string WorkflowActivityName { get; set; }
public string WorkflowSubtype { get; set; }
public string ErrorMsg { get; set; }
public bool IsRequestFromWorkflowActivity { get; set; }
public bool IsRequestFromWorkflowBtn { get; set; }
public bool IsRequestFromImport { get; set; }
public Item PatItem { get; set; }
public Item WorkOrder { get; set; }
public Item WoChangeCriteriaRel { get; set; }
public Item WoPatRels { get; set; }
public Item WoVppsRels { get; set; }
public Item WoBuildEventRels { get; set; }
public Item WoTwoReworkRels { get; set; }
public Item WoPicRels { get; set; }
public Item WoToolingRels { get; set; }
public Item WoValPlanRels { get; set; }
public Item WoAttachRels { get; set; }
public Item WoCostRels { get; set; }
public Item WoPppatRels { get; set; }
public Item WoPpicRels { get; set; }
public Item WoPpCostRels { get; set; }
public Item WoShippedToRels { get; set; }
public Item WoPBreakpointRels { get; set; }
public Item WoBsdVerificationRels { get; set; }
public Item WoPartAndCostRels { get; set; }
public Item WoMpdActionRels { get; set; }
public Item WoMmoPptShippedToRels { get; set; }
public Item WoPpqpRels { get; set; }
public class ErrorCriteria
WorkflowActivityNames = "";
public string ErrorCode { get; set; }
public string WorkflowActivityNames { get; set; }
public string WorkflowSubtypes { get; set; }
public string ValidValueSource { get; set; }
public string FieldName { get; set; }
public string SourceName { get; set; }
public string ErrPreCondition { get; set; }
public string ErrPostCondition { get; set; }
public string ErrMsgDflt { get; set; }
public bool IsWorkflowValidation { get; set; }
public bool ValidateOnSave { get; set; }
public bool ValidateOnImport { get; set; }
public bool ValidateOnSubmitToWorkflow { get; set; }
public bool IsValid { get; set; }
public bool Validate { get; set; }
public interface IDataAccessLayer
Item newItem(string itemTypeName, string action);
Item getItemById(string itemTypeName, string id);
Item getItemByAML(string aml);
string getUserAliasID(string id);
Item applySQL(string sql);
public class DataAccessLayer : IDataAccessLayer
private readonly Innovator _innovator;
public DataAccessLayer(Innovator innovator)
this._innovator = innovator;
public Item getItemById(string itemTypeName, string id)
return _innovator.getItemById(itemTypeName, id);
public Item getItemByAML(string aml)
return _innovator.applyAML(aml);
public string getUserAliasID(string id)
var userAlias = _innovator.newItem("Alias", "get");
userAlias.setProperty("source_id", _innovator.getUserID());
var aliasUser = userAlias.apply();
throw new Aras.Server.Core.InnovatorServerException(aliasUser.getErrorDetail());
return aliasUser.getItemByIndex(0).getProperty("related_id");
public string getUserID()
return _innovator.getUserID();
public Item newItem(string itemTypeName, string action)
return _innovator.newItem(itemTypeName, action);
public Item applySQL(string sql)
return _innovator.applySQL(sql);
public void end_of_method_()