예제 #1
0
        private void saCancelTransaction_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            HashSet <Order> ordersToDelete = new HashSet <Order>();

            foreach (Transaction transaction in e.SelectedObjects)
            {
                var transactionTransactionDetails = transaction.TransactionDetails.ToList();
                foreach (var transactionDetail in transactionTransactionDetails)
                {
                    // delete all orderdetails related with this transactiondetail
                    var orderDetails = ObjectSpace.GetObjectsQuery <OrderDetail>().Where(od => od.TransactionDetail == transactionDetail).ToList();
                    orderDetails.ForEach(od =>
                    {
                        od.Delete();
                    });
                    transactionDetail.Delete();
                }

                ObjectSpace.GetObjectsQuery <Order>().Where(o => o.Transaction == transaction).ToList().ForEach(o => o.Delete());

                transaction.Delete();
            }
            ObjectSpace.CommitChanges();

            // delete orphaned orders
            var orders = ObjectSpace.GetObjectsQuery <Order>().Where(o => o.OrderDetails.Count == 0).ToList();

            orders.ForEach(o => o.Delete());
            ObjectSpace.CommitChanges();
        }
예제 #2
0
        private void AppearanceController_CollectAppearanceRules(object sender, CollectAppearanceRulesEventArgs e)
        {
            IQueryable <CustomApperance> customApperances = ObjectSpace.GetObjectsQuery <CustomApperance>()
                                                            .Where(x => x.DataType == View.ObjectTypeInfo.Type);

            e.AppearanceRules.AddRange(customApperances);
        }
예제 #3
0
        private void WygenerujFaktury(int liczbaFaktur, IList <Klient> customers, IList <Produkt> products)
        {
            if (customers is null)
            {
                customers = ObjectSpace.GetObjectsQuery <Klient>().ToList();
            }

            var orderFaker = new Faker <Faktura>("pl")
                             .CustomInstantiator(f => ObjectSpace.CreateObject <Faktura>())
                             .RuleFor(o => o.NumerFaktury, f => f.Random.Int().ToString())
                             .RuleFor(o => o.DataFaktury, f => f.Date.Past(2))
                             .RuleFor(o => o.DataSprzedazy, f => f.Date.Past(20))
                             .RuleFor(o => o.Klient, f => f.PickRandom(customers));
            var orders = orderFaker.Generate(liczbaFaktur);

            if (products == null)
            {
                products = ObjectSpace.GetObjectsQuery <Produkt>().ToList();
            }

            var itemsFaker = new Faker <PozycjaFaktury>()
                             .CustomInstantiator(f => ObjectSpace.CreateObject <PozycjaFaktury>())
                             .RuleFor(o => o.Faktura, f => f.PickRandom(orders))
                             .RuleFor(o => o.Produkt, f => f.PickRandom(products))

                             .RuleFor(o => o.Ilosc, f => f.Random.Decimal(0.01M, 100M));

            var items = itemsFaker.Generate(liczbaFaktur * 10);
        }
예제 #4
0
 public override void UpdateDatabaseAfterUpdateSchema()
 {
     base.UpdateDatabaseAfterUpdateSchema();
     if (ObjectSpace.GetObjectsQuery <XpandPermissionPolicyUser>().FirstOrDefault(user => user.UserName == "NewUserActivation") == null)
     {
         var xpandUser = ObjectSpace.CreateObject <XpandPermissionPolicyUser>();
         xpandUser.UserName = "******";
         ObjectSpace.CommitChanges();
     }
 }
예제 #5
0
        private void SimpleActionOnExecute(object sender, SimpleActionExecuteEventArgs e)
        {
            var xpandUser = ObjectSpace.GetObjectsQuery <XpandPermissionPolicyUser>().First(user => user.UserName == "NewUserActivation");
            var registrationActivation = (IModelRegistrationActivation)((IModelOptionsRegistration)Application.Model.Options).Registration;

            xpandUser.SetMemberValue(registrationActivation.ActivationIdMember.Name, Guid.NewGuid().ToString());
            var oid = xpandUser.Oid;

            WebApplication.Instance.LogOff();
            WebApplication.Redirect(HttpContext.Current.Request.Url.AbsoluteUri + "/?Ua=" + oid);
        }
