Ejemplo n.º 1
0
        /// <summary>
        /// delete event when the time to check arrives. Delete all the elements that their expiration date isn't valid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeletionEventHandler(object parameter)
        {
            Task.WaitAll(Task.Run(HoldForLock));

            while (_listByTime.Start != null && DateTime.Now > _listByTime.Start._data._lastPurchaseDate.
                   AddDays(_configurationParameters.LifeTime))
            {
                _listByTime.RemoveFirst(out TimeData dataToDel);                     //delete from the link list (of times)
                BoxCategory currentBox = new BoxCategory(new Y_Data(dataToDel.Height), dataToDel.Base);
                _comunicate.ExpirationDateMessage(dataToDel.Base, dataToDel.Height); //  exact position of the real yData
                Delete(currentBox, false);                                           //delete element
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// when match is confirmed, display massages to the user acording to the quantity that left (alert if below the const alert
 /// parameter or delete if the quantity reaches to 0)
 /// </summary>
 /// <param name="currentQuantity">quantity left</param>
 /// <param name="x">base</param>
 /// <param name="y">height</param>
 /// <returns>systems operations acording to the quantity left</returns>
 private void SuccessfulReduceOperation(BoxCategory boxCategory)
 {
     if (boxCategory.YData.Quantity == 0)
     {
         _comunicate.RunOutMassage(boxCategory.Base, boxCategory.YData.Height);
         Delete(boxCategory, true);
     }
     else
     {
         if (boxCategory.YData.Quantity < _configurationParameters.AlertQuantity) //it's sure that it's not 0
         {
             _comunicate.Alert(boxCategory.Base, boxCategory.YData.Height, boxCategory.YData.Quantity);
         }
         UpdateDate(boxCategory.YData);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Delete an item from the system
        /// </summary>
        /// <param name="boxCategory">the category to delete</param>
        /// <param name="delByQuantity">An indicator that determine if the deletion was by expiration date or by 0 quantity</param>
        private void Delete(BoxCategory boxCategory, bool delByQuantity)
        {
            X_Data xToDel = new X_Data(boxCategory.Base);
            X_Data requestedBase;

            _baseTree.Search(xToDel, out requestedBase); // must be true & initialize requestedBase
            if (delByQuantity)
            {
                _listByTime.DeleteByNode(boxCategory.YData.timeRef); //remove the reference first
            }
            requestedBase.HTree.Remove(boxCategory.YData);           // delete y (the remove is by value)
            if (!requestedBase.HTree.IsrootExist())
            {
                _baseTree.Remove(requestedBase); //delete x element as well (empty yTree)
                if (IsStoreEmpty())
                {
                    _comunicate.EmptyStoreMessage();                 // in a case of an empty xTree
                }
            }
        }