예제 #1
0
        /// <summary>
        /// Selects certain values from a map, and sets them to 1, and the rest to zero. Usefull for conversions
        /// </summary>
        public ValueMap Select(SelectOperation operation, float value)
        {
            ValueMap output = CreateInstance <ValueMap>();

            output.Initialize(Width, Height);

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    switch (operation)
                    {
                    case SelectOperation.EqualTo:
                        output[x, y] = values[x, y] == value ? 1 : 0;
                        break;

                    case SelectOperation.GreaterThan:
                        output[x, y] = values[x, y] > value ? 1 : 0;
                        break;

                    case SelectOperation.LessThan:
                        output[x, y] = values[x, y] < value ? 1 : 0;
                        break;
                    }
                }
            }

            return(output);
        }
예제 #2
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="originalString">original string from which the substring should come</param>
 /// <param name="previous">Indicates if the last operation was a From or a To</param>
 /// <param name="beginIndex">The beginning index of our substring</param>
 /// <param name="endIndex">The ending index of our substring</param>
 internal FluentString(string originalString, SelectOperation previous, int beginIndex, int endIndex)
 {
     this.OriginalString = originalString;
     this.PreviousOperation = previous;
     this.BeginIndex = beginIndex;
     this.EndIndex = endIndex;
 }
        public decimal Validate()
        {
            SelectOperation SoP   = new SelectOperation();
            var             count = SoP.FindFraudIpExists(ipAddress);

            if (count > 0)
            {
                if (count > 3)
                {
                    return(1);
                }
                if (count > 2)
                {
                    return(0.9M);
                }
                if (count > 1)
                {
                    return(0.8M);
                }
            }


            var maxMindAPI = "https://www.maxmind.com/geoip/v2.1/city/{0}?use-downloadable-db=1&demo=1";

            var http = new HttpClient();

            http.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var url = String.Format(maxMindAPI, ipAddress);

            try
            {
                var response = http.GetAsync(url).Result;
                //HttpResponseMessage res1 = http.GetAsync("https://ebanking.bankofmaldives.com.mv/xe/").Result;
                var result = response.Content.ReadAsStringAsync().Result;
                IpAddressValidatorResponse obj = JsonConvert.DeserializeObject <IpAddressValidatorResponse>(result);

                if (obj != null)
                {
                    //Error Response or Not India
                    if (!string.IsNullOrEmpty(obj.error) || (obj.country != null && !obj.country.iso_code.Equals("IN")))
                    {
                        InsertOperation op = new InsertOperation();
                        op.InsertFraudRecord(ipAddress);

                        //new Record
                        return(0.5M);
                    }
                }
                return(0);
            }
            catch (Exception ex)
            {
                //Write Exception
            }
            return(0.1M);
        }
예제 #4
0
        public string response(string id)
        {
            //  DashBoardResponse _response = new DashBoardResponse();
            List <DashBoardResponse> _response        = new List <DashBoardResponse>();
            SelectOperation          _selectOperation = new SelectOperation();

            _response = _selectOperation.GetPendingTransactions(id);

            //List<DashBoardResponse> _response = new List<DashBoardResponse>()
            //{
            //    new DashBoardResponse
            //    {
            //        CardNumber="fgdffgdgdf",
            //        TransactionId="sdfhsdjf",
            //        TransDt="23-09-1222",
            //        UniqueId="456"
            //    },
            //    new DashBoardResponse
            //    {
            //        CardNumber="sdgjhdf",
            //        TransactionId="634785634785",
            //          TransDt="23-09-1222",
            //        UniqueId="4567"
            //    },
            //    new DashBoardResponse
            //    {
            //        CardNumber="dshfgsdf",
            //        TransactionId="347865378456",
            //          TransDt="23-09-1222",
            //        UniqueId="4560"
            //    },
            //    new DashBoardResponse
            //    {
            //        CardNumber="gffgdfsdfs",
            //        TransactionId="15244523423",
            //          TransDt="23-09-1222",
            //        UniqueId="4564"
            //    },
            //    new DashBoardResponse
            //    {
            //        CardNumber="5476754",
            //        TransactionId="5423554",
            //          TransDt="23-09-1222",
            //        UniqueId="45687"
            //    },


            //};
            return(Newtonsoft.Json.JsonConvert.SerializeObject(_response));
        }
예제 #5
0
        public static string SelectOperationToString(SelectOperation se)
        {
            switch (se)
            {
            case SelectOperation.Except:
                return("EXCEPT");

            case SelectOperation.Intersect:
                return("INTERSECT");

            case SelectOperation.Union:
                return("UNION");

            case SelectOperation.UnionAll:
                return("UNION ALL");
            }
            throw new Exception("Unknow select operation");
        }
예제 #6
0
        /// <summary>
        /// Execute the <see cref="IQueryOperation"/> against the database.
        /// </summary>
        /// <param name="storage">Database to execute against.</param>
        /// <returns>Query results.</returns>
        public IEnumerable<Row> Execute(IStorage storage)
        {
            var rows = new List<Row>();
            if (this.WhereClauses.Count > 0)
            {
                var select = new SelectOperation();
                select.TableName = this.TableName;
                select.ColumnNames.Add("*");

                foreach (var clause in this.WhereClauses)
                {
                    select.WhereClauses.Add(clause.Key, clause.Value);
                }

                var selectedRows = select.Execute(storage);
                foreach (var row in selectedRows)
                {
                    DeleteRow(storage, this.TableName, row.RowKey, row.Columns);
                }
            }
            return rows;
        }
예제 #7
0
 public ProceedIfCondition(string originalString, SelectOperation op, int beginIndex, int endIndex)
     : base(originalString, op, beginIndex, endIndex)
 {
 }