Exemple #1
0
        public static async Task <ApiResponse> ListFilterTrans(FilterIM filter, int count, int skip = 0, bool includeWatchOnly = true)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                Transaction    trans  = new Transaction();
                List <Payment> list   = new List <Payment>();
                PaymentOM[]    result = await trans.ListFilterTrans(filter, count, skip, includeWatchOnly);

                if (result != null)
                {
                    for (int i = 0; i < result.Length; i++)
                    {
                        list.Add(new Payment()
                        {
                            Account       = result[i].Account,
                            Address       = result[i].Address,
                            Amount        = result[i].Amount,
                            BlockHash     = result[i].BlockHash,
                            BlockIndex    = result[i].BlockIndex,
                            BlockTime     = result[i].BlockTime,
                            Category      = result[i].Category,
                            Comment       = result[i].Comment,
                            Confirmations = result[i].Confirmations,
                            Fee           = result[i].Fee,
                            Size          = result[i].Size,
                            Time          = result[i].Time,
                            TotalInput    = result[i].TotalInput,
                            TotalOutput   = result[i].TotalOutput,
                            TxId          = result[i].TxId,
                            Vout          = result[i].Vout
                        });
                    }
                    response.Result = Newtonsoft.Json.Linq.JToken.FromObject(list);
                }
                else
                {
                    response.Result = null;
                }
            }
            catch (ApiCustomException ex)
            {
                Logger.Singleton.Error(ex.ToString());
                response.Error = new ApiError(ex.ErrorCode, ex.ToString());
            }
            catch (Exception ex)
            {
                Logger.Singleton.Error(ex.ToString());
                response.Error = new ApiError(ex.HResult, ex.ToString());
            }
            return(response);
        }
        // Partial Views
        //public async Task<IActionResult> Index2([Bind("DateFrom,DateTo,CurrentFilter")]FilterIM filterIM)
        public async Task <IActionResult> Index2([Bind("DateFrom,DateTo,SearchString")] FilterIM filterIM)


        {
            ViewBag.Filter = filterIM;
            //ViewData["DateFrom"] = filterIM.DateFrom;
            //ViewData["DateTo"] = filterIM.DateTo;
            //ViewData["CurrentFilter"] = filterIM.SearchString;

            ViewBag.DateFrom      = filterIM.DateFrom;
            ViewBag.DateTo        = filterIM.DateTo;
            ViewBag.CurrentFilter = filterIM.SearchString;

            var records = dataLayer.GetUserRecords(ApplicationUser);

            if (filterIM.DateFrom != null)
            {
                records = records.Where(r => r.Date >= filterIM.DateFrom);
            }

            if (filterIM.DateTo != null)
            {
                records = records.Where(r => r.Date <= filterIM.DateTo);
            }

            dataLayer.Load(records, r => r.Category);
            dataLayer.Load(records, r => r.PaymentType);

            if (!String.IsNullOrWhiteSpace(filterIM.SearchString))
            {
                records = records.Where(r => r.Description.Contains(filterIM.SearchString) ||
                                        r.Tag.Contains(filterIM.SearchString) ||
                                        r.Category.Description.Contains(filterIM.SearchString) ||
                                        r.PaymentType.Description.Contains(filterIM.SearchString));
            }

            if (records == null ||
                !records.Any())
            {
                //return NotFound();
            }

            var list = await records.ToListAsync();

            ViewBag.List = list;

            return(View(list));
        }
Exemple #3
0
        public async Task <PaymentOM[]> ListFilterTrans(FilterIM filter, int count, int skip = 0, bool includeWatchOnly = true)
        {
            AuthenticationHeaderValue authHeaderValue = null;
            RpcClient  client  = new RpcClient(new Uri(WalletNetwork.NetWork), authHeaderValue, null, null, "application/json");
            RpcRequest request = RpcRequest.WithParameterList("ListFilterTrans", new List <object> {
                filter, count, skip, includeWatchOnly
            }, 1);
            RpcResponse response = await client.SendRequestAsync(request);

            if (response.HasError)
            {
                throw new ApiCustomException(response.Error.Code, response.Error.Message);
            }
            PaymentOM[] responseValue = response.GetResult <PaymentOM[]>();
            return(responseValue);
        }
