예제 #1
0
        public async Task <IActionResult> GetBranchesOfCompanyTrusted(
            [FromRoute] int companyId,
            [FromRoute] string token,
            [FromQuery] BranchFilter filterModel,
            [FromQuery] Sortable sortable,
            [FromQuery] Paginable paginable)
        {
            if (token != Consts.StaticToken)
            {
                return(new ContentResult {
                    StatusCode = 403
                });
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var branchList = await _branchManager.GetBranchesByCompany(companyId, filterModel, sortable, paginable);

                return(Ok(branchList));
            }
            catch (KeyNotFoundException ex)
            {
                return(NotFound(ex.Message));
            }
        }
예제 #2
0
 public override void Write(CustomFileWriter writer)
 {
     using (writer.WriteBlock("vcs"))
     {
         writer.WriteLine($"branchFilter = {BranchFilter.DoubleQuote()}");
         writer.WriteLine($"triggerRules = {TriggerRules.DoubleQuote()}");
     }
 }
        /// <summary>
        /// 8.1.2. Метод для поиска информации о местах осуществления деятельности по фильтру
        /// </summary>
        /// <param name="filter">Фильтр для поиска мест осуществления деятельности</param>
        /// <param name="startFrom">Индекс первой записи в списке возвращаемых мест</param>
        /// <param name="count">Количество записей в списке возвращаемых мест</param>
        /// <returns>Список мест осуществления деятельности</returns>
        public EntriesResponse <BranchEntry> GetBranches(BranchFilter filter, int startFrom, int count)
        {
            RequestRate(0.5); // 56

            return(Post <EntriesResponse <BranchEntry> >("reestr/branches/filter", new
            {
                filter = filter ?? new BranchFilter(),
                start_from = startFrom,
                count = count,
            }));
        }
