Exemplo n.º 1
0
        //income processing
        protected override IEnumerable <DayIncomeObject> ConvertRawData(RawIncomeManager incomeManager)
        {
            var lastIncome = 0.0;
            var incomes    = new List <DayIncomeObject>();

            var startTime = UnixTimeHelper.GetCurrentDay();

            while (true)
            {
                var rawIncome = incomeManager.GetRow(startTime);
                var income    = new DayIncomeObject(rawIncome.time, rawIncome.value);
                if (income.time == 0)
                {
                    break;
                }

                if (lastIncome > 0)
                {
                    income.value = lastIncome - income.value;
                    incomes.Add(income);
                    lastIncome -= income.value;
                }
                else
                {
                    lastIncome = income.value;
                }

                startTime -= 86400;
            }

            incomes.Reverse();
            return(incomes.ToArray());
        }
Exemplo n.º 2
0
        private void HandleTradesCallBack(string result)
        {
            var webResult = JObject.Parse(result);

            foreach (var pair in configuration.Pairs)
            {
                if (!PairTrades.ContainsKey(pair))
                {
                    PairTrades.Add(pair, new List <IMarketTrade>());
                }

                foreach (var trade in webResult[BtcePairHelper.ToString(pair)])
                {
                    var newTrade = new MarketTrade
                    {
                        Pair      = pair,
                        TradeId   = trade["tid"].Value <int>(),
                        Amount    = trade["amount"].Value <decimal>(),
                        Rate      = trade["price"].Value <decimal>(),
                        Timestamp = UnixTimeHelper.UnixTimeToDateTime(trade["timestamp"].Value <UInt32>())
                    };

                    if (PairTrades[pair].Find(a => a.TradeId == newTrade.TradeId) == null)
                    {
                        PairTrades[pair].Add(newTrade);
                    }
                }
            }

            /*
             * foreach (var tradeItem in webResult["return"].Value<JObject>())
             *  {
             *      var newTrade = new MarketTrade
             *          {
             *              Pair =  BtcePairHelper.FromString(tradeItem.Value["pair"].Value<string>()),
             *              TradeType = TradeTypeHelper.FromString(tradeItem.Value["type"].Value<string>()),
             *              Amount = tradeItem.Value["amount"].Value<decimal>(),
             *              Rate = tradeItem.Value["rate"].Value<decimal>(),
             *              OrderId = tradeItem.Value["order_id"].Value<int>(),
             *              YourOrder = tradeItem.Value["is_your_order"].Value<string>(),
             *              TimeStamp = UnixTimeHelper.UnixTimeToDateTime(tradeItem.Value["timestamp"].Value<UInt32>())
             *          };
             *
             *      if (!PairTrades.ContainsKey(newTrade.Pair))
             *          PairTrades.Add(newTrade.Pair, new List<IMarketTrade>());
             *
             *      if (PairTrades[newTrade.Pair].Find(a => a.OrderId == newTrade.OrderId) == null)
             *          PairTrades[newTrade.Pair].Add(newTrade);
             *  }*/


            OnPropertyChanged("PairTrades");

            if (MarketTradesUpdated != null)
            {
                MarketTradesUpdated(this, null);
            }

            LogApiMessage("Api message processed", "Market trades updated");
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取图形验证码
        /// </summary>
        /// <returns></returns>
        // [HttpGet("VerifyCode")]
        public async Task Get()
        {
            Response.ContentType = "image/jpeg";


            using (var stream = CheckCode.Create(out var code))
            {
                var buffer = stream.ToArray();

                //存session
                HttpContext.Session.SetString("VerifyCode", code.ToLower());
                //使用标志,不允许重复使用一个验证码。
                //这个验证码被消费一次后,要置0。
                HttpContext.Session.SetInt32("VerifyCodeValid", 1);
                //验证码生成时间。
                HttpContext.Session.SetInt32("VerifyCodeTime", UnixTimeHelper.GetTimeStampInInt32());


                //string sessionID = Request.Cookies["SessionID"];
                //RedisManager.SetString(sessionID, code);

                // Response.Cookies.Append("code",code);

                // 将验证码的token放入cookie
                // Response.Cookies.Append(VERFIY_CODE_TOKEN_COOKIE_NAME, await SecurityServices.GetVerifyCodeToken(code));

                await Response.Body.WriteAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns a multi-line string containing a description of the contents of the block.
        /// Use for debugging purposes only.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder(string.Format(@"v{0} block:
	previous block: {1}
	merkle root: {2}\n
	time: [{3}] {4}
	difficulty target (nBits): {5}
	nonce: {6}\n"    ,
                                                                    version,                                  //0
                                                                    PreviousBlockHash,                        //1
                                                                    MerkleRoot,                               //2
                                                                    TimeSeconds,                              //3
                                                                    UnixTimeHelper.FromUnixTime(TimeSeconds), //4
                                                                    DifficultyTarget,                         //5
                                                                    Nonce)                                    //6
                                                      );

            if (Transactions != null && Transactions.Count > 0)
            {
                builder.AppendLine(string.Format("   with {0} transaction(s):", Transactions.Count));
                foreach (Transaction tx in Transactions)
                {
                    builder.Append(tx);
                }
            }

            return(builder.ToString());
        }
Exemplo n.º 5
0
        private int extractHealthRuleViolations(JobConfiguration jobConfiguration, JobTarget jobTarget, ControllerApi controllerApi)
        {
            JArray listOfHealthRuleViolations = new JArray();

            foreach (JobTimeRange jobTimeRange in jobConfiguration.Input.HourlyTimeRanges)
            {
                long fromTimeUnix = UnixTimeHelper.ConvertToUnixTimestamp(jobTimeRange.From);
                long toTimeUnix   = UnixTimeHelper.ConvertToUnixTimestamp(jobTimeRange.To);

                string healthRuleViolationsJSON = controllerApi.GetHealthRuleViolations(jobTarget.ApplicationID, fromTimeUnix, toTimeUnix);
                if (healthRuleViolationsJSON != String.Empty)
                {
                    // Load health rule violations
                    JArray healthRuleViolationsInHour = JArray.Parse(healthRuleViolationsJSON);
                    foreach (JObject healthRuleViolation in healthRuleViolationsInHour)
                    {
                        listOfHealthRuleViolations.Add(healthRuleViolation);
                    }
                }
            }

            if (listOfHealthRuleViolations.Count > 0)
            {
                FileIOHelper.WriteJArrayToFile(listOfHealthRuleViolations, FilePathMap.HealthRuleViolationsDataFilePath(jobTarget));

                logger.Info("{0} health rule violations from {1:o} to {2:o}", listOfHealthRuleViolations.Count, jobConfiguration.Input.TimeRange.From, jobConfiguration.Input.TimeRange.To);
                loggerConsole.Info("{0} health rule violations", listOfHealthRuleViolations.Count);
            }

            return(listOfHealthRuleViolations.Count);
        }
