public RfqSelectForUpdate(MainWindow mainWindow, Guid requestId)
     : this()
 {
     this.mainWindow = mainWindow;
     this.requestId = requestId;
     async = new AsyncWork(mainWindow);
 }
        private async Task <IReadOnlyList <PropertyViewModel> > GetViewModelsAsync(IPropertyInfo property)
        {
            PropertyViewModel baseVm = CreateViewModel(property);
            var vms = new List <PropertyViewModel> {
                baseVm
            };

            if (baseVm.HasVariations)
            {
                using (await AsyncWork.RequestAsyncWork(this)) {
                    var variants = await GetVariationsAsync(property);

                    baseVm.HasVariantChildren = variants.Count > 0;
                    if (baseVm.HasVariantChildren)
                    {
                        foreach (PropertyVariation variant in variants)
                        {
                            vms.Add(CreateViewModel(property, variant));
                        }
                    }
                }
            }

            return(vms);
        }
Esempio n. 3
0
 public void AddAsyncWork(AsyncWork work)
 {
     lock (_asyncWorkQueue)
     {
         _asyncWorkQueue.Enqueue(work);
     }
 }
Esempio n. 4
0
        private async void SetType()
        {
            using (await AsyncWork.RequestAsyncWork(this)) {
                ITypeInfo selectedType = null;
                var       args         = new TypeRequestedEventArgs();
                TypeRequested?.Invoke(this, args);
                if (args.SelectedType == null)
                {
                    return;
                }

                try {
                    selectedType = await args.SelectedType;
                    if (selectedType == null)
                    {
                        return;
                    }
                } catch (OperationCanceledException) {
                    return;
                }

                await SetValueAsync(new ValueInfo <ITypeInfo> {
                    Value  = selectedType,
                    Source = ValueSource.Local
                });
            }
        }
Esempio n. 5
0
 public Reports(MainWindow mainWindow)
     : this()
 {
     // TODO: Complete member initialization
     this.mainWindow = mainWindow;
     async = new AsyncWork(mainWindow);
 }
 public CsProcessRequest(MainWindow mainWindow)
     : this()
 {
     // TODO: Complete member initialization
     this.mainWindow = mainWindow;
     async = new AsyncWork(mainWindow);
 }
 public ItemReceivingSelectRequest(MainWindow mainWindow)
     : this()
 {
     // TODO: Complete member initialization
     this.mainWindow = mainWindow;
     asyncMark = new AsyncWork(mainWindow); asyncLoad = new AsyncWork(mainWindow);
 }
 public ItemReceivingProcess(MainWindow mainWindow, Guid RequestId)
     : this()
 {
     this.mainWindow = mainWindow;
     this.RequestId = RequestId;
     asyncLoad = new AsyncWork(mainWindow);
 }
Esempio n. 9
0
        private async Task <IReadOnlyList <PropertyViewModel> > GetViewModelsAsync(IPropertyInfo property, IEnumerable <PropertyVariation> variantsToSkip = null)
        {
            PropertyViewModel        baseVm = GetViewModel(property);
            List <PropertyViewModel> vms    = new List <PropertyViewModel> ();

            vms.Add(baseVm);

            HashSet <PropertyVariation> skipped =
                (variantsToSkip != null) ? new HashSet <PropertyVariation> (variantsToSkip) : null;

            if (baseVm.HasVariations)
            {
                using (await AsyncWork.RequestAsyncWork(this)) {
                    var variants = await GetVariationsAsync(property);

                    for (int i = 0; i < variants.Length; i++)
                    {
                        foreach (PropertyVariation variant in variants[i])
                        {
                            if (skipped != null && skipped.Contains(variant))
                            {
                                continue;
                            }

                            vms.Add(GetViewModel(property, variant));
                        }
                    }
                }
            }

            return(vms);
        }
Esempio n. 10
0
 public DataManagement(MainWindow mainWindow, Type type)
     : this()
 {
     // TODO: Complete member initialization
     this.mainWindow = mainWindow;
     this.type = type;
     async = new AsyncWork(mainWindow); async2 = new AsyncWork(mainWindow); async3 = new AsyncWork(mainWindow);
 }
 public SelectCostObjective(MainWindow mainWindow, Items itemWindow)
     : this()
 {
     this.selectItemWindow = itemWindow;
     this.mainWindow = mainWindow;
     Scenario = CostObjectiveScenarios.SelectItem;
     async = new AsyncWork(mainWindow); async2 = new AsyncWork(mainWindow); async3 = new AsyncWork(mainWindow);
 }
