예제 #1
0
        public List <InfoBankDetailModel> GetListBank(FilterBank data)
        {
            BankRepository repo = new BankRepository(DbContext);
            var            res  = repo.GetAllBank();

            if (data.BankName != string.Empty)
            {
                res = res.Where(x => x.BankName.Contains(data.BankName));
            }

            var filter = (from x in res
                          where x.DeletedDate == null
                          select new InfoBankDetailModel()
            {
                BankID = x.ID,
                Kode = x.Kode,
                Bank = x.BankName,
                LogoBank = x.LogoBank,
                IsActive = x.IsActive
            });
            int pageNumber = data.PageNumber - 1;

            filter = filter.Skip(pageNumber * data.PageSize).Take(data.PageSize);

            return(filter.ToList());
        }
예제 #2
0
        public IActionResult GetBank()
        {
            IEnumerable <InfoBankDetailModel> banks = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseAPI + "Bank/");
                HttpContext.Session.SetString(SessionKeyBank, client.BaseAddress.ToString());
                FilterBank filter = new FilterBank();
                filter.BankName        = "";
                filter.BankAccountName = "";
                filter.UserName        = "";
                filter.PageNumber      = 1;
                filter.PageSize        = 1000;
                var responseTask = client.PostAsJsonAsync <FilterBank>("GetListBank", filter);
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var content = result.Content.ReadAsStringAsync();
                    ListBankResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <ListBankResponseModel>(content.Result);
                    banks = resutl.data;
                }
                else                 //web api sent error response
                {
                    //log response status here..
                    banks = Enumerable.Empty <InfoBankDetailModel>();
                    ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin.");
                }
            }
            return(Json(banks));
        }
예제 #3
0
        // GET: /<controller>/
        public IActionResult Index()
        {
            if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "")
            {
                IEnumerable <InfoBankDetailModel> banks = null;
                if (TempData["CustomError"] != null)
                {
                    ModelState.AddModelError(string.Empty, TempData["CustomError"].ToString());
                }
                else
                {
                    using (var client = new HttpClient())
                    {
                        client.BaseAddress = new Uri(BaseAPI + "Bank/");
                        FilterBank filter = new FilterBank();
                        filter.BankName        = "";
                        filter.BankAccountName = "";
                        filter.UserName        = "";
                        filter.PageNumber      = 1;
                        filter.PageSize        = 1000;
                        var responseTask = client.PostAsJsonAsync <FilterBank>("GetListBank", filter);
                        responseTask.Wait();

                        var result = responseTask.Result;
                        if (result.IsSuccessStatusCode)
                        {
                            var content = result.Content.ReadAsStringAsync();
                            ListBankResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <ListBankResponseModel>(content.Result);
                            banks = resutl.data;
                        }
                        else                         //web api sent error response
                        {
                            //log response status here..
                            banks = Enumerable.Empty <InfoBankDetailModel>();

                            ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                        }
                    }
                }
                return(View(banks));
            }
            else
            {
                TempData["CustomError"] = "Please login before using the web.";
                if (HttpContext.Session.GetString(Loginfrom) == "ADM/SPV")
                {
                    return(RedirectToAction("AdminLogon", "Login"));
                }
                else if (HttpContext.Session.GetString(Loginfrom) == "MDO")
                {
                    return(RedirectToAction("OwnerLogon", "Login"));
                }
                else
                {
                    return(RedirectToAction("BuyerLogon", "Login"));
                }
                //return RedirectToAction("Logon", "Login");
            }
        }
예제 #4
0
        public async Task ImportForeignFilterBanks(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt)
        {
            FilterBankExtract        fbExtract     = new FilterBankExtract();
            List <FilterBankForeign> fbForeignList = fbExtract.ExtractFilterBanksForeign(oracleConnStr);

            LoadFilterBank loadFb = new LoadFilterBank();

            foreach (FilterBankForeign fbForeign in fbForeignList)
            {
                FilterBank insertedSS = await loadFb.LoadSingleAsync(_context, _log, fbForeign, opt);
            }
        }
