Example #1
0
        /// <summary>
        /// 发布图层
        /// </summary>
        /// <param name="layerId">图层编号</param>
        /// <returns>true:发布成功,false:发布失败</returns>
        public bool PublicLayer(string layerName, string title, ListResultOutput <LayerFieldDto> listDto, string layerType)
        {
            if (!_GeoServer.IsExsitWorkSpace(_GeoWorkSpace))
            {
                _GeoServer.AddWorkSpace(_GeoWorkSpace);
            }
            if (!_GeoServer.IsExsitDataStore(_GeoWorkSpace, _GeoDataStore))
            {
                _GeoServer.AddDataStore(_GeoWorkSpace, _GeoDataStore, _PostGisHost, _PostGisPort, _PostGisDB, _PostGisUser, _PostGisPwd);
            }
            Dictionary <string, string> filedAndType = new Dictionary <string, string>();

            for (int i = 0; i < listDto.Items.Count; i++)
            {
                filedAndType.Add(listDto.Items[i].AttributeName, GetGeoFiledType(listDto.Items[i].AttributeTypeName));
            }
            filedAndType.Add("guid", GetGeoFiledType("VARCHAR"));
            filedAndType.Add("geom", GetGeoFiledType(layerType));
            if (!_GeoServer.IsExsitLayer(layerName, _GeoWorkSpace, _GeoDataStore))
            {
                _GeoServer.AddLayer(layerName, title, filedAndType, _GeoWorkSpace, _GeoDataStore, _epsg);
                _GeoServer.ModifyLayerStyle(layerName, new List <string>(), GetDefaultStyle(layerType));
            }
            return(true);
        }
        /// <summary>
        /// 根据MapID查询
        /// </summary>
        /// <param name="mapId"></param>
        /// <returns></returns>
        public ListResultOutput <MapReleationDto> GetAllListByMapId(string mapId)
        {
            try
            {
                var query = _IMapReleationRepository.GetAllList().Where(q => q.MapID == mapId).ToList().OrderBy(q => q.DataSort);
                var list  = new ListResultOutput <MapReleationDto>(query.MapTo <List <MapReleationDto> >());
                if (list.Items.Count > 0)
                {
                    for (int i = 0; i < list.Items.Count; i++)
                    {
                        if (!string.IsNullOrWhiteSpace(list.Items[i].DataConfigID))
                        {
                            var layer = _ILayerContentRepository.Get(list.Items[i].DataConfigID);
                            list.Items[i].DataConfigName = (layer != null) ? layer.LayerName : "";
                        }
                        if (!string.IsNullOrWhiteSpace(list.Items[i].DataStyleID))
                        {
                            var style = _IDataStyleRepository.Get(list.Items[i].DataStyleID);
                            list.Items[i].DataStyleName = (style != null) ? style.StyleName : "";
                        }
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// 通过图层ID获取字段字典集合
        /// </summary>
        /// <param name="layerID"></param>
        /// <returns></returns>
        public ListResultOutput <LayerFieldDictDto> GetFieldDictByLayerID(string layerID)
        {
            try
            {
                List <LayerFieldDictDto> layerFieldDicts = new List <LayerFieldDictDto>();
                var query = _ILayerFieldRepository.GetAll().Where(q => q.LayerID == layerID && q.AttributeDataType == "T").ToList();
                foreach (var item in query)
                {
                    string fieldId = item.Id;
                    var    result  = _ILayerFieldDictRepository.GetAll().Where(t => t.AttributeID == fieldId).ToList();

                    foreach (var detail in result)
                    {
                        LayerFieldDictDto dto = new LayerFieldDictDto();
                        dto.AttributeID   = detail.AttributeID;
                        dto.FieldDictDesc = detail.FieldDictDesc;
                        dto.FieldDictName = detail.FieldDictName;
                        dto.Id            = detail.Id;
                        layerFieldDicts.Add(dto);
                    }
                }

                var list = new ListResultOutput <LayerFieldDictDto>(layerFieldDicts);
                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #4
0
        public async Task <List <ComboboxItemDto> > GetEditionComboboxItems(int?selectedEditionId = null)
        {
            var editions = await _editionManager.Editions.ToListAsync();

            var editionItems = new ListResultOutput <ComboboxItemDto>(editions.Select(e => new ComboboxItemDto(e.Id.ToString(), e.DisplayName)).ToList()).Items.ToList();

            var defaultItem = new ComboboxItemDto("null", L("NotAssigned"));

            editionItems.Insert(0, defaultItem);

            if (selectedEditionId.HasValue)
            {
                var selectedEdition = editionItems.FirstOrDefault(e => e.Value == selectedEditionId.Value.ToString());
                if (selectedEdition != null)
                {
                    selectedEdition.IsSelected = true;
                }
            }
            else
            {
                defaultItem.IsSelected = true;
            }

            return(editionItems);
        }
Example #5
0
        public async Task <List <NameValue> > GetCustomersAddresses(long customerId)
        {
            string str;

            await this._customerRepository.GetAsync(customerId);

            IRepository <Address, long> repository = this._addressRepository;
            List <Address> allListAsync            = await repository.GetAllListAsync((Address x) => x.OwnerId == customerId && x.OwnerType == "Customer");

            List <NameValue> nameValues = new List <NameValue>();

            foreach (Address address in allListAsync)
            {
                ListResultOutput <CountryRegionInCountryListDto> countryRegions = this._genericAppService.GetCountryRegions(address.CountryRegionId, null);
                string[] primaryAddress = new string[] { address.PrimaryAddress, " ", address.City, null, null, null };
                str = (countryRegions.Items.Count == 1 ? string.Concat(", ", countryRegions.Items[0].Code) : "");
                primaryAddress[3] = str;
                primaryAddress[4] = " ";
                primaryAddress[5] = address.PostalCode;
                string str1 = string.Concat(primaryAddress);
                long   id   = address.Id;
                nameValues.Add(new NameValue(id.ToString(), str1));
            }
            return(nameValues);
        }
        /// <summary>
        /// 绑定下拉框 根据父ID查询
        /// </summary>
        /// <param name="pid"></param>
        /// <returns></returns>
        public async Task <ListResultOutput <LayerManagerDto> > GetLayerManagerByPID()
        {
            var result     = _iLayerManagerRepository.GetAll().Where(q => q.PID == "0000");
            var outputList = new ListResultOutput <LayerManagerDto>(result.MapTo <List <LayerManagerDto> >());

            return(outputList);
        }
        /// <summary>
        /// 通过外键获取附件列表
        /// </summary>
        /// <param name="fkid"></param>
        /// <returns></returns>
        public async Task <ListResultOutput <AttachmentDto> > GetAllList(string fkid)
        {
            var result = await _iAttachmentRepository.GetAllListAsync(q => q.FKey == fkid);

            var outputList = new ListResultOutput <AttachmentDto>(result.MapTo <List <AttachmentDto> >());

            return(outputList);
        }
        /// <summary>
        /// 获取不带count的分页列表
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <ListResultOutput <LayerManagerDto> > GetPageList(QueryLayerManagerInput input)
        {
            var result = await _iLayerManagerRepository.GetPageList(input.Name, input.PageIndex, input.PageSize);

            var outputList = new ListResultOutput <LayerManagerDto>(result.MapTo <List <LayerManagerDto> >());

            return(outputList);
        }
Example #9
0
        public async Task <ListResultOutput <StudentEnabledExamTimeDto> > GetStudentCourseExamTimes(GetExamTimeEventInput input)
        {
            input.Start = input.Start.AddDays(-1);
            input.End   = input.End.AddDays(1);

            var studentid = AbpSession.UserId ?? 0;
            var student   = await _studentRepository.FirstOrDefaultAsync(x => x.Id == studentid);

            if (student == null)
            {
                throw new UserFriendlyException("用户不存在。");
            }

            var studentSubjects = await _studentSubjectTimeRepository.GetAllListAsync(x => x.StudentId == studentid);

            var studentSubjectsIds = studentSubjects.Select(i => i.CourseId).ToList();

            var studentCourses = await _courseRepository.GetAllListAsync(x => studentSubjectsIds.Contains(x.SubjectProjectId));

            var studentCoursesIds = studentCourses.Select(i => i.Id).ToList();

            var studentSelectedExamTime = await _studentCourseExamTimeRepository.GetAllListAsync(
                x => x.StudentId == studentid &&
                !x.ExamTime.TeacherCourse.IsDeleted &&
                !x.ExamTime.TeacherCourse.Course.IsDeleted);

            var studentSelectedExamTimeIds = studentSelectedExamTime.Select(x => x.ExamTimeId).ToList();

            var query = _courseExamTimeRepository.GetAll();

            var s = ((DateTime.Today.Year - student.EntryDate.Year) * 12 + (DateTime.Today.Month - student.EntryDate.Month)) / 12 + 1;


            var studentGrade = $",{s},";

            query = query.Where(x => x.FitGrade == null || x.FitGrade == "" || x.FitGrade.Contains(studentGrade));

            query = query.Where(x => studentCoursesIds.Contains(x.TeacherCourse.CourseId) && x.Start > input.Start && x.Start < input.End);

            var studentEnabledExamTimes = await Task.FromResult(query.Select(x => new
            {
                x.Id,
                x.TeacherCourse,
                x.Start,
                x.Address,
                x.Times,
                x.End,
                //EnabledSelecting = x.Times < x.TeacherCourse.Course.LimitNumbers,
                EnabledEndTime = x.End >= DateTime.Today,
                EnabledStartTime = x.Start <= DateTime.Now,
                IsSelected = studentSelectedExamTimeIds.Contains(x.Id)
            }).ToList());

            var result = new ListResultOutput <StudentEnabledExamTimeDto>
                             (Mapper.DynamicMap <List <StudentEnabledExamTimeDto> >(studentEnabledExamTimes));

            return(result);
        }
        public async Task <ListResultOutput <ComboboxItemDto> > GetEditionsForCombobox()
        {
            List <Edition> listAsync = await this._editionManager.Editions.ToListAsync <Edition>();

            ListResultOutput <ComboboxItemDto> listResultOutput = new ListResultOutput <ComboboxItemDto>((
                                                                                                             from e in listAsync
                                                                                                             select new ComboboxItemDto(e.Id.ToString(), e.DisplayName)).ToList <ComboboxItemDto>());

            return(listResultOutput);
        }
Example #11
0
 /// <summary>
 /// 获取分类管理(通过图层与地图类型区分)
 /// </summary>
 /// <param name="dataType">图层或地图基本代码</param>
 /// <returns></returns>
 public ListResultOutput <DataTypeDto> GetAllListByDataType(string dataType)
 {
     try
     {
         var query = _IDataTypeRepository.GetAll().Where(q => q.DictCodeID == dataType);
         var list  = new ListResultOutput <DataTypeDto>(query.MapTo <List <DataTypeDto> >());
         return(list);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Example #12
0
        public ListResultOutput<UserDto> GetAllList()
        {

            string key = "userlist";
            var cacheList = _cache.Get<ListResultOutput<UserDto>>(CacheCategoryUserInfo, key);
            if (cacheList == null)
            {
                var user = _userRepository.GetAllList();
                cacheList= new ListResultOutput<UserDto>(user.MapTo<List<UserDto>>());
               _cache.Put(CacheCategoryUserInfo, key, cacheList);
            }
            return cacheList; 
        }
Example #13
0
 /// <summary>
 /// 通过类别获取所有数据
 /// </summary>
 /// <param name="typeID"></param>
 /// <returns></returns>
 public ListResultOutput <DicDataCodeDto> GetDetailByTypeID(string typeID)
 {
     try
     {
         var query = _IDicDataCodeRepository.GetAll().Where(q => q.DataTypeID == typeID).ToList();
         var list  = new ListResultOutput <DicDataCodeDto>(query.MapTo <List <DicDataCodeDto> >());
         return(list);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Example #14
0
 /// <summary>
 /// 根据通过名称获取数据
 /// </summary>
 public ListResultOutput <DataTypeDto> GetDetailByName(string name, string dataType)
 {
     try
     {
         var query  = _IDataTypeRepository.GetAll().Where(q => q.TypeName == name && q.DictCodeID == dataType);
         var result = new ListResultOutput <DataTypeDto>(query.MapTo <List <DataTypeDto> >());
         return(result);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        public async Task <ListResultOutput <HazardsTypeDto> > GetAllList()
        {
            try
            {
                var result = await _iHazardstypeRepository.GetAllListAsync();

                var outputList = new ListResultOutput <HazardsTypeDto>(result.MapTo <List <HazardsTypeDto> >());
                return(outputList);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        /// <summary>
        /// 按条件分页查询
        /// </summary>
        /// <param name="querySlopeInput"></param>
        /// <returns></returns>
        public async Task <ListResultOutput <SlopeDto> > GetPageList(QuerySlopeInput querySlopeInput)
        {
            try
            {
                var slope = await _iSlopeRepository.GetPageList(querySlopeInput.PageIndex, querySlopeInput.PageSize, querySlopeInput.DISASTERUNITNAME, querySlopeInput.LOCATION);

                var list = new ListResultOutput <SlopeDto>(slope.MapTo <List <SlopeDto> >());
                return(list);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="queryDisasterDato"></param>
        /// <returns></returns>
        public async Task <ListResultOutput <DisasterDto> > GetPageList(QueryDisasterInput queryDto)
        {
            try
            {
                var disasterEntity = await _iDisasterRepository.GetPageList(queryDto.PageIndex, queryDto.PageSize);

                var list = new ListResultOutput <DisasterDto>(disasterEntity.MapTo <List <DisasterDto> >());
                return(list);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Example #18
0
 /// <summary>
 /// 获取所有数据
 /// </summary>
 public async Task <ListResultOutput <DataTagDto> > GetAllList()
 {
     try
     {
         //var query = await _IDataTagRepository.GetAllListAsync();
         var query = _IDataTagRepository.GetAllList();
         var list  = new ListResultOutput <DataTagDto>(query.MapTo <List <DataTagDto> >());
         return(list);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        /// <summary>
        /// 获取所有数据
        /// </summary>
        /// <returns></returns>

        public async Task <ListResultOutput <DisasterDto> > GetAllList()
        {
            try
            {
                var disasterEntity = await _iDisasterRepository.GetAllListAsync();

                var list = new ListResultOutput <DisasterDto>(disasterEntity.MapTo <List <DisasterDto> >());
                return(list);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
        public async Task<List<ComboboxItemDto>> GetEditionComboboxItems(GetTimezoneComboboxItemsInput input)
        {
            var timeZones = await GetTimezoneInfos(input.DefaultTimezoneScope);
            var timeZoneItems = new ListResultOutput<ComboboxItemDto>(timeZones.Select(e => new ComboboxItemDto(e.Value, e.Name)).ToList()).Items.ToList();

            if (!string.IsNullOrEmpty(input.SelectedTimezoneId))
            {
                var selectedEdition = timeZoneItems.FirstOrDefault(e => e.Value == input.SelectedTimezoneId);
                if (selectedEdition != null)
                {
                    selectedEdition.IsSelected = true;
                }
            }

            return timeZoneItems;
        }
Example #21
0
        //  private readonly IRepository<City> citiesRepository;


        public int GetCity(GetAddressInput input)
        {

            var output = this.citiesRepository
                 .GetAll()
                .WhereIf(
                    input.Filter != null,
                    p => p.Name.Contains(input.Filter) 
                )
               .ToList()
                ;


            ListResultOutput<StreetAddressListDto> list = new ListResultOutput<StreetAddressListDto>(output.MapTo<List<StreetAddressListDto>>());
            return list.Items.ElementAt(0).Id;

        }
Example #22
0
        public async Task <List <ComboboxItemDto> > GetTimezoneComboboxItems(GetTimezoneComboboxItemsInput input)
        {
            var timeZones = await GetTimezoneInfos(input.DefaultTimezoneScope);

            var timeZoneItems = new ListResultOutput <ComboboxItemDto>(timeZones.Select(e => new ComboboxItemDto(e.Value, e.Name)).ToList()).Items.ToList();

            if (!string.IsNullOrEmpty(input.SelectedTimezoneId))
            {
                var selectedEdition = timeZoneItems.FirstOrDefault(e => e.Value == input.SelectedTimezoneId);
                if (selectedEdition != null)
                {
                    selectedEdition.IsSelected = true;
                }
            }

            return(timeZoneItems);
        }
Example #23
0
        public async Task <ListResultOutput <OrganizationUnitDto> > GetOrganizationUnits()
        {
            var result = await(from ou in _organizationUnitRepository.GetAll()
                               join uou in _userOrganizationUnitRepository.GetAll() on ou.Id equals uou.OrganizationUnitId into g
                               select new
            {
                ou          = ou,
                memberCount = g.Count()
            }).ToListAsync();
            ListResultOutput <OrganizationUnitDto> listResultOutput = new ListResultOutput <OrganizationUnitDto>(result.Select((item) =>
            {
                OrganizationUnitDto organizationUnitDto = item.ou.MapTo <OrganizationUnitDto>();
                organizationUnitDto.MemberCount         = item.memberCount;
                return(organizationUnitDto);
            }).ToList());

            return(listResultOutput);
        }
        /// <summary>
        /// 根据帐号和图层ID获取通知
        /// </summary>
        public ListResultOutput <LayerReadLogOutputDto> GetDetailByLayer(LayerReadLogOutputDto input)
        {
            try
            {
                string layerID = input.LayerID, user = input.CreateBy;
                ListResultOutput <LayerReadLogOutputDto> list;
                var layer = _ILayerContentRepository.GetAll();
                //var readLog = _ILayerReadLogRepository.GetAll().Where(q => (string.IsNullOrEmpty(layerID) ? true : q.LayerID.Contains(layerID)) && (string.IsNullOrEmpty(user) ? true : (q.CreateBy.Contains(user) && q.MsgStatus.Value.Equals(0))));

                var readLog = _ILayerReadLogRepository.GetAll();
                if (string.IsNullOrEmpty(layerID))
                {
                    readLog = readLog.Where(q => (q.CreateBy.Contains(user) && q.MsgStatus == 1));
                }
                else
                {
                    readLog = readLog.Where(q => q.LayerID.Contains(layerID) && (q.CreateBy.Contains(user) && q.MsgStatus == 1));
                }
                var query = (from r in readLog
                             join l in layer on r.LayerID equals l.Id into rl
                             from rre in rl.DefaultIfEmpty()
                             select new LayerReadLogOutputDto
                {
                    Id = r.Id,
                    LayerID = r.LayerID,
                    LayerName = (rre == null) ? "" : rre.LayerName,
                    ShpFileName = r.ShpFileName,
                    ReadStatus = r.ReadStatus,
                    Message = r.Message,
                    CreateDT = r.CreateDT,
                    CreateBy = r.CreateBy,
                    ReadStartDT = r.ReadStartDT,
                    ReadEndDT = r.ReadEndDT,
                    MsgStatus = r.MsgStatus
                }).OrderByDescending(x => x.CreateDT).ToList();

                list = new ListResultOutput <LayerReadLogOutputDto>(query.MapTo <List <LayerReadLogOutputDto> >());
                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #25
0
        /// <summary>
        /// 根据基本代码获取数据
        /// </summary>
        public ListResultOutput <DataTagDto> GetAllListByDataType(string dataType)
        {
            try
            {
                List <string> listTags = new List <string>();
                //地图标签
                //if (dataType == "ba5ab799-6acd-11e7-87f3-005056bb1c7e")
                //{
                //    var listTag = _IMapRepository.GetAll().Where(t => !string.IsNullOrEmpty(t.MapTag)).Select(t => t.MapTag).ToList();
                //    listTag.ForEach(t =>
                //    {
                //        listTags.AddRange(t.Split(','));
                //    });
                //    listTags = listTags.Distinct().ToList();
                //}
                ////图层标签
                //else if (dataType == "a2faae61-6acd-11e7-87f3-005056bb1c7e")
                //{
                //    var listTag = _ILayerContentRepository.GetAll().Where(t => !string.IsNullOrEmpty(t.LayerTag)).Select(t => t.LayerTag).ToList();
                //    listTag.ForEach(t =>
                //    {
                //        listTags.AddRange(t.Split(','));
                //    });
                //    listTags = listTags.Distinct().ToList();
                //}

                var listTagReleation = _ITagReleationRepository.GetAll().Select(t => t.DataTagID).ToList();
                listTagReleation.ForEach(t =>
                {
                    listTags.AddRange(t.Split(','));
                });
                listTags = listTags.Distinct().ToList();

                var query = _IDataTagRepository.GetAll().Where(q => q.DictCodeID == dataType && listTags.Contains(q.Id));
                var list  = new ListResultOutput <DataTagDto>(query.MapTo <List <DataTagDto> >());
                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #26
0
        /// <summary>
        /// 获取所有数据
        /// </summary>
        public async Task <ListResultOutput <MapDto> > GetAllList()
        {
            try
            {
                //var query = await _IMapRepository.GetAllListAsync();
                var query = _IMapRepository.GetAllList();
                var list  = new ListResultOutput <MapDto>(query.MapTo <List <MapDto> >());
                if (list.Items.Count > 0)
                {
                    for (int i = 0; i < list.Items.Count; i++)
                    {
                        if (list.Items[i].MapScale != null)
                        {
                            list.Items[i].MapScaleName = GetDetailCodeName(list.Items[i].MapScale);
                        }
                        if (list.Items[i].SpatialRefence != null)
                        {
                            list.Items[i].SpatialRefenceName = GetDetailCodeName(list.Items[i].SpatialRefence);
                        }
                        if (list.Items[i].MapType != null)
                        {
                            try
                            {
                                var mapType = _IDataTypeRepository.Get(list.Items[i].MapType);
                                list.Items[i].MapType = mapType.TypeName;
                            }
                            catch (Exception ex)
                            {
                                list.Items[i].MapType = "";
                            }
                        }
                        list.Items[i].MapTag = GetMultiTagNameByMapID(list.Items[i].Id);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #27
0
        private async Task <List <ComboboxItemDto> > GetEditionComboboxItems(int?selectedEditionId = null)
        {
            ListResultOutput <ComboboxItemDto> editionsForCombobox = await this._lookupAppService.GetEditionsForCombobox();

            List <ComboboxItemDto> list            = editionsForCombobox.Items.ToList <ComboboxItemDto>();
            ComboboxItemDto        comboboxItemDto = new ComboboxItemDto("null", this.L("NotAssigned"));

            list.Insert(0, comboboxItemDto);
            if (!selectedEditionId.HasValue)
            {
                comboboxItemDto.IsSelected = true;
            }
            else
            {
                ComboboxItemDto comboboxItemDto1 = list.FirstOrDefault <ComboboxItemDto>((ComboboxItemDto e) => e.Value == selectedEditionId.Value.ToString());
                if (comboboxItemDto1 != null)
                {
                    comboboxItemDto1.IsSelected = true;
                }
            }
            return(list);
        }
        public async Task<List<ComboboxItemDto>> GetEditionComboboxItems(int? selectedEditionId = null)
        {
            var editions = await _editionManager.Editions.ToListAsync();
            var editionItems = new ListResultOutput<ComboboxItemDto>(editions.Select(e => new ComboboxItemDto(e.Id.ToString(), e.DisplayName)).ToList()).Items.ToList();

            var defaultItem = new ComboboxItemDto("null", L("NotAssigned"));
            editionItems.Insert(0, defaultItem);

            if (selectedEditionId.HasValue)
            {
                var selectedEdition = editionItems.FirstOrDefault(e => e.Value == selectedEditionId.Value.ToString());
                if (selectedEdition != null)
                {
                    selectedEdition.IsSelected = true;
                }
            }
            else
            {
                defaultItem.IsSelected = true;
            }

            return editionItems;
        }
Example #29
0
        public async Task <HttpResponseMessage> GetCountryRegionsAsSelectListItems(int?countryRegionId = null, int?countryId = null, int?selectedCountryRegionId = null, bool jTable = false)
        {
            string text = string.Empty;
            object cachedRegionsJson = await _cacheManager.GetCache("_WebAppExtendedCache").GetOrDefaultAsync("CountryRegions");

            if (cachedRegionsJson == null)
            {
                ListResultOutput <CountryRegionInCountryListDto> countryRegions = this._genericAppService.GetCountryRegions(null, null);
                if (countryRegions.Items.Count > 0)
                {
                    text = JsonConvert.SerializeObject(countryRegions);
                    await _cacheManager.GetCache("_WebAppExtendedCache").SetAsync("CountryRegions", text, new TimeSpan?(TimeSpan.FromMinutes(2400.0)));
                }
            }
            else
            {
                text = cachedRegionsJson.ToString();
            }
            HttpResponseMessage result;

            if (text.Length > 0)
            {
                var  deserializedListResult = JsonConvert.DeserializeObject <ListResultOutput <CountryRegionInCountryListDto> >(text);
                var  selectListItems        = new List <GenericSelectListItemModel>(deserializedListResult.Items.Count);
                bool selectedFlag           = false;
                if (countryRegionId.HasValue && countryRegionId > 0)
                {
                    foreach (var item in deserializedListResult.Items)
                    {
                        if (item.Id == countryRegionId)
                        {
                            if (selectedCountryRegionId == item.Id)
                            {
                                selectedFlag = true;
                            }
                            selectListItems.Add(new GenericSelectListItemModel
                            {
                                Text     = item.Name,
                                Value    = item.Id.ToString(),
                                Selected = selectedFlag,
                                Group    = "",
                                Disabled = false
                            });
                            break;
                        }
                    }
                    text = JsonConvert.SerializeObject(selectListItems);
                }
                else if (countryId.HasValue && countryId > 0)
                {
                    foreach (var item in deserializedListResult.Items)
                    {
                        if (item.CountryId == countryId)
                        {
                            if (selectedCountryRegionId == item.Id)
                            {
                                selectedFlag = true;
                            }
                            selectListItems.Add(new GenericSelectListItemModel
                            {
                                Text     = item.Name,
                                Value    = item.Id.ToString(),
                                Selected = selectedFlag,
                                Group    = "",
                                Disabled = false
                            });
                        }
                        selectedFlag = false;
                    }
                    text = JsonConvert.SerializeObject(selectListItems);
                }
                else
                {
                    foreach (var item in deserializedListResult.Items)
                    {
                        if (selectedCountryRegionId == item.Id)
                        {
                            selectedFlag = true;
                        }
                        selectListItems.Add(new GenericSelectListItemModel
                        {
                            Text     = item.Name,
                            Value    = item.Id.ToString(),
                            Selected = selectedFlag,
                            Group    = "",
                            Disabled = false
                        });
                        selectedFlag = false;
                    }
                    text = JsonConvert.SerializeObject(selectListItems);
                }
                if (jTable)
                {
                    var deserializedList = JsonConvert.DeserializeObject <List <GenericSelectListItemModel> >(text);
                    List <JTableOption> listOfJTableOptions = deserializedList.Select(i => new JTableOption
                    {
                        DisplayText = i.Text,
                        Value       = i.Value
                    }).ToList <JTableOption>();
                    string jTableOptionResponseJson = JsonConvert.SerializeObject(new JTableOptionResponse
                    {
                        Result  = "OK",
                        Options = listOfJTableOptions
                    });
                    HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "OK");
                    response.Content = new StringContent(jTableOptionResponseJson, Encoding.UTF8);
                    response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                    response.Headers.CacheControl        = new CacheControlHeaderValue
                    {
                        MaxAge = new TimeSpan?(TimeSpan.FromMinutes(240.0))
                    };
                    result = response;
                }
                else
                {
                    HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "value");
                    response.Content = new StringContent(text, Encoding.UTF8);
                    response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                    response.Headers.CacheControl        = new CacheControlHeaderValue
                    {
                        MaxAge = new TimeSpan?(TimeSpan.FromMinutes(240.0))
                    };
                    result = response;
                }
            }
            else
            {
                result = null;
            }
            return(result);
        }
Example #30
0
        /// <summary>
        /// 获取地图列表(通过标签,类型,名称)
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public ListResultOutput <MapDto> GetAllListByName(MapInputDto input)
        {
            ListResultOutput <MapDto> list;

            try
            {
                string mapType = input.MapType, tag = input.MapTag, name = input.MapName, mapID = "", type = "";

                if (!string.IsNullOrEmpty(tag))
                {
                    mapID = GetMultiLayerIDByTag(tag);
                }

                if (!string.IsNullOrEmpty(mapType))
                {
                    type = GetMultiChildTypeByType(mapType);
                }

                if (string.IsNullOrWhiteSpace(input.CreateUserId))
                {
                    return(null);
                }

                var mapUserData = GetDataByUserCodeAsync(input.CreateUserId, name, type, mapID).Result;

                var listMapType    = _IDataTypeRepository.GetAll();
                var listMapRefence = _IDicDataCodeRepository.GetAll();
                var listMapScale   = _IDicDataCodeRepository.GetAll();

                var query = (from l in mapUserData
                             join t in listMapType on l.MapType equals t.Id into tt
                             from de in tt.DefaultIfEmpty()
                             join r in listMapRefence on l.SpatialRefence equals r.Id into rr
                             from re in rr.DefaultIfEmpty()
                             join dt in listMapScale on l.MapScale equals dt.Id into dtt
                             from ldt in dtt.DefaultIfEmpty()
                             select new MapDto
                {
                    Id = l.Id,
                    MapName = l.MapName,
                    MapEnName = l.MapEnName,
                    MapBBox = l.MapBBox,
                    MapPublishAddress = l.MapPublishAddress,
                    MapStatus = l.MapStatus,
                    MapDesc = l.MapDesc,
                    MapType = (de == null) ? "" : de.TypeName,
                    MapTag = l.MapTag,
                    PublishDT = l.PublishDT,
                    SortCode = l.SortCode,
                    EnabledMark = l.EnabledMark,
                    DeleteMark = l.DeleteMark,
                    CreateUserId = l.CreateUserId,
                    CreateUserName = l.CreateUserName,
                    CreateDT = l.CreateDT,
                    ModifyUserId = l.ModifyUserId,
                    ModifyUserName = l.ModifyUserName,
                    ModifyDate = l.ModifyDate,
                    MapScale = l.MapScale,
                    MapScaleName = (ldt == null) ? "" : ldt.CodeName,
                    SpatialRefence = l.SpatialRefence,
                    SpatialRefenceName = (re == null) ? "" : re.CodeName,
                    MaxY = l.MaxY,
                    MinY = l.MinY,
                    MinX = l.MinX,
                    MaxX = l.MaxX,
                    MapLegend = l.MapLegend,
                    MaxDegLat = "",
                    MinDegLat = "",
                    MinDegLon = "",
                    MaxDegLon = ""
                }).OrderByDescending(x => x.CreateDT);

                var result = query.ToList();

                list = new ListResultOutput <MapDto>(result.MapTo <List <MapDto> >());

                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #31
0
 public IndexViewModel(ListResultOutput <SupplierListDto> output, string filter = null)
 {
     output.MapTo <ListResultOutput <SupplierListDto>, IndexViewModel>(this);
     this.Filter = filter;
 }
Example #32
0
        public async Task <HttpResponseMessage> GetCountriesAsSelectListItems(int?countryId = -1, int?selectedCountryId = null, bool jTable = false)
        {
            HttpResponseMessage httpResponseMessage;
            int?   nullable;
            bool   flag;
            string empty          = string.Empty;
            object orDefaultAsync = await this._cacheManager.GetCache("_WebAppExtendedCache").GetOrDefaultAsync("Countries");

            object obj = orDefaultAsync;

            if (obj != null)
            {
                empty = obj.ToString();
            }
            else
            {
                nullable = null;
                ListResultOutput <CountriesListDto> countries = this._genericAppService.GetCountries(nullable);
                if (countries.Items.Count > 0)
                {
                    empty = JsonConvert.SerializeObject(countries);
                    await this._cacheManager.GetCache("_WebAppExtendedCache").SetAsync("Countries", empty, new TimeSpan?(TimeSpan.FromMinutes(2400)));
                }
            }
            if (empty.Length <= 0)
            {
                httpResponseMessage = null;
            }
            else
            {
                ListResultOutput <CountriesListDto> listResultOutput            = JsonConvert.DeserializeObject <ListResultOutput <CountriesListDto> >(empty);
                List <GenericSelectListItemModel>   genericSelectListItemModels = new List <GenericSelectListItemModel>(listResultOutput.Items.Count);
                bool flag1 = false;
                foreach (CountriesListDto item in listResultOutput.Items)
                {
                    nullable = selectedCountryId;
                    int id = item.Id;
                    flag = (nullable.GetValueOrDefault() == id ? nullable.HasValue : false);
                    if (flag)
                    {
                        flag1 = true;
                    }
                    GenericSelectListItemModel genericSelectListItemModel = new GenericSelectListItemModel()
                    {
                        Text     = item.Name,
                        Value    = item.Id.ToString(),
                        Selected = flag1,
                        Group    = "",
                        Disabled = false
                    };
                    genericSelectListItemModels.Add(genericSelectListItemModel);
                    flag1 = false;
                }
                empty = JsonConvert.SerializeObject(genericSelectListItemModels);
                if (!jTable)
                {
                    HttpResponseMessage stringContent = this.Request.CreateResponse <string>(HttpStatusCode.OK, "value");
                    stringContent.Content = new StringContent(empty, Encoding.UTF8);
                    stringContent.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                    HttpResponseHeaders     headers = stringContent.Headers;
                    CacheControlHeaderValue cacheControlHeaderValue = new CacheControlHeaderValue()
                    {
                        MaxAge = new TimeSpan?(TimeSpan.FromMinutes(240))
                    };
                    headers.CacheControl = cacheControlHeaderValue;
                    httpResponseMessage  = stringContent;
                }
                else
                {
                    List <GenericSelectListItemModel> genericSelectListItemModels1 = JsonConvert.DeserializeObject <List <GenericSelectListItemModel> >(empty);
                    List <JTableOption> list = (
                        from x in genericSelectListItemModels1
                        select new JTableOption()
                    {
                        DisplayText = x.Text,
                        Value = x.Value
                    }).ToList <JTableOption>();
                    JTableOptionResponse jTableOptionResponse = new JTableOptionResponse()
                    {
                        Result  = "OK",
                        Options = list
                    };
                    string str = JsonConvert.SerializeObject(jTableOptionResponse);
                    HttpResponseMessage mediaTypeHeaderValue = this.Request.CreateResponse <string>(HttpStatusCode.OK, "OK");
                    mediaTypeHeaderValue.Content = new StringContent(str, Encoding.UTF8);
                    mediaTypeHeaderValue.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                    HttpResponseHeaders     httpResponseHeader       = mediaTypeHeaderValue.Headers;
                    CacheControlHeaderValue cacheControlHeaderValue1 = new CacheControlHeaderValue()
                    {
                        MaxAge = new TimeSpan?(TimeSpan.FromMinutes(240))
                    };
                    httpResponseHeader.CacheControl = cacheControlHeaderValue1;
                    httpResponseMessage             = mediaTypeHeaderValue;
                }
            }
            return(httpResponseMessage);
        }
Example #33
0
        public async Task <FileDto> GetCustomerWithAddressesToExcel()
        {
            string          str;
            string          str1;
            List <Customer> allListAsync = await this._customerRepository.GetAllListAsync();

            List <CustomerWithAddressListDto> customerWithAddressListDtos = new List <CustomerWithAddressListDto>();

            foreach (Customer customer in allListAsync)
            {
                IRepository <Address, long> repository = this._addressRepository;
                List <Address> addresses = await repository.GetAllListAsync((Address m) => m.OwnerId == customer.Id && m.OwnerType == "Customer");

                foreach (Address address in addresses)
                {
                    CustomerWithAddressListDto customerWithAddressListDto = new CustomerWithAddressListDto()
                    {
                        CustomerId   = customer.Id,
                        AllowBillPay = customer.AllowBillPay,
                        IsActive     = customer.IsActive,
                        FirstName    = customer.FirstName,
                        LastName     = customer.LastName,
                        BusinessName = customer.BusinessName,
                        CreationTime = new DateTime?(customer.CreationTime)
                    };
                    CustomerWithAddressListDto primaryAddress = customerWithAddressListDto;
                    primaryAddress.PrimaryAddress   = address.PrimaryAddress;
                    primaryAddress.SecondaryAddress = address.SecondaryAddress;
                    primaryAddress.City             = address.City;
                    int?countryRegionId = address.CountryRegionId;
                    if (!countryRegionId.HasValue)
                    {
                        primaryAddress.CountryRegionCode = "";
                    }
                    else
                    {
                        IGenericAppService genericAppService = this._genericAppService;
                        countryRegionId = address.CountryRegionId;
                        int?nullable = new int?(countryRegionId.Value);
                        countryRegionId = null;
                        ListResultOutput <CountryRegionInCountryListDto> countryRegions = genericAppService.GetCountryRegions(nullable, countryRegionId);
                        CustomerWithAddressListDto customerWithAddressListDto1          = primaryAddress;
                        str1 = (countryRegions == null || countryRegions.Items.Count != 1 ? "" : countryRegions.Items[0].Code);
                        customerWithAddressListDto1.CountryRegionCode = str1;
                    }
                    if (address.CountryId <= 0)
                    {
                        primaryAddress.CountryCode = "";
                    }
                    else
                    {
                        ListResultOutput <CountriesListDto> countries = this._genericAppService.GetCountries(new int?(address.CountryId));
                        CustomerWithAddressListDto          customerWithAddressListDto2 = primaryAddress;
                        str = (countries == null || countries.Items.Count != 1 ? "" : countries.Items[0].Code);
                        customerWithAddressListDto2.CountryCode = str;
                    }
                    primaryAddress.PostalCode      = address.PostalCode;
                    primaryAddress.Latitude        = address.Latitude;
                    primaryAddress.Longitude       = address.Longitude;
                    primaryAddress.ContactName     = address.ContactName;
                    primaryAddress.Type            = address.Type;
                    primaryAddress.AddressId       = address.Id;
                    primaryAddress.AddressIsActive = address.IsActive;
                    customerWithAddressListDtos.Add(primaryAddress);
                }
            }
            return(this._customerListExcelExporter.ExportToFile(customerWithAddressListDtos));
        }