예제 #4
0
        /// <inheritdoc />
        public async Task <PagingResult <BranchModel> > GetBranches(BranchFilter filter = null, Sortable sortable = null, Paginable paginable = null)
        {
            try
            {
                IQueryable <Branch> query = null;

                query = await _branchRepository.GetAsync();

                if (filter != null)
                {
                    query = Filtering(filter, query);
                }
                // Calculate total count
                var queryableCount = query;
                int totalCount     = queryableCount.Count();
                if (sortable != null)
                {
                    query = Sorting(sortable, query);
                }
                if (paginable != null)
                {
                    query = Pagination(paginable, query);
                }
                var branches        = query.ToList();
                var branchModelList = new List <BranchModel>();

                var allUsersQuery = await _userRepository.GetAsync(x => !string.IsNullOrEmpty(x.Role)?x.Role.Trim().Equals(salesRoleId) : false);

                var allUsers = allUsersQuery.ToList().GroupBy(x => x.BranchId);

                foreach (var branch in branches)
                {
                    var branchModel = branch.Adapt <BranchModel>();

                    branchModel.CountSalesRep = allUsers.Where(x => x.Key == branch.Id).FirstOrDefault()?.Count();

                    branchModelList.Add(branchModel);
                }

                return(new PagingResult <BranchModel>
                {
                    Total = totalCount,
                    ItemsPerPage = paginable?.Take ?? default(int),
                    Data = branchModelList
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #5
0
        public ReplyList <BranchView> GetFilterList(BranchFilter filter)
        {
            int total = 0;
            List <BranchView> list = new List <BranchView>();

            try
            {
                filter.SearchText = filter.SearchText.ToLower();

                total = _dbContext.Branches
                        .Where(br => br.RepositoryId == filter.Id &&
                               (string.IsNullOrEmpty(filter.SearchText) ? true : br.Name.ToLower().Contains(filter.SearchText)))
                        .Count();

                if (filter.SortOrder == "asc")
                {
                    list = _dbContext.Branches.Select(br => new BranchView()
                    {
                        Id = br.Id, Name = br.Name, Sha = br.Sha, RepositoryId = br.RepositoryId
                    })
                           .Where(br => br.RepositoryId == filter.Id &&
                                  (string.IsNullOrEmpty(filter.SearchText) ? true : br.Name.ToLower().Contains(filter.SearchText)))
                           .OrderBy(r => r.Name).Skip(filter.PageNumber * filter.PageSize)
                           .Take(filter.PageSize).ToList();
                }

                else if (filter.SortOrder == "dsc")
                {
                    list = _dbContext.Branches.Select(br => new BranchView()
                    {
                        Id = br.Id, Name = br.Name, Sha = br.Sha, RepositoryId = br.RepositoryId
                    })
                           .Where(br => br.RepositoryId == filter.Id &&
                                  (string.IsNullOrEmpty(filter.SearchText) ? true : br.Name.ToLower().Contains(filter.SearchText)))
                           .OrderByDescending(r => r.Name).Skip(filter.PageNumber * filter.PageSize)
                           .Take(filter.PageSize).ToList();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message); throw;
            }

            return(new ReplyList <BranchView>()
            {
                TotalData = total,
                Data = list
            });
        }
예제 #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         lblSuccessMessage.Text = "";
     }
     if (IsPostBack)
     {
         if (PageFunc.Value == "Find")
         {
             lblErrorMessage.Text = "";
             BindChargeData(BranchFilter.SelectedValue, ReceiptTypeFilter.SelectedValue, PortOfLadingFilter.SelectedValue, ChargeTypeFilter.SelectedValue);
             lblSuccessMessage.Text = "";
         }
     }
     BranchFilter.Focus();
 }
예제 #7
0
        public FileResult Export(BranchFilter filter)
        {
            var response = _branchService.Filter(filter);

            foreach (var branch in response.Branches)
            {
                branch.Dealers = _dealerService.OnlyWithBranchId(branch.Id);
            }

            var csv = new CsvExport();

            csv.ConcatRow(0, "CÓDIGO,SUCURSAL,REGIÓN,COMPAÑÍA,CONCESIONARIOS,ESTADO");
            csv.ConcatRows(0, "Code,Name,Region,Company,Dealers,Status", response.Branches);

            var stream = csv.RetrieveFile();

            return(new StreamFactory().Csv(stream, "Sucursales"));
        }
예제 #8
0
        public override void Write(CustomFileWriter writer)
        {
            using (writer.WriteBlock("schedule"))
            {
                using (writer.WriteBlock("schedulingPolicy = daily"))
                {
                    writer.WriteLine("hour = 3");
                    writer.WriteLine("timezone = \"Europe/Berlin\"");
                }

                writer.WriteLine($"branchFilter = {BranchFilter.DoubleQuote()}");
                writer.WriteLine($"triggerRules = {TriggerRules.DoubleQuote()}");
                writer.WriteLine("triggerBuild = always()");
                writer.WriteLine("withPendingChangesOnly = false");
                writer.WriteLine($"enableQueueOptimization = {EnableQueueOptimization.ToString().ToLowerInvariant()}");
                writer.WriteLine("param(\"cronExpression_min\", \"3\")");
            }
        }
예제 #9
0
        public async Task <ResultList> GetBranchListAsync(BranchFilter branchFilterDto)
        {
            ResultList  resultList   = new ResultList();
            IList <int> userBranches = new List <int>();

            if (branchFilterDto.UserID != ConstSpecialInfoes.SuperVisorAdmin)
            {
                userBranches = await Context.UserBranches.Where(p => p.UserId == branchFilterDto.UserID)
                               .Select(p => p.BranchId).ToListAsync();
            }

            var branches = await(from branch in Context.Branches
                                 where (branchFilterDto.UserID == ConstSpecialInfoes.SuperVisorAdmin ||
                                        userBranches.Contains(branch.ID))
                                 select branch).ToListAsync();

            resultList.Results = branches;
            return(resultList);
        }
예제 #10
0
        public async Task <IActionResult> Get(
            [FromQuery] BranchFilter filterModel,
            [FromQuery] Sortable sortable,
            [FromQuery] Paginable paginable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = new PagingResult <BranchModel>();

            if (filterModel.BranchIds.Any())
            {
                return(Ok(await _branchManager.GetBranchesById(filterModel.BranchIds)));
            }

            result = await _branchManager.GetBranches(filterModel, sortable, paginable);

            return(Ok(result));
        }
예제 #11
0
        public async Task <IActionResult> GetBranchesOfCompany(
            [FromRoute] int companyId,
            [FromQuery] BranchFilter filterModel,
            [FromQuery] Sortable sortable,
            [FromQuery] Paginable paginable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var branchList = await _branchManager.GetBranchesByCompany(companyId, filterModel, sortable, paginable);

                return(Ok(branchList));
            }
            catch (KeyNotFoundException ex)
            {
                return(NotFound(ex.Message));
            }
        }
예제 #12
0
        /// <inheritdoc />
        private IQueryable <Branch> Filtering(BranchFilter branchFilter, IQueryable <Branch> query)
        {
            // TODO: Fix
            if (branchFilter.UserIds.Count == 0)
            {
                if (!string.IsNullOrEmpty(branchFilter.StateFilter))
                {
                    query = query.Where(x => x.State != null && x.State.ToLower().Equals(branchFilter.StateFilter.ToLower()));
                }

                if (!string.IsNullOrEmpty(branchFilter.CityFilter))
                {
                    query = query.Where(x => x.City != null && x.City.ToLower().Contains(branchFilter.CityFilter.ToLower()));
                }

                if (!string.IsNullOrEmpty(branchFilter.EmailFilter))
                {
                    query = query.Where(x => x.Email.ToLower().Contains(branchFilter.EmailFilter.ToLower()));
                }

                if (!string.IsNullOrEmpty(branchFilter.BranchNameFilter))
                {
                    query = query.Where(x => x.BranchName.ToLower().Contains(branchFilter.BranchNameFilter.ToLower()));
                }

                if (branchFilter.IsEnabledFilter.HasValue)
                {
                    query = query.Where(x => x.IsEnabled.Equals(branchFilter.IsEnabledFilter));
                }

                if (branchFilter.BranchIdFilter.HasValue)
                {
                    query = query.Where(x => x.Id == branchFilter.BranchIdFilter);
                }
            }

            return(query);
        }
예제 #13
0
        public JsonResult Filter(BranchFilter filter)
        {
            var response = _branchService.Filter(filter);

            return(new JsonFactory().Success(response.Branches, response.TotalRecords));
        }
예제 #14
0
    protected void Page_Init(object sender, EventArgs e)
    {
        // branches
        DataSet dsGER = new DataSet();

        dsGER = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ReportsConnectionString"].ToString(), "UGEN_SP_Select",
                                         new SqlParameter("@tableName", "KPIBranches"),
                                         new SqlParameter("@columnNames", "distinct rtrim(Branch) as Branch , Branch + ' - ' + BranchName as TextValue"),
                                         new SqlParameter("@whereClause", "1=1"));
        dtBranches = dsGER.Tables[0];
        BranchUpd.DataValueField = "Branch";
        BranchUpd.DataTextField  = "TextValue";
        BranchUpd.DataSource     = dtBranches;
        BranchUpd.DataBind();
        dtBranches.Rows.Add(new Object[] { "-", "- Show All -" });
        DataView BranchView = new DataView(dtBranches);

        BranchView.Sort             = "Branch";
        BranchFilter.DataValueField = "Branch";
        BranchFilter.DataTextField  = "TextValue";
        BranchFilter.DataSource     = BranchView;
        BranchFilter.DataBind();
        // Receipt Types
        dsGER = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ReportsConnectionString"].ToString(), "UGEN_SP_Select",
                                         new SqlParameter("@tableName", "GERRcptTypes"),
                                         new SqlParameter("@columnNames", "GERRcptType, RcptTypeDesc"),
                                         new SqlParameter("@whereClause", "1=1"));
        ReceiptTypeUpd.DataValueField = "GERRcptType";
        ReceiptTypeUpd.DataTextField  = "RcptTypeDesc";
        ReceiptTypeUpd.DataSource     = dsGER.Tables[0];
        ReceiptTypeUpd.DataBind();
        dsGER.Tables[0].Rows.Add(new Object[] { "-", "- Show All -" });
        DataView ReceiptTypeView = new DataView(dsGER.Tables[0]);

        ReceiptTypeView.Sort             = "GERRcptType";
        ReceiptTypeFilter.DataValueField = "GERRcptType";
        ReceiptTypeFilter.DataTextField  = "RcptTypeDesc";
        ReceiptTypeFilter.DataSource     = ReceiptTypeView;
        ReceiptTypeFilter.DataBind();
        // Ports of Lading
        dsGER = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ReportsConnectionString"].ToString(), "UGEN_SP_Select",
                                         new SqlParameter("@tableName", "Tables"),
                                         new SqlParameter("@columnNames", "distinct Dsc as POL, Dsc as PortofLading"),
                                         new SqlParameter("@whereClause", "TableType = 'GERPORT'"));
        POLUpd.DataValueField = "POL";
        POLUpd.DataTextField  = "PortofLading";
        POLUpd.DataSource     = dsGER.Tables[0];
        POLUpd.DataBind();
        dsGER.Tables[0].Rows.Add(new Object[] { "-", "- Show All -" });
        DataView PortOfLadingView = new DataView(dsGER.Tables[0]);

        PortOfLadingView.Sort             = "PortofLading";
        PortOfLadingFilter.DataValueField = "POL";
        PortOfLadingFilter.DataTextField  = "PortofLading";
        PortOfLadingFilter.DataSource     = PortOfLadingView;
        PortOfLadingFilter.DataBind();
        // Charge Types
        dsGER = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ReportsConnectionString"].ToString(), "UGEN_SP_Select",
                                         new SqlParameter("@tableName", "GERChargeTypes"),
                                         new SqlParameter("@columnNames", "GERChrgType, ChargeTypeDesc"),
                                         new SqlParameter("@whereClause", "1=1 order by GERChrgType"));
        ChargeTypeUpd.DataValueField = "GERChrgType";
        ChargeTypeUpd.DataTextField  = "ChargeTypeDesc";
        ChargeTypeUpd.DataSource     = dsGER.Tables[0];
        ChargeTypeUpd.DataBind();
        dsGER.Tables[0].Rows.Add(new Object[] { "-", "- Show All -" });
        DataView ChargeTypeView = new DataView(dsGER.Tables[0]);

        ChargeTypeView.Sort             = "GERChrgType";
        ChargeTypeFilter.DataValueField = "GERChrgType";
        ChargeTypeFilter.DataTextField  = "ChargeTypeDesc";
        ChargeTypeFilter.DataSource     = ChargeTypeView;
        ChargeTypeFilter.DataBind();
    }
