protected void Initialize()
        {
            this.Title = "Vici Cool Storage";

            // performance timing
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();

            string dbName = "db_viciCoolStorage.db3";

            // check the database, if it doesn't exist, create it
            this.CheckAndCreateDatabase(dbName);

            // performance timing
            Console.WriteLine("database creation: " + stopwatch.ElapsedMilliseconds.ToString());

            // query a list of people from the db
            people = Person.List();

            // performance timing
            Console.WriteLine("database query: " + stopwatch.ElapsedMilliseconds.ToString());

            // create a new table source from our people collection
            tableSource = new BasicOperations.TableSource(people);

            // initialize the table view and set the source
            this.TableView = new UITableView()
            {
                Source = tableSource
            };
        }
Esempio n. 2
0
        public void Serialization()
        {
            DeleteData();
            SetupTestData();

            Customer customer = Customer.New();

            customer.Name = "Test";
            customer.Save();

            CSList <Customer> customers = new CSList <Customer>();

            int nCustomers = customers.Count;

            Customer refCustomer = customers[nCustomers - 1];

            using (Stream stream = new MemoryStream())
            {
                BinaryFormatter formatter = new BinaryFormatter();

                formatter.Serialize(stream, customer);
                formatter.Serialize(stream, customers);

                stream.Seek(0, SeekOrigin.Begin);

                customer  = (Customer)formatter.Deserialize(stream);
                customers = (CSList <Customer>)formatter.Deserialize(stream);
            }

            Assert.AreEqual("Test", customer.Name);
            Assert.AreEqual(nCustomers, customers.Count);
            Assert.AreEqual(refCustomer, customers[nCustomers - 1]);
        }
Esempio n. 3
0
        public void ListPredicates()
        {
            DeleteData();

            Customer customer = Customer.New();

            customer.Name = "Philippe";
            customer.Save();

            customer = Customer.New();

            customer.Name = "Dirk";
            customer.Save();

            customer = Customer.New();

            customer.Name = "Paul";
            customer.Save();

            CSList <Customer> customers = Customer.List().FilteredBy(delegate(Customer c) { return(c.Name.StartsWith("P")); });

            Assert.AreEqual(2, customers.Count);

            customers = customers.FilteredBy(delegate(Customer c) { return(c.Name.EndsWith("e")); });

            Assert.AreEqual(1, customers.Count);
        }
Esempio n. 4
0
        public void Paging()
        {
            DeleteData();

            for (int i = 1; i <= 70; i++)
            {
                Customer customer = Customer.New();
                Order    order    = Order.New();

                customer.Name = "Customer" + i.ToString("0000");
                customer.Save();

                order.Customer = customer;
                order.OrderItems.Add(OrderItem.New("test", 4, 10));
                order.Save();
            }

            CSList <Order> orders;

            CSList <Customer> customers = Customer.OrderedList("Name").Range(11, 10);

            Assert.AreEqual(10, customers.Count);
            Assert.AreEqual("Customer0011", customers[0].Name);
            Assert.AreEqual("Customer0020", customers[9].Name);

            orders = Order.OrderedList("Customer.Name , OrderID").Range(51, 10);

            Assert.AreEqual(10, orders.Count);
            Assert.AreEqual("Customer0051", orders[0].Customer.Name);
            Assert.AreEqual("Customer0060", orders[9].Customer.Name);
        }
        public LocalRegistScoreViewModel()
        {
            try
            {
                _tourService       = Resolver.Resolve <ITourService>();
                _commonFun         = Resolver.Resolve <ICommonFun>();
                _commonHelper      = Resolver.Resolve <CommonHelper>();
                _localScoreService = Resolver.Resolve <ILocalScoreService>();
                _remoteService     = Resolver.Resolve <IRemoteService>();

                _tapCommand = new Command(ImageTaped);

                MessagingCenter.Subscribe <LocalRegistScorePage>(this, "CheckBoxChanged", (obj) =>
                {
                    if (CSList.Any(p => p.IsCheck == true))
                    {
                        CurrentScore        = "0";
                        CurrentSystem.Score = 0;
                    }
                    else
                    {
                        CurrentScore        = "1";
                        CurrentSystem.Score = 1;
                    }
                });

                MessagingCenter.Subscribe <StandardPic>(this, "DeleteLossImage", (obj) =>
                {
                    //删除失分照片
                    DeleteImage(obj);
                });

                MessagingCenter.Subscribe <PictureStandard>(this, "RegistScoreItemTapped", (obj) =>
                {
                    UploadStandPic(obj.StandardPicId);
                });

                MessagingCenter.Subscribe <PictureStandard>(this, "PreviewPlanAttechment", (obj) =>
                {
                    if (!string.IsNullOrEmpty(obj.Url))
                    {
                        PreviewStanderImage(obj.Url);
                    }
                });

                MessagingCenter.Subscribe <PictureStandard>(this, "DeletePlanAttechment", (obj) =>
                {
                    if (!string.IsNullOrEmpty(obj.Url))
                    {
                        DeleteStanderImage(obj);
                    }
                });
            }
            catch (Exception)
            {
                _commonFun.AlertLongText("操作异常,请重试。-->CustImproveViewModel");
                return;
            }
        }
