Exemple #1
0
        /// <summary>
        /// Gets the list of files in the directory Name passed.
        /// </summary>
        /// <returns>Returns the List of File info for this directory.
        /// Return null if an exception is raised.</returns>
        public FullyObservableCollection <ProjectItem> BuildChildren()
        {
            FullyObservableCollection <ProjectItem> projectItems = new FullyObservableCollection <ProjectItem>();

            try
            {
                IEnumerable <DirectoryInfo> subdirectories = Directory.GetDirectories(this.FullPath).Select(subdirectory => new DirectoryInfo(subdirectory));

                foreach (DirectoryInfo subdirectory in subdirectories)
                {
                    try
                    {
                        projectItems.Add(DirectoryItem.FromDirectory(subdirectory.FullName));
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogLevel.Error, "Error loading directory", ex);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, "Error fetching directories", ex);
            }

            try
            {
                foreach (FileInfo file in Directory.GetFiles(this.FullPath).Select(directoryFile => new FileInfo(directoryFile)))
                {
                    try
                    {
                        ProjectItem projectItem = ProjectItem.FromFile(file.FullName, this);

                        if (projectItem != null)
                        {
                            projectItems.Add(projectItem);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogLevel.Error, "Error reading project item", ex);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, "Error fetching files", ex);
            }

            return(projectItems);
        }
        public static FullyObservableCollection <MaintenanceModel> LoadFilteredColl(Func <FullyObservableCollection <MaintenanceModel> > fxn)
        {
            FullyObservableCollection <MaintenanceModel> temp = fxn();
            FullyObservableCollection <MaintenanceModel> mmm  = new FullyObservableCollection <MaintenanceModel>();
            MaintenanceModel m;
            int accessid = 0;

            foreach (MaintenanceModel mm in temp)
            {
                accessid = StaticCollections.GetUserCustomerAccess(mm.CustomerID);
                if (accessid == (int)UserPermissionsType.FullAccess)
                {
                    m = new MaintenanceModel
                    {
                        ID                = mm.ID,
                        ProjectID         = mm.ProjectID,
                        ProjectName       = mm.ProjectName,
                        IsChecked         = false,
                        Email             = mm.Email,
                        UserName          = mm.UserName,
                        ActionDate        = mm.ActionDate,
                        MaintenanceTypeID = mm.MaintenanceTypeID,
                        Enabled           = true
                    };
                    mmm.Add(m);
                }
            }
            return(mmm);
        }
Exemple #3
0
        public UsersViewModel()
        {
            GetCountryList();
            _countries = CountryList;
            _countries.Add(new Models.CountryModel()
            {
                GOM = new Models.GenericObjModel()
            });
            _salesdivisions = GetSalesDivisionsMasterList();

            SaveAndClose = new RelayCommand(ExecuteSaveAndClose, CanExecuteSave);
            Cancel       = new RelayCommand(ExecuteCancel, CanExecute);
            AddNew       = new RelayCommand(ExecuteAddNew, CanExecuteAddNew);

            _associate = new Models.UserModel();
            if (_countries.Count > 0)
            {
                SelectedCountry = _countries[0];
            }

            if (Associates.Count > 0)
            {
                ScrollToSelectedItem = 0;
            }
        }
        /// <summary>
        /// Add new Customer Node to treeview
        /// </summary>
        /// <param name="customer">CustomerModel</param>
        public static void AddCustomerNode(TVCustomerModel customer)
        {
            Window owner = Application.Current.Windows[0];
            FullyObservableCollection <TVCustomerViewModel> customers = (owner.DataContext as AssetTreeExViewModel).allcustomers;

            customers.Add(new TVCustomerViewModel(customer));
        }
Exemple #5
0
        private void FilterSalesRegions(int countryid)
        {
            if (SalesRegions != null)
            {
                SalesRegions.ItemPropertyChanged -= SalesRegions_ItemPropertyChanged;
            }
            FullyObservableCollection <SalesRegionModel> tempsalesregions = GetCountrySalesRegions(countryid);
            FullyObservableCollection <SalesRegionModel> newsalesregions  = new FullyObservableCollection <SalesRegionModel>();

            foreach (SalesRegionModel sd in tempsalesregions)
            {
                SalesRegionModel sm = new SalesRegionModel
                {
                    ID        = sd.ID,
                    CountryID = sd.CountryID,
                    Name      = sd.Name,
                    IsChecked = false,
                    IsEnabled = sd.IsEnabled
                };
                newsalesregions.Add(sm);
            }
            SalesRegions = newsalesregions;
            SalesRegions.ItemPropertyChanged += SalesRegions_ItemPropertyChanged;
            canexecutesave = false;
        }
        public void ItemAdded()
        {
            var list = new FullyObservableCollection <INotifyPropertyChanged>();
            var item = Substitute.For <INotifyPropertyChanged>();

            list.Add(item);
            Assert.That(list, Has.Member(item));
        }
Exemple #7
0
        public ToGoClientEditViewModel(OrderCustomer client, bool isNew = false)
        {
            EditablePhones    = new FullyObservableCollection <OrderCustomerPhone>();
            EditableAddresses = new FullyObservableCollection <OrderCustomerAddress>();

            if (!isNew)
            {
                if (client != null)
                {
                    Client            = (OrderCustomer)client.Clone();
                    OriginalPhones    = DataCatalogsSingleton.Instance.OrderCustomerPhoneData.Data.Where(a => a.OrderCustomerId == Client.Id).ToList();
                    OriginalAddresses = DataCatalogsSingleton.Instance.OrderCustomerAddressData.Data.Where(a => a.OrderCustomerId == Client.Id).ToList();

                    foreach (var ph in OriginalPhones)
                    {
                        EditablePhones.Add((OrderCustomerPhone)ph.Clone());
                    }
                    foreach (var ph in OriginalAddresses)
                    {
                        EditableAddresses.Add((OrderCustomerAddress)ph.Clone());
                    }
                }
            }
            else
            {
                Client = new OrderCustomer()
                {
                    IsActive = true
                };
                OriginalPhones = new List <OrderCustomerPhone>();
                EditablePhones.Add(new OrderCustomerPhone()
                {
                    IsPrimary = true, IsActive = true
                });
                OriginalAddresses = new List <OrderCustomerAddress>();
                EditableAddresses.Add(new OrderCustomerAddress()
                {
                    IsPrimary = true, IsActive = true
                });
            }
            EditablePhones.ItemPropertyChanged    += EditablePhones_ItemPropertyChanged;
            EditableAddresses.ItemPropertyChanged += EditablePhones_ItemPropertyChanged;
        }
 /// <summary>
 /// Populate main Customer VM collection
 /// TBD...needs to be re-populated when new customers added
 ///
 /// </summary>
 public void GetAllCustomerVMs()
 {
     customers = GetTVCustomers();
     allcustomers.Clear();
     foreach (TVCustomerModel cm in customers)
     {
         //add customer to tree
         allcustomers.Add(new TVCustomerViewModel(cm));
     }
 }
 public AttackSetViewModel(Model.AttackSet attackSet = null)
 {
     _attackViewModels = new FullyObservableCollection <AttackViewModel>();
     if (attackSet != null)
     {
         foreach (Model.Attack attack in attackSet.Attacks)
         {
             _attackViewModels.Add(new AttackViewModel(attack));
         }
     }
 }
Exemple #10
0
        public AddToGoOrderModel()
        {
            Order    = new OrderToGo();
            NewOrder = true;
            Order    = new OrderToGo()
            {
                CreatedBy   = Authorization.CurentUser,
                OrderStatus = OrderStatus.InWork,
            };
            OrderDishez = new FullyObservableCollection <DishPackageToGoOrder>();
            EventsInit();
            //Хлеб и приборы в новый заказ
            OrderDishez.Add(new DishPackageToGoOrder()
            {
                Amount          = 1,
                Code            = 2244,
                Dish            = DataCatalogsSingleton.Instance.Dishes.FirstOrDefault(a => a.Barcode == 2244),
                DishName        = DataCatalogsSingleton.Instance.Dishes.FirstOrDefault(a => a.Barcode == 2244)?.Name,
                DishId          = DataCatalogsSingleton.Instance.Dishes.FirstOrDefault(a => a.Barcode == 2244)?.Id ?? 0,
                PositionInOrder = 1,
                TotalPrice      = 0,
                Printed         = false
            });
            OrderDishez.Add(new DishPackageToGoOrder()
            {
                Amount          = 1,
                Code            = 2245,
                Dish            = DataCatalogsSingleton.Instance.Dishes.FirstOrDefault(a => a.Barcode == 2245),
                DishName        = DataCatalogsSingleton.Instance.Dishes.FirstOrDefault(a => a.Barcode == 2245)?.Name,
                DishId          = DataCatalogsSingleton.Instance.Dishes.FirstOrDefault(a => a.Barcode == 2245)?.Id ?? 0,
                PositionInOrder = 2,
                TotalPrice      = 0,
                Printed         = false
            });

            Order.DeliveryDate = DateTime.Now;
            Order.ExportTime   = DateTime.Now;
            Order.CreationDate = DateTime.Now;
            Order.ReadyTime    = DateTime.Now;
        }
 private void RefreshOutdata()
 {
     if (sourceData == null)
     {
         return;
     }
     if (outData == null)
     {
         return;
     }
     outData.Clear();
     foreach (var itm in sourceData)
     {
         if (selector(itm))
         {
             if (newFunc != null)
             {
                 outData.Add(newFunc(itm));
             }
             else
             {
                 if (transformer == null)
                 {
                     outData.Add(itm as TOut);
                 }
                 else
                 {
                     var item = new TOut();
                     transformer(itm, item);
                     outData.Add(item);
                 }
             }
         }
     }
     if (orderKeySelector != null && outData != null)
     {
         outData.Sort(orderKeySelector);
     }
 }
        private void GetCountries()
        {
            FullyObservableCollection <CountryModel> tempcountries = new FullyObservableCollection <CountryModel>();

            foreach (CountryModel cm in StaticCollections.Countries)
            {
                if (!cm.GOM.Deleted)
                {
                    tempcountries.Add(cm);
                }
            }
            Countries = tempcountries;
        }
        private FullyObservableCollection <AssetTypeModel> FilterAssetTypes(int _assetgroupid)
        {
            FullyObservableCollection <AssetTypeModel> _temp = new FullyObservableCollection <AssetTypeModel>();

            foreach (Models.AssetTypeModel atm in _assettypes)
            {
                if (atm.AssetGroupID == _assetgroupid)
                {
                    _temp.Add(atm);
                }
            }
            return(_temp);
        }
        private FullyObservableCollection <AssetGroupModel> FilterAssetGroups(int _assetprefixid)
        {
            FullyObservableCollection <Models.AssetGroupModel> _temp = new FullyObservableCollection <Models.AssetGroupModel>();

            foreach (Models.AssetGroupModel agm in _assetgroups)
            {
                if (agm.AssetAreaID == _assetprefixid)
                {
                    _temp.Add(agm);
                }
            }
            return(_temp);
        }
        private void filterAssociateAccess(int _opcoid)
        {
            FilteredAccessPermissions.Clear();
            FullyObservableCollection <Models.AccessPermissionModel> _tempfilteredaccesspermissions = new FullyObservableCollection <Models.AccessPermissionModel>();

            foreach (Models.AccessPermissionModel ap in _associateaccesspermissions)
            {
                if (ap.OperatingCompanyID == _opcoid)
                {
                    _tempfilteredaccesspermissions.Add(ap);
                }
            }
            FilteredAccessPermissions = _tempfilteredaccesspermissions;
        }
        private void FilterSalesRegions(int countryid)
        {
            FullyObservableCollection <SalesRegionModel> tempsalesregions = new FullyObservableCollection <SalesRegionModel>();

            SalesRegions?.Clear();
            foreach (SalesRegionModel sd in StaticCollections.SalesRegions)
            {
                if (sd.CountryID == countryid && !sd.Deleted)
                {
                    tempsalesregions.Add(sd);
                }
            }
            SalesRegions = tempsalesregions;
        }
        private void GetCountries()
        {
            FullyObservableCollection <CountryModel> tempcountries = new FullyObservableCollection <CountryModel>();
            FullyObservableCollection <CountryModel> loccountries  = DatabaseQueries.GetCountries();

            foreach (CountryModel cm in loccountries)
            {
                if (!cm.Deleted)
                {
                    tempcountries.Add(cm);
                }
            }
            Countries = tempcountries;
        }
        private void AddNewPermissions(object obj)
        {
            if (SelectedOperatingCompany != null)
            {
                _associateaccesspermissions.Add(new Models.AccessPermissionModel()
                {
                    ID = 0, AssociateID = _thisassociateid, CountryID = 0, AccessPermissionTypeID = 0, OperatingCompanyID = SelectedOperatingCompany.ID
                });
                _associateaccesspermissions.ItemPropertyChanged += _associateaccesspermissions_ItemPropertyChanged;
                filterAssociateAccess(SelectedOperatingCompany.GOM.ID);

                canAddNewExecute = false;
            }
        }
Exemple #19
0
        public void AddHitPointChange(HitPointChange hitPointChange)
        {
            HitPointChanges.Add(hitPointChange);

            if (hitPointChange is Hit)
            {
                if (hitPointChange.GetHitPointChange() != 0)
                {
                    Hit hit = hitPointChange as Hit;
                    if (hit.Weapon.AbilityDamage)
                    {
                        Effects.Add(new Effect.AbilityValueEffect(Types.Effect.AbilityModifier,
                                                                  hit.Weapon.Ability, -hit.Weapon.AbilityDamageValue));
                    }
                }
            }
        }
Exemple #20
0
 public void DetectNewMemberPropertyChange()
 {
     TestCollection.Add(Betty);
     Expect(TestCollection.Count, Is.EqualTo(4));
     Expect(TestCollection[3].Name, Is.EqualTo("Betty"));
     Expect(ItemEventList.Count, Is.EqualTo(0), "Item Event count");
     Expect(CollectionEventList.Count, Is.EqualTo(1), "Collection Event count");
     Expect(CollectionEventList[0].Action, Is.EqualTo(NotifyCollectionChangedAction.Add), "Action (add)");
     Expect(CollectionEventList[0].OldItems, Is.Null, "OldItems count");
     Expect(CollectionEventList[0].NewItems.Count, Is.EqualTo(1), "NewItems count");
     Expect(CollectionEventList[0].NewItems[0], Is.EqualTo(Betty), "NewItems[0] dereference");
     CollectionEventList.Clear();          // Empty for next operation
     ItemEventList.Clear();
     TestCollection[3].Id = 7;
     Expect(CollectionEventList.Count, Is.EqualTo(0), "Collection Event count");
     Expect(ItemEventList.Count, Is.EqualTo(1), "Item Event count");
     Expect(TestCollection[ItemEventList[0].CollectionIndex], Is.EqualTo(Betty), "Collection Index dereference");
 }
        public void AddWeaponSet(Model.WeaponSet weaponSet)
        {
            bool found = false;

            for (int i = 0; i < WeaponList.Count; ++i)
            {
                if (WeaponList[i].Owner == weaponSet.Owner)
                {
                    WeaponList[i] = weaponSet;
                    found         = true;
                }
            }

            if (!found)
            {
                WeaponList.Add(weaponSet);
            }
        }
Exemple #22
0
        private void LoadBusinessUnits(UserModel user)
        {
            FullyObservableCollection <SelectedItemModel> BusinessUnitsColl = new FullyObservableCollection <SelectedItemModel>();
            List <string> associatessaledivs = user.BusinessUnits.Split(',').ToList();

            foreach (ModelBaseVM sd in BusinessUnits)
            {
                BusinessUnitsColl.Add(new SelectedItemModel
                {
                    ID        = sd.ID,
                    IsChecked = associatessaledivs.Contains(sd.ID.ToString()),
                    Name      = sd.Name,
                    IsEnabled = !user.Deleted
                });
            }
            BusinessUnitOptions = BusinessUnitsColl;
            BusinessUnitOptions.ItemPropertyChanged += BusinessUnitOptions_ItemPropertyChanged;
        }
Exemple #23
0
        private void LoadReportMnuOptions(UserModel user)
        {
            FullyObservableCollection <SelectedItemModel> ReportsMnuColl = new FullyObservableCollection <SelectedItemModel>();
            List <string> reportoptions = user.ReportsMnu.Split(',').ToList();

            foreach (EnumValue ev in EnumerationLists.ReportsOptionsList)
            {
                ReportsMnuColl.Add(new SelectedItemModel
                {
                    ID        = ev.ID,
                    IsChecked = reportoptions.Contains(ev.ID.ToString()),
                    Name      = ev.Description,
                    IsEnabled = !user.Deleted
                });
            }
            ReportMnuOptions = ReportsMnuColl;
            ReportMnuOptions.ItemPropertyChanged += ReportMnuOptions_ItemPropertyChanged;
        }
        private void GetDefaultPBSalesStatuses()
        {
            List <string>            defaultprojstatuses = SetUp.DefaultSalesStatuses.Split(',').ToList();
            Collection <ModelBaseVM> salesstatuses       = DatabaseQueries.GetSalesStatuses();
            FullyObservableCollection <ModelBaseVM> SalesStatusesColl = new FullyObservableCollection <ModelBaseVM>();

            foreach (ModelBaseVM sd in salesstatuses)
            {
                SalesStatusesColl.Add(new ModelBaseVM
                {
                    ID        = sd.ID,
                    IsChecked = defaultprojstatuses.Contains(sd.ID.ToString()),
                    Name      = sd.Name
                });
            }
            DefaultPBSalesStatuses = SalesStatusesColl;
            DefaultPBSalesStatuses.ItemPropertyChanged += DefaultPBSalesStatuses_ItemPropertyChanged;
        }
Exemple #25
0
        private void LoadAdministrationMnuOptions(UserModel user)
        {
            FullyObservableCollection <SelectedItemModel> AdministrationMnuColl = new FullyObservableCollection <SelectedItemModel>();
            List <string> adminoptions = user.AdministrationMnu.Split(',').ToList();

            foreach (EnumValue ev in EnumerationLists.AdministrationMenuOptionsList)
            {
                AdministrationMnuColl.Add(new SelectedItemModel
                {
                    ID        = ev.ID,
                    IsChecked = adminoptions.Contains(ev.ID.ToString()),
                    Name      = ev.Description,
                    IsEnabled = !user.Deleted
                });
            }
            AdministrationMnuOptions = AdministrationMnuColl;
            AdministrationMnuOptions.ItemPropertyChanged += AdministrationMnuOptions_ItemPropertyChanged;
        }
        public AddLabelsViewModel(IOrderLabel order)
        {
            CurentOrder = order;
            DishPackages = new FullyObservableCollection<IDishPackageLabel>();
            foreach (var dp in order.DishPackagesForLab)
            {
                dp.PrintLabel = DataExtension.DataCatalogsSingleton.Instance.ItemLabelsInfo.Where(a => a.ParenItemId == dp.DishId).Count() > 0;
                dp.LabelSeriesCount = dp.LabelsCount;
                DishPackages.Add(dp);

            }


            order.PropertyChanged += Order_PropertyChanged;
            OrderDish = DishPackages.First();
            AllDishGridVis = Visibility.Collapsed;
            OrderDishGridVis = Visibility.Visible;
            Init();
        }
Exemple #27
0
        public DeletedAssetsViewModel()
        {
            FullyObservableCollection <AssetSummaryModel> _assetsummary = GetDeletedAssets();

            AssetModel _deletedAsset;

            foreach (AssetSummaryModel asset in _assetsummary)
            {
                _deletedAsset = new AssetModel
                {
                    ID            = asset.ID,
                    Label         = MakeLabel(asset.AssetAreaID, asset.AssetGroupID, asset.LabelID),// asset.Label;
                    Name          = asset.Description,
                    ParentAssetID = asset.ParentAssetID
                };
                _deletedassets.Add(new TVDeletedAssetViewModel(_deletedAsset, null));
            }
            DeletedAssets.ItemPropertyChanged += DeletedAssets_ItemPropertyChanged;
        }
        public AddAttackSetWindowViewModel(Model.AttackSet attackSet = null)
        {
            _attackViewModels = new FullyObservableCollection <AttackViewModel>();
            _addAttack        = new Command(ExecuteAddAttack);
            _editAttack       = new Command(ExecuteEditAttack);
            _removeAttack     = new Command(ExecuteRemoveAttack);

            if (attackSet != null)
            {
                _name = attackSet.Name;
                foreach (Model.Attack attack in attackSet.Attacks)
                {
                    _attackViewModels.Add(new AttackViewModel(attack));
                }
            }
            else
            {
                _name = "Attack";
            }
        }
Exemple #29
0
        private void FilterAssetTypes(int assetgroupid)
        {
            var  subs     = MasterAssetTypes.Where(x => x.AssetGroupID == assetgroupid);
            bool _isfound = false;
            FullyObservableCollection <AssetTypeModel> _temp = new FullyObservableCollection <AssetTypeModel>();

            foreach (AssetTypeModel atm in subs)
            {
                _temp.Add(atm);
                if (atm.ID == Asset.AssetTypeID)
                {
                    _isfound = true;
                }
            }
            if (!_isfound)
            {
                Asset.AssetTypeID = -1;
            }

            AssetTypes = _temp;
        }
        private async void LoadNavigationItems()
        {
            var roamingFolder  = ApplicationData.Current.RoamingFolder;
            var settingsFolder = await roamingFolder.CreateFolderAsync("settings", CreationCollisionOption.OpenIfExists);

            // Bug FileNotFound
            var navSettingsFile = await settingsFolder.GetFileAsync("nav_settings.json");

            var json = await FileIO.ReadTextAsync(navSettingsFile);

            JObject rss = JObject.Parse(json);

            var version = (string)rss["version"];

            JArray items = (JArray)rss["navigation_items"];
            var    count = items.Count;

            foreach (var item in items)
            {
                var type = (string)item["type"];

                switch (type)
                {
                case "divider":
                    var dividerItem = new DividerItem();
                    navigationItems.Add(dividerItem);
                    break;

                case "header":
                    var headerItem = new HeaderItem
                    {
                        Label = (string)item["label"]
                    };
                    navigationItems.Add(headerItem);
                    break;

                case "link":
                    var linkItem = new LinkItem
                    {
                        Label  = (string)item["label"],
                        PageId = Guid.Parse((string)item["link_id"])
                    };
                    navigationItems.Add(linkItem);
                    break;
                }
            }
        }