예제 #1
0
        public void TestTrackableCollection_AddIfNew(bool track)
        {
            var acc  = new Accumulator("test");
            var coll = new TrackableCollection <Simple>(acc, track)
            {
                new Simple("a"), new Simple("b"), new Simple("c")
            };

            Assert.AreEqual(3, coll.Count);
            var d = new Simple("d");

            coll.Add(d);
            Assert.AreEqual(4, coll.Count);
            Assert.AreEqual("d", coll[3].Value);
            coll.AddIfNew(d);
            Assert.AreEqual(4, coll.Count);
            Assert.AreEqual("d", coll[3].Value);

            if (track)
            {
                Assert.AreEqual(4, acc.Records.Count);
            }
            else
            {
                Assert.AreEqual(0, acc.Records.Count);
            }
        }
예제 #2
0
        public void TestTrackableCollection_ReplaceWith(bool track)
        {
            var acc  = new Accumulator("test");
            var coll = new TrackableCollection <Simple>(acc, track)
            {
                new Simple("a"), new Simple("b"), new Simple("c")
            };

            coll.ReplaceWith(new TrackableCollection <Simple>()
            {
                new Simple("c"), new Simple("d"), new Simple("e")
            });
            Assert.AreEqual(3, coll.Count);
            Assert.AreEqual("c", coll[0].Value);
            Assert.AreEqual("d", coll[1].Value);
            Assert.AreEqual("e", coll[2].Value);

            if (track)
            {
                Assert.AreEqual(4, acc.Records.Count);
            }
            else
            {
                Assert.AreEqual(0, acc.Records.Count);
            }
        }
예제 #3
0
        public void TestTrackableCollection_AddRange(bool track)
        {
            var acc  = new Accumulator("test");
            var coll = new TrackableCollection <Simple>(acc, track)
            {
                new Simple("a"), new Simple("b"), new Simple("c")
            };

            coll.AddRange(new List <Simple> {
                new Simple("d"), new Simple("e"), new Simple("f")
            });
            Assert.AreEqual(6, coll.Count);
            Assert.AreEqual("d", coll[3].Value);
            Assert.AreEqual("e", coll[4].Value);
            Assert.AreEqual("f", coll[5].Value);

            if (track)
            {
                Assert.AreEqual(6, acc.Records.Count);
            }
            else
            {
                Assert.AreEqual(0, acc.Records.Count);
            }
        }
예제 #4
0
        public void TestTrackableCollection_ReplaceAll(bool track)
        {
            var acc  = new Accumulator("test");
            var b    = new Simple("b");
            var c    = new Simple("c");
            var d    = new Simple("d");
            var coll = new TrackableCollection <Simple>(acc, track)
            {
                new Simple("a"), b, c, b, c, b, b
            };
            var total = coll.ReplaceAll(b, d);

            Assert.AreEqual(4, total);
            Assert.AreEqual(coll[1], d);
            Assert.AreEqual(coll[3], d);
            Assert.AreEqual(coll[5], d);
            Assert.AreEqual(coll[6], d);

            if (track)
            {
                Assert.AreEqual(11, acc.Records.Count);
            }
            else
            {
                Assert.AreEqual(0, acc.Records.Count);
            }
        }
예제 #5
0
        public void TestTrackableCollection_Dequeue_Empty()
        {
            IQueue <Simple> coll = new TrackableCollection <Simple>();

            Assert.AreEqual(0, coll.Count());
            coll.Dequeue();
        }
예제 #6
0
        public void TestTrackableCollection_Dequeue(bool track)
        {
            var             acc  = new Accumulator("test");
            IQueue <Simple> coll = new TrackableCollection <Simple>(acc, track);

            Assert.AreEqual(0, coll.Count());
            var a = new Simple("a");
            var b = new Simple("b");

            coll.Enqueue(a);
            coll.Enqueue(b);
            var a1 = coll.Dequeue();

            Assert.AreEqual(a, a1);
            Assert.AreEqual(1, coll.Count());
            var b1 = coll.Dequeue();

            Assert.AreEqual(b, b1);
            Assert.AreEqual(0, coll.Count());

            if (track)
            {
                Assert.AreEqual(4, acc.Records.Count);
            }
            else
            {
                Assert.AreEqual(0, acc.Records.Count);
            }
        }
예제 #7
0
        public void TestTrackableCollection_Pop_Empty()
        {
            IStack <Simple> coll = new TrackableCollection <Simple>();

            Assert.AreEqual(0, coll.Count());
            coll.Pop();
        }
예제 #8
0
        public void TestTrackableCollection_TryPop(bool track)
        {
            var             acc  = new Accumulator("test");
            IStack <Simple> coll = new TrackableCollection <Simple>(acc, track);

            Assert.AreEqual(0, coll.Count());
            var a = new Simple("a");
            var b = new Simple("b");

            coll.Push(a);
            coll.Push(b);
            Assert.IsTrue(coll.TryPop(out var b1));
            Assert.AreEqual(b, b1);
            Assert.AreEqual(1, coll.Count());
            Assert.IsTrue(coll.TryPop(out var a1));
            Assert.AreEqual(a, a1);
            Assert.AreEqual(0, coll.Count());
            Assert.IsFalse(coll.TryPop(out var c1));

            if (track)
            {
                Assert.AreEqual(4, acc.Records.Count);
            }
            else
            {
                Assert.AreEqual(0, acc.Records.Count);
            }
        }
예제 #9
0
        public void TestPropertyChanges()
        {
            var simple = new SimpleViewModel(true);
            var newC   = new TrackableCollection <string>();

            simple.ACollection = newC;
            Assert.AreEqual(simple.ACollection, newC);
            simple.ADouble = 5;
            Assert.AreEqual(simple.ADouble, 5);
            simple.AnInt = 5;
            Assert.AreEqual(simple.AnInt, 5);
            simple.AString = "yupperz";
            Assert.AreEqual(simple.AString, "yupperz");
            simple.AnEnum = SimpleViewModel.TestEnum.Three;
            Assert.AreEqual(SimpleViewModel.TestEnum.Three, simple.AnEnum);

            simple.NullableDouble = null;
            Assert.IsNull(simple.NullableDouble);
            simple.NullableInt = null;
            Assert.IsNull(simple.NullableInt);
            simple.NullableEnum = null;
            Assert.IsNull(simple.NullableEnum);
            simple.ACollection = null;
            Assert.IsNull(simple.ACollection);
            simple.StrongReference = null;
            Assert.IsNull(simple.StrongReference);
            simple.StrongReferenceBoxed = null;
            Assert.IsNull(simple.StrongReferenceBoxed);
        }
예제 #10
0
        public void TestTrackableCollection_Remove(bool track)
        {
            var acc  = new Accumulator("test");
            var b    = new Simple("b");
            var coll = new TrackableCollection <Simple>(acc, track)
            {
                new Simple("a"), b, new Simple("c")
            };

            Assert.IsTrue(coll.Remove(b));
            Assert.AreEqual(2, coll.Count);
            Assert.IsFalse(coll.Contains(b));
            coll.Add(b);
            Assert.AreEqual(3, coll.Count);
            Assert.IsTrue(coll.Contains(b));

            Assert.IsTrue(coll.Remove(b));
            Assert.AreEqual(2, coll.Count);
            Assert.IsFalse(coll.Contains(b));

            if (track)
            {
                Assert.AreEqual(6, acc.Records.Count);
            }
            else
            {
                Assert.AreEqual(0, acc.Records.Count);
            }
        }
예제 #11
0
        public void TestTrackableCollection_Move(bool track)
        {
            var acc  = new Accumulator("test");
            var a    = new Simple("a");
            var b    = new Simple("b");
            var c    = new Simple("c");
            var coll = new TrackableCollection <Simple>(acc, track)
            {
                a, b, c, b, c, b, b
            };

            coll.SafeMove(0, 3);
            Assert.AreEqual(2, coll.IndexOf(a));
            coll.SafeMove(3, 3);

            coll.SafeMove(1, 40); // should result in an Add

            coll.Clear();
            coll.Add(a);
            coll.SafeMove(0, 0);
            coll.SafeMove(0, 1);
            coll.Clear();
            coll.SafeMove(0, 0);

            if (track)
            {
                Assert.AreEqual(13, acc.Records.Count);
            }
            else
            {
                Assert.AreEqual(0, acc.Records.Count);
            }
        }
