public static bool OnListExchangePaginated(JToken id, string method, JArray parameters, out JToken result) { result = new JObject(); if (parameters == null || parameters.Count != 2) { result = RpcMessage.CreateErrorResult(id, RpcMessage.INVALID_PARAMS, "Invalid parameters"); return(false); } try { int offset = parameters[0].ToObject <int>(); int limit = parameters[1].ToObject <int>(); ExchangeList exchanges = RpcApiService.GetListExchangePaginated(offset, limit); result = JToken.FromObject(exchanges.ToByteArray()); } catch (ArgumentException e) { result = RpcMessage.CreateErrorResult(id, RpcMessage.INVALID_PARAMS, e.Message); return(false); } catch (System.Exception e) { result = RpcMessage.CreateErrorResult(id, RpcMessage.UNKNOWN_ERROR, e.Message); return(false); } return(true); }
public static ExchangeList GetListExchangePaginated(int offset, int limit) { if (offset < 0 || limit < 0) { throw new ArgumentException("offset and limit value must be >= 0"); } long latest_num = Manager.Instance.DBManager.DynamicProperties.GetLatestExchangeNum(); if (latest_num <= offset) { throw new ArgumentException("latest num is " + latest_num + ". offset num must be smaller than latest."); } limit = limit > Parameter.DatabaseParameters.EXCHANGE_COUNT_LIMIT_MAX ? Parameter.DatabaseParameters.EXCHANGE_COUNT_LIMIT_MAX : limit; long end = offset + limit; end = end > latest_num ? latest_num : end; ExchangeList result = new ExchangeList(); for (int i = offset; i < end; i++) { ExchangeCapsule exchange = Manager.Instance.DBManager.ExchangeFinal.Get(ExchangeCapsule.CalculateDatabaseKey(i)); if (exchange != null) { result.Exchanges.Add(exchange.Instance); } } return(result); }
public static RpcApiResult ListExchangePaginated(int offset, int limit, out ExchangeList exchanges) { exchanges = null; PaginatedMessage message = new PaginatedMessage(); message.Offset = offset; message.Limit = limit; JObject receive = SendCommand(RpcCommand.AssetIssue.ListExchange, new JArray() { message.ToByteArray() }); if (receive.TryGetValue("error", out JToken value)) { return(new RpcApiResult(false, value["code"].ToObject <int>(), value["message"].ToObject <string>())); } exchanges = ExchangeList.Parser.ParseFrom(receive["result"].ToObject <byte[]>()); return(RpcApiResult.Success); }
//需要调用窗体名称 System.Windows.Forms.Control INetUserControl.CreateControl(UFSoft.U8.Framework.Login.UI.clsLogin login, string MenuID, string Paramters) { UFSoft.U8.Framework.LoginContext.UserData LoginInfo = new UFSoft.U8.Framework.LoginContext.UserData(); LoginInfo = login.GetLoginInfo(); string conn = LoginInfo.ConnString; conn = Utils.ConvertConn(conn); DbHelperSQL.connectionString = conn; string sLogUserid = LoginInfo.UserId; string sLogUserName = LoginInfo.UserName; string sLogDate = LoginInfo.operDate; string sAccID = LoginInfo.AccID; //ClsUserRight clsUser = new ClsUserRight(); //if (clsUser.chkRight(login, "TH_ETS_02")) //{ ExchangeList fm = new ExchangeList(); fm.Conn = conn; fm.sUserID = sLogUserid; fm.sUserName = sLogUserName; fm.sLogDate = sLogDate; fm.sAccID = sAccID; this._Title = "Excehange"; return(fm); //} //else // return null; }
public ExchangeList List() { var list = new ExchangeList(); list.AddRange(this.ListHandler()); return(list); }
private void populateExchange() { ExchangeList.Add(Common.Enumerations.Exchange.BSE.ToString()); #if BOW ExchangeList.Add(Common.Enumerations.Exchange.NSE.ToString()); ExchangeList.Add(Common.Enumerations.Exchange.NCDEX.ToString()); ExchangeList.Add(Common.Enumerations.Exchange.MCX.ToString()); #endif SelectedExchange = Common.Enumerations.Exchange.BSE.ToString(); }
public static ExchangeList GetListExchange() { ExchangeList result = new ExchangeList(); foreach (var exchange in Manager.Instance.DBManager.ExchangeFinal.AllExchanges) { result.Exchanges.Add(exchange.Instance); } return(result); }
public static RpcApiResult ListExchange(out ExchangeList exchanges) { exchanges = null; JObject receive = SendCommand(RpcCommand.AssetIssue.ListExchange, new JArray() { }); if (receive.TryGetValue("error", out JToken value)) { return(new RpcApiResult(false, value["code"].ToObject <int>(), value["message"].ToObject <string>())); } exchanges = ExchangeList.Parser.ParseFrom(receive["result"].ToObject <byte[]>()); return(RpcApiResult.Success); }
private void GetExchangableItems() { ExchangeList.Add(new ExchangeItem { CountryName = "Japan", CountryCode = 3 }); ExchangeList.Add(new ExchangeItem { CountryName = "Canada", CountryCode = 4 }); ExchangeList.Add(new ExchangeItem { CountryName = "Euro", CountryCode = 20 }); ExchangeList.Add(new ExchangeItem { CountryName = "China", CountryCode = 33 }); ExchangeList.Add(new ExchangeItem { CountryName = "Mexico", CountryCode = 12 }); }
/// <summary> /// Initializes a new instance of the <see cref="EntityRegistry"/>. /// </summary> /// <param name="storage">The special interface for direct access to the storage.</param> public EntityRegistry(IStorage storage) { if (storage == null) throw new ArgumentNullException(nameof(storage)); Storage = storage; ConfigManager.TryRegisterService(storage); Exchanges = new ExchangeList(storage) { BulkLoad = true }; ExchangeBoards = new ExchangeBoardList(storage) { BulkLoad = true }; Securities = new SecurityList(this); Trades = new TradeList(storage); MyTrades = new MyTradeList(storage); Orders = new OrderList(storage); OrderFails = new OrderFailList(storage); Portfolios = new PortfolioList(storage); Positions = new PositionList(storage); News = new NewsList(storage); }
public static bool OnListExchange(JToken id, string method, JArray parameters, out JToken result) { result = new JObject(); if (parameters == null || parameters.Count != 0) { result = RpcMessage.CreateErrorResult(id, RpcMessage.INVALID_PARAMS, "Invalid parameters"); return(false); } try { ExchangeList exchanges = RpcApiService.GetListExchange(); result = JToken.FromObject(exchanges.ToByteArray()); } catch (System.Exception e) { result = RpcMessage.CreateErrorResult(id, RpcMessage.UNKNOWN_ERROR, e.Message); return(false); } return(true); }
public void AddExchange(Type exchangeType) { //If _exchangeList has not already been initialized, do so. if (_exchangeList == null) { _exchangeList = new List <BaseExchange>(); } if (exchangeType == typeof(Anx)) { _useAnx = true; ExchangeList.Add(new Anx(FiatType)); } else if (exchangeType == typeof(Bitfinex)) { _useBitstamp = true; ExchangeList.Add(new Bitfinex(FiatType)); } else if (exchangeType == typeof(Bitstamp)) { _useBitstamp = true; ExchangeList.Add(new Bitstamp(FiatType)); } else if (exchangeType == typeof(BitX)) { _useBitstamp = true; ExchangeList.Add(new BitX(FiatType)); } else if (exchangeType == typeof(Btce)) { _useBtce = true; ExchangeList.Add(new Btce(FiatType)); } else if (exchangeType == typeof(ItBit)) { _useItBit = true; ExchangeList.Add(new ItBit(FiatType)); } else if (exchangeType == typeof(Kraken)) { _useKraken = true; ExchangeList.Add(new Kraken(FiatType)); } else if (exchangeType == typeof(OkCoin)) { _useOkCoin = true; ExchangeList.Add(new OkCoin(FiatType)); } else if (exchangeType == typeof(Coinbase)) { _useCoinbase = true; ExchangeList.Add(new Coinbase(FiatType)); } else { throw new Exception("Unspported type."); } }
/// <summary> /// 生成收件清单 /// </summary> /// <param name="placeId">场所ID</param> /// <param name="objectId">流转对象ID</param> /// <param name="userId">用户ID</param> /// <param name="departmentId">收件单位ID</param> /// <returns></returns> public async Task <ResultEntity> CreateReceiveBill(int placeId, int objectId, int userId, int departmentId) { _logger.LogWarning($"--------------开始形成取件清单--------------"); var result = new ResultEntity(); var barcodeLogs = await _barcodeLogRepository.GetQueryable().Where(a => !a.IsSynBill && a.CurrentPlaceId == placeId && a.CurrentObjectId == objectId && a.BarcodeStatus == EnumBarcodeStatus.已签收).ToListAsync(); if (barcodeLogs.Count > 0) { var exchangeObject = await _exchangeObjectRepository.GetByIdAsync(objectId); var user = await _userRepository.GetByIdAsync(userId); var barcodeNumbers = barcodeLogs.Select(a => a.BarcodeNumber).ToList(); var letters = _letterRepository.GetQueryable().Include(a => a.ReceiveDepartment).Include(a => a.SendDepartment) .Where(a => barcodeNumbers.Contains(a.BarcodeNo)); //清单全局使用一个流水,防止串号 var serialNo = await _serialNumberManager.GetSerialNumber(0, EnumSerialNumberType.清单); var exchangeList = new ExchangeList { CreateBy = userId, CreateTime = DateTime.Now, DepartmentId = departmentId, ObjectName = exchangeObject.Name, ExchangeUserId = userId, ExchangeUserName = user.DisplayName, ObjectId = objectId, Printed = false, Type = EnumListType.收件清单 }; exchangeList.ListNo = exchangeList.GetListNo(serialNo); await _exchangeListRepository.AddAsync(exchangeList); await _unitOfWork.CommitAsync(); foreach (var letter in letters) { var barcodeLog = barcodeLogs.FirstOrDefault(a => a.BarcodeNumber == letter.BarcodeNo); if (barcodeLog != null) { var exchangeListDetail = new ExchangeListDetail { BarcodeNo = letter.LetterNo, CustomData = letter.CustomData, DetailType = barcodeLog.BarcodeSubStatus == EnumBarcodeSubStatus.退回 ? EnumListDetailType.收退件 : EnumListDetailType.收件, ExchangeListId = exchangeList.Id, ReceiveDepartmentName = letter.ReceiveDepartment.FullName, SendDepartmentName = letter.SendDepartment.FullName, SecSecretLevelText = letter.GetSecretLevel(letter.BarcodeNo).ToString(), UrgencyLevelText = letter.GetUrgencyLevel(letter.BarcodeNo).ToString(), Time = barcodeLog.LastOperationTime }; await _exchangeListDetailRepository.AddAsync(exchangeListDetail); barcodeLog.IsSynBill = true; } } result.Success = true; result.Data = exchangeList.Id; await _unitOfWork.CommitAsync(); } else { _logger.LogWarning($"暂无收件清单"); result.Message = "暂无收件清单"; } _logger.LogWarning($"--------------结束形成取件清单--------------"); return(result); }
/// <summary> /// 生成收发清单 /// </summary> /// <param name="placeId">场所ID</param> /// <param name="userId">用户ID</param> /// <param name="departmentId">单位ID</param> /// <returns></returns> public async Task <ResultEntity> CreateReceiveSendBill(int placeId, int userId, int departmentId) { _logger.LogWarning($"--------------开始形成收发件清单--------------"); var result = new ResultEntity(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var receiveBarcodeLogs = await _barcodeLogRepository.GetQueryable().Where(a => !a.IsSynBill && a.CurrentPlaceId == placeId && a.DepartmentId == departmentId && a.BarcodeStatus == EnumBarcodeStatus.已签收).ToListAsync(); stopwatch.Stop(); _logger.LogWarning($"receiveBarcodeLogs:{stopwatch.Elapsed.TotalSeconds}"); stopwatch.Restart(); var sendBarcodeLogs = await _barcodeLogRepository.GetQueryable().Where(a => !a.IsSynBill && a.CurrentPlaceId == placeId && a.DepartmentId == departmentId && a.BarcodeStatus == EnumBarcodeStatus.已投递).ToListAsync(); stopwatch.Stop(); _logger.LogWarning($"sendBarcodeLogs:{stopwatch.Elapsed.TotalSeconds}"); if (receiveBarcodeLogs.Count > 0 || sendBarcodeLogs.Count > 0) { //清单全局使用一个流水,防止串号 var serialNo = await _serialNumberManager.GetSerialNumber(0, EnumSerialNumberType.清单); var receiveBarcodeNumbers = receiveBarcodeLogs.Select(a => a.BarcodeNumber).ToList(); stopwatch.Restart(); var receiveLettesr = await _letterRepository.GetQueryable().Include(a => a.ReceiveDepartment).Include(a => a.SendDepartment) .Where(a => receiveBarcodeNumbers.Contains(a.BarcodeNo)).ToListAsync(); stopwatch.Stop(); _logger.LogWarning($"receiveLettesr:{stopwatch.Elapsed.TotalSeconds}"); var sendBarcodeNumbers = sendBarcodeLogs.Select(a => a.BarcodeNumber).ToList(); stopwatch.Restart(); var sendLetters = await _letterRepository.GetQueryable().Include(a => a.ReceiveDepartment) .Include(a => a.SendDepartment) .Where(a => sendBarcodeNumbers.Contains(a.BarcodeNo)).ToListAsync(); stopwatch.Stop(); _logger.LogWarning($"sendLetters:{stopwatch.Elapsed.TotalSeconds}"); var department = await _departmentRepository.GetByIdAsync(departmentId); var user = await _userRepository.GetByIdAsync(userId); //添加主清单 var exchangeList = new ExchangeList { CreateBy = userId, ObjectName = department.Name, ExchangeUserId = userId, ExchangeUserName = user.DisplayName, CreateTime = DateTime.Now, DepartmentId = departmentId, Printed = false, Type = EnumListType.收发清单 }; exchangeList.ListNo = exchangeList.GetListNo(serialNo); await _exchangeListRepository.AddAsync(exchangeList); await _unitOfWork.CommitAsync(); //添加收件详情 stopwatch.Restart(); foreach (var letter in receiveLettesr) { var barcodeLog = receiveBarcodeLogs.FirstOrDefault(a => a.BarcodeNumber == letter.BarcodeNo); if (barcodeLog != null) { var exchangeListDetail = new ExchangeListDetail { BarcodeNo = letter.LetterNo, CustomData = letter.CustomData, DetailType = barcodeLog.BarcodeSubStatus == EnumBarcodeSubStatus.退回 ? EnumListDetailType.收退件 : EnumListDetailType.收件, ExchangeListId = exchangeList.Id, ReceiveDepartmentName = letter.ReceiveDepartment.FullName, SendDepartmentName = letter.SendDepartment.FullName, SecSecretLevelText = letter.GetSecretLevel(letter.BarcodeNo).ToString(), UrgencyLevelText = letter.GetUrgencyLevel(letter.BarcodeNo).ToString(), Time = barcodeLog.LastOperationTime }; await _exchangeListDetailRepository.AddAsync(exchangeListDetail); barcodeLog.IsSynBill = true; } } //添加发件详情 foreach (var letter in sendLetters) { var barcodeLog = sendBarcodeLogs.FirstOrDefault(a => a.BarcodeNumber == letter.BarcodeNo); if (barcodeLog != null) { var exchangeListDetail = new ExchangeListDetail { BarcodeNo = letter.LetterNo, CustomData = letter.CustomData, DetailType = barcodeLog.BarcodeSubStatus == EnumBarcodeSubStatus.退回 ? EnumListDetailType.发退件 : EnumListDetailType.发件, ExchangeListId = exchangeList.Id, ReceiveDepartmentName = letter.ReceiveDepartment.FullName, SendDepartmentName = letter.SendDepartment.FullName, SecSecretLevelText = letter.GetSecretLevel(letter.BarcodeNo).ToString(), UrgencyLevelText = letter.GetUrgencyLevel(letter.BarcodeNo).ToString(), Time = barcodeLog.OperationTime }; await _exchangeListDetailRepository.AddAsync(exchangeListDetail); barcodeLog.IsSynBill = true; } } stopwatch.Stop(); _logger.LogWarning($"循环插入:{stopwatch.Elapsed.TotalSeconds}"); await _unitOfWork.CommitAsync(); result.Success = true; result.Data = exchangeList.Id; } else { result.Message = "暂无收发清单数据"; _logger.LogWarning($"暂无收发清单数据"); } _logger.LogWarning($"--------------结束形成收发件清单--------------"); return(result); }