Esempio n. 1
0
        protected void OnRadioChanged(MouseEventArgs e)
        {
            if (IsDisabled)
            {
                return;
            }
            if (RadioGroup != null)
            {
                _ = RadioGroup.TrySetValueAsync(Value, !SelectedValueChanged.HasDelegate);
                return;
            }
            var newStatus = Status == RadioStatus.Selected ? RadioStatus.UnSelected : RadioStatus.Selected;

            if (StatusChanging.HasDelegate)
            {
                var arg = new BChangeEventArgs <RadioStatus>();
                arg.OldValue = Status;
                arg.NewValue = newStatus;
                StatusChanging.InvokeAsync(arg).Wait();
                if (arg.DisallowChange)
                {
                    return;
                }
            }


            if (newStatus == RadioStatus.Selected && !TypeHelper.Equal(SelectedValue, Value))
            {
                SelectedValue = Value;
            }

            if (RadioGroup == null)
            {
                SetFieldValue(SelectedValue, true);
                if (FormItem != null)
                {
                    FormItem.MarkAsRequireRender();
                    FormItem.Refresh();
                }
            }
            if (StatusChanged.HasDelegate)
            {
                _ = StatusChanged.InvokeAsync(newStatus);
            }
            if (SelectedValueChanged.HasDelegate)
            {
                _ = SelectedValueChanged.InvokeAsync(SelectedValue);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Saves a single <see cref="IOrder"/>
        /// </summary>
        /// <param name="order">The <see cref="IOrder"/> to save</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IOrder order, bool raiseEvents = true)
        {
            if (!((Order)order).HasIdentity && order.OrderNumber <= 0)
            {
                // We have to generate a new 'unique' order number off the configurable value
                ((Order)order).OrderNumber = _storeSettingService.GetNextOrderNumber();
            }

            var includesStatusChange = ((Order)order).IsPropertyDirty("OrderStatus") &&
                                       ((Order)order).HasIdentity;

            if (raiseEvents)
            {
                if (Saving.IsRaisedEventCancelled(new SaveEventArgs <IOrder>(order), this))
                {
                    ((Order)order).WasCancelled = true;
                    return;
                }

                if (includesStatusChange)
                {
                    StatusChanging.RaiseEvent(new StatusChangeEventArgs <IOrder>(order), this);
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateOrderRepository(uow))
                {
                    repository.AddOrUpdate(order);
                    uow.Commit();
                }
            }

            if (!raiseEvents)
            {
                return;
            }

            Saved.RaiseEvent(new SaveEventArgs <IOrder>(order), this);
            if (includesStatusChange)
            {
                StatusChanged.RaiseEvent(new StatusChangeEventArgs <IOrder>(order), this);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Saves a single <see cref="IInvoice"/>
        /// </summary>
        /// <param name="invoice">The <see cref="IInvoice"/> to save</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IInvoice invoice, bool raiseEvents = true)
        {
            if (!((Invoice)invoice).HasIdentity && invoice.InvoiceNumber <= 0)
            {
                // We have to generate a new 'unique' invoice number off the configurable value
                ((Invoice)invoice).InvoiceNumber = _storeSettingService.GetNextInvoiceNumber();
            }

            var includesStatusChange = ((Invoice)invoice).IsPropertyDirty("InvoiceStatusKey") &&
                                       ((Invoice)invoice).HasIdentity == false;

            if (raiseEvents)
            {
                if (Saving.IsRaisedEventCancelled(new SaveEventArgs <IInvoice>(invoice), this))
                {
                    ((Invoice)invoice).WasCancelled = true;
                    return;
                }

                if (includesStatusChange)
                {
                    StatusChanging.RaiseEvent(new StatusChangeEventArgs <IInvoice>(invoice), this);
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateInvoiceRepository(uow))
                {
                    repository.AddOrUpdate(invoice);
                    uow.Commit();
                }
            }

            if (!raiseEvents)
            {
                return;
            }

            Saved.RaiseEvent(new SaveEventArgs <IInvoice>(invoice), this);
            if (includesStatusChange)
            {
                StatusChanged.RaiseEvent(new StatusChangeEventArgs <IInvoice>(invoice), this);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Saves a collection of <see cref="IShipment"/> objects
        /// </summary>
        /// <param name="shipmentList">Collection of <see cref="IShipment"/> to save</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IEnumerable <IShipment> shipmentList, bool raiseEvents = true)
        {
            var shipmentsArray = shipmentList as IShipment[] ?? shipmentList.ToArray();

            var newShipmentCount = shipmentsArray.Count(x => x.ShipmentNumber <= 0 && !((Shipment)x).HasIdentity);


            if (newShipmentCount > 0)
            {
                var lastShipmentumber =
                    _storeSettingService.GetNextShipmentNumber(newShipmentCount);
                foreach (var newShipment in shipmentsArray.Where(x => x.ShipmentNumber <= 0 && !((Shipment)x).HasIdentity))
                {
                    ((Shipment)newShipment).ShipmentNumber = lastShipmentumber;
                    lastShipmentumber = lastShipmentumber - 1;
                }
            }

            var existingShipmentsWithStatusChanges =
                shipmentsArray.Where(
                    x => ((Shipment)x).HasIdentity && ((Shipment)x).IsPropertyDirty("ShipmentStatus"))
                .ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <IShipment>(shipmentsArray), this);
                if (existingShipmentsWithStatusChanges.Any())
                {
                    StatusChanging.RaiseEvent(
                        new StatusChangeEventArgs <IShipment>(existingShipmentsWithStatusChanges),
                        this);
                }
            }

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <IShipment>(shipmentsArray), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateShipmentRepository(uow))
                {
                    foreach (var shipment in shipmentsArray)
                    {
                        repository.AddOrUpdate(shipment);
                    }
                    uow.Commit();
                }
            }

            if (!raiseEvents)
            {
                return;
            }
            Saved.RaiseEvent(new SaveEventArgs <IShipment>(shipmentsArray), this);
            if (existingShipmentsWithStatusChanges.Any())
            {
                StatusChanged.RaiseEvent(new StatusChangeEventArgs <IShipment>(existingShipmentsWithStatusChanges), this);
            }
        }
Esempio n. 5
0
 public void OnStateChanging(object sender, PortStatus newStatus)
 {
     StatusChanging?.Invoke(sender, newStatus);
 }
Esempio n. 6
0
 private void OnStatusChanging(SkypeStatus currentStatus, SkypeStatus newStatus)
 {
     _context.InvokeThreadSafe(() => StatusChanging.Raise(this, currentStatus, newStatus));
 }