Exemplo n.º 1
0
        /// <summary>
        /// Processes pending transfer items by getting a list of pending items
        /// and transferring them via a web service call.
        /// </summary>
        /// <param name="pStoreNumber">
        /// Unique identifier of the store where items are being transferred FROM.
        /// </param>
        /// <param name="transferDate">
        /// ShopDate
        /// </param>
        /// <param name="errorMessage">
        /// Out parameter that is set with the message of any error occurring during this process.
        /// </param>
        /// <returns>
        /// Returns true if no errors encountered. False is returned if any errors occur.
        /// </returns>
        public static bool ProcessPendingTransfers(string pStoreNumber, string transferDate, out string errorMessage)
        {
            errorMessage = "";
            string errorCode = "";
            bool   errorbool = true;

            DataTable  transferItems  = new DataTable();
            List <int> cashlinxStores = new List <int>();

            TransfersDBProcedures.ExecuteGetCommonTOTickets(pStoreNumber, transferDate, out transferItems, out cashlinxStores, out errorCode, out errorMessage);
            if (!InvokeWebServiceForAllTransfers(pStoreNumber, transferItems, cashlinxStores, out errorMessage))
            {
                errorbool = false;
            }

            return(errorbool);
        }
Exemplo n.º 2
0
        public static List <IItem> GetJsupItemsByStore(DesktopSession dSession, string pStoreNumber, string pTransferType, out string errorMessage)
        {
            // Declare OUT parameters.
            DataTable table     = new DataTable();
            DataTable tableDesc = new DataTable();
            string    errorCode;
            string    errorText;

            errorMessage = string.Empty;

            List <IItem> items = new List <IItem>();

            bool retVal =
                TransfersDBProcedures.ExecuteGetJsupMerchandise(
                    pStoreNumber, pTransferType,
                    out table, out tableDesc, out errorCode, out errorText);

            if (retVal == false || table == null || string.IsNullOrEmpty(errorText) == false)
            {
                errorMessage = errorCode + ": " + errorText;
                FileLogger.Instance.logMessage(LogLevel.ERROR, null, errorMessage);
                return(items);
            }

            IItem item = new Item(); //re-instantiated and re-used in each loop iteration

            foreach (DataRow r in table.Rows)
            {
                if (pTransferType.Equals("SCRAP", StringComparison.CurrentCultureIgnoreCase))
                {
                    item = new ScrapItem();
                }
                else if (pTransferType.Equals("REFURB", StringComparison.CurrentCultureIgnoreCase))
                {
                    //item = new Item();
                    item = new ScrapItem();
                }
                else if (pTransferType.Equals("EXCESS", StringComparison.CurrentCultureIgnoreCase))
                {
                    // item = new Item();
                    item = new ScrapItem();
                }
                //else handled by TransfersDBProcedures's call above returning false with errorCode and errorText having been set

                int    icndocFromRow      = Utilities.GetIntegerValue(r["ICN_DOC"], -1);
                string storeNumberFromRow = Utilities.GetStringValue(r["STORENUMBER"], "");

                item.RefurbNumber      = Utilities.GetIntegerValue(r["RFB_NO"]);
                item.Icn               = Utilities.GetStringValue(r["ICN"]);
                item.TicketDescription = Utilities.GetStringValue(r["MD_DESC"]);
                item.ItemAmount        = Utilities.GetDecimalValue(r["PFI_AMOUNT"]);

                item.ItemStatus          = (ProductStatus)Enum.Parse(typeof(ProductStatus), Utilities.GetStringValue(r["STATUS_CD"], ""));
                item.mDocType            = Utilities.GetStringValue(r["ICN_DOC_TYPE"]);
                item.mStore              = Utilities.GetIntegerValue(r["ICN_STORE"]);
                item.CategoryCode        = Utilities.GetIntegerValue(r["CAT_CODE"], 0);
                item.CategoryDescription = Utilities.GetStringValue(r["CAT_DESC"], "");
                item.mItemOrder          = Utilities.GetIntegerValue(r["ICN_ITEM"]);
                item.CaccLevel           = Utilities.GetIntegerValue(r["CACC_LEV"], -1);

                item.Attributes = new List <ItemAttribute>();

                //Used to get the attributes of the item.
                //This will be helpful later, such as determining the type of metal for scraps.
                for (int iMask = 1; iMask <= 15; iMask++)
                {
                    ItemAttribute itemAttribute = new ItemAttribute();

                    if (Utilities.GetIntegerValue(r["MASK" + iMask.ToString()], 0) > 0)
                    {
                        itemAttribute.MaskOrder = iMask;

                        Answer answer = new Answer();
                        answer.AnswerCode = Utilities.GetIntegerValue(r["MASK" + iMask.ToString()], 0);
                        answer.AnswerText = Utilities.GetStringValue(r["MASK_DESC" + iMask.ToString()], "");

                        // Pull from Other Description List Table
                        if (tableDesc != null && answer.AnswerCode == 999)
                        {
                            string sOtherDscFilter = "STORENUMBER = '" + storeNumberFromRow + "'";
                            sOtherDscFilter += " and ICN_STORE = " + item.mStore.ToString();
                            sOtherDscFilter += " and ICN_YEAR = " + item.mYear.ToString();
                            sOtherDscFilter += " and ICN_DOC = '" + icndocFromRow + "' ";
                            sOtherDscFilter += " and ICN_DOC_TYPE = " + item.mDocType;
                            sOtherDscFilter += " and ICN_ITEM = " + item.mItemOrder;
                            sOtherDscFilter += " and ICN_SUB_ITEM = 0";
                            sOtherDscFilter += " and MASK_SEQ = " + iMask.ToString();

                            DataRow[] dataOtherDScRows = tableDesc.Select(sOtherDscFilter);
                            if (dataOtherDScRows.Length > 0)
                            {
                                answer.AnswerCode = 999;
                                answer.AnswerText = Utilities.GetStringValue(dataOtherDScRows[0]["OD_DESC"], "");
                            }
                            else
                            {
                                answer.AnswerCode = 0;
                                answer.AnswerText = "";
                            }
                        }
                        itemAttribute.Answer = answer;
                    }
                    if (itemAttribute.Answer.AnswerCode == 999 || itemAttribute.Answer.AnswerCode > 0)
                    {
                        item.Attributes.Add(itemAttribute);
                    }
                }

                //Set item attributes
                int iCategoryMask = dSession.CategoryXML.GetCategoryMask(item.CategoryCode);
                DescribedMerchandise dmPawnItem = new DescribedMerchandise(iCategoryMask);

                Item pawnItem = (Item)item;
                Item.PawnItemMerge(ref pawnItem, dmPawnItem.SelectedPawnItem, true);

                //Should copy the description, etc. over to the item.
                PropertyInfo[] fromFields = typeof(Item).GetProperties();
                PropertyInfo[] toFields   = //typeof(ScrapItem).GetProperties();
                                            item.GetType().GetProperties();
                PropertyHandler.SetProperties(fromFields, toFields, pawnItem, item);

                //Does not merge well.
                item.Quantity = Utilities.GetIntegerValue(r["QUANTITY"]);

                if (item is ScrapItem)
                {
                    //Wait to add scrap items until after merge.
                    ((ScrapItem)item).StoreNumber  = storeNumberFromRow;
                    ((ScrapItem)item).TicketNumber = icndocFromRow;
                }

                items.Add(item);
            }

            return(items);
        }