예제 #6
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            if (!ObjectSpace.GetObjectsQuery <ASPxTokenListPropertyEditorObject>().Any())
            {
                var childObject = ObjectSpace.CreateObject <ASPxTokenListPropertyEditorChildObject>();
                childObject.Name = "aaaa";

                childObject      = ObjectSpace.CreateObject <ASPxTokenListPropertyEditorChildObject>();
                childObject.Name = "bbbb";

                ObjectSpace.CommitChanges();
            }
        }
예제 #7
0
        private void simpleAction2_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            var art = ObjectSpace.GetObjectsQuery <RaksArtykul>();

            foreach (RaksArtykul artykul in art)
            {
                if (artykul.Jednostka == null)
                {
                    var jm = ObjectSpace.FindObject <RaksJednostkaMiary>(new BinaryOperator(nameof(RaksJednostkaMiary.Id), artykul.IdJednostkiMiary));
                    if (jm == null)
                    {
                        jm       = ObjectSpace.CreateObject <RaksJednostkaMiary>();
                        jm.Id    = artykul.IdJednostkiMiary;
                        jm.Skrot = artykul.SkrotJednostkiMiary;
                        jm.Nazwa = artykul.NazwaJednostkiMiary;
                    }
                    artykul.Jednostka = jm;
                }


                if (artykul.Vat == null)
                {
                    var rec = ObjectSpace.FindObject <RaksStawkaVat>(new BinaryOperator(nameof(RaksStawkaVat.Id), artykul.IdStawki));
                    if (rec == null)
                    {
                        rec    = ObjectSpace.CreateObject <RaksStawkaVat>();
                        rec.Id = artykul.IdStawki;
                        rec.WartoscProcentowa = artykul.StawkaVat;
                        rec.TypStawkiVat      = artykul.TypStawki;
                    }
                    artykul.Vat = rec;
                }

                if (artykul.Dostawca == null)
                {
                    RaksKontakt rec = FindKontakt(artykul.IdDostawcy, artykul.NazwaDostawcy, artykul.NipDostawcy);
                    artykul.Dostawca = rec;
                }
                if (artykul.Producent == null && !string.IsNullOrEmpty(artykul.NazwaProducenta))
                {
                    RaksKontakt rec = FindKontakt(artykul.IdProducenta, artykul.NazwaProducenta, artykul.NipProducenta);
                    artykul.Producent = rec;
                }
            }
            ObjectSpace.CommitChanges();
        }
예제 #8
0
 public override void UpdateDatabaseAfterUpdateSchema()
 {
     base.UpdateDatabaseAfterUpdateSchema();
     if (CurrentDBVersion <= new Version("17.1.6.4"))
     {
         var modelDifferenceObjects = ObjectSpace.GetObjectsQuery <ModelDifferenceObject>().ToArray().Where(o => o.DeviceCategory == DeviceCategory.All).ToArray();
         foreach (var modelDifferenceObject in modelDifferenceObjects)
         {
             modelDifferenceObject.DeviceCategory = DeviceCategory.Desktop;
         }
         ObjectSpace.CommitChanges();
         foreach (var modelDifferenceObject in modelDifferenceObjects)
         {
             modelDifferenceObject.DeviceCategory = DeviceCategory.All;
         }
         ObjectSpace.CommitChanges();
     }
 }
