public void OnReturn(IRetrieveRequestHandler handler) { if (Target is null || !handler.AllowSelectField(Target) || !handler.ShouldSelectField(Target)) { return; } var listHandler = handlerFactory.CreateHandler <IListRequestProcessor>(rowType); var listRequest = listHandler.CreateRequest(); listRequest.ColumnSelection = attr.ColumnSelection; listRequest.IncludeColumns = includeColumns; listRequest.Criteria = foreignKeyCriteria == new ValueCriteria(masterKeyField.AsObject(handler.Row)) & filterCriteria; IListResponse response = listHandler.Process(handler.Connection, listRequest); var list = rowListFactory(); foreach (var item in response.Entities) { list.Add(item); } Target.AsObject(handler.Row, list); }
public void OnReturn(IRetrieveRequestHandler handler) { if (ReferenceEquals(null, Target) || !handler.ShouldSelectField(Target)) { return; } var idField = (handler.Row as IIdRow).IdField; var listHandler = listHandlerFactory(); var listRequest = new ListRequest { ColumnSelection = ColumnSelection.List, EqualityFilter = new Dictionary <string, object> { { foreignKeyField.PropertyName ?? foreignKeyField.Name, idField[handler.Row] } } }; IListResponse response = listHandler.Process(handler.Connection, listRequest); var list = rowListFactory(); foreach (var item in response.Entities) { list.Add(item); } Target.AsObject(handler.Row, list); }
public static IActionResult ToHttpResponse <TModel>(this IListResponse <TModel> response) { return(new ObjectResult(response) { StatusCode = (int)response.HttpCode }); }
public bool Initialize(string jsonString = null) { if (jsonString == null && this.BaseUrl != "") { if (!_listDictionary) { IListResponse <T, R> mr = (IListResponse <T, R>) this.Send(); this._Success = mr.Success; this._Message = mr.Message; if (this.Success) { this.Process(mr); } } else { IListDictionaryResponse <T, R> mr = (IListDictionaryResponse <T, R>) this.Send(); this._Success = mr.Success; this._Message = mr.Message; if (this.Success) { this.Process(mr); } } return(this.Success); } else { return(false); } }
public static List <Zendesk> SearchCustomFieldTickets(string searchCriteria, ref List <long?> listTickets) { /* Created by Neil Jansen - 5 December 2018 * Create a list of Zendesk objects through filtering the custom fields in Zendesk * * Updated by Neil Jansen - 12 December 2018 * Changed function name to specify 'CustomFields' - Updated Zendesk list object creation to include new parameters */ ConnectToZendesk(); List <Zendesk> zendeskTickets = new List <Zendesk>(); IListResponse <Ticket> responses = client.Search.Find(new ZendeskQuery <Ticket>().WithCustomFilter("fieldvalue", searchCriteria)); List <Ticket> responseTickets = (List <Ticket>)responses.Results; ZendDeskEmailEntry fromEmails = new ZendDeskEmailEntry(); ZendDeskEmailEntry toEmails = new ZendDeskEmailEntry(); foreach (Ticket singleTicket in responseTickets) { if (!listTickets.Any(ticket => ticket.Equals(singleTicket.Id))) { fromEmails = ZendDeskEmailParser.GetEmailList(singleTicket.Via.Source.From); toEmails = ZendDeskEmailParser.GetEmailList(singleTicket.Via.Source.To); zendeskTickets.Add(new Zendesk(singleTicket.Id.ToString(), singleTicket.Created, singleTicket.Updated, singleTicket.Subject, singleTicket.Status.ToString(), singleTicket.Priority, false, fromEmails.Address, fromEmails.Name, toEmails.Address, toEmails.Name, singleTicket.RequesterId.GetValueOrDefault())); listTickets.Add(singleTicket.Id); } } return(zendeskTickets); }
public void OnReturn(IRetrieveRequestHandler handler) { if (ReferenceEquals(null, Target) || !handler.AllowSelectField(Target) || !handler.ShouldSelectField(Target)) { return; } var idField = (Field)((handler.Row as IIdRow).IdField); var listHandler = listHandlerFactory(); var listRequest = new ListRequest { ColumnSelection = this.attr.ColumnSelection, IncludeColumns = this.includeColumns, Criteria = foreignKeyCriteria == new ValueCriteria(idField.AsObject(handler.Row)) & filterCriteria }; IListResponse response = listHandler.Process(handler.Connection, listRequest); var list = rowListFactory(); foreach (var item in response.Entities) { list.Add(item); } Target.AsObject(handler.Row, list); }
public static List <Zendesk> SearchRequestorTickets(string searchCriteria, ref List <long?> listTickets) { /* Created by Neil Jansen - 18 December 2018 * Create a list of Zendesk objects through filtering the Description field in Zendesk */ //true if sandbox, false for production ConnectToZendesk(); List <Zendesk> zendeskTickets = new List <Zendesk>(); IListResponse <Ticket> responses = client.Search.Find(new ZendeskQuery <Ticket>().WithCustomFilter("requester", searchCriteria)); List <Ticket> responseTickets = (List <Ticket>)responses.Results; ZendDeskEmailEntry fromEmails = new ZendDeskEmailEntry(); ZendDeskEmailEntry toEmails = new ZendDeskEmailEntry(); foreach (Ticket singleTicket in responseTickets) { if (!listTickets.Any(ticket => ticket.Equals(singleTicket.Id))) { fromEmails = ZendDeskEmailParser.GetEmailList(singleTicket.Via.Source.From); toEmails = ZendDeskEmailParser.GetEmailList(singleTicket.Via.Source.To); zendeskTickets.Add(new Zendesk(singleTicket.Id.ToString(), singleTicket.Created, singleTicket.Updated, singleTicket.Subject, singleTicket.Status.ToString(), singleTicket.Priority, false, fromEmails.Address, fromEmails.Name, toEmails.Address, toEmails.Name, singleTicket.RequesterId.GetValueOrDefault())); listTickets.Add(singleTicket.Id); } } return(zendeskTickets); }
public void OnReturn(IRetrieveRequestHandler handler) { if (ReferenceEquals(null, Target) || !handler.AllowSelectField(Target) || !handler.ShouldSelectField(Target)) { return; } var listHandler = DefaultHandlerFactory.ListHandlerFor(rowType); var listRequest = DefaultHandlerFactory.ListRequestFor(rowType); listRequest.ColumnSelection = this.attr.ColumnSelection; listRequest.IncludeColumns = this.includeColumns; listRequest.Criteria = foreignKeyCriteria == new ValueCriteria(masterKeyField.AsObject(handler.Row)) & filterCriteria; IListResponse response = listHandler.Process(handler.Connection, listRequest); var list = rowListFactory(); foreach (var item in response.Entities) { list.Add(item); } Target.AsObject(handler.Row, list); }
public void OnReturn(IRetrieveRequestHandler handler) { if (ReferenceEquals(null, Target) || !handler.AllowSelectField(Target) || !handler.ShouldSelectField(Target)) { return; } var idField = (Field)((handler.Row as IIdRow).IdField); var listHandler = listHandlerFactory(); var listRequest = new ListRequest { ColumnSelection = ColumnSelection.KeyOnly, IncludeColumns = new HashSet <string> { itemKeyField.PropertyName ?? itemKeyField.Name }, Criteria = thisKeyCriteria == new ValueCriteria(idField.AsObject(handler.Row)) & filterCriteria }; IListResponse response = listHandler.Process(handler.Connection, listRequest); var list = listFactory(); foreach (Row item in response.Entities) { list.Add(itemKeyField.AsObject(item)); } Target.AsObject(handler.Row, list); }
public void OnReturn(IRetrieveRequestHandler handler) { if (Target is null || !handler.AllowSelectField(Target) || !handler.ShouldSelectField(Target)) { return; } var idField = handler.Row.IdField; var listHandler = handlerFactory.CreateHandler <IListRequestProcessor>(rowType); var listRequest = listHandler.CreateRequest(); listRequest.ColumnSelection = ColumnSelection.KeyOnly; listRequest.IncludeColumns = new HashSet <string> { itemKeyField.PropertyName ?? itemKeyField.Name }; listRequest.Criteria = thisKeyCriteria == new ValueCriteria(idField.AsObject(handler.Row)) & filterCriteria; IListResponse response = listHandler.Process(handler.Connection, listRequest); var list = listFactory(); foreach (IRow item in response.Entities) { list.Add(itemKeyField.AsObject(item)); } Target.AsObject(handler.Row, list); }
public void OnReturn(IListRequestHandler handler) { if (ReferenceEquals(null, Target) || !handler.ShouldSelectField(Target) || handler.Response.Entities.IsEmptyOrNull()) { return; } var idField = (Field)((handler.Row as IIdRow).IdField); var listHandler = listHandlerFactory(); var listRequest = new ListRequest { ColumnSelection = ColumnSelection.KeyOnly, IncludeColumns = new HashSet <string> { itemKeyField.PropertyName ?? itemKeyField.Name, thisKeyField.PropertyName ?? thisKeyField.Name } }; var thisKeyCriteria = new Criteria(thisKeyField.PropertyName ?? thisKeyField.Name); var enumerator = handler.Response.Entities.Cast <Row>(); while (true) { var part = enumerator.Take(1000); if (!part.Any()) { break; } enumerator = enumerator.Skip(1000); listRequest.Criteria = thisKeyCriteria.In( part.Select(x => idField.AsObject(x))); IListResponse response = listHandler.Process( handler.Connection, listRequest); var lookup = response.Entities.Cast <Row>() .ToLookup(x => thisKeyField.AsObject(x).ToString()); foreach (var row in part) { var list = listFactory(); var matching = lookup[idField.AsObject(row).ToString()]; foreach (var x in matching) { list.Add(itemKeyField.AsObject(x)); } Target.AsObject(row, list); } } }
public override void Process(IListResponse <Coin, CoinData> mr) { foreach (CoinData data in mr.Data) { CoinInfo ci = new CoinInfo(-1, data.CurrencyLong, data.Currency, null, data.CoinType, data.TxFee, 0, Convert.ToInt32(data.MinConfirmation), data.BaseAddress, data.IsActive, data.IsActive, (data.IsActive) ? CoinInfo.CoinStatus.OK : CoinInfo.CoinStatus.Unknown, null, null, null); this._Data.Add(data.Currency, ci); } }
public override void Process(IListResponse <Summary, SummaryData> mr) { foreach (SummaryData data in mr.Data) { this._Data.Add(data.MarketName, new SummaryInfo(-1, data.MarketName, data.High, data.Low, data.Volume, data.Last, data.BaseVolume, data.TimeStamp, data.Bid, data.Ask, data.OpenBuyOrders, data.OpenSellOrders, data.PrevDay, data.Created)); } }
public override void Process(IListResponse <Summary, SummaryData> mr) { foreach (SummaryData data in mr.Data) { string name = data.QuotedCurrency.ToString().ToUpper() + "-" + data.BaseCurrency; SummaryInfo si = new SummaryInfo(Convert.ToInt64(data.Id), name, Convert.ToDouble(data.HighMarketAsk), Convert.ToDouble(data.LowMarketBid), Convert.ToDouble(data.Volume24H), Convert.ToDouble(data.LastTradedPrice), 0, DateTime.UtcNow, Convert.ToDouble(data.MarketBid), Convert.ToDouble(data.MarketAsk), 0, 0, Convert.ToDouble(data.LastPrice24H), DateTime.UtcNow); this._Data.Add(name, si); } }
public static IActionResult ToHttpResponse <TModel>(this IListResponse <TModel> response) { var status = HttpStatusCode.OK; return(new ObjectResult(response) { StatusCode = (int)status }); }
public override void Process(IListResponse <Coin, CoinData> mr) { foreach (CoinData data in mr.Data) { string name = data.QuotedCurrency.ToString().ToUpper() + "-" + data.BaseCurrency; CoinInfo ci = new CoinInfo(Convert.ToInt64(data.Id), name, data.BaseCurrency, null, null, 0, 0, 0, null, !data.Disabled, !data.Disabled, (!data.Disabled) ? CoinInfo.CoinStatus.OK : CoinInfo.CoinStatus.Unknown, null, null, null); this._Data.Add(name, ci); } }
public void OnReturn(IListRequestHandler handler) { if (Target is null || !handler.AllowSelectField(Target) || !handler.ShouldSelectField(Target) || handler.Response.Entities.IsEmptyOrNull()) { return; } var idField = handler.Row.IdField; var listHandler = handlerFactory.CreateHandler <IListRequestProcessor>(rowType); var listRequest = listHandler.CreateRequest(); listRequest.ColumnSelection = ColumnSelection.KeyOnly; listRequest.IncludeColumns = new HashSet <string> { itemKeyField.PropertyName ?? itemKeyField.Name, thisKeyField.PropertyName ?? thisKeyField.Name }; var enumerator = handler.Response.Entities.Cast <IRow>(); while (true) { var part = enumerator.Take(1000); if (!part.Any()) { break; } enumerator = enumerator.Skip(1000); listRequest.Criteria = thisKeyCriteria.In( part.Select(x => idField.AsObject(x))) & filterCriteria; IListResponse response = listHandler.Process( handler.Connection, listRequest); var lookup = response.Entities.Cast <IRow>() .ToLookup(x => thisKeyField.AsObject(x).ToString()); foreach (var row in part) { var list = listFactory(); var matching = lookup[idField.AsObject(row).ToString()]; foreach (var x in matching) { list.Add(itemKeyField.AsObject(x)); } Target.AsObject(row, list); } } }
public override void Process(IListResponse <Markets, MarketData> mr) { foreach (MarketData data in mr.Data) { string symbol; string[] s = data.Symbol.Split("-".ToCharArray()); symbol = s[1] + "-" + s[0]; this._Data.Add(symbol, new MarketInfo(data.CoinType, data.CoinTypePair, data.CoinType, data.Trading, 0, data.FeeRate, data.FeeRate, Convert.ToDouble(data.High), Convert.ToDouble(data.Low), data.Vol, data.LastDealPrice, data.Sell, Convert.ToDouble(data.Buy), 0, 0, Convert.ToDouble(data.ChangeRate), 0, 0, 0, 0, 0)); } }
public void OnReturn(IListRequestHandler handler) { if (ReferenceEquals(null, Target) || !handler.AllowSelectField(Target) || !handler.ShouldSelectField(Target) || handler.Response.Entities.IsEmptyOrNull()) { return; } var idField = (Field)((handler.Row as IIdRow).IdField); var listHandler = listHandlerFactory(); var listRequest = new ListRequest { ColumnSelection = this.attr.ColumnSelection, IncludeColumns = this.includeColumns }; var enumerator = handler.Response.Entities.Cast <Row>(); while (true) { var part = enumerator.Take(1000); if (!part.Any()) { break; } enumerator = enumerator.Skip(1000); listRequest.Criteria = foreignKeyCriteria.In( part.Select(x => idField.AsObject(x))) & filterCriteria; IListResponse response = listHandler.Process( handler.Connection, listRequest); var lookup = response.Entities.Cast <Row>() .ToLookup(x => foreignKeyField.AsObject(x).ToString()); foreach (var row in part) { var list = rowListFactory(); var matching = lookup[idField.AsObject(row).ToString()]; foreach (var x in matching) { list.Add(x); } Target.AsObject(row, list); } } }
public static void Publish <TModel>(this Exception ex, IListResponse <TModel> response) { response.DidError = true; response.ErrorMessage = ex.Message; // todo: Add code to save exception in log file // todo: Add code to save exception in database // todo: Add code to send an email if exception is critical }
public override void Process(IListResponse <Coin, CoinData> mr) { foreach (CoinData data in mr.Data) { CoinInfo.ListingStatus listingstatus = CryptoShark2.CoinInfo.ListingStatusConverter(data.ListingStatus); CoinInfo.CoinStatus coinstatus = CryptoShark2.CoinInfo.CoinStatusConverter(data.Status); bool enabled = ValidateStatus(data.Status); CoinInfo ci = new CoinInfo(data.Id, data.Name, data.Symbol, data.Algorithm, null, data.WithdrawFee, data.MinWithdraw, Convert.ToInt32(data.DepositConfirmations), null, enabled, enabled, coinstatus, data.StatusMessage, null, null); this._Data.Add(data.Symbol, ci); } }
public override void Process(IListResponse <Coin, CoinData> mr) { foreach (CoinData data in mr.Data) { string infourl = null; if (data.InfoUrl != null) { infourl = data.InfoUrl.ToString(); } this._Data.Add(data.Coin, new CoinInfo(-1, data.Name, data.Coin, null, null, data.WithdrawMinFee, data.WithdrawMinAmount, Convert.ToInt32(data.ConfirmationCount), null, data.EnableDeposit, data.EnableWithdraw, (data.EnableDeposit && data.EnableWithdraw) ? CoinInfo.CoinStatus.OK : CoinInfo.CoinStatus.Unknown, null, infourl, null)); } }
public override void Process(IListResponse <Summary, SummaryData> mr) { foreach (SummaryData data in mr.Data) { string symbol; string[] s = data.Symbol.Split("-".ToCharArray()); symbol = s[1] + "-" + s[0]; this._Data.Add(symbol, new SummaryInfo(-1, symbol, data.High, data.Low, data.Vol, data.LastDealPrice, data.VolValue, new DateTime(data.Datetime), data.Buy, data.Sell, -1, -1, -1, new DateTime(data.Datetime))); } }
public static IActionResult ToHttpResponse<TModel>(this IListResponse<TModel> response) { var status = HttpStatusCode.OK; if (response.DidError) status = HttpStatusCode.InternalServerError; else if (response.Model == null) status = HttpStatusCode.NoContent; return new ObjectResult(response) { StatusCode = (int)status }; }
public void OnReturn(IListRequestHandler handler) { if (Target is null || !handler.AllowSelectField(Target) || !handler.ShouldSelectField(Target) || handler.Response.Entities.IsEmptyOrNull()) { return; } var listHandler = handlerFactory.CreateHandler <IListRequestProcessor>(rowType); var listRequest = listHandler.CreateRequest(); listRequest.ColumnSelection = attr.ColumnSelection; listRequest.IncludeColumns = includeColumns; var enumerator = handler.Response.Entities.Cast <IRow>(); while (true) { var part = enumerator.Take(1000); if (!part.Any()) { break; } enumerator = enumerator.Skip(1000); listRequest.Criteria = foreignKeyCriteria.In( part.Select(x => masterKeyField.AsObject(x))) & filterCriteria; IListResponse response = listHandler.Process( handler.Connection, listRequest); var lookup = response.Entities.Cast <IRow>() .ToLookup(x => foreignKeyField.AsObject(x).ToString()); foreach (var row in part) { var list = rowListFactory(); var matching = lookup[masterKeyField.AsObject(row).ToString()]; foreach (var x in matching) { list.Add(x); } Target.AsObject(row, list); } } }
public override void Process(IListResponse <Summary, SummaryData> mr) { foreach (SummaryData data in mr.Data) { string label = data.Label.Replace("/", "-"); string[] temp = label.Split("-".ToCharArray()); label = temp[1] + "-" + temp[0]; // for some reason, some exchanges report the same label more than once. if (!this._Data.ContainsKey(label)) { this._Data.Add(label, new SummaryInfo(data.TradePairId, label, data.High, data.Low, data.Volume, data.LastPrice, data.BaseVolume, DateTime.UtcNow, data.BidPrice, data.AskPrice, data.BuyVolume, data.SellVolume, data.Open, DateTime.UtcNow)); } } }
public override void Process(IListResponse <Markets, MarketData> mr) { foreach (MarketData data in mr.Data) { MarketInfo mi = new MarketInfo(); mi.MarketCurrency = data.MarketCurrency; mi.BaseCurrency = data.BaseCurrency; mi.Id = -1; mi.MarketName = data.MarketName; mi.MinTradeSize = Constants.MinTradeSize; mi.MakerFeeRate = Constants.TradeFee; mi.TakerFeeRate = Constants.TradeFee; mi.IsActive = data.IsActive; this._Data.Add(data.MarketName, mi); } }
public static IActionResult ToHttpResponse <TModel>(this IListResponse <TModel> response) { HttpStatusCode oK = HttpStatusCode.OK; if (response.DidError) { oK = HttpStatusCode.InternalServerError; } else if (response.Model == null) { oK = HttpStatusCode.NotFound; } ObjectResult result1 = new ObjectResult(response); result1.StatusCode = (new int?((int)oK)); return(result1); }
/// <summary> /// Override to create a model from an existing list response (used to transform /// between collection types while maintaining parameters such as page size, page count etc...). /// </summary> /// <param name="source"></param> /// <returns></returns> public static ListResponse <TModel> Create <TModel>(this IListResponse source, IEnumerable <TModel> items) where TModel : class { return(new ListResponse <TModel>() { Model = items, Columns = source.Columns, Help = source.Help, Title = source.Title, PageCount = source.PageCount, PageIndex = source.PageIndex, PageSize = source.PageSize, NextPartitionKey = source.NextPartitionKey, NextRowKey = source.NextRowKey, HasMoreRecords = source.HasMoreRecords, }); }
public static IActionResult toHttpResponse <TModel>(this IListResponse <TModel> listResponse) { var status = HttpStatusCode.OK; if (listResponse.DidError) { status = HttpStatusCode.InternalServerError; } else if (listResponse.Model == null) { status = HttpStatusCode.NotFound; } return(new ObjectResult(listResponse) { StatusCode = (int)status }); }
public void ThenItShouldBeChanged() { _userIdentities = _client.UserIdentities.GetAll(_user.Id ?? 0); Assert.That(_userIdentities.Results.First().Value == _randomEmail); }
public void WhenICallUserIdentityResourceGetAllForThisUser() { _userIdentities = _client.UserIdentities.GetAll(_user.Id ?? 0); }
public void ThenItShouldBeChanged() { _userIdentities = _client.UserIdentities.GetAll(_user.Id ?? 0); Assert.That(_userIdentities.Results.First().Value == "*****@*****.**"); }