Ejemplo n.º 1
0
 private async void StoreItemLoaded(object sender, RoutedEventArgs e)
 {
     try
     {
         var bitmap = new BitmapImage();
         bitmap.BeginInit();
         string imageFilePath = "";
         try
         {
             imageFilePath = await StoreCache.CacheLookup((((StackPanel)e.Source).Children[1] as TextBlock)?.Text);
         }
         catch
         {
             imageFilePath = "Ressources/script.png";
         }
         var stream = File.OpenRead(imageFilePath);
         //bitmap.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
         bitmap.CacheOption  = BitmapCacheOption.OnLoad;
         bitmap.StreamSource = stream;
         bitmap.EndInit();
         stream.Close();
         stream.Dispose();
         var brush = new ImageBrush {
             Stretch = Stretch.UniformToFill, ImageSource = bitmap
         };
         ((Ellipse)((StackPanel)e.Source).Children[0]).Fill = brush;
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
Ejemplo n.º 2
0
        public object removeStore(Dictionary <string, object> dicParas)
        {
            try
            {
                string        storeId      = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty;
                IStoreService storeService = BLLContainer.Resolve <IStoreService>();
                var           storeModel   = storeService.GetModels(p => p.id.ToString().Equals(storeId)).FirstOrDefault <t_store>();
                if (storeModel == null)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店不存在"));
                }

                if (storeService.Delete(storeModel))
                {
                    List <StoreCacheModel> list            = StoreCache.GetStore();
                    StoreCacheModel        storeCacheModel = list.Where <StoreCacheModel>(p => p.StoreID == int.Parse(storeId)).FirstOrDefault <StoreCacheModel>();
                    if (storeCacheModel != null)
                    {
                        list.Remove(storeCacheModel);
                    }
                }

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 3
0
 public ExtensionEventStoreWithCacheTests()
     : base(
         StoreCache.NewUsing(
             new List <AggregateTypeCacheExpiration> { AggregateTypeCacheExpiration.Of(nameof(User), TimeSpan.FromSeconds(10)) },
             EventStoreAdapter.Store.NewUsing("tcp://localhost:1113", "TestStore")))
 {
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Objects for all chains this server is participating in
        /// </summary>
        //private Dictionary<Hash, BlockChain> ParticipatingChains = new Dictionary<Hash, BlockChain>();

        //private Dictionary<Hash, User> KnownUsers = new Dictionary<Hash, User>();


        public void Initialize(Hash.HashProvider Provider)
        {
            if (StoreCache != null)
            {
                StoreCache.Initialize();
            }

            KnownPeers = new ConsistentHash <Peer>(Provider);
        }
Ejemplo n.º 5
0
        public void Dispose()
        {
            if (StoreCache != null)
            {
                StoreCache.Dispose();
            }

            foreach (var client in KnownPeers.AllNodes)
            {
                client.Dispose();
            }
        }
Ejemplo n.º 6
0
 private void Window_Closing(object sender, CancelEventArgs e)
 {
     if (Content.GetType() != typeof(StoreDetailView))
     {
         StoreCache.Clear();
         Kernel.StoreWindow = null;
         GC.Collect();
         return;
     }
     Title    = "VOTC Store";
     e.Cancel = true;
     Content  = new StoreUi();
     GC.Collect(10, GCCollectionMode.Forced);
 }
Ejemplo n.º 7
0
        public static void StoreInit()
        {
            string        errMsg       = string.Empty;
            IStoreService storeService = BLLContainer.Resolve <IStoreService>();
            string        sql          = " select ID as StoreID,store_password as StorePassword,store_dbname as StoreDBName,companyname as StoreName,StoreType,StoreDBDeployType from t_store where state = 1";

            System.Data.DataSet ds = XCGameManabll.ExecuteQuerySentence(sql, null);
            DataTable           dt = ds.Tables[0];

            if (dt.Rows.Count > 0)
            {
                var list = Utils.GetModelList <StoreCacheModel>(ds.Tables[0]).ToList();
                StoreCache.Add(list);
            }
        }
Ejemplo n.º 8
0
        public bool IsEffectiveStore(string storeId, out string errMsg)
        {
            errMsg = string.Empty;
            List <StoreCacheModel> list = StoreCache.GetStore();
            var model = list.Where <StoreCacheModel>(p => p.StoreID.ToString().Equals(storeId)).FirstOrDefault <StoreCacheModel>();

            if (model == null)
            {
                errMsg = "门店信息不存在";
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 9
0
        public bool IsEffectiveStore(string storeId, out XCGameManaDeviceStoreType deviceStoreType, ref StoreCacheModel storeModel, out string errMsg)
        {
            errMsg          = string.Empty;
            deviceStoreType = XCGameManaDeviceStoreType.Store;
            List <StoreCacheModel> list = StoreCache.GetStore();
            var model = list.Where <StoreCacheModel>(p => p.StoreID.ToString().Equals(storeId)).FirstOrDefault <StoreCacheModel>();

            if (model == null)
            {
                errMsg = "门店信息不存在";
                return(false);
            }
            else
            {
                storeModel      = model;
                deviceStoreType = (XCGameManaDeviceStoreType)(storeModel.StoreType);
                return(true);
            }
        }
Ejemplo n.º 10
0
        public T Get <T>(ComparableBytesAbstract Key) where T : Hashable
        {
            if (StoreCache.Exists(Key))
            {
                return(StoreCache.Get <T>(Key));
            }
            else
            {
                //try and get from the closest peer
                if (KnownPeers.NodeCount > 0)
                {
                    var closestPeer = GetPeer(Key);

                    if (closestPeer != null)
                    {
                        return(closestPeer.TryGet <T>(Key));
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 11
0
        public static ApplicationContainer Build(
            string connectionString,
            string eventStoreName,
            IReadOnlyList <AggregateTypeCacheExpiration> aggregateTypeCacheExpirations)
        {
            var store               = Store.NewUsing(connectionString, eventStoreName);
            var cachedStore         = StoreCache.NewUsing(aggregateTypeCacheExpirations, store);
            var domainEventResolver = NewtonSoftDomainEventResolver.New();

            var commandHandlerContainer = CommandHandlerContainerBuilder.New()
                                          .Use(cachedStore)
                                          .Build();

            var domainEventHandlerContainer = DomainEventHandlerContainerBuilder.New()
                                              .Use(cachedStore)
                                              .Build();

            return(new ApplicationContainer(
                       commandHandlerContainer,
                       domainEventHandlerContainer,
                       domainEventResolver));
        }
Ejemplo n.º 12
0
 public StoreServicesCaches(StoreCache store)
 {
     Data = store;
 }
Ejemplo n.º 13
0
        public void Setup()
        {
            var Data = new StoreCache();

            services = new StoreServicesCaches(Data);
        }
Ejemplo n.º 14
0
        public object updateStore(Dictionary <string, object> dicParas)
        {
            string errMsg         = string.Empty;
            string storeId        = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty;
            string companyname    = dicParas.ContainsKey("companyname") ? dicParas["companyname"].ToString() : string.Empty;
            string province       = dicParas.ContainsKey("province") ? dicParas["province"].ToString() : string.Empty;
            string address        = dicParas.ContainsKey("address") ? dicParas["address"].ToString() : string.Empty;
            string boss           = dicParas.ContainsKey("boss") ? dicParas["boss"].ToString() : string.Empty;
            string phone          = dicParas.ContainsKey("phone") ? dicParas["phone"].ToString() : string.Empty;
            string telphone       = dicParas.ContainsKey("telphone") ? dicParas["telphone"].ToString() : string.Empty;
            string clienttype     = dicParas.ContainsKey("clienttype") ? dicParas["clienttype"].ToString() : string.Empty;
            string power_due_date = dicParas.ContainsKey("power_due_date") ? dicParas["power_due_date"].ToString() : string.Empty;
            string note           = dicParas.ContainsKey("note") ? dicParas["note"].ToString() : string.Empty;
            string parentid       = dicParas.ContainsKey("parentid") ? dicParas["parentid"].ToString() : string.Empty;
            string developer      = dicParas.ContainsKey("developer") ? dicParas["developer"].ToString() : string.Empty;
            string store_password = dicParas.ContainsKey("store_password") ? dicParas["store_password"].ToString() : string.Empty;
            string wxfee          = dicParas.ContainsKey("wxfee") ? dicParas["wxfee"].ToString() : string.Empty;

            if (!CheckAddStore(dicParas, out errMsg))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
            }

            IStoreService storeService = BLLContainer.Resolve <IStoreService>();
            var           store        = storeService.GetModels(p => p.id.ToString().Equals(storeId)).FirstOrDefault <t_store>();

            if (store == null)
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店不存在"));
            }

            string store_dbname = string.Empty;

            store.companyname    = companyname;
            store.province       = province;
            store.address        = address;
            store.boss           = boss;
            store.phone          = phone;
            store.telphone       = telphone;
            store.clienttype     = clienttype;
            store.createtime     = System.DateTime.Now;
            store.updatetime     = System.DateTime.Now;
            store.power_due_date = System.DateTime.Parse(System.DateTime.Parse(power_due_date).ToString("yyyy-MM-dd") + " 00:00:00");
            store.note           = note;
            store.parentid       = parentid;
            store.developer      = developer;
            store.store_password = store_password;
            store.store_dbname   = "xcgamedb" + storeId;
            store.wxfee          = Convert.ToDecimal(decimal.Parse(wxfee) / 1000);

            if (storeService.Update(store))
            {
                List <StoreCacheModel> list            = StoreCache.GetStore();
                StoreCacheModel        storeCacheModel = list.Where <StoreCacheModel>(p => p.StoreID == int.Parse(storeId)).FirstOrDefault <StoreCacheModel>();
                if (storeCacheModel == null)
                {
                    StoreCacheModel model = new StoreCacheModel();
                    model.StoreID       = int.Parse(storeId);
                    model.StoreName     = companyname;
                    model.StorePassword = store_password;
                    model.StoreType     = Convert.ToInt32(store.StoreType);
                    model.StoreDBName   = store.store_dbname;
                    list.Add(model);
                }
                else
                {
                    storeCacheModel.StoreName     = companyname;
                    storeCacheModel.StorePassword = store_password;
                    storeCacheModel.StoreType     = Convert.ToInt32(store.StoreType);
                    storeCacheModel.StoreDBName   = store.store_dbname;
                }
            }

            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
        }
Ejemplo n.º 15
0
        public async Task GetStream(int retryCount)
        {
            TwitterClient client = new TwitterClient(accessToken);

            IsStreamRunning       = true;
            IsStreamRunningString = "Streaming...";
            try
            {
                await client.GetStream(async (tweet) =>
                {
                    if (tweet != null)
                    {
                        switch (tweet.tweetRole)//ここでいろいろ振り分けるぞ~^^
                        {
                        case AdvancedTweet.TweetRoles.Tweet:
                            tweetColumns[0].tweetList.Insert(0, tweet);
                            var user = tweet.tweet.entities.user_mentions.Where(x => x.screen_name == accessToken.screenName).FirstOrDefault();
                            if (user != null)
                            {
                                tweetColumns[1].tweetList.Insert(0, tweet);
                            }
                            break;

                        case AdvancedTweet.TweetRoles.Event:
                            break;

                        case AdvancedTweet.TweetRoles.Delete:
                            break;

                        case AdvancedTweet.TweetRoles.Friends:
                            var storage = new StoreSettings();
                            var cache   = new StoreCache();
                            List <User> friends;

                            if (TmpUserData.Friends == null)
                            {
                                TmpUserData.Friends = new ObservableCollection <User>();
                            }

                            var prev = storage.TryGetValueWithDefault("FriendCount" + accessToken.screenName, 0);

                            if (prev == tweet.friends.friends.Count)
                            {
                                friends = await cache.TryLoadCache <List <User> >("FriendObject" + accessToken.screenName);
                                if (friends == null)
                                {
                                    var friendsClient = new TwitterClient(accessToken);
                                    friends           = await friendsClient.GetUsersDetailsByIds(tweet.friends.friends);
                                    storage.AddOrUpdateValue("FriendCount" + accessToken.screenName, tweet.friends.friends.Count);
                                    await cache.SaveCache("FriendObject" + accessToken.screenName, friends);
                                }
                            }
                            else
                            {
                                var friendsClient = new TwitterClient(accessToken);
                                friends           = await friendsClient.GetUsersDetailsByIds(tweet.friends.friends);
                                storage.AddOrUpdateValue("FriendCount" + accessToken.screenName, tweet.friends.friends.Count);
                                await cache.SaveCache("FriendObject" + accessToken.screenName, friends);
                            }

                            if (friends != null)
                            {
                                foreach (var friend in friends)
                                {
                                    TmpUserData.Friends.Add(friend);
                                }
                            }
                            break;

                        default:
                            break;
                        }
                        foreach (var column in tweetColumns)
                        {
                            var count = column.tweetList.Count;
                            if (count > tweetCountUpper)
                            {
                                column.tweetList.RemoveAt(count - 2);
                                column.tweetList.RemoveAt(count - 3);
                            }
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                if (retryCount < 3)
                {
                    var message = new MessageDialog("ユーザーストリームへの接続に失敗しました。リトライします。" + ex.Message, "おや?なにかがおかしいようです。");
                    await message.ShowAsync();
                    await GetStream(++retryCount);
                }
                else
                {
                    IsStreamRunning       = false;
                    IsStreamRunningString = "Disconnected.";
                    var message = new MessageDialog("ユーザーストリームへの接続に3回連続で失敗しました。ネットワークへの接続を確認してください。:" + ex.Message, "おや?なにかがおかしいようです。");
                    await message.ShowAsync();
                }
            }
        }