예제 #9
0
        private void paInvalidate_Execute(object sender, PopupWindowShowActionExecuteEventArgs e)
        {
            NPInvalidateCard invalidation = (NPInvalidateCard)e.PopupWindowViewCurrentObject;


            Debug.Assert(View.SelectedObjects.Count == 1, "Card invalidation should be executed for single record");
            Card card = (Card)View.SelectedObjects[0];
            // create transaction
            var transaction = ObjectSpace.CreateObject <Transaction>();

            transaction.Card = card;

            transaction.ProductType = EProductType.Money;

            //
            var tiYukleme = (ObjectSpace.GetObjectsQuery <TransactionItem>()
                             .Where(ti => ti.Active && ti.ProductType == EProductType.Money && ti.Type == ETransactionType.Charge)).First();

            var transactionDetail = ObjectSpace.CreateObject <TransactionDetail>();
            var refundAmount      = -1 * invalidation.RefundAmount;

            transactionDetail.Item     = tiYukleme;
            transactionDetail.Quantity = refundAmount;
            transactionDetail.Total    = refundAmount;
            transaction.TransactionDetails.Add(transactionDetail);

            if (card.Returnable)
            {
                var transactionDetailDeposit = ObjectSpace.CreateObject <TransactionDetail>();
                transactionDetailDeposit.Item     = ObjectSpace.GetObjectsQuery <TransactionItem>().First(ti => ti.SpecialCode == "DEPOSIT");
                transactionDetailDeposit.Quantity = -1;
                transactionDetailDeposit.Total    = invalidation.DepositAmount;
                transaction.TransactionDetails.Add(transactionDetailDeposit);
            }

            transaction.UpdateTotalsAndDate();

            card.CardNo = $"Eski kart - {card.CardNo} - {DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss")}";

            card.Active = false;

            ObjectSpace.CommitChanges();
        }
예제 #10
0
        void ObjectSpace_ObjectChanged(object sender, ObjectChangedEventArgs e)
        {
            var parent = ObjectSpace.GetObject(((NestedFrame)Frame).ViewItem.CurrentObject as Faktura);

            if (View.CurrentObject == e.Object &&
                e.PropertyName == nameof(Klient.Nazwa) &&
                ObjectSpace.IsModified &&
                e.OldValue != e.NewValue)
            {
                Klient changedContact = (Klient)e.Object;
                var    newCustomer    = ObjectSpace.GetObjectsQuery <Klient>().Where(k => k.Nazwa == (string)e.NewValue).FirstOrDefault();
                if (parent != null && newCustomer != null)
                {
                    parent.ZmienKlienta(newCustomer);
                    View.Refresh();
                    changedContact.Nazwa = (string)e.OldValue;
                }
            }
        }
예제 #11
0
 public override void UpdateDatabaseAfterUpdateSchema()
 {
     base.UpdateDatabaseAfterUpdateSchema();
     if (!ObjectSpace.GetObjectsQuery <Order>().Any())
     {
         for (int i = 0; i < 2; i++)
         {
             var product = ObjectSpace.CreateObject <Product>();
             product.ProductName = $"{nameof(Product.ProductName)}{i}";
             var accessory = ObjectSpace.CreateObject <Accessory>();
             accessory.Product       = product;
             accessory.AccessoryName = $"{nameof(Accessory.AccessoryName)}{i}";
             var order = ObjectSpace.CreateObject <Order>();
             order.Product   = product;
             order.Accessory = accessory;
             order.AggregatedOrders.Add(order);
         }
         ObjectSpace.CommitChanges();
     }
 }