Esempio n. 6
0
        public void RandomCreation()
        {
            DeleteData();

            Random rnd = new Random();

            Customer cust = Customer.New();

            cust.Name = "Blabla";

            double total = 0.0;

            for (int i = 0; i < 5; i++)
            {
                Order order = Order.New();

                order.Customer = cust;

                for (int j = 0; j < 20; j++)
                {
                    int    qty   = rnd.Next(1, 10);
                    double price = rnd.NextDouble() * 500.0;

                    order.OrderItems.Add(OrderItem.New("test", (short)qty, price));

                    total += qty * price;
                }

                order.Save();
            }

            CSList <Order> orders = new CSList <Order>();

            Assert.AreEqual(5, orders.Count);

            double total2 = Convert.ToDouble(OrderItem.GetScalar("Qty*Price", CSAggregate.Sum));

            Assert.AreEqual(total, total2, 0.000001);

            foreach (Order order in orders)
            {
                Assert.AreEqual(cust, order.Customer);
                Assert.AreEqual(20, order.OrderItems.Count);
                Assert.AreEqual(cust.Name, order.Customer.Name);

                order.OrderItems[rnd.Next(0, 19)].Delete();

                Assert.AreEqual(19, order.OrderItems.Count);
            }

            total2 = Convert.ToDouble(OrderItem.GetScalar("Qty*Price", CSAggregate.Sum));

            if (total <= total2)
            {
                Assert.Fail();
            }

            Assert.AreEqual(95, new CSList <OrderItem>().Count);
        }