Exemplo n.º 3
0
        public static bool TransferToGunRoom(List <TransferItemVO> mdseToTransfer, out int transferNumber, string carrier, out string errorMessage, string gunFacilityName)
        {
            errorMessage   = "";
            transferNumber = 0;
            string errorCode = "";

            icn       = new List <string>();
            icnQty    = new List <string>();
            gunNumber = new List <string>();
            gunType   = new List <string>();
            if (mdseToTransfer.Count > 0)
            {
                foreach (TransferItemVO transfermdse in mdseToTransfer)
                {
                    storeNumber = transfermdse.StoreNumber;
                    icn.Add(transfermdse.ICN);
                    icnQty.Add(transfermdse.ICNQty);
                    custNumber = transfermdse.CustomerNumber;
                    tranDate   = transfermdse.TransactionDate;
                    mrDate     = transfermdse.MdseRecordDate;
                    mrTime     = transfermdse.MdseRecordTime;

                    mrUser    = transfermdse.MdseRecordUser;
                    mrDesc    = transfermdse.MdseRecordDesc;
                    mrChange  = transfermdse.MdseRecordChange;
                    mrType    = transfermdse.MdseRecordType;
                    classcode = transfermdse.ClassCode;
                    acctNum   = transfermdse.AcctNumber;
                    createdBy = transfermdse.CreatedBy;
                    gunNumber.Add(transfermdse.GunNumber);
                    gunType.Add(transfermdse.GunType);
                }

                if (icn.Count > 0)
                {
                    //Make the db call for transfer
                    GlobalDataAccessor.Instance.beginTransactionBlock();

                    /* storeNumber will be value from last item being transferred (set in foreach loop above),
                     * but all items should be coming FROM the same store.
                     */
                    if (TransfersDBProcedures.ExecuteTransferOutOfStore(storeNumber, icn, icnQty,
                                                                        custNumber, tranDate, mrDate, mrTime, mrUser, mrDesc,
                                                                        mrChange, mrType, classcode, acctNum, createdBy, gunNumber, gunType, 0, 0, 0, gunFacilityName, true, out transferNumber,
                                                                        carrier, out errorCode, out errorMessage))
                    {
                        GlobalDataAccessor.Instance.endTransactionBlock(EndTransactionType.COMMIT);
                        if (transferNumber > 0 && errorCode == "0")
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        FileLogger.Instance.logMessage(LogLevel.ERROR, null, errorMessage);
                        errorMessage = "Gun Transfer database call failed";
                        GlobalDataAccessor.Instance.endTransactionBlock(EndTransactionType.ROLLBACK);
                    }
                }
            }
            else
            {
                errorMessage = "No data passed for transferring";
            }

            return(false);
        }