Exemplo n.º 6
0
        private int extractEvents(JobConfiguration jobConfiguration, JobTarget jobTarget, ControllerApi controllerApi, string eventType)
        {
            JArray listOfEvents = new JArray();

            foreach (JobTimeRange jobTimeRange in jobConfiguration.Input.HourlyTimeRanges)
            {
                long fromTimeUnix = UnixTimeHelper.ConvertToUnixTimestamp(jobTimeRange.From);
                long toTimeUnix   = UnixTimeHelper.ConvertToUnixTimestamp(jobTimeRange.To);

                string eventsJSON = controllerApi.GetEvents(jobTarget.ApplicationID, eventType, fromTimeUnix, toTimeUnix);
                if (eventsJSON != String.Empty)
                {
                    // Load events
                    JArray eventsInHour = JArray.Parse(eventsJSON);
                    foreach (JObject interestingEvent in eventsInHour)
                    {
                        listOfEvents.Add(interestingEvent);
                    }
                }
            }

            if (listOfEvents.Count > 0)
            {
                FileIOHelper.WriteJArrayToFile(listOfEvents, this.FilePathMap.EventsDataFilePath(jobTarget, eventType));

                logger.Info("{0} {1} events from {2:o} to {3:o}", eventType, listOfEvents.Count, jobConfiguration.Input.TimeRange.From, jobConfiguration.Input.TimeRange.To);
                loggerConsole.Info("{0} {1} events", eventType, listOfEvents.Count);
            }

            return(listOfEvents.Count);
        }
Exemplo n.º 7
0
        public void AddDateRangeQuery(string name, DateTime from, DateTime to)
        {
            long   fromLong = UnixTimeHelper.UnixTimeLong(from);
            long   toLong   = UnixTimeHelper.UnixTimeLong(to);
            string value    = $"fromTo({fromLong},{toLong})";

            SetParam(GetParamName(name), value);
        }
Exemplo n.º 8
0
        public IActionResult DoLogin(string email, string pwd, string captcha)
        {
            string verifyCode = HttpContext.Session.GetString("VerifyCode");
            int    time       = HttpContext.Session.GetInt32("VerifyCodeTime").GetValueOrDefault(0);
            int    valid      = HttpContext.Session.GetInt32("VerifyCodeValid").GetValueOrDefault(0);

            if (valid != 1 || !UnixTimeHelper.IsValid(time, 15))
            {
                Re re = new Re()
                {
                    Ok = false, Msg = "验证码过期或失效"
                };
                return(Json(re, MyJsonConvert.GetSimpleOptions()));
            }
            //销毁验证码的标志
            HttpContext.Session.SetInt32("VerifyCodeValid", 0);
            if (string.IsNullOrEmpty(verifyCode) || string.IsNullOrEmpty(captcha))
            {
                Re re = new Re()
                {
                    Ok = false, Msg = "错误参数"
                };
                return(Json(re, MyJsonConvert.GetSimpleOptions()));
            }
            else
            {
                if (!captcha.ToLower().Equals(verifyCode))
                {
                    Re re = new Re()
                    {
                        Ok = false, Msg = "验证码错误"
                    };
                    return(Json(re, MyJsonConvert.GetSimpleOptions()));
                }
                string token;
                User   user;
                if (!AuthService.LoginByPWD(email, pwd, out token, out user))
                {
                    //登录失败
                    Re re = new Re()
                    {
                        Ok = false, Msg = "wrongUsernameOrPassword"
                    };
                    return(Json(re, MyJsonConvert.GetSimpleOptions()));
                }
                else
                {
                    //登录成功
                    HttpContext.Session.SetString("_token", token);
                    HttpContext.Session.SetString("_userId", user.UserId.ToString("x"));
                    Re re = new Re()
                    {
                        Ok = true
                    };
                    return(Json(re, MyJsonConvert.GetSimpleOptions()));
                }
            }
        }
