Example #1
0
 public void Exec()
 {
     using (var orderSync = new OrderSync())
     {
         orderSync.UpdateFromWeb();
     }
 }
Example #2
0
 void orderSync_SyncEnded(object sender, EventArgs e)
 {
     this.Dispatcher.BeginInvoke(new Action(() => MessageBox.Show("同步完成")));
     this.Dispatcher.BeginInvoke(new Action(() => this.btnUpdate.Content = "开始同步"));
     orderSync.SyncSarting -= orderSync_SyncSarting;
     orderSync.SyncEnded   -= orderSync_SyncEnded;
     orderSync.Syncing     -= orderSync_SyncSarting;
     this.orderSync         = null;
 }
Example #3
0
        public void OrderSync_Test_06()
        {
            StringSynCollection left  = new StringSynCollection(null);
            StringSynCollection right = new StringSynCollection(null);

            OrderSync.Sync(left, right);
            Assert.AreEqual(0, left.Equal.Count);
            Assert.AreEqual(0, right.Equal.Count);
            Assert.AreEqual(0, left.Less.Count);
            Assert.AreEqual(0, right.Less.Count);
            Assert.AreEqual(0, left.More.Count);
            Assert.AreEqual(0, right.More.Count);
        }
Example #4
0
        public void OrderSync_Test_05()
        {
            StringSynCollection left  = new StringSynCollection("a", "b", "c", "g", "i", "j");
            StringSynCollection right = new StringSynCollection("a", "b", "c", "g", "i", "k");

            OrderSync.Sync(left, right);
            Assert.AreEqual(5, left.Equal.Count);
            Assert.AreEqual(5, right.Equal.Count);
            Assert.AreEqual(1, left.Less.Count);
            Assert.AreEqual(0, right.Less.Count);
            Assert.AreEqual(0, left.More.Count);
            Assert.AreEqual(1, right.More.Count);
        }
Example #5
0
        public void OrderSync_Test_02()
        {
            StringSynCollection left  = new StringSynCollection(null);
            StringSynCollection right = new StringSynCollection("a", "b", "h", "i", "k", "m", "p", "z");

            OrderSync.Sync(left, right);
            Assert.AreEqual(0, left.Equal.Count);
            Assert.AreEqual(0, right.Equal.Count);
            Assert.AreEqual(0, left.Less.Count);
            Assert.AreEqual(0, right.Less.Count);
            Assert.AreEqual(0, left.More.Count);
            Assert.AreEqual(8, right.More.Count);
        }
Example #6
0
        public void OrderSync_Test_01()
        {
            StringSynCollection left  = new StringSynCollection("a", "b", "c", "g", "i", "j");
            StringSynCollection right = new StringSynCollection("a", "b", "h", "i", "k", "m", "p", "z");

            OrderSync.Sync(left, right);
            Assert.AreEqual(3, left.Equal.Count);  //abi
            Assert.AreEqual(3, right.Equal.Count); //abi
            Assert.AreEqual(3, left.Less.Count);   //cgj
            Assert.AreEqual(1, right.Less.Count);  //h
            Assert.AreEqual(0, left.More.Count);
            Assert.AreEqual(4, right.More.Count);  //kmpz
        }
Example #7
0
        protected override void OnActivate()
        {
            try
            {
                var mainMenu  = new MainMenu();
                var orderSync = new OrderSync();

                modules.Add(mainMenu);

                var mainModules = new Dictionary <Type, object>
                {
                    { typeof(IMainMenu), mainMenu },
                    { typeof(IOrderSync), orderSync }
                };

                foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
                {
                    if (!type.IsClass || !typeof(IModule).IsAssignableFrom(type))
                    {
                        continue;
                    }

                    if (type == typeof(MainMenu))
                    {
                        continue;
                    }

                    var constructor = type.GetConstructors()[0];

                    var parameters       = constructor.GetParameters();
                    var objectParameters = new object[parameters.Length];

                    for (var i = 0; i < parameters.Length; i++)
                    {
                        var parameter = parameters[i];
                        objectParameters[i] = mainModules[parameter.ParameterType];
                    }

                    modules.Add((IModule)Activator.CreateInstance(type, objectParameters));
                }

                foreach (var module in this.modules.OrderByDescending(x => x is IMainMenu))
                {
                    module.Activate();
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
Example #8
0
        private void Start()
        {
            try
            {
                if (this.orderSync != null)
                {
                    this.orderSync.Stop();
                    return;
                }
                Shop[] shops        = null;
                var    selectedShop = this.cbbShops.SelectedItem as Shop;
                if (selectedShop == null || selectedShop.Id == 0)
                {
                    shops = this.cbbShops.ItemsSource.OfType <Shop>().Where(obj => obj.Id > 0).ToArray();
                }
                else
                {
                    shops = new Shop[] { selectedShop };
                }

                var popOrderId = this.tbPopOrderId.Text.Trim();
                if (string.IsNullOrWhiteSpace(popOrderId) == false && this.cbbShops.SelectedIndex < 1)
                {
                    throw new Exception("订单编号不为空,则必须选择一个店铺");
                }
                this.orderSync              = new OrderSync(shops, this.dpStart.Value.Value, this.dpEnd.Value.Value, popOrderId);
                this.orderSync.SyncSarting += orderSync_SyncSarting;
                this.orderSync.Syncing     += orderSync_Syncing;
                this.orderSync.SyncEnded   += orderSync_SyncEnded;
                this.orderSync.StartUpdate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }