Exemple #1
0
        // 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));
        }
Exemple #2
0
        //check if static item is active, i.e. exists or not disabled
        private static bool isStaticActive(string sql, string[] parameterNames, AWF myAWF, int itemSequence)
        {
            string[] parameterVals = { myAWF.Products.Item[itemSequence].ItemCode };

            string scalarRequestString = AWFPostgresDataLayer.SelectScalar(sql, parameterNames, parameterVals);

            if (!string.IsNullOrEmpty(scalarRequestString))
            {
                return(0 == Convert.ToInt32(scalarRequestString));
            }
            else
            {
                throw new FormatException(string.Format("job/pd#: {0}, item: {1}, returns no 'status' value from prinlut 'asset' table", myAWF.JobNumber.ToString(), myAWF.Products.Item[itemSequence].ItemCode));
            }
        }
Exemple #3
0
        // 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)));
        }
Exemple #4
0
        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");
            }
        }
Exemple #5
0
        private static productType productTypeStaticSearch(string sql, string[] parameterNames, AWF myAWF, int itemSequence)
        {
            string[] parameterVals = { myAWF.Products.Item[itemSequence].ItemCode };

            string scalarRequestString = AWFPostgresDataLayer.SelectScalar(sql, parameterNames, parameterVals);

            if (!string.IsNullOrEmpty(scalarRequestString))
            {
                return((productType)(Convert.ToInt32(scalarRequestString)));
            }
            else
            {
                throw new FormatException(string.Format("job/pd#: {0}, item: {1}, returns no 'type' value from DB", myAWF.JobNumber.ToString(), myAWF.Products.Item[itemSequence].ItemCode));
            }
        }