Esempio n. 12
0
 public AddItem(MainWindow mainWindow)
     : this()
 {
     IsRequesting = false;
     stackQuantity.Visibility = Visibility.Hidden;
     this.mainWindow = mainWindow;
     background = new AsyncWork(mainWindow);
 }
Esempio n. 13
0
 public PoGenerateWindow(MainWindow mainWindow, Guid requestId)
     : this()
 {
     // TODO: Complete member initialization
     this.mainWindow = mainWindow;
     this.RequestId = requestId;
     asyncLoad = new AsyncWork(mainWindow); asyncLoadItems = new AsyncWork(mainWindow);
 }
Esempio n. 14
0
        protected override async Task UpdateCurrentValueAsync()
        {
            if (this.predefinedValues == null)
            {
                return;
            }

            using (await AsyncWork.RequestAsyncWork(this)) {
                await base.UpdateCurrentValueAsync();

                var newValues = new Dictionary <string, bool?> (this.predefinedValues.PredefinedValues.Count);

                ValueInfo <IReadOnlyList <TValue> >[] values = await Task.WhenAll(Editors.Select (ed => ed.GetValueAsync <IReadOnlyList <TValue> > (Property, Variation)).ToArray());

                foreach (ValueInfo <IReadOnlyList <TValue> > valueInfo in values)
                {
                    if (valueInfo.Value == null || valueInfo.Source == ValueSource.Unset)
                    {
                        foreach (var kvp in this.predefinedValues.PredefinedValues)
                        {
                            newValues[kvp.Key] = null;
                        }

                        continue;
                    }

                    foreach (var kvp in this.predefinedValues.PredefinedValues)
                    {
                        bool currentValue = valueInfo.Value.Contains(kvp.Value);
                        if (newValues.TryGetValue(kvp.Key, out bool?presentValue))
                        {
                            if (presentValue.HasValue && presentValue.Value != currentValue)
                            {
                                newValues[kvp.Key] = null;
                            }
                        }
                        else
                        {
                            newValues[kvp.Key] = currentValue;
                        }
                    }
                }

                this.fromUpdate = true;
                foreach (var vm in Choices)
                {
                    if (newValues.TryGetValue(vm.Name, out bool?value))
                    {
                        vm.IsFlagged = value;
                    }
                    else
                    {
                        vm.IsFlagged = false;
                    }
                }
                this.fromUpdate = false;
            }
        }
Esempio n. 15
0
 public ViewRequest(RequestModel model, MainWindow mainWindow)
     : this()
 {
     // TODO: Complete member initialization
     this.model = model;
     this.mainWindow = mainWindow;
     this.IsEnabled = false;
     async = new AsyncWork(mainWindow); async2 = new AsyncWork(mainWindow);
 }
Esempio n. 16
0
 public CsItemSelect(MainWindow mainWindow)
     : this()
 {
     // TODO: Complete member initialization
     this.mainWindow = mainWindow;
     asyncLoad = new AsyncWork(mainWindow);
     processDialog = new CsProcessRequest(mainWindow);
     processDialog.items = new List<CanvasItemModel>();
 }
Esempio n. 17
0
 public CsSelectVendor(MainWindow mainWindow, List<CanvasItemModel> items, Guid RequestId, int vendorNumber, CsProcessRequest csProcessRequest)
     : this()
 {
     // TODO: Complete member initialization
     this.mainWindow = mainWindow;
     this.items = items;
     this.RequestId = RequestId;
     this.vendorNumber = vendorNumber;
     this.csProcessRequestDialog = csProcessRequest;
     async = new AsyncWork(mainWindow);
 }
Esempio n. 18
0
        private async void CreateInstance()
        {
            IsCreateInstancePending = true;

            try {
                using (await AsyncWork.RequestAsyncWork(this)) {
                    ITypeInfo selectedType = null;

                    var types = await AssignableTypes.Task;
                    // If there's only one assignable type, we'll skip selection
                    if (types.Count == 1)
                    {
                        var kvp = types.First();
                        if (kvp.Value.Count == 1)
                        {
                            var group = kvp.Value.First();
                            if (!group.Skip(1).Any())
                            {
                                selectedType = group.First();
                            }
                        }
                    }

                    if (selectedType == null)
                    {
                        var args = new TypeRequestedEventArgs();
                        TypeRequested?.Invoke(this, args);
                        if (args.SelectedType == null)
                        {
                            return;
                        }

                        try {
                            selectedType = await args.SelectedType;
                            if (selectedType == null)
                            {
                                return;
                            }
                        } catch (OperationCanceledException) {
                            return;
                        }
                    }

                    await SetValueAsync(new ValueInfo <object> {
                        Value           = await TargetPlatform.EditorProvider.CreateObjectAsync(selectedType),
                        ValueDescriptor = selectedType,
                        Source          = ValueSource.Local
                    });
                }
            } finally {
                IsCreateInstancePending = false;
            }
        }