예제 #5
0
        public ListBankAccountResultModel GetListUserBankAccount(FilterBank data)
        {
            var query = (from b in DbContext.Bank
                         join ub in DbContext.UserBank on b.ID equals ub.BankID
                         join u in DbContext.User on ub.UserID equals u.ID
                         join ur in DbContext.UserRole on u.ID equals ur.UserID
                         join r in DbContext.Role on ur.RoleID equals r.ID
                         where ub.DeletedDate == null
                         select new ListBankUserAccountOutputModel()
            {
                BankAccount = ub.AccountNumber,
                Role = r.Name,
                BankName = b.BankName,
                UserName = u.UserName,
                AccountBankName = ub.AccountName
            });

            if (data.BankAccountName != string.Empty)
            {
                query = query.Where(x => x.AccountBankName == data.BankAccountName);
            }

            if (data.BankName != string.Empty)
            {
                query = query.Where(x => x.BankName == data.BankName);
            }

            if (data.UserName != string.Empty)
            {
                query = query.Where(x => x.UserName == data.UserName);
            }

            int pageNumber = data.PageNumber - 1;

            var requery = query.Skip(pageNumber * data.PageSize).Take(data.PageSize);

            ListBankAccountResultModel result = new ListBankAccountResultModel();

            result.data = requery.ToList();

            result.TotalData = query.Count();
            result.TotalPage = (query.Count() / data.PageSize) + 1;

            return(result);
        }
예제 #6
0
        private void FilterStream(CrossTimeDspConfiguration configuration, SampleBuffer inputBuffer, SampleType dataPathSampleType, SampleType outputSampleType)
        {
            // setup
            FilterBank filters = new FilterBank(configuration.Engine.Precision, inputBuffer.WaveFormat.SampleRate, inputBuffer.WaveFormat.Channels, configuration.Engine.Q31Adaptive.Q31_32x64_Threshold, configuration.Engine.Q31Adaptive.Q31_64x64_Threshold);

            foreach (Filter filter in configuration.Filters)
            {
                filter.AddTo(filters);
            }

            // time duration of reverse time pass
            DateTime filteringStartedUtc = DateTime.UtcNow;

            using (SampleBuffer reverseTimeBuffer = new SampleBuffer(inputBuffer.WaveFormat.SampleRate, outputSampleType.BitsPerSample(), inputBuffer.WaveFormat.Channels))
            {
                SampleBlock recirculatingDataPathBlock = null;
                for (LinkedListNode <SampleBlock> blockNode = inputBuffer.Blocks.Last; blockNode != null; blockNode = blockNode.Previous)
                {
                    SampleBlock filteredBlock = filters.FilterReverse(blockNode.Value, dataPathSampleType, outputSampleType, ref recirculatingDataPathBlock);
                    reverseTimeBuffer.Blocks.AddFirst(filteredBlock);
                }
                if (recirculatingDataPathBlock != null)
                {
                    recirculatingDataPathBlock.Dispose();
                }
                reverseTimeBuffer.RecalculateBlocks();

                DateTime filteringStoppedUtc = DateTime.UtcNow;
                if (filters.TimingAvailable)
                {
                    this.TestContext.WriteLine("{0} ({1} {2} {3})", (filteringStoppedUtc - filteringStartedUtc).ToString(Constant.ElapsedTimeFormat), filters.ToDataPathTime.ToString(Constant.ElapsedTimeFormat), filters.FilterTime.ToString(Constant.ElapsedTimeFormat), filters.ToOutputTime.ToString(Constant.ElapsedTimeFormat));
                }
                else
                {
                    this.TestContext.WriteLine("{0}", (filteringStoppedUtc - filteringStartedUtc).ToString(Constant.ElapsedTimeFormat));
                }
            }
        }
예제 #7
0
        public ActionResult <ListBankResponseModel> GetListBank([FromBody] FilterBank filter)
        {
            ListBankResponseModel res = new ListBankResponseModel();

            try
            {
                BankBL posBL = new BankBL(DbContext);
                var    data  = posBL.GetListBank(filter);

                res.data = data;

                res.Message  = "Success";
                res.Response = true;

                return(res);
            }
            catch (Exception ex)
            {
                res.Message  = ex.Message;
                res.Response = false;
                return(res);
            }
        }