예제 #12
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            if (!ObjectSpace.GetObjectsQuery <PersistentAssemblyInfo>().Any(info => info.Name == "OneToMany"))
            {
                var persistentAssemblyInfo = ObjectSpace.CreateObject <PersistentAssemblyInfo>();
                persistentAssemblyInfo.Name = "OneToMany";

                var projectCassInfo      = persistentAssemblyInfo.CreateClass("Project");
                var contributorClassInfo = persistentAssemblyInfo.CreateClass("Contributor");

                projectCassInfo.TypeAttributes.Add(ObjectSpace.CreateObject <PersistentDefaultClassOptionsAttribute>());
                projectCassInfo.CreateSimpleMember(DBColumnType.String, "Name");
                projectCassInfo.CreateCollection(contributorClassInfo).CreateAssociation("Project-Contributors");

                contributorClassInfo.TypeAttributes.Add(ObjectSpace.CreateObject <PersistentDefaultClassOptionsAttribute>());
                contributorClassInfo.CreateSimpleMember(DBColumnType.String, "Name");
                contributorClassInfo.CreateReferenceMember(projectCassInfo).CreateAssociation("Project-Contributors");
                ObjectSpace.CommitChanges();
            }
        }
 public override void UpdateDatabaseAfterUpdateSchema()
 {
     base.UpdateDatabaseAfterUpdateSchema();
     if (!ObjectSpace.GetObjectsQuery <DocumentObject>().Any())
     {
         var assembly       = GetType().Assembly;
         var documentObject = ObjectSpace.CreateObject <DocumentObject>();
         documentObject.Name    = "Test document 1";
         documentObject.Content = assembly.GetManifestResourceStream(assembly.GetManifestResourceNames().First(s => s.Contains("Lorem"))).Bytes();
         documentObject         = ObjectSpace.CreateObject <DocumentObject>();
         documentObject.Name    = "Test document 2";
         documentObject.Content = assembly.GetManifestResourceStream(assembly.GetManifestResourceNames().First(s => s.Contains("Lorem2"))).Bytes();
         documentObject         = ObjectSpace.CreateObject <DocumentObject>();
         documentObject.Name    = "Test document 3";
         documentObject.Content = assembly.GetManifestResourceStream(assembly.GetManifestResourceNames().First(s => s.Contains("Lorem3"))).Bytes();
         documentObject         = ObjectSpace.CreateObject <DocumentObject>();
         documentObject.Name    = "Template";
         documentObject.Content = assembly.GetManifestResourceStream(assembly.GetManifestResourceNames().First(s => s.Contains("LoresumV2"))).Bytes();
         ObjectSpace.CommitChanges();
     }
 }
예제 #14
0
 public IQueryable <T> Query <T>() => ObjectSpace.GetObjectsQuery <T>();
예제 #15
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            //string name = "MyName";
            //DomainObject1 theObject = ObjectSpace.FindObject<DomainObject1>(CriteriaOperator.Parse("Name=?", name));
            //if(theObject == null) {
            //    theObject = ObjectSpace.CreateObject<DomainObject1>();
            //    theObject.Name = name;
            //}
            PermissionPolicyUser sampleUser = ObjectSpace.FindObject <PermissionPolicyUser>(new BinaryOperator("UserName", "User"));

            if (sampleUser == null)
            {
                sampleUser          = ObjectSpace.CreateObject <PermissionPolicyUser>();
                sampleUser.UserName = "******";
                sampleUser.SetPassword("");
            }
            PermissionPolicyRole defaultRole = CreateDefaultRole();

            sampleUser.Roles.Add(defaultRole);

            PermissionPolicyUser userAdmin = ObjectSpace.FindObject <PermissionPolicyUser>(new BinaryOperator("UserName", "Admin"));

            if (userAdmin == null)
            {
                userAdmin          = ObjectSpace.CreateObject <PermissionPolicyUser>();
                userAdmin.UserName = "******";
                // Set a password if the standard authentication type is used
                userAdmin.SetPassword("");
            }
            // If a role with the Administrators name doesn't exist in the database, create this role
            PermissionPolicyRole adminRole = ObjectSpace.FindObject <PermissionPolicyRole>(new BinaryOperator("Name", "Administrators"));

            if (adminRole == null)
            {
                adminRole      = ObjectSpace.CreateObject <PermissionPolicyRole>();
                adminRole.Name = "Administrators";
            }
            adminRole.IsAdministrative = true;
            userAdmin.Roles.Add(adminRole);

            DodajKraje(ObjectSpace);

            var stawki = ObjectSpace.GetObjectsQuery <StawkaVat>().ToList();

            if (stawki.Count == 0)
            {
                stawki.Add(NowaStawka("23%", 23M));
                stawki.Add(NowaStawka("0%", 0M));
                stawki.Add(NowaStawka("7%", 7M));
                stawki.Add(NowaStawka("ZW", 0M));
            }

            var prodFaker = new Faker <Produkt>("pl")
                            .CustomInstantiator(f => ObjectSpace.CreateObject <Produkt>())
                            .RuleFor(o => o.Nazwa, f => f.Commerce.ProductName())
                            .RuleFor(o => o.Stawka, f => f.PickRandom(stawki))
                            .RuleFor(o => o.CenaSprzedazy, f => f.Random.Decimal(0.01M, 1000M));

            var products = prodFaker.Generate(1000);


            ObjectSpace.CommitChanges(); //This line persists created object(s).
        }
