// product type internal static productType getProductType(AWF myAWF, int itemSequence, RBA_Variables variables) { string sql = "SELECT type " + "FROM asset " + "WHERE name = :asset_name; "; string[] parameterNames = { "asset_name" }; string[] parameterVals = { string.Format("{0}{1} {2} {3}", variables.VASSET_PREFIX, myAWF.Products.Item[itemSequence].SourcePDNumber, myAWF.Products.Item[itemSequence].SourcePDLine, myAWF.Products.Item[itemSequence].ItemCode) }; string scalarRequestString = AWFPostgresDataLayer.SelectScalar(sql, parameterNames, parameterVals); return(String.IsNullOrEmpty(scalarRequestString) ? productTypeStaticSearch(sql, parameterNames, myAWF, itemSequence) : (productType)(Convert.ToInt32(scalarRequestString))); }
private static asset getAsset(AWF myAWF, int itemSequence, RBA_Variables variables) { string sql = string.Empty; string itemCode = string.Format("%{0}%", myAWF.Products.Item[itemSequence].ItemCode); string PDNumber = string.Format("{0}%", variables.VASSET_PREFIX + myAWF.Products.Item[itemSequence].SourcePDNumber); string[] parameterNames = new string[1]; string[] parameterVals = new string[1]; switch (getProductType(myAWF, itemSequence, variables)) { case productType.Static: sql = "SELECT id, name " + "FROM asset " + "WHERE name LIKE :stock_code " + "LIMIT 1"; parameterNames = new string[] { "stock_code" }; parameterVals = new string[] { itemCode }; break; case productType.Variable: sql = "SELECT id, name " + "FROM asset " + "WHERE name LIKE :printdirect_number " + "AND name LIKE :stock_code " + "LIMIT 1"; parameterNames = new string[] { "printdirect_number", "stock_code" }; parameterVals = new string[] { PDNumber, itemCode }; break; } DataTable rtTable = AWFPostgresDataLayer.GetDataTable(sql, parameterNames, parameterVals); if (rtTable.Rows.Count == 1) { return(new asset { Id = Convert.ToString(rtTable.Rows[0]["id"]), Name = Convert.ToString(rtTable.Rows[0]["name"]) }); } else { throw new Exception("Asset not found in Asset Table"); } }
public AWF_VariableAsset(string pathToXML, int itemSequence, RBA_Variables variables) { this._variables = variables; AWF_VariableAsset_init(pathToXML, itemSequence); }
// update aaudit internal static int updateAaudit(AWF myAWF, string actionString, string eventId, int itemSequence, RBA_Variables variables) { asset myAsset = getAsset(myAWF, itemSequence, variables); switch (getProductType(myAWF, itemSequence, variables)) { case productType.Static: AWF_DB_Log.insertAauditRecordInDb(myAsset.Id, eventId, string.Format("{0}: {1} | Job Number: {2}", actionString, myAWF.Products.Item[itemSequence].ItemCode, myAWF.JobNumber.ToString())); break; case productType.Variable: AWF_DB_Log.insertAauditRecordInDb(myAsset.Id, eventId, string.Format("{0}: {1}", actionString, myAsset.Name)); break; } string sql = "UPDATE asset " + "SET tlc=(SELECT DISTINCT tc " + "FROM aaudit WHERE id = :asset_id " + "AND seq = (SELECT DISTINCT MAX(seq) " + "FROM aaudit WHERE id = :asset_id ) LIMIT 1) " + (actionString.Contains("DESTROY/CANCEL") ? ", status = 3" : String.Empty) + "WHERE id = :asset_id; "; string[] parameterNames = { "asset_id" }; string[] parameterVals = { myAsset.Id }; return(AWFPostgresDataLayer.ExecuteNonQuery(sql, parameterNames, parameterVals)); }
public AWForder(string pathToXML, int itemSequence, RBA_Variables variables) { this._variables = variables; this.AWForder_init(pathToXML, itemSequence); }