예제 #12
0
    bool PlanesFound()
    {
        if (planeManager == null)
        {
            return(false);
        }

        s_Planes = planeManager.trackables;
        return(s_Planes.count > 0);
    }
        private void SaveInventoryToDB(TrackableCollection <ItemInventoryRet> trackableCollection)
        {
            try
            {
                QBPOSEntities db = new QBPOSEntities();
                //RemoveAllIDbInventoryItems(db);
                foreach (ItemInventoryRet itm in trackableCollection)
                {
                    InventoryItem i = db.InventoryItems.FirstOrDefault(x => x.ListID == itm.ListID);
                    if (i == null)
                    {
                        i = new InventoryItem();
                        db.InventoryItems.Add(i);
                    }

                    i.ALU            = itm.ALU;
                    i.Attribute      = itm.Attribute;
                    i.DepartmentCode = itm.DepartmentCode;
                    i.ItemDesc1      = itm.Desc1;
                    i.ItemDesc2      = itm.Desc2;
                    i.ItemNumber     = System.Convert.ToInt32(itm.ItemNumber);
                    i.ItemType       = itm.ItemType;
                    i.ListID         = itm.ListID;
                    i.Price          = Convert.ToDouble(itm.Price1);
                    i.Size           = itm.Size;
                    i.TaxCode        = itm.TaxCode;
                    i.UnitOfMeasure  = itm.UnitOfMeasure;
                }
                try
                {
                    db.SaveChanges();
                    System.Windows.MessageBox.Show("Inventory Items Import Complete");
                }

                catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine(
                            "Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                            eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                              ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    throw;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #14
0
        public async Task TestUndo()
        {
            var simple    = new SimpleViewModel(true);
            var originalC = simple.ACollection;

            Assert.AreEqual(0, originalC.Count);
            var origBoxed  = simple.StrongReferenceBoxed;
            var origStrong = simple.StrongReference;
            var acc        = new Accumulator("test");

            simple.Accumulator = acc;
            var newC = new TrackableCollection <string>(acc, true);

            simple.ACollection = newC;
            Assert.AreEqual(simple.ACollection, newC);
            newC.Add("poop");
            newC.Add("stinks");

            simple.ADouble = 5;
            Assert.AreEqual(simple.ADouble, 5);
            simple.AnInt = 5;
            Assert.AreEqual(simple.AnInt, 5);
            simple.AString = "yupperz";
            Assert.AreEqual(simple.AString, "yupperz");
            simple.AnEnum = SimpleViewModel.TestEnum.Three;
            Assert.AreEqual(SimpleViewModel.TestEnum.Three, simple.AnEnum);

            simple.NullableDouble = null;
            Assert.IsNull(simple.NullableDouble);
            simple.NullableInt = null;
            Assert.IsNull(simple.NullableInt);
            simple.NullableEnum = null;
            Assert.IsNull(simple.NullableEnum);
            simple.ACollection = null;
            Assert.IsNull(simple.ACollection);
            simple.StrongReference = null;
            Assert.IsNull(simple.StrongReference);
            simple.StrongReferenceBoxed = null;
            Assert.IsNull(simple.StrongReferenceBoxed);

            Assert.AreEqual(13, acc.Records.Count);

            await acc.UndoAll(acc.Name);

            Assert.AreEqual(simple.AString, nameof(SimpleViewModel.AString));
            Assert.AreEqual(simple.AnInt, 542);
            Assert.AreEqual(simple.ADouble, 542);
            Assert.AreEqual(simple.StrongReferenceBoxed, origBoxed);
            Assert.AreEqual(simple.StrongReference, origStrong);
            Assert.AreEqual(simple.ACollection, originalC);
            Assert.AreEqual(0, originalC.Count);
            Assert.AreEqual(simple.NullableInt, 0);
            Assert.AreEqual(simple.NullableDouble, 0);
            Assert.AreEqual(simple.NullableEnum, SimpleViewModel.TestEnum.Two);
        }
예제 #15
0
        public void TestTrackableCollection_Move_BadIndex()
        {
            var a    = new Simple("a");
            var b    = new Simple("b");
            var c    = new Simple("c");
            var coll = new TrackableCollection <Simple>()
            {
                a, b, c, b, c, b, b
            };

            coll.SafeMove(-1, 10);
        }
        private void SaveToDataBase(TrackableCollection <SalesReceiptRet> trackableCollection)
        {
            try
            {
                POSAIData.POSAIEntities db = new POSAIData.POSAIEntities();
                foreach (SalesReceiptRet saleReceipt in trackableCollection)
                {
                    POSAIData.SalesReceipt sr = new POSAIData.SalesReceipt();

                    RemoveExistingDbReceipts(db, saleReceipt);

                    sr.SalesReceiptNumber = saleReceipt.SalesReceiptNumber;
                    sr.TxnDate            = saleReceipt.TxnDate;

                    // do details
                    foreach (POSAI_mvvm.QuickBooks.SalesReceiptRetSalesReceiptItemRet saleReceiptDetail in saleReceipt.SalesReceiptItems)
                    {
                        POSAIData.SalesReceiptDetails itm = new POSAIData.SalesReceiptDetails();
                        itm.ItemListID = saleReceiptDetail.ListID;
                        itm.Tax        = saleReceiptDetail.TaxAmount;
                        itm.QtySold    = System.Convert.ToDecimal(saleReceiptDetail.Qty);
                        itm.ItemKey    = saleReceiptDetail.Desc1 + "|" + saleReceiptDetail.Desc2 + "|" + saleReceiptDetail.Attribute + "|" + saleReceiptDetail.Size;
                        itm.ItemALU    = saleReceiptDetail.ALU;
                        itm.ItemDesc1  = saleReceiptDetail.Desc1;
                        itm.ItemDesc2  = saleReceiptDetail.Desc2;
                        sr.SalesReceiptDetails.Add(itm);
                    }
                    db.SalesReceipts.Add(sr);
                }

                db.SaveChanges();
                MessageBox.Show("Sale Receipt Import Complete");
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #17
0
        public void TestTrackableCollection_Last()
        {
            var a    = new Simple("a");
            var b    = new Simple("b");
            var c    = new Simple("c");
            var coll = new TrackableCollection <Simple>()
            {
                a, b, c, b, c, b, b
            };
            var last = coll.Last();

            Assert.AreEqual(b, last);
        }
예제 #18
0
        public void TestTrackableCollection_First_Empty()
        {
            var a    = new Simple("a");
            var b    = new Simple("b");
            var c    = new Simple("c");
            var coll = new TrackableCollection <Simple>()
            {
                a, b, c, b, c, b, b
            };

            coll.Clear();
            coll.First();
        }
        private void SaveToDataBase(TrackableCollection <InventoryQtyAdjustmentRet> trackableCollection)
        {
            try
            {
                POSAIData.POSAIEntities db = new POSAIData.POSAIEntities();



                foreach (InventoryQtyAdjustmentRet qbadj in trackableCollection)
                {
                    RemoveExistingAdjustment(db, qbadj);

                    POSAIData.InventoryAdjustment adj = new POSAIData.InventoryAdjustment();
                    adj.AdjustmentNumber = qbadj.InventoryAdjustmentNumber.ToString();
                    adj.AdjustmentSource = qbadj.InventoryAdjustmentSource;
                    adj.TxnDate          = qbadj.TxnDate;
                    adj.TxnID            = qbadj.TxnID;

                    foreach (var qbadjitm in qbadj.InventoryQtyAdjustmentItemRet)
                    {
                        POSAIData.InventoryAdjustmentItem adjitm = new POSAIData.InventoryAdjustmentItem();
                        adjitm.ItemListID         = qbadjitm.ListID;
                        adjitm.NewQuantity        = qbadjitm.NewQuantity;
                        adjitm.OldQuantity        = qbadjitm.OldQuantity;
                        adjitm.QuantityDifference = qbadjitm.QtyDifference;
                        adj.InventoryAdjustmentItems.Add(adjitm);
                    }
                    db.InventoryAdjustments.Add(adj);
                }
                db.SaveChanges();
                MessageBox.Show("Inventory Adjustment Import Complete");
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #20
0
        public void TestTrackableCollection_ReverseIndexOf()
        {
            var b    = new Simple("b");
            var c    = new Simple("c");
            var coll = new TrackableCollection <Simple>()
            {
                new Simple("a"), b, new Simple("c"), b, c
            };
            var idx = coll.ReverseIndexOf(b);

            Assert.AreEqual(3, idx);
            idx = coll.ReverseIndexOf(c);
            Assert.AreEqual(4, idx);
        }
예제 #21
0
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     try
     {
         TrackableCollection <PublicationLocalization> localizations = ((TrackableCollection <PublishedAction>)value)?.FirstOrDefault()?.Publication?.Localizations;
         string refName = (string)parameter;
         var    result  = localizations.SingleOrDefault(_ => _.ResourceKey == refName)?.Value;
         return(result ?? refName);
     }
     catch
     {
         return(Binding.DoNothing);
     }
 }
예제 #22
0
        public void TestTrackableCollection_Index()
        {
            var coll = new TrackableCollection <Simple>()
            {
                new Simple("a"), new Simple("b"), new Simple("c")
            };

            Assert.IsNotNull(coll[1]);
            Assert.AreEqual("b", coll[1].Value);

            coll[1] = new Simple("d");
            Assert.IsNotNull(coll[1]);
            Assert.AreEqual("d", coll[1].Value);
            Assert.AreEqual(3, coll.Count);
        }
예제 #23
0
    void InitUpdate()
    {
        // プレーンを取得
        ARPlaneManager aRPlaneManager = FindObjectOfType <ARPlaneManager>();
        TrackableCollection <ARPlane> trackableCollection = aRPlaneManager.trackables;

        // プレーンを取得できた場合、ボタンを活性化する
        if (trackableCollection.count > 0)
        {
            gameStartButton.GetComponent <Button>().interactable = true;
            arReloadButton.GetComponent <Button>().interactable  = true;
            arSearchImage.SetActive(false);
            playTrackableCollection = trackableCollection;
        }
    }
예제 #24
0
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     try
     {
         TrackableCollection <PublicationLocalization> localizations = ((TrackableCollection <PublishedAction>)value)?.FirstOrDefault()?.Publication?.Localizations;
         ProcessReferentialIdentifier refID = (ProcessReferentialIdentifier)parameter;
         string refName = refID.ToString();
         var    result  = localizations?.SingleOrDefault(_ => _.ResourceKey == refName)?.Value;
         return(result);
     }
     catch
     {
         return(Binding.DoNothing);
     }
 }
예제 #25
0
        public void TestTrackableCollection_Contains()
        {
            var b    = new Simple("b");
            var coll = new TrackableCollection <Simple>()
            {
                new Simple("a"), b, new Simple("c")
            };

            Assert.IsTrue(coll.Contains(b));
            var d = new Simple("d");

            Assert.IsFalse(coll.Contains(d));
            coll.Add(d);
            Assert.IsTrue(coll.Contains(d));
        }
예제 #26
0
        public void TestPropertyChanged()
        {
            var simple = new SimpleViewModel(true);
            Dictionary <string, int> propChanges = new Dictionary <string, int>();

            simple.PropertyChanged += (s, e) =>
            {
                if (propChanges.ContainsKey(e.PropertyName))
                {
                    propChanges[e.PropertyName]++;
                }
                else
                {
                    propChanges[e.PropertyName] = 1;
                }
            };
            var newC = new TrackableCollection <string>();

            simple.ACollection = newC;
            Assert.AreEqual(simple.ACollection, newC);
            simple.ADouble = 5;
            Assert.AreEqual(simple.ADouble, 5);
            simple.AnInt = 5;
            Assert.AreEqual(simple.AnInt, 5);
            simple.AString = "yupperz";
            Assert.AreEqual(simple.AString, "yupperz");
            simple.AnEnum = SimpleViewModel.TestEnum.Three;
            Assert.AreEqual(SimpleViewModel.TestEnum.Three, simple.AnEnum);

            simple.NullableDouble = null;
            Assert.IsNull(simple.NullableDouble);
            simple.NullableInt = null;
            Assert.IsNull(simple.NullableInt);
            simple.NullableEnum = null;
            Assert.IsNull(simple.NullableEnum);
            simple.ACollection = null;
            Assert.IsNull(simple.ACollection);
            simple.StrongReference = null;
            Assert.IsNull(simple.StrongReference);
            simple.StrongReferenceBoxed = null;
            Assert.IsNull(simple.StrongReferenceBoxed);

            foreach (var prop in simple.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Where(p => p.CanRead && p.CanWrite && p.Name != nameof(TrackableViewModel.Accumulator)))
            {
                Assert.IsTrue(propChanges.ContainsKey(prop.Name), $"Property {prop.Name} was not raised!");
                Assert.IsTrue(propChanges[prop.Name] > 0 && propChanges[prop.Name] < 3);
            }
        }
예제 #27
0
        /// <summary>
        ///
        /// </summary>
        public TreeViewExt() : base()
        {
            DefaultStyleKey = typeof(TreeViewExt);

            Columns       = new TreeViewColumnCollection();
            SelectedIndex = new int[1] {
                -1
            };
            SelectedItems = new TrackableCollection <object>();

            GotFocus += OnGotFocus;

            SelectedItemChanged        += OnSelectedItemChanged;
            SelectedItems.ItemsChanged += OnSelectedItemsChanged;

            this.Bind(TreeViewExtensions.SelectedItemsProperty, this, "SelectedItems");
        }
예제 #28
0
 public SimpleViewModel(bool setup)
 {
     if (!setup)
     {
         return;
     }
     AString = nameof(AString);
     AnInt   = 542;
     ADouble = 542.0;
     StrongReferenceBoxed = new SimpleViewModel(false);
     StrongReference      = new SimpleViewModel(false);
     NullableInt          = 0;
     NullableDouble       = 0;
     NullableEnum         = TestEnum.Two;
     AnEnum      = TestEnum.Two;
     ACollection = new TrackableCollection <string>();
 }
예제 #29
0
 private Wallet(string path, byte[] passwordKey, bool create)
 {
     this.path = path;
     if (create)
     {
         this.iv             = new byte[16];
         this.masterKey      = new byte[32];
         this.accounts       = new Dictionary <UInt160, Account>();
         this.contracts      = new Dictionary <UInt160, Contract>();
         this.coins          = new TrackableCollection <TransactionInput, Coin>();
         this.current_height = Blockchain.Default?.HeaderHeight + 1 ?? 0;
         using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
         {
             rng.GetNonZeroBytes(iv);
             rng.GetNonZeroBytes(masterKey);
         }
         Version current_version = Assembly.GetExecutingAssembly().GetName().Version;
         BuildDatabase();
         SaveStoredData("PasswordHash", passwordKey.Sha256());
         SaveStoredData("IV", iv);
         SaveStoredData("MasterKey", masterKey.AesEncrypt(passwordKey, iv));
         SaveStoredData("Version", new[] { current_version.Major, current_version.Minor, current_version.Build, current_version.Revision }.Select(p => BitConverter.GetBytes(p)).SelectMany(p => p).ToArray());
         SaveStoredData("Height", BitConverter.GetBytes(current_height));
         ProtectedMemory.Protect(masterKey, MemoryProtectionScope.SameProcess);
     }
     else
     {
         byte[] passwordHash = LoadStoredData("PasswordHash");
         if (passwordHash != null && !passwordHash.SequenceEqual(passwordKey.Sha256()))
         {
             throw new CryptographicException();
         }
         this.iv        = LoadStoredData("IV");
         this.masterKey = LoadStoredData("MasterKey").AesDecrypt(passwordKey, iv);
         ProtectedMemory.Protect(masterKey, MemoryProtectionScope.SameProcess);
         this.accounts       = LoadAccounts().ToDictionary(p => p.PublicKeyHash);
         this.contracts      = LoadContracts().ToDictionary(p => p.ScriptHash);
         this.coins          = new TrackableCollection <TransactionInput, Coin>(LoadCoins());
         this.current_height = BitConverter.ToUInt32(LoadStoredData("Height"), 0);
     }
     Array.Clear(passwordKey, 0, passwordKey.Length);
     this.thread = new Thread(ProcessBlocks);
     this.thread.IsBackground = true;
     this.thread.Name         = "Wallet.ProcessBlocks";
     this.thread.Start();
 }
 public void ViewCases()
 {
     if (
         Hearings.Any(x => x.ChangeTracker.State != ObjectState.Unchanged) &&
         _dialogService.MessageBox("there are some docket items that just have been modified. Do you want to discard changes?", "Court Docket", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question) == System.Windows.MessageBoxResult.No
         
         )
     {
         return;
     }
     DataContainer.SearchDocket();
     _hearings = null;
     this.NotifyOfPropertyChange(() => Hearings);
     this.NotifyOfPropertyChange(() => DocketCount);
 }
 public void Save()
 {
     bool succeeded = false;
     try
     {
         DataContainer.SaveDocket();
         succeeded = true;
     }
     catch (Exception ex)
     {
         throw;
     }
     if (succeeded)
     {
         DataContainer.SearchDocket();
         _courtCases = null;
         NotifyOfPropertyChange(() => CourtCases);
         _hearings = null;
         this.NotifyOfPropertyChange(() => Hearings);
         this.NotifyOfPropertyChange(() => CanSave);
         this.NotifyOfPropertyChange(() => DocketCount);
     }
 }
 public LawersFeeAndCourtCosts()
 {
     LawyersFees = new TrackableCollection<IDataItem>();
 }
예제 #33
0
 /// <summary>
 /// 批次项下的转手的发货单确认数量
 /// </summary>
 /// <param name="deliverys"></param>
 /// <returns></returns>
 public decimal DeliveryQty(TrackableCollection<Delivery> deliverys)
 {
     using (var deliveryService = SvcClientManager.GetSvcClient<DeliveryServiceClient>(SvcType.DeliverySvc))
     {
         decimal dlvQty = 0;
         foreach (Delivery dlv in deliverys)
         {
             const string strInfo = "it.Id = @p1 ";
             var parameters = new List<object> { dlv.Id };
             Delivery delivery =
                 deliveryService.Select(strInfo, parameters, new List<string> { "DeliveryLines" }).FirstOrDefault();
             if (delivery != null)
             {
                 FilterDeleted(delivery.DeliveryLines);
                 foreach (DeliveryLine dlvLine in delivery.DeliveryLines)
                 {
                     if (dlvLine.IsVerified)
                     {
                         dlvQty += (dlvLine.VerifiedWeight == null
                                        ? 0
                                        : Convert.ToDecimal(dlvLine.VerifiedWeight));
                     }
                 }
             }
         }
         return dlvQty;
     }
 }
예제 #34
0
        public void Initialize()
        {
            _isPresentAmountCanEdit = true;
            using (var businessPartnerService = SvcClientManager.GetSvcClient<BusinessPartnerServiceClient>(SvcType.BusinessPartnerSvc))
            {
                List<BusinessPartner> list = businessPartnerService.GetInternalCustomersByUser(CurrentUser.Id);
                if (list.Count > 0)
                {
                    _idList = list.Select(c => c.Id).ToList();
                }

                _applicants = businessPartnerService.GetInternalCustomersByUser(CurrentUser.Id);
                _applicants.Insert(0, new BusinessPartner ());
            }

            _deliveries = new TrackableCollection<Delivery>();
            _showCommercialInvoiceLines = new TrackableCollection<CommercialInvoice>();
            BindCboList();

            if (ObjectId > 0)
            {
                LoadAttachments();
                using (
                    var letterOfCreditService =
                        SvcClientManager.GetSvcClient<LetterOfCreditServiceClient>(SvcType.LetterOfCreditSvc))
                {
                    const string strInfo = "it.Id = @p1 ";
                    var parameters = new List<object> {ObjectId};
                    LetterOfCredit letterOfCredit =
                        letterOfCreditService.Select(strInfo, parameters,
                                                     new List<string>
                                                         {
                                                             "Quota",
                                                             "Quota.Currency",
                                                             "BusinessPartner",
                                                             "BusinessPartner1",
                                                             "Currency",
                                                             "Deliveries",
                                                              "LCCIRels.CommercialInvoice"
                                                         }).FirstOrDefault();
                    if (letterOfCredit != null)
                    {
                        _amount = letterOfCredit.IssueAmount;
                        _lcNo = letterOfCredit.LCNo;
                        _lcType = letterOfCredit.LCType;
                        _lcStatusId = letterOfCredit.LCStatus;
                        _applicantId = letterOfCredit.ApplicantId;
                        _beneficiaryId = letterOfCredit.BeneficiaryId;
                        _beneficiaryName = letterOfCredit.BusinessPartner1.ShortName;
                        _currencyName = letterOfCredit.Currency.Name;
                        _currencyId = letterOfCredit.CurrencyId;
                        _lcDays = letterOfCredit.LCDays;
                        _promptBasisId = letterOfCredit.PromptBasis;
                        _advisingBankId = letterOfCredit.AdvisingBankId;
                        _issueBankId = letterOfCredit.IssueBankId;
                        _issueDate = letterOfCredit.IssueDate;
                        _issueQuantity = letterOfCredit.IssueQuantity;
                        _acceptanceExpiryDate = letterOfCredit.AcceptanceExpiryDate;
                        _lcExpiryDate = letterOfCredit.LCExpiryDate;
                        _latestShippmentDate = letterOfCredit.LatestShippmentDate;
                        _actualAcceptanceDate = letterOfCredit.ActualAcceptanceDate;
                        _presentAmount = letterOfCredit.PresentAmount;
                        _presentDate = letterOfCredit.PresentDate;
                        _comment = letterOfCredit.Comment;
                        _iborType = letterOfCredit.IBORType;
                        _financeStatus = letterOfCredit.FinancialStatus ? 1 : 0;
                        _iborValue = letterOfCredit.IBORValue;
                        _float = letterOfCredit.Float;
                        _interest = letterOfCredit.Interest;
                        _quotaNo = letterOfCredit.Quota == null ? "" : letterOfCredit.Quota.QuotaNo;
                        _selectedQuotaId = letterOfCredit.QuotaId;
                        _deliveries = letterOfCredit.Deliveries;
                        _paymentRequestId = letterOfCredit.PaymentRequestId;
                        if (letterOfCredit.Quota != null)
                        {
                            _IsLCFinished = letterOfCredit.Quota.IsFundflowFinished ?? true;
                        }
                        FilterDeleted(letterOfCredit.LCCIRels);

                        if (letterOfCredit.LCCIRels != null && letterOfCredit.LCCIRels.Count > 0)
                        {
                            _isPresentAmountCanEdit = false;
                            _showCommercialInvoiceLines.Clear();
                            foreach (var rel in letterOfCredit.LCCIRels)
                            {
                                _showCommercialInvoiceLines.Add(rel.CommercialInvoice);
                            }
                        }
                    }
                }
            }
            else
            {
                LCStatusId = (int)DBEntity.EnumEntity.LCStatus.Issued;
            }

            PropertyChanged += LetterOfCreditDetailVMPropertyChanged;
        }
예제 #35
0
 /// <summary>
 /// 信用证利息计算
 /// </summary>
 /// <param name="rcPromptBasis">到期的基准</param>
 /// <param name="rcPresentAmount">交单金额</param>
 /// <param name="rcDeliveries">信用证提单集合</param>
 /// <param name="rcFloat">信用证利息的浮点</param>
 /// <param name="rcIBORValue">拆借利率的利率值</param>
 /// <param name="rcDays">远期证的天数</param>
 /// <param name="rcIssueDate">开证日期</param>
 /// <returns></returns>
 public decimal LCRateCalculation(LCPromptBasis rcPromptBasis, decimal? rcPresentAmount,
                                  TrackableCollection<Delivery> rcDeliveries, decimal? rcFloat,
                                  decimal? rcIBORValue, int? rcDays, DateTime? rcIssueDate)
 {
     try
     {
         if (rcPresentAmount == null)
         {
             return 0;
         }
         rcFloat = (rcFloat ?? 0);
         rcIBORValue = (rcIBORValue ?? 0);
         rcDays = (rcDays ?? 0);
         
         decimal rate = (decimal) rcPresentAmount*
                            ((decimal) rcFloat*(decimal) 0.01 + (decimal) rcIBORValue*(decimal) 0.01)*(int) rcDays/360;
         return rate;
     }
     catch (Exception e)
     {
         throw new Exception(ResLetterOfCredit.InterestError + e.Message);
     }
 }
예제 #36
0
        /**
         * NEWLY ADDED 
         * IMPLEMENT GET ORDER BY EXTERNAL ID
         */
        public Order GetOrderByExternalId(String pId)
        {
            using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
            {
                Order lOrder = lContainer.Orders.Where((pOrder) => pOrder.ExternalId == pId).FirstOrDefault();
                User lUser = lContainer.Users.Where((pUser) => pUser.Id == lOrder.UserId).FirstOrDefault();
                lOrder.Customer = lUser;

                List<OrderItem> lOrderItems = lContainer.OrderItems.Where((pOrderItem) => pOrderItem.order_Id == lOrder.ExternalOrderId).ToList<OrderItem>();
                TrackableCollection<OrderItem> lTrackableOrderItems = new TrackableCollection<OrderItem>();

                foreach(OrderItem lItem in lOrderItems)
                {
                    Media lMedia = lContainer.Medias.Where((pMedia) => pMedia.Id == lItem.MediaId).FirstOrDefault();
                    Stock lStock = lContainer.Stocks.Where((pStock) => pStock.MediaId == lItem.MediaId).FirstOrDefault();
                    lMedia.Stocks = lStock;
                    lItem.Media = lMedia;

                    lTrackableOrderItems.Add(lItem);
                }

                lOrder.OrderItems = lTrackableOrderItems;

                return lOrder;
            }
        }
예제 #37
0
 /// <summary>
 /// 批次对应的出库的确认数量
 /// </summary>
 /// <param name="warehouseOuts"></param>
 /// <returns></returns>
 public decimal WarehouseOutQty(TrackableCollection<WarehouseOut> warehouseOuts)
 {
     using (
         var warehouseOutService =
             SvcClientManager.GetSvcClient<WarehouseOutServiceClient>(SvcType.WarehouseOutSvc))
     {
         decimal outQty = 0;
         foreach (WarehouseOut whs in warehouseOuts)
         {
             const string strInfo = "it.Id = @p1 ";
             var parameters = new List<object> { whs.Id };
             WarehouseOut wareHouseOut =
                 warehouseOutService.Select(strInfo, parameters, new List<string> { "WarehouseOutLines" }).
                     FirstOrDefault();
             if (wareHouseOut != null)
             {
                 FilterDeleted(wareHouseOut.WarehouseOutLines);
                 foreach (WarehouseOutLine whsLine in wareHouseOut.WarehouseOutLines)
                 {
                     if (whsLine.IsVerified != null && (bool)whsLine.IsVerified)
                     {
                         outQty += (whsLine.VerifiedQuantity == null
                                        ? 0
                                        : Convert.ToDecimal(whsLine.VerifiedQuantity));
                     }
                 }
             }
         }
         return outQty;
     }
 }
예제 #38
0
		/// <summary>
		/// 获取银行
		/// </summary>
		/// <returns></returns>
		public void SetBankAccounts(int id)
		{
			using (
				var bankAccountService =
					SvcClientManager.GetSvcClient<BankAccountServiceReference.BankAccountServiceClient>(SvcType.BankAccountSvc))
			{
				const string strQuery = "it.BusinessPartnerId = @p1 ";
				var parameters = new List<object> { id };
				List<BankAccount> baList = bankAccountService.SelectByRange(strQuery, parameters,
																	BankForm, BankTo, new List<string> { "Bank", "Currency" });
				if (BankAccounts == null) 
				{
					BankAccounts = new TrackableCollection<BankAccount>();
				}
				
				BankAccounts.Clear();
				foreach (var item in baList) 
				{
					BankAccounts.Add(item);
				}
			}
		}