예제 #1
0
        /// <param name="url">Адрес сервера TFS</param>
        /// <param name="myItems">Список ID моих рабочих элементов</param>
        /// <param name="builds">Список сегодняшних билдов</param>
        /// <param name="coolDown">Время между обновлениями рабочих элементов в минутах</param>
        /// <param name="currentItem">Функция получения рабочего элемента для списания времени</param>
        /// <param name="rules">Функция для получения списка правил проверка рабочих элементов</param>
        public TfsObservable(string url,
                             IList <int> myItems,
                             IList <string> builds,
                             int coolDown,
                             Func <WorkItem> currentItem,
                             Func <IList <IRule> > rules)
            : base(url)
        {
            _currentItem        = currentItem;
            _rules              = rules;
            _versionControl     = Project.GetService <VersionControlServer>();
            _hourTimer          = new Timer(1000 * 60 * 60);
            _hourTimer.Elapsed += (sender, args) => RequestUpdate(true);

            _itemsTimer         = new Timer(1000 * 60 * coolDown);
            _hourTimer.Elapsed += (sender, args) => RequestUpdate();

            SystemEvents.SessionSwitch          += OnSessionSwitched;
            AppDomain.CurrentDomain.ProcessExit += (sender, e) => Logoff?.Invoke(this, e);

            MyItems = new List <WorkItem>(FindById(myItems).Values);

            _cache            = new MemoryCache(new MemoryCacheOptions());
            _capacitySearcher = new CachedCapacitySearcher(_cache, Project);

            _buildClient = Project.GetClient <BuildHttpClient>();

            _myBuilds.AddRange(builds);
            _ruleBuilder = new RuleBuilder();
        }
예제 #2
0
        public override Result EndExecute(IAsyncResult asyncValue)
        {
            AsyncResult asyncResult = (AsyncResult)asyncValue;
            Logoff      l           = (Logoff)asyncResult.AsyncDelegate;

            result = l.EndInvoke(asyncValue);

            return(result);
        }
예제 #3
0
        public async Task LogoffCodeTest(string token, string device, bool exception, Type exceptionType = null)
        {
            var tokenRep = TokenRepositoryMock.CreateRepository();

            try
            {
                await Logoff.Execute(tokenRep, token, device);

                Assert.IsFalse(exception);
            }
            catch (Exception ex)
            {
                Assert.IsTrue((exception) && (exceptionType.FullName == ex.GetType().FullName));
            }
        }
예제 #4
0
        public async Task LogoffFlowTest(string token, string device, bool callCloseCount)
        {
            var tokenRep = TokenRepositoryMock.CreateRepository();

            try
            {
                await Logoff.Execute(tokenRep, token, device);

                Assert.AreEqual(tokenRep.CloseCount, callCloseCount ? 1 : 0);
            }
            catch
            {
                Assert.AreEqual(tokenRep.CloseCount, callCloseCount ? 1 : 0);
            }
        }
예제 #5
0
 //发送退出消息
 private void SendLoginoffMsg()
 {
     try
     {
         Logoff lgf = new Logoff();
         lgf.ID = ZJM;
         lgf.Pwd = "123456";
         string strMsg = JSON.ToJson(lgf);
         tch.SendToServer(1003, CommandType.joson, strMsg);
     }
     catch (Exception ex)
     {
         LOG.LogHelper.WriteLog("发送登录消息失败", ex);
     }
 }
예제 #6
0
        public static CommandProcessor GetCommandProcessor(string request, System.Net.Sockets.TcpClient connection)
        {
            CommandProcessor result = null;

            switch (getCommand(request))
            {
            case "LOGON":
                result = new Logon();
                break;

            case "LOGOFF":
                result = new Logoff();
                break;

            case "SAVECARRIER":
                result = new SaveCarrier();
                break;

            case "SAVESTATUS":
                result = new SaveStatus();
                break;

            case "QUERYCARRIER":
                result = new QueryCarrier();
                break;

            case "QUERYSTATUS":
                result = new QueryStatus();
                break;

            case "QUERYALLCARRIERS":
                result = new QueryAllCarriers();
                break;

            case "QUERYALLSTATUS":
                result = new QueryAllStatus();
                break;
            }
            if (result != null)
            {
                result.Command    = getCommand(request);
                result.Request    = getRequestContent(request);
                result.Connection = connection;
            }
            return(result);
        }
예제 #7
0
        public async Task LogoffInvalidParametersTest(bool isTokenRepNull, string token, string device)
        {
            var tokenRep = isTokenRepNull ? null : TokenRepositoryMock.CreateRepository();

            try
            {
                await Logoff.Execute(tokenRep, token, device);

                Assert.Fail();
            }
            catch (Exception ex)
            {
                if (isTokenRepNull)
                {
                    Assert.AreEqual(ex.GetType(), typeof(ArgumentNullException));
                }
                else
                {
                    Assert.AreEqual(ex.GetType(), typeof(ArgumentException));
                }
            }
        }
예제 #8
0
 public override Result Execute()
 {
     logoff = new Logoff(receiver.Unjoin);
     logoff.BeginInvoke(username, callbackMethod, this);
     return new NullResult();
 }