Exemplo n.º 4
0
        public static bool TransferItemsOutOfStore(List <TransferItemVO> mdseToTransfer, out int transferNumber, string carrier, out string errorMessage, bool isClxToClx, string toShopName)
        {
            errorMessage   = "";
            transferNumber = 0;
            string errorCode = "";

            icn       = new List <string>();
            icnQty    = new List <string>();
            gunNumber = new List <string>();
            gunType   = new List <string>();
            if (mdseToTransfer.Count > 0)
            {
                foreach (TransferItemVO transfermdse in mdseToTransfer)
                {
                    storeNumber = transfermdse.StoreNumber;
                    icn.Add(transfermdse.ICN);
                    icnQty.Add(transfermdse.ICNQty);
                    custNumber = transfermdse.CustomerNumber;
                    tranDate   = transfermdse.TransactionDate;
                    mrDate     = transfermdse.MdseRecordDate;
                    mrTime     = transfermdse.MdseRecordTime;

                    mrUser    = transfermdse.MdseRecordUser;
                    mrDesc    = transfermdse.MdseRecordDesc;
                    mrChange  = transfermdse.MdseRecordChange;
                    mrType    = transfermdse.MdseRecordType;
                    classcode = transfermdse.ClassCode;
                    acctNum   = transfermdse.AcctNumber;
                    createdBy = transfermdse.CreatedBy;
                    gunNumber.Add(transfermdse.GunNumber);
                    gunType.Add(transfermdse.GunType);
                }

                if (icn.Count > 0)
                {
                    //Make the db call for transfer
                    GlobalDataAccessor.Instance.beginTransactionBlock();

                    /* storeNumber will be value from last item being transferred (set in foreach loop above),
                     * but all items should be coming FROM the same store.
                     */
                    if (TransfersDBProcedures.ExecuteTransferOutOfStore(storeNumber, icn, icnQty,
                                                                        custNumber, tranDate, mrDate, mrTime, mrUser, mrDesc,
                                                                        mrChange, mrType, classcode, acctNum, createdBy, gunNumber, gunType, 0, 0, 0, toShopName, isClxToClx, out transferNumber,
                                                                        carrier, out errorCode, out errorMessage))
                    {
                        GlobalDataAccessor.Instance.endTransactionBlock(EndTransactionType.COMMIT);
                        return(true);
                        //Web Service invocation will be done during shop close
                        //Make the web service call

                        /*TransferWebService transferwebService = new TransferWebService();
                         * storeNumber will be value from last item being transferred (set in foreach loop above),
                         * but all items should be coming FROM the same store.
                         * if (!isClxToClx)
                         * {
                         * if (transferwebService.CompleteShopAndGunTransferWS(storeNumber, transferNumber, Utilities.GetIntegerValue(toShopName)))
                         * {
                         * return true;
                         * }
                         * }
                         * else
                         * {
                         * FileLogger.Instance.logMessage(LogLevel.DEBUG, transferwebService, "Web Service call Aborted since transfer is Clx to Clx");
                         * return true;
                         * }
                         * FileLogger.Instance.logMessage(LogLevel.ERROR, transferwebService, transferwebService.ErrorMessage);
                         * errorMessage = "Transfer web service call failed";
                         * return false;*/
                    }
                    else
                    {
                        FileLogger.Instance.logMessage(LogLevel.ERROR, null, errorMessage);
                        errorMessage = "Transfer database call failed";
                        GlobalDataAccessor.Instance.endTransactionBlock(EndTransactionType.ROLLBACK);
                    }
                }
            }
            else
            {
                errorMessage = "No data passed for transferring";
            }

            return(false);
        }
