Beispiel #1
0
        public IHttpActionResult SubmitLog([FromBody] LoggingMessage logging)
        {
            switch (logging.LogType)
            {
            case 1:
                Devicelog.Info(null, logging.PrepareLogMessage());
                break;

            case 2:
                Devicelog.Warn(null, logging.PrepareLogMessage());
                break;

            case 3:
                Devicelog.Debug(null, logging.PrepareLogMessage());
                break;

            case 4:
                Devicelog.Error(logging.ExceptionObj, logging.PrepareLogMessage());
                break;

            default:
                Devicelog.Info(null, logging.PrepareLogMessage());
                break;
            }

            return(Ok(new { Status = Constants.WebApiStatusOk, data = "Success" }));
        }
        public void GetItem(string key)
        {
            int retries = MAX_RETRIES;

            while (retries > 0)
            {
                try
                {
                    if (Database.Instance.Multiplexer.IsConnected)
                    {
                        var redisValue = Database.Instance.StringGet(key);
                        var message    = redisValue.IsNullOrEmpty ? NoValueFound : Success;
                        logger.Info($"Geting item {key} : {Success} (from {MAX_RETRIES - retries + 1})");
                        break;
                    }
                    else
                    {
                        retries--;
                        if (retries == 0)
                        {
                            logger.Info($"Get failed...{MAX_RETRIES} retries");
                        }
                    }
                }
                catch (Exception e)
                {
                    retries--;
                    if (retries == 0)
                    {
                        logger.Error(e, $"{e.Message}, {e.StackTrace}");
                    }
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// 電源状態の変化イベント
 /// </summary>
 /// <param name="sender">object</param>
 /// <param name="e">イベント引数</param>
 private void SystemEvents_PowerModeChanged(object sender, Microsoft.Win32.PowerModeChangedEventArgs e)
 {
     if (e.Mode == Microsoft.Win32.PowerModes.Suspend)
     {
         powerdownflag = true;
         appLog.Info("<TM> [{0}] 電源がサスペンド状態になりました。", string.IsNullOrWhiteSpace(Name) ? "" : Name);
     }
     else if (e.Mode == Microsoft.Win32.PowerModes.Resume)
     {
         appLog.Info("<TM> [{0}] 電源がサスペンド状態から復帰しました。", Name);
     }
 }
Beispiel #4
0
 public void GetItem(string key)
 {
     try
     {
         var redisValue = Database.Instance.StringGet(key);
         var message    = redisValue.IsNullOrEmpty ? NoValueFound : Success;
         logger.Info($"Geting item {key} : {Success}");
     }
     catch (Exception e)
     {
         logger.Error(e, e.Message);
     }
 }
Beispiel #5
0
        public IHttpActionResult WebRegistration(UserProfile model)
        {
            string message = string.Empty;

            using (var userRepository = new UserRepository())
            {
                var result = userRepository.WebRegistration(model, out message);
                if (!string.IsNullOrEmpty(message))
                {
                    log.Info(message);
                }

                return(Ok(new { result.Status, data = result }));
            }
        }
Beispiel #6
0
        public IHttpActionResult GetUserDetailsById(long userId)
        {
            string message = string.Empty;

            using (var userRepository = new UserRepository())
            {
                var result = userRepository.GetUserDetailById(userId, out message);
                if (!string.IsNullOrEmpty(message))
                {
                    log.Info(message);
                }

                return(Ok(new { result.Status, data = result }));
            }
        }
        public IHttpActionResult SubmitBidding(BiddingProfile posting)
        {
            string message = string.Empty;

            using (var repository = new BiddingRepository(posting.userid))
            {
                var result = repository.BiddingSubmition(posting, out message);
                if (!string.IsNullOrEmpty(message))
                {
                    log.Info(message);
                }

                return(Ok(new { result.Status, data = result }));
            }
        }
Beispiel #8
0
        public void RefreshPartyList(
            IEnumerable <uint> partyIDList)
        {
            lock (LockObject)
            {
                var dic   = this.GetCombatantMainDictionary();
                var party = partyIDList
                            .Where(x => dic.ContainsKey(x))
                            .Select(x => dic[x])
                            .ToArray();

                var sortedPartyList =
                    from x in party
                    orderby
                    x.IsPlayer ? 0 : 1,
                    x.DisplayOrder,
                    x.Role.ToSortOrder(),
                    x.Job,
                    x.ID descending
                select
                    x;

                this.PartyList.Clear();
                this.PartyList.AddRange(sortedPartyList);

                this.PartyCount = party.Length;

                var composition = PartyCompositions.Unknown;

                if (this.PartyCount == 4)
                {
                    composition = PartyCompositions.LightParty;
                }
                else
                {
                    if (this.PartyCount >= 8)
                    {
                        var tanks = party.Count(x => x.Role == Roles.Tank);
                        switch (tanks)
                        {
                        case 1:
                        case 3:
                            composition = PartyCompositions.FullPartyT1;
                            break;

                        case 2:
                        case 6:
                            composition = PartyCompositions.FullPartyT2;
                            break;
                        }
                    }
                }

                if (this.PartyComposition != composition)
                {
                    this.PartyComposition = composition;
                    AppLogger.Info($"party composition changed. current={composition} party_count={party.Length}");
                }
            }
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            var logger = new AppLogger(@"D:\Logs");

            //Info
            //Warning
            //Errors
            //2019_09_23_18_23.text
            // zalowoano info

            logger.SaveDirecotry(@"D:\");

            logger.Info(@"Zalogownao info...");

            //try
            //{
            //    logger.Warning(@"Zalgowano waring...")
            //}
            //catch (Exception ex)
            //{

            //    logger.Error(ex.Message);
            //}

            Console.Read();
        }
        /// <summary>
        /// 获取条件单
        /// </summary>
        /// <param name="contractCode"></param>
        /// <returns></returns>
        private static long QueryConditionOrders(string contractCode)
        {
            _logger.Start();
            var req = new QueryConditionOrdersRequest
            {
                ContractCodeList = new List <string>()
                {
                    contractCode
                },
                TaskTypeList   = new List <int>(),
                TrigTypeList   = new List <int>(),
                TaskStatusList = new List <int>(),
                Direct         = 0,
                Side           = 0,
                StartTime      = 0,
                EndTime        = 0
            };
            var data = _tradeClient.QueryConditionOrdersAsync(req).Result;

            _logger.StopAndLog();
            AppLogger.Info($"query condition orders, data:{JsonConvert.SerializeObject(data)}");

            long taskId = 0;

            if (data != null && data.Result.Any())
            {
                taskId = data.Result.FirstOrDefault(x => x.TaskStatus == 1)?.TaskId ?? 0;
            }

            return(taskId);
        }
        public IHttpActionResult Put(int id, ModelEmployee model)
        {
            try
            {
                var emp = _unitOfWork.Employees.GetById(id);
                if (emp == null)
                {
                    return(NotFound());
                }

                //(Source,Destination)
                _mapper.Map(model, emp);

                if (_unitOfWork.Complete() > 0)
                {
                    AppLogger.Info("Update employee successful. From: Employees using Web API");
                    return(Ok(_mapper.Map <ModelEmployee>(emp)));
                }
                else
                {
                    AppLogger.Error("Update employee error. From: Employees using Web API");
                    return(InternalServerError());
                }
            }
            catch (Exception ex)
            {
                AppLogger.Error("Update employee error. From: Employees using Web API");
                return(InternalServerError(ex));
            }
        }
        public IHttpActionResult Delete(int id)
        {
            try
            {
                var emp = _unitOfWork.Employees.GetById(id);
                if (emp == null)
                {
                    return(NotFound());
                }

                _unitOfWork.Employees.Remove(emp);


                if (_unitOfWork.Complete() > 0)
                {
                    var result = _unitOfWork.Employees.GetAll();

                    //Mapping
                    var mappedResult = _mapper.Map <IEnumerable <ModelEmployee> >(result);

                    AppLogger.Info("Delete employee successful. From: Employees using Web API");
                    return(Ok(mappedResult));
                }
                else
                {
                    AppLogger.Error("Delete employee error. From: Employees using Web API");
                    return(InternalServerError());
                }
            }
            catch (Exception ex)
            {
                AppLogger.Error("Delete employee error. From: Employees using Web API");
                return(InternalServerError(ex));
            }
        }
Beispiel #13
0
        public ActionResult Create(ModelEmployeeMvc emp)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (db)
                    {
                        DynamicParameters param = new DynamicParameters();
                        param.Add("@firstName", emp.FirstName);
                        param.Add("@lastName", emp.LastName);
                        param.Add("@contactNumber", emp.ContactNumber);
                        param.Add("@email", emp.Email);
                        param.Add("@address", emp.Address);

                        db.Open();
                        db.Execute("AddNewEmployee", param, commandType: CommandType.StoredProcedure);

                        AppLogger.Info("Insert new employee. From: Employees using Dapper");
                        db.Close();
                        return(RedirectToAction("Index"));
                    }
                }
                return(View());
            }
            catch (Exception ex)
            {
                AppLogger.Error("Insert new employee error. From: Employees using Dapper");
                return(View(ex));
            }
        }
Beispiel #14
0
 public ActionResult DeleteConfirm(int id)
 {
     try
     {
         if (id > 0)
         {
             using (db)
             {
                 db.Open();
                 DynamicParameters param = new DynamicParameters();
                 param.Add("@empId", id);
                 db.Query <ModelEmployeeMvc>("DeleteEmployee", param, commandType: CommandType.StoredProcedure).SingleOrDefault();
                 db.Close();
                 AppLogger.Info("Get employee successful. From: Employees using Dapper");
                 return(RedirectToAction("Index"));
             }
         }
         AppLogger.Info("Get employee unsuccessful. From: Employees using Dapper");
         return(HttpNotFound());
     }
     catch
     {
         AppLogger.Info("Get employee error. From: Employees using Dapper");
         return(View());
     }
 }
        /// <summary>
        /// Subscribe order update for these events: creation, trade, cancellation.
        /// </summary>
        /// <param name="symbol">Trading symbol (wildcard * is allowed)</param>
        /// <param name="clientId"></param>
        public void Subscribe(string symbol, string clientId = "")
        {
            string topic = $"orders#{symbol}";

            _WebSocket.Send($"{{\"action\":\"sub\", \"ch\":\"{topic}\", \"cid\": \"{clientId}\" }}");

            AppLogger.Info($"WebSocket subscribed, topic={topic}");
        }
        /// <summary>
        /// Unsubscribe market by price order book
        /// </summary>
        /// <param name="symbol">Trading symbol</param>
        /// <param name="type">Market depth aggregation level</param>
        /// <param name="clientId">Client id</param>
        public void UnSubscribe(string symbol, string type, string clientId = "")
        {
            string topic = $"market.{symbol}.depth.{type}";

            _WebSocket.Send($"{{\"unsub\": \"{topic}\",\"id\": \"{clientId}\" }}");

            AppLogger.Info($"WebSocket subscribed, topic={topic}, clientId={clientId}");
        }
Beispiel #17
0
        /// <summary>
        /// Unsubscribe balance updates
        /// </summary>
        /// <param name="model">Whether to include frozen balance.</param>
        /// <param name="clientId">Client id</param>
        public void UnSubscribe(string model, string clientId = "")
        {
            string topic = "accounts";

            _WebSocket.Send($"{{ \"op\":\"unsub\", \"cid\": \"{clientId}\", \"topic\":\"{topic}\", \"model\": \"{model}\" }}");

            AppLogger.Info($"WebSocket unsubscribed, topic={topic}, model={model}");
        }
        /// <summary>
        /// Get order details by a given order ID.
        /// </summary>
        /// <param name="orderId">Order id</param>
        /// <param name="clientId">Client id</param>
        public void Request(string orderId, string clientId = "")
        {
            string topic = "orders.detail";

            _WebSocket.Send($"{{ \"op\":\"req\", \"cid\": \"{clientId}\", \"topic\":\"{topic}\", \"order-id\":\"{orderId}\" }}");

            AppLogger.Info($"WebSocket requested, topic={topic}, orderId={orderId}");
        }
Beispiel #19
0
        /// <summary>
        /// Unsubscribe balance updates
        /// </summary>
        /// <param name="mode">Trigger mode</param>
        /// <param name="clientId">Client id</param>
        public void UnSubscribe(string mode, string clientId = "")
        {
            string topic = $"accounts.update#{mode}";

            _WebSocket.Send($"{{\"action\":\"unsub\", \"cid\": \"{clientId}\", \"ch\":\"{topic}\" }}");

            AppLogger.Info($"WebSocket unsubscribed, topic={topic}");
        }
Beispiel #20
0
        /// <summary>
        /// Unsubscribe trade update
        /// </summary>
        /// <param name="symbol">Trading symbol (wildcard * is allowed)</param>
        /// <param name="clientId">Client id</param>
        public void UnSubscribe(string symbol, string clientId = "")
        {
            string topic = $"trade.clearing#{symbol}";

            _WebSocket.Send($"{{\"action\":\"unsub\", \"cid\": \"{clientId}\", \"ch\":\"{topic}\" }}");

            AppLogger.Info($"WebSocket subscribed, topic={topic}, clientId={clientId}");
        }
        /// <summary>
        /// Request the full candlestick data according to specified criteria
        /// </summary>
        /// <param name="symbol">Trading symbol</param>
        /// <param name="period">Candlestick internval
        /// possible values: 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1mon, 1week, 1year</param>
        /// <param name="from">From timestamp in second</param>
        /// <param name="to">To timestamp in second</param>
        /// <param name="clientId">Client id</param>
        public void Req(string symbol, string period, int from, int to, string clientId = "")
        {
            string topic = $"market.{symbol}.kline.{period}";

            _WebSocket.Send($"{{ \"req\": \"{topic}\",\"id\": \"{clientId}\", \"from\":{from}, \"to\":{to} }}");

            AppLogger.Info($"WebSocket requested, topic={topic}, clientId={clientId}");
        }
        /// <summary>
        /// Unsubscribe order updates
        /// </summary>
        /// <param name="symbol">Trading symbol</param>
        /// <param name="clientId">Client id</param>
        public void UnSubscribe(string symbol, string clientId = "")
        {
            string topic = $"orders.{symbol}.update";

            _WebSocket.Send($"{{ \"op\":\"unsub\", \"cid\": \"{clientId}\", \"topic\":\"{topic}\" }}");

            AppLogger.Info($"WebSocket unsubscribed, topic={topic}, clientId={clientId}");
        }
Beispiel #23
0
        /// <summary>
        /// Unsubscribe full Market By Price order book
        /// </summary>
        /// <param name="symbol">Trading symbol</param>
        /// <param name="level">Number of price levels: 5, 10, 20</param>
        /// <param name="clientId">Client id</param>
        public void UnSubscribeFull(string symbol, int level, string clientId = "")
        {
            string topic = $"market.{symbol}.mbp.refresh.{level}";

            _WebSocket.Send($"{{\"unsub\": \"market.{symbol}.mbp.refresh.{level}\",\"id\": \"{clientId}\" }}");

            AppLogger.Info($"WebSocket unsubscribed, topic={topic}, clientId={clientId}");
        }
Beispiel #24
0
        /// <summary>
        /// Subscribe incremental update of Market By Price order book
        /// </summary>
        /// <param name="symbol">Trading symbol</param>
        /// <param name="clientId">Client id</param>
        public void Subscribe(string symbol, string clientId = "")
        {
            string topic = $"market.{symbol}.mbp.150";

            _WebSocket.Send($"{{\"sub\": \"{topic}\",\"id\": \"{clientId}\" }}");

            AppLogger.Info($"WebSocket subscribed, topic={topic}, clientId={clientId}");
        }
Beispiel #25
0
        /// <summary>
        /// Request full Market By Price order book
        /// </summary>
        /// <param name="symbol">Trading symbol, Only support 39 currency pairs at this point of time
        /// Possible values: btcusdt, ethusdt, eosusdt, bchusdt, ltcusdt, xrpusdt, htusdt, bsvusdt,
        /// etcusdt, zecusdt, ethbtc, eosbtc, bchbtc, ltcbtc, xrpbtc, htbtc, bsvbtc, etcbtc, zecbtc,
        /// idtbtc, hotbtc, xmxeth, zechusd, lxteth, ucbtc, uuubtc, gtceth, mxcbtc, datxbtc, uipbtc,
        /// butbtc, tosbtc, musketh, ftibtc, rteeth, fairbtc, covabtc, renbtc, manbtc
        /// </param>
        /// <param name="clientId">Client id</param>
        public void Req(string symbol, string clientId = "")
        {
            string topic = $"market.{symbol}.mbp.150";

            _WebSocket.Send($"{{\"req\": \"{topic}\",\"id\": \"{clientId}\" }}");

            AppLogger.Info($"WebSocket request, topic={topic}, clientId={clientId}");
        }
        /// <summary>
        /// Request all account data of the current user.
        /// </summary>
        /// <param name="clientId">Client id</param>
        public void Request(string clientId = "")
        {
            string topic = "accounts.list";

            _WebSocket.Send($"{{ \"op\":\"req\", \"cid\":\"{clientId}\", \"topic\": \"{topic}\" }}");

            AppLogger.Info($"WebSocket requested, topic={topic}");
        }
        /// <summary>
        /// 获取持仓
        /// </summary>
        private static void GetPositions()
        {
            _logger.Start();
            var data = _tradeClient.GetPositionsAsync().Result;

            _logger.StopAndLog();

            AppLogger.Info($"get positions, data:{JsonConvert.SerializeObject(data)}");
        }
Beispiel #28
0
        /// <summary>
        /// 获取最新成交
        /// </summary>
        private static void GetTrades()
        {
            _logger.Start();
            var data = _marketClient.GetTradesAsync("BTCUSDT", 10).Result;

            _logger.StopAndLog();

            AppLogger.Info($"get trades, data:{JsonConvert.SerializeObject(data)}");
        }
Beispiel #29
0
        /// <summary>
        /// 获取合约深度信息
        /// </summary>
        private static void PostQueryMarketDepth()
        {
            _logger.Start();
            var data = _marketClient.PostQueryMarketDepthAsync("BTCUSDT", 10).Result;

            _logger.StopAndLog();

            AppLogger.Info($"post query market depth, data:{JsonConvert.SerializeObject(data)}");
        }
        /// <summary>
        /// 获取活跃委托
        /// </summary>
        /// <param name="contractCode"></param>
        private static void GetOpenOrders(string contractCode)
        {
            _logger.Start();
            var data = _tradeClient.GetOpenOrdersAsync(contractCode).Result;

            _logger.StopAndLog();

            AppLogger.Info($"get open orders, data:{JsonConvert.SerializeObject(data)}");
        }