コード例 #1
0
        public static bool RemoveToken(Guid token)
        {
            TokenInfo tinfo = GetToken(token);

            DistributedCacheManage.RemoveCache("tokenList", tinfo.UserId + (char)1 + tinfo.tokenId.ToString());
            return(true);
        }
コード例 #2
0
        public void DistributedAllCacheSync(List <CacheObject> cachelist)
        {
            foreach (var cache in cachelist)
            {
                DistributedCacheManage.SyncLocalCache(cache);
            }

            //客户端回调
            IClientService mCallBack = OperationContext.Current.GetCallbackChannel <IClientService>();

            //异步执行同步缓存
            new Action <List <CacheObject> >(delegate(List <CacheObject> _cachelist)
            {
                List <WCFClientInfo> clist = WcfServerManage.wcfClientDic.Values.ToList().FindAll(x => (x.plugin == "SuperPlugin" && x.IsConnect == true));
                foreach (var client in clist)
                {
                    //排除自己给自己同步缓存
                    if (mCallBack == client.callbackClient || WcfServerManage.Identify == client.ServerIdentify)
                    {
                        continue;
                    }
                    else
                    {
                        //将上级中间件的缓存同步到下级中间件
                        client.callbackClient.DistributedAllCacheSync(_cachelist);
                    }
                }
            }).BeginInvoke(cachelist, null, null);
        }
コード例 #3
0
ファイル: bookWcfController.cs プロジェクト: hongfagj/efwplus
 public ServiceResponseData GetBooks()
 {
     //DataTable dt = NewDao<IBookDao>().GetBooks("", 0);
     EFWCoreLib.WcfFrame.Utility.Upgrade.ClientUpgradeManager.DownLoadUpgrade();
     DistributedCacheManage.SetCache("test", "kakake", "kakake123");
     //responseData.AddData(dt);
     return(responseData);
 }
コード例 #4
0
 public static bool AddToken(TokenInfo entity)
 {
     lock (syncObj)
     {
         tokenList.Add(entity);
         DistributedCacheManage.SetCache("tokenList", entity.tokenId.ToString(), JsonConvert.SerializeObject(entity.userinfo));
         //if (AddCache != null)
         //{
         //    AddCache("tokenList", entity.tokenId.ToString(), JsonConvert.SerializeObject(entity.userinfo));
         //}
     }
     return(true);
 }
コード例 #5
0
        public static bool RemoveToken(string token)
        {
            TokenInfo tinfo = GetToken(token);

            if (tinfo != null)
            {
                lock (syncObj)
                {
                    tokenList.Remove(tinfo);
                    //if (RemoveCache != null)
                    //{
                    //    RemoveCache("tokenList", tinfo.tokenId.ToString());
                    //}
                    DistributedCacheManage.RemoveCache("tokenList", tinfo.tokenId.ToString());
                }
            }
            return(true);
        }
コード例 #6
0
        public string CreateDomain(string ipAddress)
        {
            //客户端回调
            IClientService  mCallBack = OperationContext.Current.GetCallbackChannel <IClientService>();
            HeaderParameter para      = HeaderOperater.GetHeaderValue(OperationContext.Current.RequestContext.RequestMessage);
            string          ClientID  = WcfServerManage.CreateClient(OperationContext.Current.SessionId, ipAddress, DateTime.Now, mCallBack, para.pluginname, para.replyidentify);

            //异步执行同步缓存
            new Action(delegate()
            {
                if (para.pluginname == "SuperPlugin")
                {
                    //创建连接时候会将上级中间件的缓存同步到下级中间件
                    DistributedCacheManage.SyncAllCache(mCallBack);
                }
            }).BeginInvoke(null, null);

            return(ClientID);
        }
コード例 #7
0
        public static TokenInfo GetToken(string userId)
        {
            TokenInfo existToken = null;

            try
            {
                CacheObject co = DistributedCacheManage.GetLocalCache("tokenList");
                if (co != null)
                {
                    CacheData cd = co.cacheValue.SingleOrDefault(x => (x.deleteflag == false && x.key.Split((char)1)[0] == userId));
                    if (cd != null)
                    {
                        existToken = JsonConvert.DeserializeObject <TokenInfo>(cd.value);
                        //更新时间
                        DistributedCacheManage.SetCache("tokenList", cd.key, JsonConvert.SerializeObject(existToken));
                    }
                }
            }
            catch { }
            return(existToken);
        }