Esempio n. 7
0
        private void Open()
        {
            var mdlg = new OpenFileDialog();

            mdlg.CheckFileExists = true;
            mdlg.Multiselect     = false;
            mdlg.Filter          = "Tvtest channel file(*.ch2)|*.ch2|All file(*.*)|*.*";
            if (mdlg.ShowDialog() == true)
            {
                foreach (var item in Ch2.ReadChe2File(mdlg.FileName))
                {
                    switch (item.Type)
                    {
                    case CHType.GR:
                        if (!GRList.Any(x => x.ServiceID == item.ServiceID))
                        {
                            GRList.Add(new ChannelViewModel(item));
                        }
                        break;

                    case CHType.BS:
                        if (!BSList.Any(x => x.ServiceID == item.ServiceID))
                        {
                            BSList.Add(new ChannelViewModel(item));
                        }
                        break;

                    case CHType.CS:
                        if (!CSList.Any(x => x.ServiceID == item.ServiceID))
                        {
                            CSList.Add(new ChannelViewModel(item));
                        }
                        break;

                    default:
                        if (!SKList.Any(x => x.ServiceID == item.ServiceID))
                        {
                            SKList.Add(new ChannelViewModel(item));
                        }
                        break;
                    }
                }
                GRList.Sort((x, y) => x.Channel == y.Channel ? x.ServiceID.CompareTo(y.ServiceID) : x.Channel.CompareTo(y.Channel));
                BSList.Sort((x, y) => x.Channel == y.Channel ? x.ServiceID.CompareTo(y.ServiceID) : x.Channel.CompareTo(y.Channel));
                CSList.Sort((x, y) => x.Channel == y.Channel ? x.ServiceID.CompareTo(y.ServiceID) : x.Channel.CompareTo(y.Channel));
                SKList.Sort((x, y) => x.Channel == y.Channel ? x.ServiceID.CompareTo(y.ServiceID) : x.Channel.CompareTo(y.Channel));
                ChannelList  = new ObservableCollection <ChannelViewModel>(GRList.Concat(BSList).Concat(CSList).Concat(SKList));
                this.isSaved = false;
                this.NotifyPropertyChanged(nameof(this.Caption));
            }
            else
            {
                return;
            }
        }
    static void Main(string[] args)
    {
        CSList <Contact> contacts = new CSList <Contact>();
        //add contacts to the list
        var x = from c in contacts
                select new {
            c.Id,
            c.Name
            ContactTypeName = c.ContactType.Name
        };
    }
}
Esempio n. 9
0
        public void OrderBy()
        {
            Order.List().DeleteAll();

            Order order;

            order               = Order.New();
            order.Customer      = Customer.New();
            order.Customer.Name = "Alain";
            order.OrderDate     = new DateTime(2005, 1, 10);
            order.Save();

            order               = Order.New();
            order.Customer      = Customer.New();
            order.Customer.Name = "Luc";
            order.OrderDate     = new DateTime(2005, 1, 6);
            order.Save();

            order               = Order.New();
            order.Customer      = Customer.New();
            order.Customer.Name = "Gerard";
            order.OrderDate     = new DateTime(2005, 1, 8);
            order.Save();

            CSList <Order> orders = Order.List();

            orders.OrderBy = "OrderDate";

            Assert.AreEqual(new DateTime(2005, 1, 6), orders[0].OrderDate);
            Assert.AreEqual(new DateTime(2005, 1, 10), orders[2].OrderDate);

            orders = new OrderCollection();

            orders.OrderBy = "Customer.Name";

            Assert.AreEqual(orders[0].Customer.Name, "Alain");
            Assert.AreEqual(orders[2].Customer.Name, "Luc");

            CSList <OrderItem> orderItems = new CSList <OrderItem>("Order.Customer.Name=''").OrderedBy("Order.Customer.Name");

            Assert.AreEqual(0, orderItems.Count);

            Assert.AreEqual("Luc", Order.GetScalar("Customer.Name", CSAggregate.Max, "Customer.Name<>'Alain'"));
            Assert.AreEqual("Alain", Order.GetScalar("Customer.Name", CSAggregate.Min));

#if !SQLITE
            Assert.AreEqual(new DateTime(2005, 1, 10), Order.GetScalar <DateTime>("OrderDate", CSAggregate.Max));
            Assert.AreEqual(new DateTime(2005, 1, 6), Order.GetScalar <DateTime>("OrderDate", CSAggregate.Min));
#endif
        }