Exemple #4
0
        public Result <ObservableCollection <TradeRecordInfo> > ListFilterTrans(FilterIM filer, int skip = 0, bool includeWatchOnly = true, int count = 5)
        {
            var result = new Result <ObservableCollection <TradeRecordInfo> >();

            var         p        = Math.Pow(10, 8);
            ApiResponse response = TransactionApi.ListFilterTrans(filer, count, skip, includeWatchOnly).Result;

            result.IsFail = response.HasError;
            if (result.IsFail)
            {
                return(result);
            }

            var payments = response.GetResult <List <Payment> >();

            result.Value = new ObservableCollection <TradeRecordInfo>();
            payments.ForEach(x =>
            {
                var item = new TradeRecordInfo(x);
                result.Value.Add(item);
            });

            return(result);
        }
        private FilterIM GetFilterCondition()
        {
            FilterIM filterData = new FilterIM {
                StartTime = -1, EndTime = -1, TradeType = 0
            };
            var date = DateTime.Now;

            switch (TimeSelectIndex)
            {
            case 1:    //today
            {
                var startdate = date;
                filterData.StartTime = Time.GetEpochTime(startdate.Year, startdate.Month, startdate.Day, 0, 0, 0);
                var endDate = date.AddDays(1);
                filterData.EndTime = Time.GetEpochTime(endDate.Year, endDate.Month, endDate.Day, 0, 0, 0);
            }
            break;

            case 2:    //thisWeek
            {
                var startdate = date.AddDays(-(int)date.DayOfWeek);
                filterData.StartTime = Time.GetEpochTime(startdate.Year, startdate.Month, startdate.Day, 0, 0, 0);
                var endDate = date.AddDays(-(int)date.DayOfWeek + 7);
                filterData.EndTime = Time.GetEpochTime(endDate.Year, endDate.Month, endDate.Day, 0, 0, 0);
            }
            break;

            case 3:    //thismonth
            {
                var startdate = date.AddDays(-date.Day + 1);
                filterData.StartTime = Time.GetEpochTime(startdate.Year, startdate.Month, startdate.Day, 0, 0, 0);
                var endDate = date.AddDays(-(int)date.Day + 1).AddMonths(1);
                filterData.EndTime = Time.GetEpochTime(endDate.Year, endDate.Month, endDate.Day, 0, 0, 0);
            }
            break;

            case 4:    //prevMon
            {
                var startdate = date.AddDays(-date.Day + 1).AddMonths(-1);
                filterData.StartTime = Time.GetEpochTime(startdate.Year, startdate.Month, startdate.Day, 0, 0, 0);
                var endDate = startdate.AddMonths(1);
                filterData.EndTime = Time.GetEpochTime(endDate.Year, endDate.Month, endDate.Day, 0, 0, 0);
            }
            break;

            case 5:    //thisYear
            {
                var startdate = date;
                filterData.StartTime = Time.GetEpochTime(startdate.Year, 1, 1, 0, 0, 0);
                var endDate = startdate.AddYears(1);
                filterData.EndTime = Time.GetEpochTime(endDate.Year, 1, 1, 0, 0, 0);
            }
            break;

            case 6:    //other
            {
                var startdate = StartDate;
                filterData.StartTime = Time.GetEpochTime(startdate.Year, startdate.Month, startdate.Day, 0, 0, 0);
                var endDate = EndDate;
                filterData.EndTime = Time.GetEpochTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59);
            }
            break;

            default:
                break;
            }

            switch (TradeSelectIndex)
            {
            case 1: filterData.TradeType = 1; break;

            case 2: filterData.TradeType = 2; break;

            case 3: filterData.TradeType = 3; break;

            case 4: filterData.TradeType = 4; break;

            default: break;
            }

            if (SearchText != null && !string.IsNullOrEmpty(SearchText.Trim()))
            {
                filterData.Account = SearchText.Trim();
            }

            if (SearchAmount != null && !string.IsNullOrEmpty(SearchAmount.Trim()))
            {
                double amount = 0;
                if (double.TryParse(SearchAmount, out amount))
                {
                    filterData.Amount = Convert.ToInt64(amount * Math.Pow(10, 8));
                }
            }

            return(filterData);
        }