コード例 #8
0
        public static AuthResult ValidateToken(string token)
        {
            AuthResult result = new AuthResult()
            {
                ErrorMsg = "Token不存在或已过期"
            };
            CacheObject co = DistributedCacheManage.GetLocalCache("tokenList");

            if (co != null)
            {
                CacheData cd = co.cacheValue.Find(x => x.key == token && x.deleteflag == false);
                if (cd != null)
                {
                    result.token    = token;
                    result.User     = JsonConvert.DeserializeObject <UserInfo>(cd.value);
                    result.ErrorMsg = string.Empty;
                }
            }

            return(result);
        }
コード例 #9
0
 public static bool AddToken(TokenInfo entity)
 {
     //tokenList.Add(entity);
     DistributedCacheManage.SetCache("tokenList", entity.UserId + (char)1 + entity.tokenId.ToString(), JsonConvert.SerializeObject(entity));
     return(true);
 }
コード例 #10
0
 // GET efwplusApi/<plugin>/<controller>/<action>/5
 public Books GetBook(int id)
 {
     DistributedCacheManage.SetCache("test", id.ToString(), "kakake");
     return(NewObject <Books>().getmodel(id) as Books);
 }
コード例 #11
0
ファイル: BaseService.cs プロジェクト: hongfagj/efwplus
 public List <CacheObject> GetDistributedCacheData(List <CacheIdentify> cacheIdList)
 {
     return(DistributedCacheManage.GetCacheObjectList(cacheIdList));
 }
コード例 #12
0
 public CacheIdentify DistributedCacheSyncIdentify(CacheIdentify cacheId)
 {
     return(DistributedCacheManage.CompareCache(cacheId));
 }
コード例 #13
0
        public static void Run(StartType type)
        {
            switch (type)
            {
            case StartType.BaseService:
                mAppHost = new ServiceHost(typeof(BaseService));
                //初始化连接池,默认10分钟清理连接
                ClientLinkPoolCache.Init(true, 200, 30, 600, "wcfserver", 30);

                AppGlobal.AppRootPath = System.Windows.Forms.Application.StartupPath + "\\";
                AppGlobal.appType     = AppType.WCF;
                AppGlobal.IsSaas      = HostSettingConfig.GetValue("issaas") == "1" ? true : false;
                AppGlobal.AppStart();


                ClientManage.IsHeartbeat   = HostSettingConfig.GetValue("heartbeat") == "1" ? true : false;
                ClientManage.HeartbeatTime = Convert.ToInt32(HostSettingConfig.GetValue("heartbeattime"));

                ClientManage.StartHost();
                mAppHost.Open();

                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "数据服务启动完成");
                break;

            case StartType.FileService:
                AppGlobal.AppRootPath = System.Windows.Forms.Application.StartupPath + "\\";

                mFileHost = new ServiceHost(typeof(FileService));
                mFileHost.Open();

                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "文件服务启动完成");
                break;

            case StartType.HttpService:
                //初始化连接池,默认10分钟清理连接
                ClientLinkPoolCache.Init(true, 200, 30, 600, "httpserver", 30);
                AppGlobal.AppRootPath = System.Windows.Forms.Application.StartupPath + "\\";

                mHttpHost = new WebServiceHost(typeof(HttpService));
                mHttpHost.Open();

                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "Http服务启动完成");
                break;

            case StartType.RouterBaseService:
                mRouterHost = new ServiceHost(typeof(RouterBaseService));
                RouterManage.Start();
                mRouterHost.Open();

                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "路由数据服务启动完成");
                break;

            case StartType.RouterFileService:
                mFileRouterHost = new ServiceHost(typeof(RouterFileService));
                mFileRouterHost.Open();

                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "路由文件服务启动完成");
                break;

            case StartType.SuperClient:
                SuperClient.Start();
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "超级客户端启动完成");

                PublisherManage.Start();
                SubscriberManager.Start();
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "发布订阅启动完成");

                DistributedCacheManage.Start();
                DistributedCacheClient.Start();
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "分布式缓存启动完成");

                UpgradeManage.Start();
                UpgradeClient.Start();
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "升级包管理启动完成");

                MonitorTirggerManage.Start();
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "监视触发器启动完成");
                break;

            case StartType.MiddlewareTask:
                MiddlewareTask.StartTask();    //开启定时任务
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "定时任务启动完成");
                break;
            }
        }