예제 #9
0
 /// <summary>
 ///     Отправить сообщение в сокет
 /// </summary>
 public void SendMessage(Logoff msg) => SendMessageImpl(new ClientMsg {
     logoff = msg
 });
예제 #10
0
 public override Result Execute()
 {
     logoff = new Logoff(receiver.Unjoin);
     logoff.BeginInvoke(username, callbackMethod, this);
     return(new NullResult());
 }
        public void TryRebuildLogoff(string filePath)
        {
            string collectionName = "Logoff";
            List<Logoff> LogoffBatch = new List<Logoff>();
            foreach (DataRow entry in LoadFromCSV(collectionName, filePath).Rows)
            {
                DateTime LoginTimestamp;
                Logoff u = new Logoff()
                {
                    UserId = entry["userid"].ToString(),
                    GameId = entry["gameid"].ToString(),
                    UserSessionId = entry["sessionid"].ToString(),
                    Platform = entry["platform"].ToString(),
                    City = (entry["location.city"] == null || entry["location.city"] == null) ? "" : entry["location.city"].ToString(),
                    Country = (entry["location.country"] == null || entry["location.country"] == null) ? "" : entry["location.country"].ToString(),
                    Region = (entry["location.region"] == null || entry["location.region"] == null) ? "" : entry["location.region"].ToString(),
                    Longitude = (entry["location.longitude"].ToString() == "" || entry["location.longitude"].ToString() == null) ? 0 : float.Parse(entry["location.longitude"].ToString(), CultureInfo.InvariantCulture.NumberFormat),
                    Latitude = (entry["location.latitude"].ToString() == "" || entry["location.latitude"].ToString() == null) ? 0 : float.Parse(entry["location.latitude"].ToString(), CultureInfo.InvariantCulture.NumberFormat),
                    LocationId = (entry["location.id"].ToString() == "" || entry["location.id"].ToString() == null) ? 0 : Convert.ToInt32(entry["location.id"].ToString()),
                    InstallDateRecord = (entry["isnewuser"].ToString() == "" || entry["isnewuser"].ToString() == null) ? 0 : ((Convert.ToBoolean(entry["isnewuser"].ToString())) ? 1 : 0),
                    SessionLength = -1,
                    LogoffTimestamp = (DateTime.TryParse(entry["keen.timestamp"].ToString(), out LoginTimestamp) != false) ? LoginTimestamp : DateTime.MinValue
                };

                LogoffBatch.Add(u);
            }

            try
            {
                UserSessions.Instance.processLogoffs(LogoffBatch);
            }
            catch (Exception)
            {
                Logger.Instance.Info("New User Insert Fail");
            }
        }
예제 #12
0
 private void LogOff_Click(object sender, RoutedEventArgs e)
 {
     Logoff.LogoffToLogin();
 }
        public HashSet<Logoff> ExtractLogoffsFromDay(DateTime date)
        {
            DateTime end = date.Subtract(date.TimeOfDay);
            DateTime start = date.AddDays(-1).Subtract(date.TimeOfDay);
            HashSet<Logoff> logoffEvents = new HashSet<Logoff>();
            var result = provider.GetResource("Logoff", start, end);

            if (result.Any())
            {
                foreach (JObject entry in result)
                {
                    DateTime logoffTime = DateTime.Parse(entry["keen"]["timestamp"].ToString());
                    Logoff logoff = new Logoff()
                    {
                        UserId = entry["userid"].ToString(),
                        GameId = entry["gameid"].ToString(),
                        UserSessionId = entry["sessionid"].ToString(),
                        Platform = entry["platform"].ToString(),
                        LoginTimestamp = logoffTime
                    };
                    if (logoffEvents.Add(logoff) == false)
                    {
                        Logger.Instance.Info(String.Format("{0} is a duplicate sessionId detected", logoff.UserSessionId));
                        //do something about duplicates from keen call becuse something is wrong.
                        // "badness detected" -- PJ

                    }

                }
            }
            return logoffEvents;
        }
        public HashSet<Logoff> ExtractLatestLogoffs(DateTime LastRecord)
        {
            HashSet<Logoff> Logoffs = new HashSet<Logoff>();

            DateTime end = DateTime.UtcNow;
            DateTime start = LastRecord;
            var result = provider.GetResource("Logoff", start, end);

            if (result.Any())
            {
                foreach (JObject entry in result)
                {
                    DateTime logoffTime = DateTime.Parse(entry["keen"]["timestamp"].ToString());
                    Logoff u = new Logoff()
                    {
                        UserId = entry["userid"].ToString(),
                        GameId = entry["gameid"].ToString(),
                        UserSessionId = entry["sessionid"].ToString(),
                        Platform = entry["platform"].ToString(),
                        LogoffTimestamp = logoffTime
                    };

                    if (Logoffs.Add(u) == false)
                    {
                        Logger.Instance.Info(String.Format("{0} is a duplicate Login from keen", u.UserId));
                        //do something about duplicates from keen call becuse something is wrong.
                        // "badness detected" -- PJ

                    }

                }
            }

            return Logoffs;
        }