Exemplo n.º 9
0
        public void ConvertDateTimeToUnixTime_Should_BeCorrect()
        {
            var date = DateTime.Now;

            var result   = UnixTimeHelper.ConvertDateTimeToUnixTime(date);
            var expected = (date - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;

            Assert.AreEqual(expected, result);
        }
Exemplo n.º 10
0
        public IList <Transaction> Transactions;        //If null, it means this object holds only the headers


        /// <summary>
        /// Special case constructor, used for the genesis node, cloneAsHeader and unit tests.
        /// </summary>
        /// <param name="parameters"></param>
        public Block(NetworkParameters parameters) : base(parameters)
        {
            // Set up a few basic things. We are not complete after this though.
            version           = 1;
            difficultyTarget  = (uint)0x1d07fff8L;
            TimeSeconds       = UnixTimeHelper.ToUnixTime(DateTime.UtcNow);
            PreviousBlockHash = Sha256Hash.ZeroHash;
            Length            = 80;
        }
Exemplo n.º 11
0
        public void ConvertUnixTimeToDateTime_Should_BeCorrect()
        {
            double timestamp = 1557311131;

            var result   = UnixTimeHelper.ConvertUnixTimeToDateTime(timestamp);
            var expected = (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(timestamp);

            Assert.AreEqual(expected, result);
        }
        public ProtrackPlaybackRecord(string str)
        {
            string[] args = str.Split(',');

            Longitude  = decimal.Parse(args[0]);
            Latitude   = decimal.Parse(args[1]);
            GpsTimeUtc = UnixTimeHelper.ToDateTime(int.Parse(args[2]));
            Speed      = int.Parse(args[3]);
            Course     = int.Parse(args[4]);
        }
Exemplo n.º 13
0
        public override IDictionary <string, object> GetParams()
        {
            var list = base.GetParams();

            list.Add("imei", this.Imei);
            list.Add("begintime", UnixTimeHelper.ToUnixTime(BeginTimeUtc));
            list.Add("endtime", UnixTimeHelper.ToUnixTime(EndTimeUtc));

            return(list);
        }
Exemplo n.º 14
0
        private void UpdateDayIncomePlot(IEnumerable <DayIncomeObject> incomes)
        {
            var points = new List <DataPoint>();

            foreach (var income in incomes)
            {
                var dp = new DataPoint(DateTimeAxis.ToDouble(UnixTimeHelper.UnixTimeToDateTime(income.time)), income.value);
                points.Add(dp);
            }

            BasePlot.LoadIncome(points.ToArray());
        }
Exemplo n.º 15
0
        /// <summary>
        /// <exception cref="VerificationException"></exception>
        /// </summary>
        private void checkTimestamp()
        {
            EnsureParsedHeader();

            // Allow injection of a fake clock to allow unit testing.
            ulong currentTime = FakeClock > 0?FakeClock:UnixTimeHelper.ToUnixTime(DateTime.UtcNow);

            if (TimeSeconds > currentTime + AllowedTimeDrift)
            {
                throw new VerificationException("Block too far in future");
            }
        }
Exemplo n.º 16
0
        public static Task <ScheduleMessageResponse> ScheduleMessageAsync(SlackClient slackClient, string channelName, int minutesToSchedule = 1)
        {
            const string DateTimeFormat    = "dd MMMM yyyy HH:mm:ss tt";
            var          now               = DateTime.Now;
            var          scheduledDateTime = now.AddMinutes(minutesToSchedule);

            var scheduledMessage = new MessageToSchedule
            {
                ChannelIdOrName = channelName,
                Text            = $"Scheduled message\nNow dateTime - {now.ToString(DateTimeFormat)}\nScheduled dateTime - {scheduledDateTime.ToString(DateTimeFormat)}",
                PostAt          = UnixTimeHelper.ToUnixTime(scheduledDateTime)
            };

            return(slackClient.Chat.ScheduleMessageAsync(scheduledMessage));
        }
        public override IDictionary <string, object> GetParams()
        {
            RequestTimeUtc = DateTime.UtcNow;
            var unixTime = UnixTimeHelper.ToUnixTime(RequestTimeUtc);

            string signature = GetSignature(unixTime);

            var list = base.GetParams(); // retrieving base parameters (if any)

            list.Add("time", unixTime);
            list.Add("account", this.Account);
            list.Add("signature", signature);

            return(list);
        }
        private int extractEvents(JobConfiguration jobConfiguration, JobTarget jobTarget, ControllerApi controllerApi, string eventType)
        {
            loggerConsole.Info("Extract List of Events {0} ({1} time ranges)", eventType, jobConfiguration.Input.HourlyTimeRanges.Count);

            JArray listOfEventsArray = new JArray();

            if (File.Exists(FilePathMap.ApplicationEventsDataFilePath(jobTarget, eventType)) == false)
            {
                foreach (JobTimeRange jobTimeRange in jobConfiguration.Input.HourlyTimeRanges)
                {
                    long fromTimeUnix = UnixTimeHelper.ConvertToUnixTimestamp(jobTimeRange.From);
                    long toTimeUnix   = UnixTimeHelper.ConvertToUnixTimestamp(jobTimeRange.To);

                    try
                    {
                        string eventsJSON = controllerApi.GetApplicationEvents(jobTarget.ApplicationID, eventType, fromTimeUnix, toTimeUnix);
                        if (eventsJSON != String.Empty)
                        {
                            // Load events
                            JArray eventsInHourArray = JArray.Parse(eventsJSON);

                            foreach (JObject eventObject in eventsInHourArray)
                            {
                                listOfEventsArray.Add(eventObject);
                            }

                            Console.Write("[{0}]+", eventsInHourArray.Count);
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Warn(ex);
                        logger.Warn("Unable to parse JSON for Events Application={0}, EventType={1}, From={2}, To={3}", jobTarget.ApplicationID, eventType, fromTimeUnix, toTimeUnix);
                    }
                }

                if (listOfEventsArray.Count > 0)
                {
                    FileIOHelper.WriteJArrayToFile(listOfEventsArray, FilePathMap.ApplicationEventsDataFilePath(jobTarget, eventType));

                    logger.Info("{0} {1} events from {2:o} to {3:o}", eventType, listOfEventsArray.Count, jobConfiguration.Input.TimeRange.From, jobConfiguration.Input.TimeRange.To);
                    loggerConsole.Info("{0} {1} events", eventType, listOfEventsArray.Count);
                }
            }

            return(listOfEventsArray.Count);
        }
Exemplo n.º 19
0
        private void UpdatePaymentPlot(DayIncomeManager dayIncomeManager, IEnumerable <PaymentObject> payments)
        {
            var points = new List <ScatterPoint>();

            foreach (var payment in payments)
            {
                var Date           = UnixTimeHelper.UnixTimeToDateTime(payment.time);
                var dayIncomeValue = dayIncomeManager.GetRow((long)UnixTimeHelper.Convert(Date)).value;
                if (dayIncomeValue > 0)
                {
                    var sp = new ScatterPoint(DateTimeAxis.ToDouble(Date), dayIncomeValue);
                    points.Add(sp);
                }
            }

            BasePlot.LoadPayment(points.ToArray());
        }
Exemplo n.º 20
0
        private void populateApplicationInfo(JObject applicationJSON, ControllerApplication controllerApplication)
        {
            controllerApplication.ApplicationName = getStringValueFromJToken(applicationJSON, "name");
            controllerApplication.Description     = getStringValueFromJToken(applicationJSON, "description");
            controllerApplication.ApplicationID   = getLongValueFromJToken(applicationJSON, "id");
            if (isTokenPropertyNull(applicationJSON, "applicationTypeInfo") == false &&
                isTokenPropertyNull(applicationJSON["applicationTypeInfo"], "applicationTypes") == false)
            {
                controllerApplication.Types = applicationJSON["applicationTypeInfo"]["applicationTypes"].ToString(Newtonsoft.Json.Formatting.None);
            }

            controllerApplication.CreatedBy    = getStringValueFromJToken(applicationJSON, "createdBy");
            controllerApplication.CreatedOnUtc = UnixTimeHelper.ConvertFromUnixTimestamp(getLongValueFromJToken(applicationJSON, "createdOn"));
            try { controllerApplication.CreatedOn = controllerApplication.CreatedOnUtc.ToLocalTime(); } catch { }
            controllerApplication.UpdatedBy    = getStringValueFromJToken(applicationJSON, "modifiedBy");
            controllerApplication.UpdatedOnUtc = UnixTimeHelper.ConvertFromUnixTimestamp(getLongValueFromJToken(applicationJSON, "modifiedOn"));
            try { controllerApplication.UpdatedOn = controllerApplication.UpdatedOnUtc.ToLocalTime(); } catch { }
        }
Exemplo n.º 21
0
        public void AddDateQuery(string name, QueryDateType type, DateTime date)
        {
            long   dateLong = UnixTimeHelper.UnixTimeLong(date);
            string itemFilter;

            switch (type)
            {
            case QueryDateType.After: itemFilter = "from"; break;

            case QueryDateType.Before: itemFilter = "to"; break;

            default: throw new NotSupportedException($"The type {type} does not exist within the QueryDateType enum.");
            }

            string item = $"{itemFilter}({dateLong})";

            SetParam(GetParamName(name), item);
        }
Exemplo n.º 22
0
        public void Update()
        {
            var lastRawIncomeTime = rawManager.GetLast().time;
            ////Day Start////
            var currentDay = UnixTimeHelper.GetCurrentDay();

            dayIncome = rawManager.GetLast().value - rawManager.GetRow(currentDay).value;
            var recentIncome      = manager.GetLast().value;
            var penultimateIncome = manager.GetPenultimate().value;

            dayTrend = recentIncome / penultimateIncome - 1;

            var lastDayIncomeArray = rawManager.GetInvertSlice(lastRawIncomeTime - 86400);
            var lastDayAmountArray = lastDayIncomeArray.Select(r => r.value).ToArray();

            dayAver     = StatisticHelper.GetAverageSpeed(lastDayAmountArray, 86400);
            dayExpected = StatisticHelper.GetMedianSpeed(lastDayAmountArray, 86400);
            ////Day End////

            ////Week Start////
            var weekDayIncome = manager.GetIncome(7);

            weekIncome = weekDayIncome;
            var twoWeekDayIncome = manager.GetIncome(14);
            var weeksDiff        = twoWeekDayIncome - weekDayIncome;

            weekTrend = (weeksDiff > 0) ? weekDayIncome / weeksDiff - 1 : 0.0;

            var weekIncomeArray       = rawManager.GetInvertSlice(lastRawIncomeTime - 604800);
            var weekIncomeAmountArray = weekIncomeArray.Select(r => r.value).ToArray();

            weekAver     = StatisticHelper.GetAverageSpeed(weekIncomeAmountArray, 604800);
            weekExpected = StatisticHelper.GetMedianSpeed(weekIncomeAmountArray, 604800);
            ////Week End////

            ////Total Start////
            var allIncome = manager.GetAll().Select(d => d.value);

            totalIncome = allIncome.Sum();
            totalTrend  = StatisticHelper.GetGlobalTrend(allIncome.ToArray());
            ////Total End////
        }
        private int extractHealthRuleViolations(JobConfiguration jobConfiguration, JobTarget jobTarget, ControllerApi controllerApi)
        {
            JArray listOfHealthRuleViolations = new JArray();

            if (File.Exists(FilePathMap.ApplicationHealthRuleViolationsDataFilePath(jobTarget)) == false)
            {
                foreach (JobTimeRange jobTimeRange in jobConfiguration.Input.HourlyTimeRanges)
                {
                    long fromTimeUnix = UnixTimeHelper.ConvertToUnixTimestamp(jobTimeRange.From);
                    long toTimeUnix   = UnixTimeHelper.ConvertToUnixTimestamp(jobTimeRange.To);

                    string healthRuleViolationsJSON = controllerApi.GetApplicationHealthRuleViolations(jobTarget.ApplicationID, fromTimeUnix, toTimeUnix);
                    if (healthRuleViolationsJSON != String.Empty)
                    {
                        try
                        {
                            // Load health rule violations
                            JArray healthRuleViolationsInHourArray = JArray.Parse(healthRuleViolationsJSON);
                            foreach (JObject healthRuleViolationObject in healthRuleViolationsInHourArray)
                            {
                                listOfHealthRuleViolations.Add(healthRuleViolationObject);
                            }
                        }
                        catch (Exception)
                        {
                            logger.Warn("Unable to parse JSON for HR Violations Application={0}, From={1}, To={2}", jobTarget.ApplicationID, fromTimeUnix, toTimeUnix);
                        }
                    }
                }

                if (listOfHealthRuleViolations.Count > 0)
                {
                    FileIOHelper.WriteJArrayToFile(listOfHealthRuleViolations, FilePathMap.ApplicationHealthRuleViolationsDataFilePath(jobTarget));

                    logger.Info("{0} health rule violations from {1:o} to {2:o}", listOfHealthRuleViolations.Count, jobConfiguration.Input.TimeRange.From, jobConfiguration.Input.TimeRange.To);
                    loggerConsole.Info("{0} health rule violations", listOfHealthRuleViolations.Count);
                }
            }

            return(listOfHealthRuleViolations.Count);
        }
Exemplo n.º 24
0
        private void extractListOfMetrics(
            JobTarget jobTarget,
            JobConfiguration jobConfiguration,
            string metricPathPrefix,
            string fileNamePrefix,
            int maxDepth)
        {
            using (ControllerApi controllerApi = new ControllerApi(jobTarget.Controller, jobTarget.UserName, AESEncryptionHelper.Decrypt(jobTarget.UserPassword)))
            {
                DateTime startTime = jobConfiguration.Input.HourlyTimeRanges[jobConfiguration.Input.HourlyTimeRanges.Count - 1].From;
                DateTime endTime   = jobConfiguration.Input.HourlyTimeRanges[jobConfiguration.Input.HourlyTimeRanges.Count - 1].To;

                StringBuilder sbMetricPath = new StringBuilder(128);
                sbMetricPath.Append(metricPathPrefix);

                for (int currentDepth = 0; currentDepth <= maxDepth; currentDepth++)
                {
                    sbMetricPath.Append("|*");

                    string metricPath = sbMetricPath.ToString();
                    loggerConsole.Trace("Depth {0:00}/{1:00}, {2}", currentDepth, maxDepth, metricPath);
                    logger.Info("Retrieving metric lists for Application {0}({1}), Metric='{2}', From {3:o}, To {4:o}", jobTarget.Application, jobTarget.ApplicationID, metricPath, startTime, endTime);

                    string metricsJson = String.Empty;

                    string metricsDataFilePath = FilePathMap.MetricsListDataFilePath(jobTarget, fileNamePrefix, currentDepth);
                    if (File.Exists(metricsDataFilePath) == false)
                    {
                        metricsJson = controllerApi.GetMetricData(
                            jobTarget.ApplicationID,
                            metricPath,
                            UnixTimeHelper.ConvertToUnixTimestamp(startTime),
                            UnixTimeHelper.ConvertToUnixTimestamp(endTime),
                            true);

                        FileIOHelper.SaveFileToPath(metricsJson, metricsDataFilePath);
                    }
                }
            }
        }
Exemplo n.º 25
0
        public static JWT GetJWT(long tokenId, string userNmae, long userId, string group, long exp = 31536000)
        {
            JWT_Header header = new JWT_Header()
            {
                alg = "sha1"
            };
            JWT_Payload payload = new JWT_Payload
            {
                tokenId   = tokenId,
                iss       = "localhost",
                username  = userNmae,
                userId    = userId,
                group     = group,
                startTime = UnixTimeHelper.GetTimeStampInLong(),
                exp       = exp,
                random    = RandomTool.CreatSafeNum(8)
            };
            StringBuilder message = new StringBuilder();

            message.Append(header.alg);
            message.Append(payload.tokenId);
            message.Append(payload.iss);
            message.Append(payload.username);
            message.Append(payload.userId);
            message.Append(payload.group);
            message.Append(payload.startTime);
            message.Append(payload.exp);
            message.Append(payload.random);
            string password  = "";
            string signature = SHAEncrypt_Helper.Hash1Encrypt(message + password);
            JWT    jWT       = new JWT()
            {
                Header    = header,
                Payload   = payload,
                Signature = signature
            };

            return(jWT);
        }
        private void updateEntityWithDeeplinks(SIMEntityBase entityRow, JobTimeRange jobTimeRange)
        {
            // Decide what kind of timerange
            string DEEPLINK_THIS_TIMERANGE = DEEPLINK_TIMERANGE_LAST_15_MINUTES;

            if (jobTimeRange != null)
            {
                long fromTimeUnix        = UnixTimeHelper.ConvertToUnixTimestamp(jobTimeRange.From);
                long toTimeUnix          = UnixTimeHelper.ConvertToUnixTimestamp(jobTimeRange.To);
                long differenceInMinutes = (toTimeUnix - fromTimeUnix) / (60000);
                DEEPLINK_THIS_TIMERANGE = String.Format(DEEPLINK_TIMERANGE_BETWEEN_TIMES, toTimeUnix, fromTimeUnix, differenceInMinutes);
            }

            // Determine what kind of entity we are dealing with and adjust accordingly
            if (entityRow is SIMApplication)
            {
                entityRow.ControllerLink  = String.Format(DEEPLINK_CONTROLLER, entityRow.Controller, DEEPLINK_THIS_TIMERANGE);
                entityRow.ApplicationLink = String.Format(DEEPLINK_SIMAPPLICATION, entityRow.Controller, DEEPLINK_THIS_TIMERANGE);
            }
            else if (entityRow is SIMTier)
            {
                SIMTier entity = (SIMTier)entityRow;
                entity.ControllerLink     = String.Format(DEEPLINK_CONTROLLER, entity.Controller, DEEPLINK_THIS_TIMERANGE);
                entityRow.ApplicationLink = String.Format(DEEPLINK_SIMAPPLICATION, entityRow.Controller, DEEPLINK_THIS_TIMERANGE);
            }
            else if (entityRow is SIMNode)
            {
                SIMNode entity = (SIMNode)entityRow;
                entity.ControllerLink     = String.Format(DEEPLINK_CONTROLLER, entity.Controller, DEEPLINK_THIS_TIMERANGE);
                entityRow.ApplicationLink = String.Format(DEEPLINK_SIMAPPLICATION, entityRow.Controller, DEEPLINK_THIS_TIMERANGE);
            }
            else if (entityRow is Machine)
            {
                Machine entity = (Machine)entityRow;
                entity.ControllerLink     = String.Format(DEEPLINK_CONTROLLER, entity.Controller, DEEPLINK_THIS_TIMERANGE);
                entityRow.ApplicationLink = String.Format(DEEPLINK_SIMAPPLICATION, entityRow.Controller, DEEPLINK_THIS_TIMERANGE);
                entity.MachineLink        = String.Format(DEEPLINK_SIMMACHINE, entity.Controller, entity.ApplicationID, entity.MachineID, DEEPLINK_THIS_TIMERANGE);
            }
        }
Exemplo n.º 27
0
        private static List <LicenseValue> parseLicenseValuesArray(JArray licenseValuesArray, LicenseRule thisLicenseRule, string agentType)
        {
            List <LicenseValue> licenseValuesList = new List <LicenseValue>(licenseValuesArray.Count);

            foreach (JToken licenseValueToken in licenseValuesArray)
            {
                try
                {
                    JArray licenseValueArray = (JArray)licenseValueToken;

                    if (licenseValueArray.Count == 2)
                    {
                        LicenseValue licenseValue = new LicenseValue();

                        licenseValue.Controller  = thisLicenseRule.Controller;
                        licenseValue.AccountName = thisLicenseRule.AccountName;
                        licenseValue.AccountID   = thisLicenseRule.AccountID;

                        licenseValue.RuleName = thisLicenseRule.RuleName;

                        licenseValue.AgentType = agentType;

                        licenseValue.LicenseEventTimeUtc = UnixTimeHelper.ConvertFromUnixTimestamp((long)licenseValueArray[0]);
                        licenseValue.LicenseEventTime    = licenseValue.LicenseEventTimeUtc.ToLocalTime();

                        if (isTokenNull(licenseValueArray[1]) == false)
                        {
                            licenseValue.Average = (long)licenseValueArray[1];
                        }

                        licenseValuesList.Add(licenseValue);
                    }
                }
                catch { }
            }

            return(licenseValuesList);
        }
Exemplo n.º 28
0
        //获得同步状态
        //  [HttpPost]
        public JsonResult GetSyncState(string token)
        {
            User user = TokenSerivce.GetUserByToken(token);

            if (user == null)
            {
                ApiRe apiRe = new ApiRe()
                {
                    Ok  = false,
                    Msg = "Not logged in",
                };
                string json = JsonSerializer.Serialize(apiRe, MyJsonConvert.GetSimpleOptions());

                return(Json(apiRe, MyJsonConvert.GetOptions()));
            }
            ApiGetSyncState apiGetSyncState = new ApiGetSyncState()
            {
                LastSyncUsn  = user.Usn,
                LastSyncTime = UnixTimeHelper.GetTimeStampInLong(DateTime.Now)
            };

            return(Json(apiGetSyncState, MyJsonConvert.GetSimpleOptions()));
        }
Exemplo n.º 29
0
        /// <summary>
        /// Метод запускающий новый поток с запросом по указанному адресу.
        /// </summary>
        /// <param name="url">Адрес сервера</param>
        private void StartRequest(string url)
        {
            Status = Status.Process;

            new Thread((o) =>
            {
                currentRequest = (HttpWebRequest)WebRequest.Create(url);
                //currentRequest.Method = "GET";
                currentRequest.Timeout     = this.Request.TimeOut * 1000;
                currentRequest.ContentType = "application/json";
                this.Request.Response      = string.Empty;

                this.LastRequestTimeEnded = UnixTimeHelper.UnixTimeNow();
                try
                {
                    HttpWebResponse response = (HttpWebResponse)currentRequest.GetResponse();
                    this.Request.Response    = response.StatusCode.ToString();
                    response.Close();
                }
                catch (Exception ex)
                {
                    this.Request.Response = ex.ToString();
                }

                this.DurationRequestTime = UnixTimeHelper.UnixTimeNow() - this.LastRequestTimeEnded;
                Status = Status.ReadyToPost;

                if (this.Request.Interval == 0)
                {
                    IsAborted = true;
                }

                string logString = string.Format("Адрес {0} вернул код: {1}. Время обращения: {2}. Ожидание ответа: {3}", Request.Url, Request.Response, TimeToString(LastRequestTimeEnded), TimeToString(DurationRequestTime));
                Logs.Add(logString);
                currentRequest = null;
            }).Start();
        }
        public override bool Execute(ProgramOptions programOptions, JobConfiguration jobConfiguration)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            StepTiming stepTimingFunction = new StepTiming();

            stepTimingFunction.JobFileName = programOptions.OutputJobFilePath;
            stepTimingFunction.StepName    = jobConfiguration.Status.ToString();
            stepTimingFunction.StepID      = (int)jobConfiguration.Status;
            stepTimingFunction.StartTime   = DateTime.Now;
            stepTimingFunction.NumEntities = jobConfiguration.Target.Count;

            this.DisplayJobStepStartingStatus(jobConfiguration);

            FilePathMap = new FilePathMap(programOptions, jobConfiguration);

            try
            {
                if (this.ShouldExecute(programOptions, jobConfiguration) == false)
                {
                    return(true);
                }

                if (jobConfiguration.Target.Count(t => t.Type == APPLICATION_TYPE_APM) == 0)
                {
                    logger.Warn("No {0} targets to process", APPLICATION_TYPE_APM);
                    loggerConsole.Warn("No {0} targets to process", APPLICATION_TYPE_APM);

                    return(true);
                }

                // Process each target
                for (int i = 0; i < jobConfiguration.Target.Count; i++)
                {
                    Stopwatch stopWatchTarget = new Stopwatch();
                    stopWatchTarget.Start();

                    JobTarget jobTarget = jobConfiguration.Target[i];

                    if (jobTarget.Type != null && jobTarget.Type.Length > 0 && jobTarget.Type != APPLICATION_TYPE_APM)
                    {
                        continue;
                    }

                    StepTiming stepTimingTarget = new StepTiming();
                    stepTimingTarget.Controller      = jobTarget.Controller;
                    stepTimingTarget.ApplicationName = jobTarget.Application;
                    stepTimingTarget.ApplicationID   = jobTarget.ApplicationID;
                    stepTimingTarget.JobFileName     = programOptions.OutputJobFilePath;
                    stepTimingTarget.StepName        = jobConfiguration.Status.ToString();
                    stepTimingTarget.StepID          = (int)jobConfiguration.Status;
                    stepTimingTarget.StartTime       = DateTime.Now;

                    stepTimingTarget.NumEntities = 9;

                    try
                    {
                        this.DisplayJobTargetStartingStatus(jobConfiguration, jobTarget, i + 1);

                        #region Prepare time range

                        long fromTimeUnix        = UnixTimeHelper.ConvertToUnixTimestamp(jobConfiguration.Input.HourlyTimeRanges[jobConfiguration.Input.HourlyTimeRanges.Count - 1].From);
                        long toTimeUnix          = UnixTimeHelper.ConvertToUnixTimestamp(jobConfiguration.Input.HourlyTimeRanges[jobConfiguration.Input.HourlyTimeRanges.Count - 1].To);
                        long differenceInMinutes = (toTimeUnix - fromTimeUnix) / (60000);

                        #endregion

                        // Set up controller access
                        using (ControllerApi controllerApi = new ControllerApi(jobTarget.Controller, jobTarget.UserName, AESEncryptionHelper.Decrypt(jobTarget.UserPassword)))
                        {
                            #region Application

                            loggerConsole.Info("Application Name");

                            string applicationJSON = controllerApi.GetAPMApplication(jobTarget.ApplicationID);
                            if (applicationJSON != String.Empty)
                            {
                                FileIOHelper.SaveFileToPath(applicationJSON, FilePathMap.APMApplicationDataFilePath(jobTarget));
                            }

                            #endregion

                            #region Tiers

                            loggerConsole.Info("List of Tiers");

                            string tiersJSON = controllerApi.GetAPMTiers(jobTarget.ApplicationID);
                            if (tiersJSON != String.Empty)
                            {
                                FileIOHelper.SaveFileToPath(tiersJSON, FilePathMap.APMTiersDataFilePath(jobTarget));
                            }

                            #endregion

                            #region Nodes

                            loggerConsole.Info("List of Nodes");

                            string nodesJSON = controllerApi.GetAPMNodes(jobTarget.ApplicationID);
                            if (nodesJSON != String.Empty)
                            {
                                FileIOHelper.SaveFileToPath(nodesJSON, FilePathMap.APMNodesDataFilePath(jobTarget));
                            }

                            #endregion

                            #region Backends

                            loggerConsole.Info("List of Backends");

                            string backendsJSON = controllerApi.GetAPMBackends(jobTarget.ApplicationID);
                            if (backendsJSON != String.Empty)
                            {
                                FileIOHelper.SaveFileToPath(backendsJSON, FilePathMap.APMBackendsDataFilePath(jobTarget));
                            }

                            controllerApi.PrivateApiLogin();
                            backendsJSON = controllerApi.GetAPMBackendsAdditionalDetail(jobTarget.ApplicationID);
                            if (backendsJSON != String.Empty)
                            {
                                FileIOHelper.SaveFileToPath(backendsJSON, FilePathMap.APMBackendsDetailDataFilePath(jobTarget));
                            }

                            List <AppDRESTBackend> backendsList = FileIOHelper.LoadListOfObjectsFromFile <AppDRESTBackend>(FilePathMap.APMBackendsDataFilePath(jobTarget));
                            if (backendsList != null)
                            {
                                loggerConsole.Info("DBMon Mappings for Backends ({0} entities)", backendsList.Count);

                                int j = 0;

                                var listOfBackendsInHourChunks = backendsList.BreakListIntoChunks(ENTITIES_EXTRACT_NUMBER_OF_BACKENDS_TO_PROCESS_PER_THREAD);

                                ParallelOptions parallelOptions = new ParallelOptions();
                                if (programOptions.ProcessSequentially == true)
                                {
                                    parallelOptions.MaxDegreeOfParallelism = 1;
                                }
                                else
                                {
                                    parallelOptions.MaxDegreeOfParallelism = BACKEND_PROPERTIES_EXTRACT_NUMBER_OF_THREADS;
                                }

                                Parallel.ForEach <List <AppDRESTBackend>, int>(
                                    listOfBackendsInHourChunks,
                                    parallelOptions,
                                    () => 0,
                                    (listOfBackendsInHourChunk, loop, subtotal) =>
                                {
                                    // Set up controller access
                                    ControllerApi controllerApiParallel = new ControllerApi(jobTarget.Controller, jobTarget.UserName, AESEncryptionHelper.Decrypt(jobTarget.UserPassword));
                                    // Login into private API
                                    controllerApiParallel.PrivateApiLogin();

                                    foreach (AppDRESTBackend backend in listOfBackendsInHourChunk)
                                    {
                                        if (File.Exists(FilePathMap.APMBackendToDBMonMappingDataFilePath(jobTarget, backend)) == false)
                                        {
                                            string backendToDBMonMappingJSON = controllerApi.GetAPMBackendToDBMonMapping(backend.id);
                                            if (backendToDBMonMappingJSON != String.Empty)
                                            {
                                                FileIOHelper.SaveFileToPath(backendToDBMonMappingJSON, FilePathMap.APMBackendToDBMonMappingDataFilePath(jobTarget, backend));
                                            }
                                        }
                                    }

                                    return(listOfBackendsInHourChunk.Count);
                                },
                                    (finalResult) =>
                                {
                                    Interlocked.Add(ref j, finalResult);
                                    Console.Write("[{0}].", j);
                                }
                                    );

                                loggerConsole.Info("Completed {0} Backends", backendsList.Count);

                                stepTimingTarget.NumEntities = stepTimingTarget.NumEntities + backendsList.Count;
                            }

                            #endregion

                            #region Business Transactions

                            loggerConsole.Info("List of Business Transactions");

                            string businessTransactionsJSON = controllerApi.GetAPMBusinessTransactions(jobTarget.ApplicationID);
                            if (businessTransactionsJSON != String.Empty)
                            {
                                FileIOHelper.SaveFileToPath(businessTransactionsJSON, FilePathMap.APMBusinessTransactionsDataFilePath(jobTarget));
                            }

                            #endregion

                            #region Service Endpoints

                            loggerConsole.Info("List of Service Endpoints");

                            string serviceEndPointsJSON = controllerApi.GetAPMServiceEndpoints(jobTarget.ApplicationID);
                            if (serviceEndPointsJSON != String.Empty)
                            {
                                FileIOHelper.SaveFileToPath(serviceEndPointsJSON, FilePathMap.APMServiceEndpointsDataFilePath(jobTarget));
                            }

                            controllerApi.PrivateApiLogin();
                            serviceEndPointsJSON = controllerApi.GetAPMServiceEndpointsAdditionalDetail(jobTarget.ApplicationID);
                            if (serviceEndPointsJSON != String.Empty)
                            {
                                FileIOHelper.SaveFileToPath(serviceEndPointsJSON, FilePathMap.APMServiceEndpointsDetailDataFilePath(jobTarget));
                            }

                            #endregion

                            #region Errors

                            loggerConsole.Info("List of Errors");

                            string errorsJSON = controllerApi.GetAPMErrors(jobTarget.ApplicationID);
                            if (errorsJSON != String.Empty)
                            {
                                FileIOHelper.SaveFileToPath(errorsJSON, FilePathMap.APMErrorsDataFilePath(jobTarget));
                            }

                            #endregion

                            #region Information Points

                            loggerConsole.Info("List of Information Points");

                            string informationPointsJSON = controllerApi.GetAPMInformationPoints(jobTarget.ApplicationID);
                            if (informationPointsJSON != String.Empty)
                            {
                                FileIOHelper.SaveFileToPath(informationPointsJSON, FilePathMap.APMInformationPointsDataFilePath(jobTarget));
                            }

                            controllerApi.PrivateApiLogin();
                            string informationPointsDetailJSON = controllerApi.GetAPMInformationPointsAdditionalDetail(jobTarget.ApplicationID);
                            if (informationPointsDetailJSON != String.Empty)
                            {
                                FileIOHelper.SaveFileToPath(informationPointsDetailJSON, FilePathMap.APMInformationPointsDetailDataFilePath(jobTarget));
                            }

                            #endregion

                            #region Node Properties

                            List <AppDRESTNode> nodesList = FileIOHelper.LoadListOfObjectsFromFile <AppDRESTNode>(FilePathMap.APMNodesDataFilePath(jobTarget));
                            if (nodesList != null)
                            {
                                loggerConsole.Info("Node Properties for Nodes ({0} entities)", nodesList.Count);

                                int j = 0;

                                var listOfNodesInHourChunks = nodesList.BreakListIntoChunks(ENTITIES_EXTRACT_NUMBER_OF_NODES_TO_PROCESS_PER_THREAD);

                                ParallelOptions parallelOptions = new ParallelOptions();
                                if (programOptions.ProcessSequentially == true)
                                {
                                    parallelOptions.MaxDegreeOfParallelism = 1;
                                }
                                else
                                {
                                    parallelOptions.MaxDegreeOfParallelism = NODE_PROPERTIES_EXTRACT_NUMBER_OF_THREADS;
                                }

                                Parallel.ForEach <List <AppDRESTNode>, int>(
                                    listOfNodesInHourChunks,
                                    parallelOptions,
                                    () => 0,
                                    (listOfNodesInHourChunk, loop, subtotal) =>
                                {
                                    // Set up controller access
                                    ControllerApi controllerApiParallel = new ControllerApi(jobTarget.Controller, jobTarget.UserName, AESEncryptionHelper.Decrypt(jobTarget.UserPassword));

                                    // Login into private API
                                    controllerApiParallel.PrivateApiLogin();

                                    foreach (AppDRESTNode node in listOfNodesInHourChunk)
                                    {
                                        if (File.Exists(FilePathMap.APMNodeRuntimePropertiesDataFilePath(jobTarget, node)) == false)
                                        {
                                            string nodePropertiesJSON = controllerApi.GetAPMNodeProperties(node.id);
                                            if (nodePropertiesJSON != String.Empty)
                                            {
                                                FileIOHelper.SaveFileToPath(nodePropertiesJSON, FilePathMap.APMNodeRuntimePropertiesDataFilePath(jobTarget, node));
                                            }
                                        }
                                        if (File.Exists(FilePathMap.APMNodeMetadataDataFilePath(jobTarget, node)) == false)
                                        {
                                            string nodeMetadataJSON = controllerApi.GetAPMNodeMetadata(jobTarget.ApplicationID, node.id);
                                            if (nodeMetadataJSON != String.Empty)
                                            {
                                                FileIOHelper.SaveFileToPath(nodeMetadataJSON, FilePathMap.APMNodeMetadataDataFilePath(jobTarget, node));
                                            }
                                        }
                                    }

                                    return(listOfNodesInHourChunk.Count);
                                },
                                    (finalResult) =>
                                {
                                    Interlocked.Add(ref j, finalResult);
                                    Console.Write("[{0}].", j);
                                }
                                    );

                                loggerConsole.Info("Completed {0} Nodes", nodesList.Count);

                                stepTimingTarget.NumEntities = stepTimingTarget.NumEntities + nodesList.Count;
                            }

                            #endregion

                            #region Backend to Tier Mappings

                            List <AppDRESTTier> tiersRESTList = FileIOHelper.LoadListOfObjectsFromFile <AppDRESTTier>(FilePathMap.APMTiersDataFilePath(jobTarget));
                            if (tiersRESTList != null)
                            {
                                loggerConsole.Info("Backend to Tier Mappings ({0} entities)", tiersRESTList.Count);

                                int j = 0;

                                foreach (AppDRESTTier tier in tiersRESTList)
                                {
                                    string backendMappingsJSON = controllerApi.GetAPMBackendToTierMapping(tier.id);
                                    if (backendMappingsJSON != String.Empty && backendMappingsJSON != "[ ]")
                                    {
                                        FileIOHelper.SaveFileToPath(backendMappingsJSON, FilePathMap.APMBackendToTierMappingDataFilePath(jobTarget, tier));
                                    }

                                    if (j % 10 == 0)
                                    {
                                        Console.Write("[{0}].", j);
                                    }
                                    j++;
                                }

                                loggerConsole.Info("Completed {0} Tiers", tiersRESTList.Count);

                                stepTimingTarget.NumEntities = stepTimingTarget.NumEntities + tiersRESTList.Count;
                            }

                            #endregion

                            #region Overflow Business Transactions

                            if (tiersRESTList != null)
                            {
                                loggerConsole.Info("Contents of Overflow Business Transaction in Tiers ({0} entities)", tiersRESTList.Count);

                                int j = 0;

                                foreach (AppDRESTTier tier in tiersRESTList)
                                {
                                    JArray droppedBTsArray          = new JArray();
                                    JArray droppedBTsDebugModeArray = new JArray();

                                    bool noMoreBTs = false;
                                    long currentFetchedEventCount = 0;
                                    long endEventID = 0;
                                    while (noMoreBTs == false)
                                    {
                                        string batchOfBTsJSON = controllerApi.GetAPMBusinessTransactionsInOverflow(tier.id, currentFetchedEventCount, endEventID, fromTimeUnix, toTimeUnix, differenceInMinutes);

                                        if (batchOfBTsJSON != String.Empty)
                                        {
                                            JObject batchOfBTsContainer = JObject.Parse(batchOfBTsJSON);
                                            if (batchOfBTsContainer != null)
                                            {
                                                // Copy out both of the containers, not sure why there are multiple
                                                if (isTokenPropertyNull(batchOfBTsContainer, "droppedTransactionItemList") == false)
                                                {
                                                    foreach (JObject btObject in batchOfBTsContainer["droppedTransactionItemList"])
                                                    {
                                                        droppedBTsArray.Add(btObject);
                                                    }
                                                }
                                                if (isTokenPropertyNull(batchOfBTsContainer, "debugModeDroppedTransactionItemList") == false)
                                                {
                                                    foreach (JObject btObject in batchOfBTsContainer["debugModeDroppedTransactionItemList"])
                                                    {
                                                        droppedBTsDebugModeArray.Add(btObject);
                                                    }
                                                }

                                                currentFetchedEventCount = getLongValueFromJToken(batchOfBTsContainer, "eventSummariesCount");
                                                endEventID = getLongValueFromJToken(batchOfBTsContainer, "endEventId");

                                                if (currentFetchedEventCount == 0 || endEventID == 0)
                                                {
                                                    // Done getting batches
                                                    noMoreBTs = true;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            noMoreBTs = true;
                                        }
                                    }

                                    if (droppedBTsArray.Count > 0)
                                    {
                                        FileIOHelper.SaveFileToPath(droppedBTsArray.ToString(), FilePathMap.APMTierOverflowBusinessTransactionRegularDataFilePath(jobTarget, tier));
                                    }
                                    if (droppedBTsDebugModeArray.Count > 0)
                                    {
                                        FileIOHelper.SaveFileToPath(droppedBTsDebugModeArray.ToString(), FilePathMap.APMTierOverflowBusinessTransactionDebugDataFilePath(jobTarget, tier));
                                    }

                                    if (j % 10 == 0)
                                    {
                                        Console.Write("[{0}].", j);
                                    }
                                    j++;
                                }

                                loggerConsole.Info("Completed {0} Tiers", tiersRESTList.Count);
                            }

                            #endregion
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Warn(ex);
                        loggerConsole.Warn(ex);

                        return(false);
                    }
                    finally
                    {
                        stopWatchTarget.Stop();

                        this.DisplayJobTargetEndedStatus(jobConfiguration, jobTarget, i + 1, stopWatchTarget);

                        stepTimingTarget.EndTime    = DateTime.Now;
                        stepTimingTarget.Duration   = stopWatchTarget.Elapsed;
                        stepTimingTarget.DurationMS = stopWatchTarget.ElapsedMilliseconds;

                        List <StepTiming> stepTimings = new List <StepTiming>(1);
                        stepTimings.Add(stepTimingTarget);
                        FileIOHelper.WriteListToCSVFile(stepTimings, new StepTimingReportMap(), FilePathMap.StepTimingReportFilePath(), true);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                loggerConsole.Error(ex);

                return(false);
            }
            finally
            {
                stopWatch.Stop();

                this.DisplayJobStepEndedStatus(jobConfiguration, stopWatch);

                stepTimingFunction.EndTime    = DateTime.Now;
                stepTimingFunction.Duration   = stopWatch.Elapsed;
                stepTimingFunction.DurationMS = stopWatch.ElapsedMilliseconds;

                List <StepTiming> stepTimings = new List <StepTiming>(1);
                stepTimings.Add(stepTimingFunction);
                FileIOHelper.WriteListToCSVFile(stepTimings, new StepTimingReportMap(), FilePathMap.StepTimingReportFilePath(), true);
            }
        }