} // getAll /// <summary> /// Execute Auto Assignment /// </summary> /// <param name="po">PO to be modified</param> /// <param name="newRecord">new</param> /// <returns>true if modified</returns> static public bool Execute(PO po, bool newRecord) { if (s_assignments == null) { s_assignments = GetAll(po.GetCtx()); } bool modified = false; for (int i = 0; i < s_assignments.Length; i++) { MAssignSet set = s_assignments[i]; if (!set.IsActive()) { continue; } // Check IDs if (po.Get_Table_ID() == set.GetAD_Table_ID() && (po.GetAD_Client_ID() == set.GetAD_Client_ID() || set.GetAD_Client_ID() == 0)) { // Check Timing String rule = set.GetAutoAssignRule(); if (!newRecord && rule.Equals(AUTOASSIGNRULE_CreateOnly)) { continue; } if (newRecord && (rule.Equals(AUTOASSIGNRULE_UpdateOnly) || rule.Equals(AUTOASSIGNRULE_UpdateIfNotProcessed))) { continue; } // Eliminate Processed if (rule.Equals(AUTOASSIGNRULE_CreateAndUpdateIfNotProcessed) || rule.Equals(AUTOASSIGNRULE_UpdateIfNotProcessed)) { int indexProcessed = po.Get_ColumnIndex("Processed"); if (indexProcessed != -1 && "Y".Equals(po.Get_Value(indexProcessed))) { continue; } } // if (set.ExecuteIt(po)) { modified = true; } } } return(modified); } // execute
/// <summary> /// Get all Assignments /// </summary> /// <param name="ctx">ctx</param> /// <returns>Assognment array</returns> static public MAssignSet[] GetAll(Ctx ctx) { List <MAssignSet> list = new List <MAssignSet>(); String sql = "SELECT * FROM AD_AssignSet"; try { DataSet ds = DataBase.DB.ExecuteDataset(sql); foreach (DataRow dr in ds.Tables[0].Rows) { list.Add(new MAssignSet(ctx, dr, null)); } } catch (Exception e) { s_log.Log(Level.SEVERE, sql, e); } MAssignSet[] retValue = new MAssignSet[list.Count]; retValue = list.ToArray(); return(retValue); } // getAll