using System;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
    public static class APIBaseInfoService
    {
        #region 获取常量
        /// 
        /// 获取培训级别
        /// 
        /// 
        public static List getSysConst(string groupId)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.Sys_Const
                                    where x.GroupId == groupId
                                    orderby x.SortIndex
                                    select new Model.BaseInfoItem { BaseInfoId = x.ConstValue, BaseInfoCode = x.SortIndex.ToString(), BaseInfoName = x.ConstText }).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 获取项目列表
        /// 
        /// 获取项目列表
        /// 
        /// 
        public static List getProjectList()
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.Base_Project
                                    orderby x.ProjectCode
                                    select new Model.BaseInfoItem
                                    {
                                        BaseInfoId = x.ProjectId,
                                        BaseInfoCode = x.ProjectCode,
                                        BaseInfoName = x.ProjectName
                                    }
                                ).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 根据项目号获取项目信息
        /// 
        /// 根据项目号获取项目信息
        /// 
        /// 
        /// 
        public static Model.BaseInfoItem getProjectByCode(string projectCode)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.Base_Project
                                    where x.ProjectCode == projectCode
                                    select new Model.BaseInfoItem
                                    {
                                        BaseInfoId = x.ProjectId,
                                        BaseInfoCode = x.ProjectCode,
                                        BaseInfoName = x.ProjectName
                                    }
                                ).FirstOrDefault();
                return getDataLists;
            }
        }
        #endregion
        #region 根据项目id获取区域表
        /// 
        /// 根据项目id获取区域表
        /// 
        /// 
        /// 
        public static List getProjectWorkArea(string projectId)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.WBS_UnitWork
                                    where x.ProjectId == projectId && x.SuperUnitWork == null
                                    orderby x.UnitWorkCode
                                    select new Model.BaseInfoItem
                                    {
                                        BaseInfoId = x.UnitWorkId,
                                        BaseInfoCode = x.UnitWorkCode,
                                        BaseInfoName = BLL.UnitWorkService.GetUnitWorkALLName(x.UnitWorkId)
                                    }
                                ).ToList();
                return getDataLists;
            }
        }
        /// 
        /// 根据项目、单位ID获取单位工程
        /// 
        /// 
        /// 
        /// 
        public static List GetProjecUnitWorkByUnitId(string projectId, string unitId)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.WBS_UnitWork
                                    where x.ProjectId == projectId && x.UnitId == unitId && x.SuperUnitWork == null
                                    orderby x.UnitWorkCode
                                    select new Model.BaseInfoItem
                                    {
                                        BaseInfoId = x.UnitWorkId,
                                        BaseInfoCode = x.UnitWorkCode,
                                        BaseInfoName = BLL.UnitWorkService.GetUnitWorkALLName(x.UnitWorkId)
                                    }
                                ).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 获取材质列表
        /// 
        /// 获取材质列表
        /// 
        /// 
        public static List GetMaterial()
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.Base_Material
                                    orderby x.MaterialCode
                                    select new Model.BaseInfoItem
                                    {
                                        BaseInfoId = x.MaterialId,
                                        BaseInfoCode = x.MaterialCode,
                                        BaseInfoName = x.MetalType
                                    }
                                ).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 焊接探伤类型,探伤比例
        /// 
        /// 获取探伤类型
        /// 
        /// 
        public static List getDetectionType()
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.Base_DetectionType
                                    orderby x.DetectionTypeCode
                                    select new Model.BaseInfoItem
                                    {
                                        BaseInfoId = x.DetectionTypeId,
                                        BaseInfoCode = x.DetectionTypeCode,
                                        BaseInfoName = x.DetectionTypeName
                                    }
                                ).ToList();
                return getDataLists;
            }
        }
        /// 
        /// 获取探伤比例
        /// 
        /// 
        public static List getDetectionRate()
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.Base_DetectionRate
                                    orderby x.DetectionRateCode
                                    select new Model.BaseInfoItem
                                    {
                                        BaseInfoId = x.DetectionRateId,
                                        BaseInfoCode = x.DetectionRateCode,
                                        BaseInfoName = x.DetectionRateValue.Value.ToString() + "%"
                                    }
                                ).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 根据类型获取巡检隐患类型表
        /// 
        /// 根据类型获取巡检隐患类型表
        /// 
        /// 
        /// 
        public static List getHazardRegisterTypes(string type)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.HSSE_Hazard_HazardRegisterTypes
                                    where x.HazardRegisterType == type
                                    orderby x.TypeCode
                                    select new Model.BaseInfoItem { BaseInfoId = x.RegisterTypesId, BaseInfoCode = x.TypeCode, BaseInfoName = x.RegisterTypesName }).ToList();
                return getDataLists;
            }
        }
        #endregion                     
        #region 根据项目id获取项目图片
        /// 
        /// 根据项目id获取项目图片
        /// 
        ///         
        /// 
        public static List getProjectPictureByProjectId(string projectId, string pictureType, string strParam)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.InformationProject_Picture
                                    join y in db.AttachFile on x.PictureId equals y.ToKeyId
                                    where x.States == Const.State_2 && y.AttachUrl != null && x.ProjectId == projectId && x.PictureType == pictureType
                                    orderby x.UploadDate descending
                                    select new Model.BaseInfoItem
                                    {
                                        BaseInfoId = x.PictureId,
                                        BaseInfoName = x.Title,
                                        BaseInfoCode = string.Format("{0:yyyy-MM-dd}", x.UploadDate),
                                        ImageUrl = y.AttachUrl.Replace('\\', '/'),
                                    });
                if (!string.IsNullOrEmpty(strParam))
                {
                    getDataLists = getDataLists.Where(x => x.BaseInfoName.Contains(strParam));
                }
                return getDataLists.ToList();
            }
        }
        /// 
        /// 项目图片信息保存方法
        /// 
        /// 图片信息
        public static void SaveProjectPicture(Model.PictureItem picture)
        {
            Model.InformationProject_Picture newPicture = new Model.InformationProject_Picture
            {
                PictureId = picture.PictureId,
                ProjectId = picture.ProjectId,
                Title = picture.Title,
                ContentDef = picture.ContentDef,
                PictureType = picture.PictureTypeId,
                UploadDate = System.DateTime.Now,
                States = Const.State_2,
                CompileMan = picture.CompileManId,
            };
            if (string.IsNullOrEmpty(newPicture.PictureId))
            {
                newPicture.PictureId = SQLHelper.GetNewID();
                PictureService.AddPicture(newPicture);
            }
            else
            {
                PictureService.UpdatePicture(newPicture);
            }
            CommonService.btnSaveData(newPicture.ProjectId, Const.ProjectPictureMenuId, newPicture.PictureId, newPicture.CompileMan, true, newPicture.Title, "../InformationProject/PictureView.aspx?PictureId={0}");
            //// 保存附件
            APIUpLoadFileService.SaveAttachUrl(Const.ProjectPictureMenuId, newPicture.PictureId, picture.AttachUrl, "0");
        }
        #endregion
        #region 根据项目id获取项目地图
        /// 
        /// 根据项目id获取项目地图
        /// 
        ///         
        /// 
        public static List getProjectMapByProjectId(string projectId, string mapType)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.InformationProject_ProjectMap
                                    join y in db.AttachFile on x.ProjectMapId equals y.ToKeyId
                                    where y.AttachUrl != null && x.ProjectId == projectId && x.MapType == mapType
                                    orderby x.UploadDate descending
                                    select new Model.BaseInfoItem
                                    {
                                        BaseInfoId = x.ProjectMapId,
                                        BaseInfoName = x.Title,
                                        BaseInfoCode = string.Format("{0:yyyy-MM-dd}", x.UploadDate),
                                        ImageUrl = y.AttachUrl.Replace('\\', '/'),
                                    }).Take(5).ToList();
                return getDataLists;
            }
        }
        /// 
        /// 项目地图信息保存方法
        /// 
        /// 地图信息
        public static void SaveProjectMap(Model.PictureItem projectMap)
        {
            Model.InformationProject_ProjectMap newProjectMap = new Model.InformationProject_ProjectMap
            {
                ProjectMapId = projectMap.PictureId,
                ProjectId = projectMap.ProjectId,
                Title = projectMap.Title,
                ContentDef = projectMap.ContentDef,
                MapType = projectMap.PictureTypeId,
                UploadDate = System.DateTime.Now,
                CompileMan = projectMap.CompileManId,
            };
            if (string.IsNullOrEmpty(newProjectMap.ProjectMapId))
            {
                newProjectMap.ProjectMapId = SQLHelper.GetNewID();
                ProjectMapService.AddProjectMap(newProjectMap);
            }
            else
            {
                ProjectMapService.UpdateProjectMap(newProjectMap);
            }
            //// 保存附件
            APIUpLoadFileService.SaveAttachUrl(Const.ProjectProjectMapMenuId, newProjectMap.ProjectMapId, projectMap.AttachUrl, "0");
        }
        #endregion
        #region 获取通知通告
        /// 
        /// 根据项目id获取通知通告
        /// 
        /// 
        /// 
        public static List getNoticesList(string projectId, string strParam)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.InformationProject_Notice
                                    where x.AccessProjectId.Contains(projectId) && x.IsRelease == true
                                    && (strParam == null || x.NoticeTitle.Contains(strParam))
                                    orderby x.ReleaseDate descending
                                    select new Model.NoticeItem
                                    {
                                        NoticeId = x.NoticeId,
                                        NoticeCode = x.NoticeCode,
                                        NoticeTitle = x.NoticeTitle,
                                        ReleaseDate = string.Format("{0:yyyy-MM-dd HH:mm}", x.ReleaseDate)
                                    }).ToList();
                return getDataLists;
            }
        }
        /// 
        /// 根据项目id获取通知通告
        /// 
        /// 
        /// 
        public static List getNoticesList(string projectId, string userId, string strParam)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.InformationProject_Notice
                                    where x.AccessProjectId.Contains(projectId) && x.IsRelease == true
                                    && (strParam == null || x.NoticeTitle.Contains(strParam))
                                    select new Model.NoticeItem
                                    {
                                        NoticeId = x.NoticeId,
                                        NoticeCode = x.NoticeCode,
                                        NoticeTitle = x.NoticeTitle,
                                        ReleaseDate = string.Format("{0:yyyy-MM-dd HH:mm}", x.ReleaseDate),
                                        IsRead = db.Sys_UserRead.FirstOrDefault(y => y.DataId == x.NoticeId && y.ProjectId == projectId && y.UserId == userId) == null ? false : true,
                                    }).ToList();
                return getDataLists.OrderBy(x => x.IsRead).ThenByDescending(x => x.ReleaseDate).ToList();
            }
        }
        /// 
        /// 根据项目id获取通知通告
        /// 
        /// 
        /// 
        public static Model.NoticeItem getNoticesByNoticeId(string noticeId)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.InformationProject_Notice
                                    where x.NoticeId == noticeId
                                    select new Model.NoticeItem
                                    {
                                        NoticeId = x.NoticeId,
                                        NoticeCode = x.NoticeCode,
                                        NoticeTitle = x.NoticeTitle,
                                        ReleaseDate = string.Format("{0:yyyy-MM-dd HH:mm}", x.ReleaseDate),
                                        MainContent = x.MainContent,
                                        AttachUrl = db.AttachFile.FirstOrDefault(y => y.ToKeyId == x.NoticeId).AttachUrl.Replace("\\", "/"),
                                    }).FirstOrDefault();
                return getDataLists;
            }
        }
        #endregion
        #region 获取岗位信息
        /// 
        /// 获取岗位信息
        /// 
        /// 
        public static List getWorkPost(string strParam)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.Base_WorkPost
                                    where strParam == null || x.WorkPostName.Contains(strParam)
                                    orderby x.WorkPostName
                                    select new Model.BaseInfoItem { BaseInfoId = x.WorkPostId, BaseInfoCode = x.WorkPostCode, BaseInfoName = x.WorkPostName }).ToList();
                return getDataLists;
            }
        }
        /// 
        /// 获取岗位信息
        /// 
        /// 
        public static List getProjectWorkPost(string projectId, string strParam)
        {
            var getIdLists = Funs.DB.SitePerson_Person.Where(x => (x.ProjectId == projectId || (projectId == null && x.ProjectId == null))).Select(x => x.WorkPostId).Distinct();
            var getDataLists = (from x in Funs.DB.Base_WorkPost
                                where getIdLists.Contains(x.WorkPostId) && (strParam == null || x.WorkPostName.Contains(strParam))
                                orderby x.WorkPostName
                                select new Model.BaseInfoItem { BaseInfoId = x.WorkPostId, BaseInfoCode = x.WorkPostCode, BaseInfoName = x.WorkPostName }).ToList();
            return getDataLists;
        }
        #endregion
        #region 获取培训类别
        /// 
        /// 获取培训类别
        /// 
        /// 
        public static List getTrainType()
        {
            var getDataLists = (from x in Funs.DB.Base_TrainType
                                orderby x.TrainTypeCode
                                select new Model.BaseInfoItem { BaseInfoId = x.TrainTypeId, BaseInfoCode = x.TrainTypeCode, BaseInfoName = x.TrainTypeName }).ToList();
            return getDataLists;
        }
        #endregion
        #region 获取培训级别
        /// 
        /// 获取培训级别
        /// 
        /// 
        public static List getTrainLevel()
        {
            var getDataLists = (from x in Funs.DB.Base_TrainLevel
                                orderby x.TrainLevelCode
                                select new Model.BaseInfoItem { BaseInfoId = x.TrainLevelId, BaseInfoCode = x.TrainLevelCode, BaseInfoName = x.TrainLevelName }).ToList();
            return getDataLists;
        }
        #endregion
        #region 获取法律法规类型
        /// 
        /// 获取法律法规类型
        /// 
        /// 
        public static List getLawsRegulationsType()
        {
            var getDataLists = (from x in Funs.DB.Base_LawsRegulationsType
                                orderby x.Code
                                select new Model.BaseInfoItem { BaseInfoId = x.Id, BaseInfoCode = x.Code, BaseInfoName = x.Name }).ToList();
            return getDataLists;
        }
        #endregion
        #region 获取标准规范类型
        /// 
        /// 获取标准规范类型
        /// 
        /// 
        public static List getHSSEStandardListType()
        {
            var getDataLists = (from x in Funs.DB.Base_HSSEStandardListType
                                orderby x.TypeCode
                                select new Model.BaseInfoItem { BaseInfoId = x.TypeId, BaseInfoCode = x.TypeCode, BaseInfoName = x.TypeName }).ToList();
            return getDataLists;
        }
        #endregion
        #region 获取规章制度类型
        /// 
        /// 获取规章制度类型
        /// 
        /// 
        public static List getRulesRegulationsType()
        {
            var getDataLists = (from x in Funs.DB.Base_RulesRegulationsType
                                orderby x.RulesRegulationsTypeCode
                                select new Model.BaseInfoItem { BaseInfoId = x.RulesRegulationsTypeId, BaseInfoCode = x.RulesRegulationsTypeCode, BaseInfoName = x.RulesRegulationsTypeName }).ToList();
            return getDataLists;
        }
        #endregion
        #region 获取管理规定类型
        /// 
        /// 获取管理规定类型
        /// 
        /// 
        public static List getManageRuleType()
        {
            var getDataLists = (from x in Funs.DB.Base_ManageRuleType
                                orderby x.ManageRuleTypeCode
                                select new Model.BaseInfoItem { BaseInfoId = x.ManageRuleTypeId, BaseInfoCode = x.ManageRuleTypeCode, BaseInfoName = x.ManageRuleTypeName }).ToList();
            return getDataLists;
        }
        #endregion
        #region 获取机具设备类型
        /// 
        /// 获取机具设备类型
        /// 
        /// 
        public static List getSpecialEquipment(bool isSpecial)
        {
            var getDataLists = (from x in Funs.DB.Base_SpecialEquipment
                                where x.IsSpecial == isSpecial
                                orderby x.SpecialEquipmentCode
                                select new Model.BaseInfoItem { BaseInfoId = x.SpecialEquipmentId, BaseInfoCode = x.SpecialEquipmentCode, BaseInfoName = x.SpecialEquipmentName }).ToList();
            return getDataLists;
        }
        #endregion
        #region 获取工作阶段
        /// 
        /// 获取工作阶段
        /// 
        /// 
        public static List getWorkStage()
        {
            var getDataLists = (from x in Funs.DB.Base_WorkStage
                                orderby x.WorkStageCode
                                select new Model.BaseInfoItem { BaseInfoId = x.WorkStageId, BaseInfoCode = x.WorkStageCode, BaseInfoName = x.WorkStageName }).ToList();
            return getDataLists;
        }
        #endregion
        #region 获取项目班组
        /// 
        /// 获取项目班组
        /// 
        /// 
        /// 
        /// 
        public static List getTeamGroup(string projectId, string unitId)
        {
            var getDataLists = (from x in Funs.DB.ProjectData_TeamGroup
                                where x.ProjectId == projectId && (unitId == null || x.UnitId == unitId)
                                orderby x.TeamGroupCode
                                select new Model.BaseInfoItem { BaseInfoId = x.TeamGroupId, BaseInfoCode = x.TeamGroupCode, BaseInfoName = x.TeamGroupName }).ToList();
            return getDataLists;
        }
        /// 
        /// 获取项目班组组长
        /// 
        /// 
        /// 
        /// 
        public static Model.BaseInfoItem getTeamGroupLeader(string teamGroupId)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.ProjectData_TeamGroup
                                    join y in  db.SitePerson_Person on x.GroupLeaderId equals y.PersonId
                                    where x.TeamGroupId == teamGroupId && y.PersonId != null
                                    select new Model.BaseInfoItem { BaseInfoId = y.PersonId, BaseInfoCode = y.CardNo, BaseInfoName = y.PersonName }).FirstOrDefault();
                return getDataLists;
            }
        }
        #endregion
        #region 获取项目区域
        /// 
        /// 获取项目区域
        /// 
        /// 
        public static List getWorkArea(string projectId, string unitId)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.WBS_UnitWork
                                    where x.ProjectId == projectId && (unitId == null || x.UnitId == unitId)
                                    orderby x.UnitWorkCode
                                    select new Model.BaseInfoItem { BaseInfoId = x.UnitWorkId, BaseInfoCode = x.UnitWorkCode, BaseInfoName = x.UnitWorkName }).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 获取作业票-安全措施
        /// 
        /// 获取作业票-安全措施
        /// 
        /// 
        public static List getSafetyMeasures(string licenseType)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.Base_SafetyMeasures
                                    where x.LicenseType == licenseType
                                    orderby x.SortIndex
                                    select new Model.BaseInfoItem { BaseInfoId = x.SafetyMeasuresId, BaseInfoCode = x.SortIndex.ToString(), BaseInfoName = x.SafetyMeasures }).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 获取图片分类
        /// 
        /// 获取图片分类
        /// 
        /// 
        public static List getPictureType(string menuType)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.Base_PictureType
                                    where menuType == null || x.MenuType ==menuType
                                    orderby x.Code
                                    select new Model.BaseInfoItem { BaseInfoId = x.PictureTypeId, BaseInfoCode = x.Code, BaseInfoName = x.Name }).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 获取作业许可证(定稿)类型分类
        /// 
        /// 获取作业许可证类型分类
        /// 
        /// 
        public static List getBase_LicenseType()
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.Base_LicenseType
                                    orderby x.LicenseTypeCode
                                    select new Model.BaseInfoItem { BaseInfoId = x.LicenseTypeId, BaseInfoCode = x.LicenseTypeCode, BaseInfoName = x.LicenseTypeName }).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 获取特岗证书
        /// 
        /// 获取图片分类
        /// 
        /// 
        public static List getCertificate()
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.Base_Certificate
                                    orderby x.CertificateCode
                                    select new Model.BaseInfoItem { BaseInfoId = x.CertificateId, BaseInfoCode = x.CertificateCode, BaseInfoName = x.CertificateName }).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 获取部门
        /// 
        /// 获取图片分类
        /// 
        /// 
        public static List getDepart()
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.Base_Depart
                                    orderby x.DepartCode
                                    select new Model.BaseInfoItem { BaseInfoId = x.DepartId, BaseInfoCode = x.DepartCode, BaseInfoName = x.DepartName }).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 获取应急预案类型
        /// 
        /// 获取图片分类
        /// 
        /// 
        public static List getEmergencyType()
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.Base_EmergencyType
                                    orderby x.EmergencyTypeCode
                                    select new Model.BaseInfoItem { BaseInfoId = x.EmergencyTypeId, BaseInfoCode = x.EmergencyTypeCode, BaseInfoName = x.EmergencyTypeName }).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 获取国家基础数据
        /// 
        /// 获取国家基础数据
        /// 
        /// 
        public static List getCountry()
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.RealName_Country
                                    orderby x.Name
                                    select new Model.BaseInfoItem { BaseInfoId = x.CountryId, BaseInfoCode = x.Name, BaseInfoName = x.Cname }).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 获取省份基础数据
        /// 
        /// 获取省份基础数据
        /// 
        /// 
        public static List getProvinceByCountry(string countryId)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.RealName_City
                                    where countryId == null || countryId=="" || x.CountryId== countryId
                                    orderby x.ProvinceCode
                                    select new Model.BaseInfoItem { BaseInfoId = x.ProvinceCode, BaseInfoCode = x.Name, BaseInfoName = x.Cname }).ToList();
                return getDataLists;
            }
        }
        #endregion
        #region 获取实名制数据字典信息
        /// 
        /// 获取实名制数据字典信息
        /// 
        /// 
        public static List getBasicDataByDictTypeCode(string dictTypeCode)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                var getDataLists = (from x in db.RealName_BasicData
                                    where x.DictTypeCode == dictTypeCode
                                    orderby x.DictCode
                                    select new Model.BaseInfoItem { BaseInfoId = x.DictCode, BaseInfoCode = x.DictCode, BaseInfoName = x.DictName }).ToList();
                return getDataLists;
            }
        }
        #endregion
    }
}