예제 #8
0
        public async Task <FilterBank> LoadSingleAsync(WRLDCWarehouseDbContext _context, ILogger _log, FilterBankForeign fbForeign, EntityWriteOption opt)
        {
            // check if entity already exists
            FilterBank existingFb = await _context.FilterBanks.SingleOrDefaultAsync(lr => lr.WebUatId == fbForeign.WebUatId);

            // check if we should not modify existing entities
            if (opt == EntityWriteOption.DontReplace && existingFb != null)
            {
                return(existingFb);
            }

            // find the region
            int    regionWebUatId = fbForeign.RegionWebUatId;
            Region region         = await _context.Regions.SingleOrDefaultAsync(r => r.WebUatId == regionWebUatId);

            // if region doesnot exist, skip the import. Ideally, there should not be such case
            if (region == null)
            {
                _log.LogCritical($"Unable to find region with webUatId {regionWebUatId} while inserting FilterBank with webUatId {fbForeign.WebUatId} and name {fbForeign.Name}");
                return(null);
            }

            // find the State of the LineReactor via the State WebUatId
            int   stateWebUatId = fbForeign.StateWebUatId;
            State state         = await _context.States.SingleOrDefaultAsync(s => s.WebUatId == stateWebUatId);

            // if state doesnot exist, skip the import. Ideally, there should not be such case
            if (state == null)
            {
                _log.LogCritical($"Unable to find State with webUatId {stateWebUatId} while inserting FilterBank with webUatId {fbForeign.WebUatId} and name {fbForeign.Name}");
                return(null);
            }

            // find the Substation of the LineReactor via the Substation WebUatId
            int        ssWebUatId = fbForeign.SubstationWebUatId;
            Substation substation = await _context.Substations.SingleOrDefaultAsync(ss => ss.WebUatId == ssWebUatId);

            // if Substation doesnot exist, skip the import. Ideally, there should not be such case
            if (substation == null)
            {
                _log.LogCritical($"Unable to find Substation with webUatId {ssWebUatId} while inserting FilterBank with webUatId {fbForeign.WebUatId} and name {fbForeign.Name}");
                return(null);
            }

            int       voltLevelWebUatId = fbForeign.VoltLevelWebUatId;
            VoltLevel voltLevel         = await _context.VoltLevels.SingleOrDefaultAsync(v => v.WebUatId == voltLevelWebUatId);

            // if voltLevel doesnot exist, skip the import. Ideally, there should not be such case
            if (voltLevel == null)
            {
                _log.LogCritical($"Unable to find VoltLevel with webUatId {voltLevelWebUatId} while inserting FilterBank with webUatId {fbForeign.WebUatId} and name {fbForeign.Name}");
                return(null);
            }

            // check if we have to replace the entity completely
            if (opt == EntityWriteOption.Replace && existingFb != null)
            {
                _context.FilterBanks.Remove(existingFb);
            }

            // if entity is not present, then insert or check if we have to replace the entity completely
            if (existingFb == null || (opt == EntityWriteOption.Replace && existingFb != null))
            {
                FilterBank newFb = new FilterBank();
                newFb.Name             = fbForeign.Name;
                newFb.RegionId         = region.RegionId;
                newFb.StateId          = state.StateId;
                newFb.SubstationId     = substation.SubstationId;
                newFb.VoltLevelId      = voltLevel.VoltLevelId;
                newFb.IsSwitchable     = fbForeign.IsSwitchable == 0 ? false : true;
                newFb.FilterBankNumber = fbForeign.FilterBankNumber.ToString();

                newFb.WebUatId = fbForeign.WebUatId;
                _context.FilterBanks.Add(newFb);
                await _context.SaveChangesAsync();

                return(newFb);
            }

            // check if we have to modify the entity
            if (opt == EntityWriteOption.Modify && existingFb != null)
            {
                existingFb.Name             = fbForeign.Name;
                existingFb.RegionId         = region.RegionId;
                existingFb.StateId          = state.StateId;
                existingFb.SubstationId     = substation.SubstationId;
                existingFb.VoltLevelId      = voltLevel.VoltLevelId;
                existingFb.IsSwitchable     = fbForeign.IsSwitchable == 0 ? false : true;
                existingFb.FilterBankNumber = fbForeign.FilterBankNumber.ToString();
                await _context.SaveChangesAsync();

                return(existingFb);
            }
            return(null);
        }
예제 #9
0
 public override void AddTo(FilterBank filters)
 {
     filters.AddBiquad(this.Type, this.F0, this.Q, this.GainInDB);
 }
예제 #10
0
 public abstract void AddTo(FilterBank filters);
예제 #11
0
 public override void AddTo(FilterBank filters)
 {
     filters.AddThreeWayLinearization(this.LowCrossover, this.HighCrossover, this.WooferRolloff, this.MidRolloff, this.GainInDB);
 }