Esempio n. 19
0
 public Register(MainWindow mainWindow)
     : this()
 {
     this.mainWindow = mainWindow;
     background = new AsyncWork(mainWindow);
     background2 = new AsyncWork(mainWindow);
     background3 = new AsyncWork(mainWindow);
     asyncUserCheck = new AsyncWork(mainWindow);
     CurrentUser = App.Current.Properties["User"] as UserModel;
     if (CurrentUser == null) {
         stackUserType.Visibility = Visibility.Collapsed;
     }
 }
        protected override async Task UpdateCurrentValueAsync()
        {
            if (Event == null)
            {
                return;
            }
            if (Editors.Count == 0)
            {
                SetCurrentMethods(null);
                return;
            }

            using (await AsyncWork.RequestAsyncWork(this)) {
                // Right now we only show events if one item is selected, but there's no technical reason
                // we can't attach the same event to the same handler across multiple objects, so the ground
                // work is done.
                IReadOnlyList <string>[] methodLists = await Task.WhenAll(Editors.OfType <IObjectEventEditor>().Select(ed => ed.GetHandlersAsync(Event)));

                bool disagree = false;
                IReadOnlyList <string> methods = methodLists[0];
                for (int i = 1; i < methodLists.Length; i++)
                {
                    IReadOnlyList <string> methodList = methodLists[i];
                    if (methodList.Count != methods.Count)
                    {
                        disagree = true;
                        break;
                    }

                    for (int x = 0; x < methodList.Count; i++)
                    {
                        if (methodList[x] != methods[x])
                        {
                            disagree = true;
                            break;
                        }
                    }

                    if (disagree)
                    {
                        break;
                    }
                }

                MultipleValues = disagree;
                SetCurrentMethods((!disagree) ? methods : null);
            }
        }
        private async void UpdateMaxMin()
        {
            bool isDefault = true;
            T    max = default(T), min = default(T);

            if (this.selfConstraint != null)
            {
                isDefault = false;
                max       = this.selfConstraint.MaxValue;
                min       = this.selfConstraint.MinValue;
            }

            if (this.clampProperties != null && Editors.Count > 0)
            {
                bool doMax = this.clampProperties.MaximumProperty != null;
                bool doMin = this.clampProperties.MinimumProperty != null;

                using (await AsyncWork.RequestAsyncWork(this)) {
                    // TODO: max/min property get error case
                    foreach (IObjectEditor editor in Editors)
                    {
                        if (doMax)
                        {
                            ValueInfo <T> maxinfo = await editor.GetValueAsync <T> (this.clampProperties.MaximumProperty);

                            max = (isDefault) ? maxinfo.Value : Min(max, maxinfo.Value);
                        }

                        if (doMin)
                        {
                            ValueInfo <T> mininfo = await editor.GetValueAsync <T> (this.clampProperties.MinimumProperty);

                            min = (isDefault) ? mininfo.Value : Max(min, mininfo.Value);
                        }
                    }
                }
            }

            MaximumValue = max;
            MinimumValue = min;
        }
Esempio n. 22
0
        private async void OnVariationsChanged(object sender, EventArgs e)
        {
            using (await AsyncWork.RequestAsyncWork(this)) {
                PropertyViewModel pvm = (PropertyViewModel)sender;
                var variations        = (await GetVariationsAsync(pvm.Property)).SelectMany(vs => vs).Distinct();
                var properties        = this.editors
                                        .OfType <PropertyViewModel> ()
                                        .Where(evm => Equals(evm.Property, pvm.Property) && evm.Variation != null)
                                        .ToDictionary(evm => evm.Variation);

                List <PropertyViewModel> toAdd = new List <PropertyViewModel> ();
                foreach (PropertyVariation variation in variations)
                {
                    if (!properties.Remove(variation))
                    {
                        toAdd.Add(GetViewModel(pvm.Property, variation));
                    }
                }

                if (properties.Count > 0)
                {
                    var toRemove = new List <PropertyViewModel> ();
                    foreach (var kvp in properties)
                    {
                        toRemove.Add(kvp.Value);
                    }

                    RemoveProperties(toRemove);
                }

                if (toAdd.Count > 0)
                {
                    AddProperties(toAdd);
                }
            }
        }