Esempio n. 10
0
        // This method checks to see if the database exists, and if it doesn't, it creates
        // it and inserts some data. It also sets our database to be the default database
        // connection.
        protected void CheckAndCreateDatabase(string dbName)
        {
            // determine whether or not the database exists
            bool dbExists = File.Exists(GetDBPath(dbName));

            // configure the current database, create if it doesn't exist, and then run the anonymous
            // delegate method after it's created
            CSConfig.SetDB(GetDBPath(dbName), SqliteOption.CreateIfNotExists, () => {
                CSDatabase.ExecuteNonQuery("CREATE TABLE People (PersonID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName text, LastName text)");

                // if the database had to be created, let's populate with initial data
                if (!dbExists)
                {
                    // declare vars
                    CSList <Person> people = new CSList <Person> ();
                    Person person;

                    // create a list of people that we're going to insert
                    person = new Person()
                    {
                        FirstName = "Peter", LastName = "Gabriel"
                    };
                    people.Add(person);
                    person = new Person()
                    {
                        FirstName = "Thom", LastName = "Yorke"
                    };
                    people.Add(person);
                    person = new Person()
                    {
                        FirstName = "J", LastName = "Spaceman"
                    };
                    people.Add(person);
                    person = new Person()
                    {
                        FirstName = "Benjamin", LastName = "Gibbard"
                    };
                    people.Add(person);

                    // save the people collection to the database
                    people.Save();
                }
            });
        }
Esempio n. 11
0
        public void Paging2()
        {
            Customer customer = Customer.New();

            customer.Name = "Customer";
            customer.Save();
            for (int i = 1; i <= 5; i++)
            {
                Order order = Order.New();


                order.Customer = customer;
                order.OrderItems.Add(OrderItem.New("test", 4, 10));
                order.Save();
            }

            CSList <Order> orders = Order.List("has(OrderItems where Qty > 1)").OrderedBy("OrderID").Range(2, 2);

            Assert.AreEqual(2, orders.Count);
        }
Esempio n. 12
0
        public void ManyToOne()
        {
            SetupTestData();

            Customer    customer    = new CSList <Customer>()[0];
            SalesPerson salesPerson = SalesPerson.New();

            salesPerson.Name = "Test";
            salesPerson.Save();

            Order order = Order.New();

            order.SalesPerson = null;
            order.Customer    = customer;

            order.Save();

            int id = order.OrderID;

            order = Order.Read(id);

            Assert.AreEqual(order.Customer, customer);

            order.SalesPerson = salesPerson;
            order.Save();

            order = Order.Read(id);

            Assert.AreEqual(salesPerson, order.SalesPerson);

            order.SalesPerson = null;
            order.Save();

            order = Order.Read(id);

            Assert.IsNull(order.SalesPerson);
            Assert.IsNull(order.SalesPersonID);
        }
Esempio n. 13
0
 public TableSource(CSList <Person> items) : base()
 {
     this.items = items;
 }
Esempio n. 14
0
        public void DeleteFromCollections()
        {
            Order order = Order.New();

            order.Customer      = Customer.New();
            order.Customer.Name = "me";


            for (int i = 0; i < 100; i++)
            {
                OrderItem item = order.OrderItems.AddNew();

                item.Description = "test" + (i + 1);
                item.Price       = i;
                item.Qty         = (short)i;
            }

            order.Save();

            order = Order.Read(order.OrderID);

            Assert.AreEqual(order.OrderItems.Count, 100);

            foreach (OrderItem item in order.OrderItems)
            {
                if ((item.Qty % 5) == 0)
                {
                    item.MarkForDelete();
                }
            }

            order.Save();

            Assert.AreEqual(order.OrderItems.Count, 80);

            order = Order.Read(order.OrderID);

            Assert.AreEqual(order.OrderItems.Count, 80);

            CSList <OrderItem> items = new CSList <OrderItem>(order.OrderItems);

            items.AddFilter("Qty < 50");

            Assert.AreEqual(40, items.Count);

            items.DeleteAll();

            order = Order.Read(order.OrderID);

            Assert.AreEqual(40, order.OrderItems.Count);

            order.OrderItems.AddFilter("Qty >= 80");

            Assert.AreEqual(16, order.OrderItems.Count);

            order.OrderItems.DeleteAll();

            Assert.AreEqual(0, order.OrderItems.Count);

            order = Order.Read(order.OrderID);

            Assert.AreEqual(24, order.OrderItems.Count);
        }
Esempio n. 15
0
 public TableSource(UIViewController ctrl, CSList <AmazonProductInfo> items)
 {
     mTableItems           = items;
     mParentViewController = ctrl;
 }