예제 #16
0
        public ActionResult Get()
        {
            IQueryable <Department> departments = ObjectSpace.GetObjectsQuery <Department>();

            return(Ok(departments));
        }
예제 #17
0
        public ActionResult Get()
        {
            IQueryable <Employee> employees = ObjectSpace.GetObjectsQuery <Employee>();

            return(Ok(employees));
        }
예제 #18
0
        private void PrzygotujDaneTestowe()
        {
            var stawki = ObjectSpace.GetObjectsQuery <StawkaVAT>().ToList();

            if (stawki.Count == 0)
            {
                stawki.Add(NowaStawka("23%", 23M));
                stawki.Add(NowaStawka("0%", 0M));
                stawki.Add(NowaStawka("7%", 7M));
                stawki.Add(NowaStawka("ZW", 0M));
            }

            var adrFaker = new Faker <AdresKlienta>("pl")
                           .CustomInstantiator(f => ObjectSpace.CreateObject <AdresKlienta>())
                           .RuleFor(o => o.Miejscowosc, f => f.Address.City())
                           .RuleFor(o => o.KodPocztowy, f => f.Address.ZipCode())
                           .RuleFor(o => o.Ulica, f => f.Address.StreetName());
            var adresses = adrFaker.Generate(200);

            ObjectSpace.CommitChanges();


            var cusFaker = new Faker <Klient>("pl")
                           .CustomInstantiator(f => ObjectSpace.CreateObject <Klient>())
                           .RuleFor(o => o.Telefon, f => f.Person.Phone)
                           .RuleFor(o => o.Skrot, f => f.Company.CompanyName())
                           .RuleFor(o => o.Nazwa, f => f.Company.CompanyName())
                           .RuleFor(o => o.Email, (f, u) => f.Internet.Email())
                           .RuleFor(o => o.AdresSiedziby, f => f.PickRandom(adresses))
                           .RuleFor(o => o.InnyAdresKorespondecyjny, true)
                           .RuleFor(o => o.AdresKorespondencyjny, f => f.PickRandom(adresses));


            var customers = cusFaker.Generate(100);

            ObjectSpace.CommitChanges();

            var conFaker = new Faker <Kontakt>("pl")
                           .CustomInstantiator(f => ObjectSpace.CreateObject <Kontakt>())
                           .RuleFor(o => o.Imie, f => f.Person.FirstName)
                           .RuleFor(o => o.Nazwisko, f => f.Person.LastName)
                           .RuleFor(o => o.Nazwisko, f => f.Person.LastName)
                           .RuleFor(o => o.Email, (f, u) => f.Internet.Email())
                           .RuleFor(o => o.Telefon, f => f.Person.Phone);

            var contacts = conFaker.Generate(10000);

            ObjectSpace.CommitChanges();



            var meetFaker = new Faker <Spotkanie>("pl")
                            .CustomInstantiator(f => ObjectSpace.CreateObject <Spotkanie>())
                            .RuleFor(o => o.Klient, f => f.PickRandom(customers))
                            .RuleFor(o => o.StartOn, f => f.Date.Soon(10));
            var meetings = meetFaker.Generate(1000);



            var prodFaker = new Faker <Produkt>("pl")
                            .CustomInstantiator(f => ObjectSpace.CreateObject <Produkt>())
                            .RuleFor(o => o.Nazwa, f => f.Commerce.ProductName())
                            .RuleFor(o => o.StawkaVAT, f => f.PickRandom(stawki))
                            .RuleFor(o => o.Cena, f => f.Random.Decimal(0.01M, 1000M));

            var products = prodFaker.Generate(100);

            WygenerujFaktury(1000, customers, products);
        }