Esempio n. 23
0
        protected override async Task UpdateCurrentValueAsync()
        {
            if (ValueModel == null)
            {
                return;
            }

            using (await AsyncWork.RequestAsyncWork(this)) {
                await base.UpdateCurrentValueAsync();

                ValueType = CurrentValue?.ValueDescriptor as ITypeInfo;

                if (CurrentValue?.Value != null)
                {
                    ValueModel.SelectedObjects.Reset(new[] { CurrentValue.Value });
                }
                else
                {
                    ValueModel.SelectedObjects.Clear();
                }

                SetCanDelve(ValueModel.SelectedObjects.Count > 0);
            }
        }
Esempio n. 24
0
 public CsApprove(MainWindow mainWindow)
     : this()
 {
     this.mainWindow = mainWindow;
     async = new AsyncWork(mainWindow); async2 = new AsyncWork(mainWindow); async3 = new AsyncWork(mainWindow);
 }
Esempio n. 25
0
 public void Run()
 {
     Task = AsyncWork?.Invoke();
     Callback?.Invoke(CallbackState);
 }
Esempio n. 26
0
 public Login(MainWindow mainWindow)
     : this()
 {
     this.mainWindow = mainWindow;
     async = new AsyncWork(mainWindow);
 }
Esempio n. 27
0
 public AddVendor(MainWindow mainWindow)
     : this()
 {
     this.mainWindow = mainWindow;
     async = new AsyncWork(mainWindow);
 }
Esempio n. 28
0
        /// <summary>
        /// Executes the test and marks the test as pass/fail
        /// </summary>
        internal void RealRun()
        {
            if (_errorCase == ErrorCase.NullBegin || _errorCase == ErrorCase.NullEnd)
            {
                try
                {
                    //In case of error conditions we except the method to throw exception
                    RunAPMTest();

                    Assert.True(false, string.Format("Failed to catch ArgumentNullException"));
                }
                catch (ArgumentNullException)
                {
                    Debug.WriteLine("Caught ArgumentNullException as expected");
                }
            }
            else if (_errorCase == ErrorCase.Throwing)
            {
                //This should throw an exception
                RunAPMTest();

                //block until the expcetion is thrown
                ((IAsyncResult)_task).AsyncWaitHandle.WaitOne();  // avoid Wait() as we are using Exception property directly

                AggregateException exp = _task.Exception;

                if (exp != null &&
                    exp.InnerExceptions.Count == 1 &&
                    exp.InnerExceptions[0] is TPLTestException)
                {
                    Debug.WriteLine("Caught AggregateException as expected");
                }
                else
                {
                    Assert.True(false, string.Format("Failed to catch AggregateException"));
                }
            }
            else
            {
                AsyncWork work = RunAPMTest();

                _task.Wait(); //block for the task to run to completion.

                if (_sourceType == TaskType.Task)
                {
                    SequenceEquals(_expectedInputs, work.Inputs);
                }
                else
                {
                    SequenceEquals(_expectedInputs, ((Task <ReadOnlyCollection <object> >)_task).Result);
                }

                //verify Overload / State

                TaskCreationOptions expectedOption = TaskCreationOptions.None;
                if (_overloadChoice == OverloadChoice.WithTaskOption)
                {
                    expectedOption = TestOption;
                }

                if (_task.CreationOptions != expectedOption)
                {
                    Assert.True(false, string.Format("task is not created with expected TestOption"));
                }

                if (((TaskOptionAndScheduler)(work.ObservedState)).Option != expectedOption)
                {
                    Assert.True(false, string.Format("state verification failed on Option"));
                }

                TaskScheduler expectedScheduler = TaskScheduler.Default;

                if (work.ObservedTaskScheduler != expectedScheduler)
                {
                    Assert.True(false, string.Format("task is not running under expected TestOption"));
                }

                if (((TaskOptionAndScheduler)(work.ObservedState)).Scheduler != expectedScheduler)
                {
                    Assert.True(false, string.Format("state verification failed on Scheduler"));
                }
            }
        }
 public PurchaseRequestScreen(MainWindow mainWindow)
     : this()
 {
     this.mainWindow = mainWindow;
     submitRequest = new AsyncWork(mainWindow);
 }
        private async void OnVariantsChanged(object sender, EventArgs e)
        {
            IPropertyInfo property = sender as IPropertyInfo;

            if (property == null)
            {
                property = ((PropertyViewModel)sender).Property;
            }

            using (await AsyncWork.RequestAsyncWork(this)) {
                var variationsTask = GetVariationsAsync(property);

                PropertyViewModel baseVm = null;
                var properties           = new Dictionary <PropertyVariation, PropertyViewModel> ();
                foreach (PropertyViewModel pvm in this.editors.OfType <PropertyViewModel> ())
                {
                    if (!Equals(property, pvm.Property))
                    {
                        continue;
                    }

                    if (pvm.Variation == null)
                    {
                        baseVm = pvm;
                    }
                    else
                    {
                        properties.Add(pvm.Variation, pvm);
                    }
                }

                if (baseVm == null)
                {
                    throw new InvalidOperationException("Base property view model couldn't be found");
                }

                var variations = await variationsTask;
                baseVm.HasVariantChildren = variations.Count > 0;

                List <PropertyViewModel> toAdd = new List <PropertyViewModel> ();
                foreach (PropertyVariation variation in variations)
                {
                    if (!properties.Remove(variation))
                    {
                        toAdd.Add(CreateViewModel(property, variation));
                    }
                }

                if (properties.Count > 0)
                {
                    var toRemove = new List <PropertyViewModel> ();
                    foreach (var kvp in properties)
                    {
                        toRemove.Add(kvp.Value);
                    }

                    RemoveProperties(toRemove);
                }

                if (toAdd.Count > 0)
                {
                    AddProperties(toAdd);
                }
            }
        }
 public RfqProcessRequest(MainWindow mainWindow)
     : this()
 {
     this.mainWindow = mainWindow;
     asyncOnSave = new AsyncWork(mainWindow); asyncOnLoad = new AsyncWork(mainWindow); asyncOnSearch = new AsyncWork(mainWindow);
 }