예제 #12
0
        private WaveStream FilterStream(WaveStream inputStream, out StreamPerformance performance)
        {
            performance = new StreamPerformance();

            // populate filters
            FilterBank forwardTimeFilters = new FilterBank(this.Configuration.Engine.Precision, inputStream.WaveFormat.SampleRate, inputStream.WaveFormat.Channels, this.Configuration.Engine.Q31Adaptive.Q31_32x64_Threshold, this.Configuration.Engine.Q31Adaptive.Q31_64x64_Threshold);
            FilterBank reverseTimeFilters = new FilterBank(this.Configuration.Engine.Precision, inputStream.WaveFormat.SampleRate, inputStream.WaveFormat.Channels, this.Configuration.Engine.Q31Adaptive.Q31_32x64_Threshold, this.Configuration.Engine.Q31Adaptive.Q31_64x64_Threshold);

            foreach (Filter filter in this.Configuration.Filters)
            {
                switch (filter.TimeDirection)
                {
                case TimeDirection.Forward:
                    filter.AddTo(forwardTimeFilters);
                    break;

                case TimeDirection.Reverse:
                    filter.AddTo(reverseTimeFilters);
                    break;

                default:
                    throw new NotSupportedException(String.Format("Unhandled time direction {0}.", filter.TimeDirection));
                }
            }

            // do reverse time pass
            // If the only reverse time filter is the anti-clipping gain then there's nothing to do.
            SampleType dataPathSampleType    = this.Configuration.Engine.Precision == FilterPrecision.Double ? SampleType.Double : SampleType.Int32;
            bool       hasForwardTimeFilters = forwardTimeFilters.FilterCount > 0;
            SampleType outputSampleType      = SampleTypeExtensions.FromBitsPerSample(this.Configuration.Output.BitsPerSample);

            if (reverseTimeFilters.FilterCount > 0 && (this.Stopping == false))
            {
                using (SampleBuffer inputBuffer = new SampleBuffer(inputStream))
                {
                    // set up buffer for output of reverse time pass and dispose input stream as it's no longer needed
                    performance.ReverseBufferCompleteUtc = DateTime.UtcNow;
                    SampleType   reverseTimeSampleType = hasForwardTimeFilters ? dataPathSampleType : outputSampleType;
                    SampleBuffer reverseTimeBuffer     = new SampleBuffer(inputStream.WaveFormat.SampleRate, reverseTimeSampleType.BitsPerSample(), inputStream.WaveFormat.Channels);
                    inputStream.Dispose();

                    // input blocks are disposed as they're processed to limit peak memory consumption (and removed from the input buffer for completeness)
                    SampleBlock recirculatingDataPathBlock = null;
                    for (LinkedListNode <SampleBlock> blockNode = inputBuffer.Blocks.Last; blockNode != null; blockNode = blockNode.Previous, inputBuffer.Blocks.RemoveLast())
                    {
                        using (SampleBlock block = blockNode.Value)
                        {
                            SampleBlock filteredBlock = reverseTimeFilters.FilterReverse(block, dataPathSampleType, reverseTimeSampleType, ref recirculatingDataPathBlock);
                            reverseTimeBuffer.Blocks.AddFirst(filteredBlock);
                        }

                        if (this.Stopping)
                        {
                            break;
                        }
                    }
                    if (recirculatingDataPathBlock != null)
                    {
                        recirculatingDataPathBlock.Dispose();
                    }

                    // prepare to apply forward time pass to output of reverse time pass or just to write output
                    reverseTimeBuffer.RecalculateBlocks();
                    inputStream = reverseTimeBuffer;
                    performance.ReverseTimeCompleteUtc = DateTime.UtcNow;
                }
            }

            // do forward time pass
            if (hasForwardTimeFilters && (this.Stopping == false))
            {
                SampleBuffer outputStream = new SampleBuffer(inputStream.WaveFormat.SampleRate, outputSampleType.BitsPerSample(), inputStream.WaveFormat.Channels);
                SampleBlock  recirculatingDataPathBlock = null;
                if (inputStream is SampleBuffer)
                {
                    SampleBuffer inputBlocks = (SampleBuffer)inputStream;
                    for (LinkedListNode <SampleBlock> blockNode = inputBlocks.Blocks.First; blockNode != null; blockNode = blockNode.Next, inputBlocks.Blocks.RemoveFirst())
                    {
                        using (SampleBlock block = blockNode.Value)
                        {
                            SampleBlock filteredBlock = forwardTimeFilters.Filter(block, dataPathSampleType, outputSampleType, ref recirculatingDataPathBlock);
                            outputStream.Blocks.AddLast(filteredBlock);
                        }

                        if (this.Stopping)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    byte[] inputBuffer = new byte[Constant.SampleBlockSizeInBytes];
                    while (inputStream.CanRead)
                    {
                        int bytesRead = inputStream.Read(inputBuffer, 0, inputBuffer.Length);
                        if (bytesRead < 1)
                        {
                            // workaround for NAudio bug: WaveStream.CanRead is hard coded to true regardless of position
                            break;
                        }

                        using (SampleBlock block = new SampleBlock(inputBuffer, bytesRead, SampleTypeExtensions.FromBitsPerSample(inputStream.WaveFormat.BitsPerSample)))
                        {
                            SampleBlock filteredBlock = forwardTimeFilters.Filter(block, dataPathSampleType, outputSampleType, ref recirculatingDataPathBlock);
                            outputStream.Blocks.AddLast(filteredBlock);
                        }

                        if (this.Stopping)
                        {
                            return(null);
                        }
                    }
                }
                if (recirculatingDataPathBlock != null)
                {
                    recirculatingDataPathBlock.Dispose();
                }

                // release input stream as it's no longer needed and complete output
                inputStream.Dispose();
                outputStream.RecalculateBlocks();
                inputStream = outputStream;
            }

            forwardTimeFilters.Dispose();
            reverseTimeFilters.Dispose();

            performance.CompleteTimeUtc = DateTime.UtcNow;
            return(inputStream);
        }
예제 #13
0
 public override void AddTo(FilterBank filters)
 {
     filters.AddFirstOrder(this.Type, this.F0, this.GainInDB);
 }
예제 #14
0
 public override void AddTo(FilterBank filters)
 {
     filters.AddThirdOrder(this.Biquad.Type, this.Biquad.F0, this.Biquad.Q, this.Biquad.GainInDB, this.FirstOrder.Type, this.FirstOrder.F0, this.FirstOrder.GainInDB);
 }
예제 #15
0
        public async Task <FilterBankOwner> LoadSingleAsync(WRLDCWarehouseDbContext _context, ILogger _log, FilterBankOwnerForeign fbOwnerForeign, EntityWriteOption opt)
        {
            // check if entity already exists
            FilterBankOwner existingFbOwner = await _context.FilterBankOwners.SingleOrDefaultAsync(fbO => fbO.WebUatId == fbOwnerForeign.WebUatId);

            // check if we should not modify existing entities
            if (opt == EntityWriteOption.DontReplace && existingFbOwner != null)
            {
                return(existingFbOwner);
            }

            // find the FilterBank via the FilterBank WebUatId
            int        fbWebUatId = fbOwnerForeign.FilterBankWebUatId;
            FilterBank filterBank = await _context.FilterBanks.SingleOrDefaultAsync(ss => ss.WebUatId == fbWebUatId);

            // if FilterBank doesnot exist, skip the import. Ideally, there should not be such case
            if (filterBank == null)
            {
                _log.LogCritical($"Unable to find FilterBank with webUatId {fbWebUatId} while inserting FilterBankOwner with webUatId {fbOwnerForeign.WebUatId}");
                return(null);
            }

            // find the Owner of the substation via the Owner WebUatId
            int   ownerWebUatId = fbOwnerForeign.OwnerWebUatId;
            Owner owner         = await _context.Owners.SingleOrDefaultAsync(o => o.WebUatId == ownerWebUatId);

            // if owner doesnot exist, skip the import. Ideally, there should not be such case
            if (owner == null)
            {
                _log.LogCritical($"Unable to find FilterBank with webUatId {ownerWebUatId} while inserting FilterBankOwner with webUatId {fbOwnerForeign.WebUatId}");
                return(null);
            }

            try
            {
                // check if we have to replace the entity completely
                if (opt == EntityWriteOption.Replace && existingFbOwner != null)
                {
                    _context.FilterBankOwners.Remove(existingFbOwner);
                }

                // if entity is not present, then insert or check if we have to replace the entity completely
                if (existingFbOwner == null || (opt == EntityWriteOption.Replace && existingFbOwner != null))
                {
                    FilterBankOwner newFbOwner = new FilterBankOwner();
                    newFbOwner.OwnerId      = owner.OwnerId;
                    newFbOwner.FilterBankId = filterBank.FilterBankId;
                    newFbOwner.WebUatId     = fbOwnerForeign.WebUatId;

                    _context.FilterBankOwners.Add(newFbOwner);
                    await _context.SaveChangesAsync();

                    return(newFbOwner);
                }

                // check if we have to modify the entity
                if (opt == EntityWriteOption.Modify && existingFbOwner != null)
                {
                    existingFbOwner.OwnerId      = owner.OwnerId;
                    existingFbOwner.FilterBankId = filterBank.FilterBankId;
                    await _context.SaveChangesAsync();

                    return(existingFbOwner);
                }
            }
            catch (DbUpdateException e)
            {
                _log.LogCritical($"Error occured while inserting FilterBankOwner with webUatId {fbOwnerForeign.WebUatId}, owner id {owner.OwnerId} and ssId {filterBank.SubstationId}");
                _log.LogCritical($"EntityWriteOption = {opt.ToString()}");
                _log.LogCritical($"{e.Message}");
                return(null);
            }

            return(null);
        }