Exemplo n.º 5
0
        public static bool TransferScrap(
            List <TransferItemVO> mdseToTransfer,
            int scrapTransferFacilityNumber,
            int excessTransferFacilityNumber,
            int refurbTransferFacilityNumber,
            string carrier,
            out int transferNumber,
            out string errorMessage)
        {
            errorMessage   = String.Empty;
            transferNumber = 0;
            string errorCode = String.Empty;

            icn       = new List <string>();
            icnQty    = new List <string>();
            gunNumber = new List <string>();
            gunType   = new List <string>();
            if (mdseToTransfer.Count > 0)
            {
                foreach (TransferItemVO transfermdse in mdseToTransfer)
                {
                    storeNumber = transfermdse.StoreNumber;
                    icn.Add(transfermdse.ICN);
                    icnQty.Add(transfermdse.ICNQty);
                    custNumber = transfermdse.CustomerNumber;
                    tranDate   = transfermdse.TransactionDate;
                    mrDate     = transfermdse.MdseRecordDate;
                    mrTime     = transfermdse.MdseRecordTime;
                    mrUser     = transfermdse.MdseRecordUser;
                    mrDesc     = transfermdse.MdseRecordDesc;
                    mrChange   = transfermdse.MdseRecordChange;
                    mrType     = transfermdse.MdseRecordType;
                    classcode  = transfermdse.ClassCode;
                    acctNum    = transfermdse.AcctNumber;
                    createdBy  = transfermdse.CreatedBy;
                    gunNumber.Add(transfermdse.GunNumber);
                    gunType.Add(transfermdse.GunType);
                }

                if (icn.Count > 0)
                {
                    //Make the db call for transfer

                    /* storeNumber will be value from last item being transferred (set in foreach loop above),
                     * but all items should be coming FROM the same store.
                     */
                    if (!(TransfersDBProcedures.ExecuteTransferOutOfStore(storeNumber, icn, icnQty,
                                                                          custNumber, tranDate, mrDate, mrTime, mrUser, mrDesc,
                                                                          mrChange, mrType, classcode, acctNum, createdBy, gunNumber, gunType, scrapTransferFacilityNumber, excessTransferFacilityNumber, refurbTransferFacilityNumber,
                                                                          null, true, out transferNumber, carrier, out errorCode, out errorMessage)))
                    {
                        FileLogger.Instance.logMessage(LogLevel.ERROR, null, "(Error " + errorCode + ") " + errorMessage);
                        errorMessage = "Transfer database call failed with error code " + errorCode;
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            else
            {
                errorMessage = "No data passed for transferring";
            }

            return(false);
        }