Esempio n. 32
0
        public AddItem(MainWindow mainWindow, EditRequisition editRequisition)
            : this()
        {
            // TODO: Complete member initialization
            this.mainWindow = mainWindow;
            this.editRequisition = editRequisition;

            background = new AsyncWork(mainWindow);
        }
Esempio n. 33
0
        public AddItem(MainWindow mainWindow, PurchaseRequestScreen purchaseRequestScreen)
            : this()
        {
            this.mainWindow = mainWindow;
            this.requestScreen = purchaseRequestScreen;

            background = new AsyncWork(mainWindow);
        }
Esempio n. 34
0
 public AllRequests(MainWindow mainWindow)
     : this()
 {
     this.mainWindow = mainWindow;
     asyncLoad = new AsyncWork(mainWindow);
 }
Esempio n. 35
0
        private async Task PushValuesAsync(FlaggableChoiceViewModel <TValue> changedChoice)
        {
            SetError(null);

            using (await AsyncWork.RequestAsyncWork(this)) {
                try {
                    // Snapshot current choices so we don't catch updates mid-push for multi-editors
                    var currentChoices = Choices.ToDictionary(c => c, c => c.IsFlagged);

                    foreach (IObjectEditor editor in Editors)
                    {
                        ValueInfo <IReadOnlyList <TValue> > value = await editor.GetValueAsync <IReadOnlyList <TValue> > (Property, Variation);

                        HashSet <TValue> current;
                        if (value.Value == null || value.Source == ValueSource.Unset)
                        {
                            current = new HashSet <TValue> ();
                        }
                        else
                        {
                            current = new HashSet <TValue> (value.Value);
                        }

                        foreach (var choice in currentChoices)
                        {
                            if (!choice.Value.HasValue)
                            {
                                continue;
                            }

                            if (choice.Value.Value)
                            {
                                current.Add(choice.Key.Value);
                            }
                            else
                            {
                                current.Remove(choice.Key.Value);
                            }
                        }

                        IReadOnlyList <TValue> values = current.ToArray();
                        if (this.validator != null)
                        {
                            if (!this.validator.IsValid(values))
                            {
                                // Some combinables simply don't have a valid "none", but if we're going from indeterminate we still need to
                                // update the value, so we'll flip the changed value to true in that case so we don't go right back to indeterminate
                                if (values.Count == 0)
                                {
                                    changedChoice.IsFlagged = true;
                                    // We're explicitly triggering a change and need the update here so we need to update our snapshot.
                                    currentChoices = Choices.ToDictionary(c => c, c => c.IsFlagged);
                                }

                                continue;
                            }
                        }

                        if (this.coerce != null)
                        {
                            values = this.coerce.CoerceValue(values);
                        }

                        await editor.SetValueAsync(Property, new ValueInfo <IReadOnlyList <TValue> > {
                            Source = ValueSource.Local,
                            Value  = values
                        });
                    }
                } catch (Exception ex) {
                    if (ex is AggregateException aggregate)
                    {
                        aggregate = aggregate.Flatten();
                        ex        = aggregate.InnerExceptions[0];
                    }

                    SetError(ex.ToString());
                }
            }
        }