예제 #15
0
        /// <inheritdoc />
        public async Task <PagingResult <BranchModel> > GetBranchesByCompany(int companyId, BranchFilter filter, Sortable sortable, Paginable paginable)
        {
            var company = await _companyRepository.GetAsync(companyId);

            if (company == null)
            {
                throw new KeyNotFoundException();
            }

            IQueryable <Branch> query = await _branchRepository.GetAsync(x => x.Company.Id == companyId);

            query = Filtering(filter, query);

            var queryableCount = query;
            int totalCount     = queryableCount.Count();

            query = Sorting(sortable, query);

            query = Pagination(paginable, query);

            var branches        = query.ToList();
            var branchModelList = new List <BranchModel>();

            var allUsersQuery = await _userRepository.GetAsync(x => !string.IsNullOrEmpty(x.Role)?x.Role.Trim().Equals(salesRoleId) : false);

            foreach (var branch in branches)
            {
                var branchModel = branch.Adapt <BranchModel>();

                branchModel.CountSalesRep = allUsersQuery.Where(x => x.BranchId == branch.Id)?.Count();

                branchModelList.Add(branchModel);
            }

            return(new PagingResult <BranchModel>
            {
                Total = totalCount,
                ItemsPerPage = paginable.Take ?? 0,
                Data = branchModelList
            });
        }
예제 #16
0
        public async Task <ResultList> GetAllBranchAsync(BranchFilter filterDto)
        {
            var branches = await GetBranchesAsync(filterDto);

            return(branches);
        }
예제 #17
0
        private async Task <ResultList> GetBranchesAsync(BranchFilter branchFilter)
        {
            string provinceCode = string.Empty;
            string cityCode     = string.Empty;
            string villageCode  = string.Empty;

            if (branchFilter == null)
            {
                branchFilter = new BranchFilter();
            }


            if (branchFilter.ProvinceId != 0)
            {
                provinceCode = Context.Zones.Where(x => x.ID == branchFilter.ProvinceId).FirstOrDefault().OSTAN;
            }

            if (branchFilter.CityId != 0)
            {
                cityCode = Context.Zones.Where(x => x.ID == branchFilter.CityId).FirstOrDefault().SHAHRESTAN;
            }

            if (branchFilter.VillageId != 0)
            {
                villageCode = Context.Zones.Where(x => x.ID == branchFilter.VillageId).FirstOrDefault().Abadi;
            }

            var branchesJoin = (from zone in Context.Zones
                                join branch in Context.Branches on zone.ID equals branch.ZoneID
                                select new BranchZoneJoinModel
            {
                ID = branch.ID,
                BranchName = branch.BranchName,
                BranchCode = branch.BranchCode,
                OstanName = zone.OstanName,
                OSTAN = zone.OSTAN,
                ShahrestName = zone.ShahrestName,
                SHAHRESTAN = zone.SHAHRESTAN,
                BakhshName = zone.BakhshName,
                BAKHSH = zone.BAKHSH,
                DehestanName = zone.DehestanName,
                Dehestan = zone.Dehestan,
                AbadiName = zone.AbadiName,
                Abadi = zone.Abadi,
                ZoneID = zone.ID,
                Latitude = branch.Latitude,
                Longitude = branch.Longitude,
                BranchHeadName = branch.BranchHeadName,
                Fax = branch.Fax,
                PhoneNumber = branch.PhoneNumber,
                MeetingAddress1 = branch.MeetingAddress1,
                MeetingAddress2 = branch.MeetingAddress2,
                Address = branch.Address,
                BDN = branch.BDN,
                IsActive = branch.IsActive
            }).AsQueryable()
                               .Where(x => branchFilter.ProvinceId == 0 || string.IsNullOrEmpty(provinceCode) || x.OSTAN == provinceCode)
                               .Where(x => branchFilter.CityId == 0 || string.IsNullOrEmpty(cityCode) || x.SHAHRESTAN == cityCode)
                               .Where(x => branchFilter.VillageId == 0 || string.IsNullOrEmpty(villageCode) || x.Abadi == villageCode)
                               .Where(x => string.IsNullOrEmpty(branchFilter.branchName) || x.BranchName.Contains(branchFilter.branchName))
                               .Where(x => string.IsNullOrEmpty(branchFilter.branchCode) || x.BranchCode.Contains(branchFilter.branchCode))
                               .Where(x => string.IsNullOrEmpty(branchFilter.BranchHeadName) || x.BranchHeadName.Contains(branchFilter.BranchHeadName))
                               .Where(x => string.IsNullOrEmpty(branchFilter.MeetingAddress1) || x.MeetingAddress1.Contains(branchFilter.MeetingAddress1))
                               .Where(x => string.IsNullOrEmpty(branchFilter.MeetingAddress2) || x.MeetingAddress2.Contains(branchFilter.MeetingAddress2))
                               .Where(x => string.IsNullOrEmpty(branchFilter.Fax) || x.Fax == branchFilter.Fax)
                               .Where(x => string.IsNullOrEmpty(branchFilter.PhoneNumber) || x.PhoneNumber == branchFilter.PhoneNumber)
                               .Where(x => string.IsNullOrEmpty(branchFilter.Address) || x.MeetingAddress2.Contains(branchFilter.Address));



            var result = new ResultList();

            result.TotalRows = branchesJoin.Count();
            branchesJoin     = ApplySorting(branchFilter, branchesJoin);
            if (branchFilter.PageNumber != 0)
            {
                branchesJoin = branchesJoin.Skip((branchFilter.PageNumber - 1) * _take).Take(_take);
            }
            result.MaxPageRows = _take;

            var branches = branchesJoin.Select(p => new Branch()
            {
                ID              = p.ID,
                BranchName      = p.BranchName,
                BranchCode      = p.BranchCode,
                ZoneID          = p.ZoneID,
                MasterAddress   = p.OstanName + " " + p.ShahrestName + " " + p.AbadiName,
                Address         = p.Address,
                Latitude        = p.Latitude,
                Longitude       = p.Longitude,
                BranchHeadName  = p.BranchHeadName,
                Fax             = p.Fax,
                BDN             = p.BDN,
                IsActive        = p.IsActive,
                MeetingAddress1 = p.MeetingAddress1,
                MeetingAddress2 = p.MeetingAddress2,
                PhoneNumber     = p.PhoneNumber,
            });

            result.Results = await branches.ToListAsync();

            return(result);
        }