示例#1
0
 private void Add2Coordinate(List <string> data)
 {
     for (_i = 0; _i < data.Count; _i++)
     {
         _currentLine = data[_i];
         string[] item = _currentLine.Split(',');
         using (var context = new StreetContext())
         {
             string roomName = $"{item[9]}-{item[10]}";
             //水岸星城坐标导入
             //var room1 = context.Rooms.SingleOrDefault(r => r.Building.Alias == item[6] && r.Name == roomName);
             //                经纬度坐标                                  //社区name——小区alias——楼栋id——房间号
             var room1 = context.Rooms.FirstOrDefault(r => r.Building.Subdivision.Alias.Contains(item[7]) && r.Building.Name == item[8] && r.Name == roomName);
             //var room1 = context.Rooms.SingleOrDefault(r => r.Building.Subdivision.Community.Name == item[4].Replace("社区", "") && r.Building.Subdivision.Alias.Contains(item[7]) && r.Building.Name == item[8] && r.Name == roomName);
             if (room1 != null)
             {
                 //经纬度
                 room1.Longitude = Convert.ToDouble(item[11]);
                 room1.Latitude  = Convert.ToDouble(item[12]);
                 //楼高
                 double h = (Convert.ToDouble(item[2]) + Convert.ToDouble(item[3]) / 2);
                 room1.Height = Math.Round(h, 2);
             }
             context.SaveChanges();
             tbInfo.Text = "Add Coordinate OK!";
             //return "Add Coordinate OK!";
         }
     }
 }
示例#2
0
        private static void AddUser2Role(StreetContext context, Role role, User user)
        {
            RoleUser ru = new RoleUser {
                Role = role, User = user
            };

            context.RoleUsers.Add(ru);
        }
示例#3
0
        public AuthController(StreetContext xjpContext, IJwtFactory jwtFactory, IOptions <JwtIssuerOptions> jwtOptions, IUserService userService, IMemoryCache cache)
        {
            _jwtFactory  = jwtFactory;
            _jwtOptions  = jwtOptions.Value;
            _userService = userService;
            _cache       = cache;

            _repository = new XjpRepository(xjpContext);
        }
示例#4
0
        private static User AddUser(StreetContext context, string name)
        {
            var user = context.Users.SingleOrDefault(s => s.UserName == name);

            if (user == null)
            {
                user = new User {
                    UserName = name, Password = "******"
                };
                context.Users.Add(user);
            }
            return(user);
        }
示例#5
0
        private static Role AddRole(StreetContext context, string name)
        {
            var role = context.Roles.SingleOrDefault(s => s.Name == name);

            if (role == null)
            {
                role = new Role {
                    Name = name
                };
                context.Roles.Add(role);
            }
            return(role);
        }
示例#6
0
        //添加街道数据
        private static StreetUnit AddStreet(StreetContext context, string name)
        {
            StreetUnit street = context.Streets.SingleOrDefault(s => s.Name == name);

            if (street == null)
            {
                street = new StreetUnit {
                    Name = name
                };
                context.Streets.Add(street);
            }

            return(street);
        }
示例#7
0
        private static Community AddCommunity(StreetContext context, StreetUnit street, string name)
        {
            var community = context.Communitys.SingleOrDefault(s => s.Name == name);

            if (community == null)
            {
                community = new Community {
                    Name = name
                };
                community.Street = street;
                //street.Communities.Add(community);
                context.Communitys.Add(community);
            }
            return(community);
        }
示例#8
0
        /// <summary>
        /// 添加网格,及网格员
        /// </summary>
        /// <param name="context"></param>
        /// <param name="community">网格所属社区</param>
        /// <param name="role">用户组</param>
        /// <param name="userName">用户名</param>
        private static void AddGrid(StreetContext context, Community community, int gridCount, Role role, string userName)
        {
            for (int i = 1; i <= gridCount; i++)
            {
                //网格
                var netGrid = context.NetGrids.SingleOrDefault(s => s.Name == i.ToString() && s.Community.Id == community.Id);
                if (netGrid == null)
                {
                    netGrid = new NetGrid {
                        Name = i.ToString()
                    };
                    netGrid.Community = community;
                    context.NetGrids.Add(netGrid);
                }

                //网格员
                var user = AddUser(context, netGrid, userName + i.ToString());
                AddUser2Role(context, role, user);
                netGrid.User = user;
            }
        }
示例#9
0
        private void Add2Alias(List <string> data)
        {
            for (_i = 0; _i < data.Count; _i++)
            {
                _currentLine = data[_i];
                string[] item = _currentLine.Split(',');
                using (var context = new StreetContext())
                {
                    var subdivision1 = context.Subdivisions.SingleOrDefault(s => s.Name == item[0]);
                    if (subdivision1 != null)
                    {
                        //CheckValue(item,3);
                        subdivision1.Alias = item[1];
                        //subdivision1.Community.Id = int.Parse(item[3]);
                    }

                    context.SaveChanges();
                    tbInfo.Text = "Add alias OK!";
                    //return "Add Coordinate OK!";
                }
            }
        }
示例#10
0
        /// <summary>
        /// 添加初始数据
        /// </summary>
        public static string AddData(string comName, string gridUser, int gridCount)
        {
            try
            {
                using (var context = new StreetContext())
                {
                    //添加街道  var street = AddStreet(context, "徐家棚");
                    var street = AddStreet(context, "徐家棚");

                    //add 网格员 Role
                    var roleWangGe = AddRole(context, "网格员");

                    #region 添加水岸星城社区、网格、网格员账户
                    //添加社区
                    var saxcCommunity = AddCommunity(context, street, comName);

                    //网格
                    AddGrid(context, saxcCommunity, gridCount, roleWangGe, gridUser);
                    #endregion

                    //添加管理员role,user
                    Role adminRole = AddRole(context, "Administrator");
                    User adminUser = AddUser(context, "admin");

                    AddUser2Role(context, adminRole, adminUser);
                    AddUser2Role(context, roleWangGe, adminUser);

                    context.SaveChanges();
                }
                return("Add data OK!");
            }
            catch (Exception err)
            {
                return(err.Message);
            }
        }
示例#11
0
 public PersonController(StreetContext xjpContext) //StreetContext context
 {
     _context    = xjpContext;                     // new StreetContext();
     _repository = new XjpRepository(_context);
 }
 public StreetRoadRepository()
 {
     _context = new StreetContext();
 }
示例#13
0
 public XjpRepository(StreetContext context)
 {
     _context = context;
 }
示例#14
0
 public XjpRepository()
 {
     _context = new StreetContext();
 }
示例#15
0
 public IActionResult Index()
 {
     return(View(StreetContext.AllStreets()));
 }
示例#16
0
 public PeopleController(StreetContext context)
 {
     _context = context;
 }
示例#17
0
        private void Add2DB(List <string> data)
        {
            //if (data.Count > 0)
            for (_i = 0; _i < data.Count; _i++)
            {
                _currentLine = data[_i];
                string[] item = _currentLine.Split(',');
                //string[] item = data[0].Split(',');
                if (IsEmpty(item, 7))
                {
                    continue;
                }

                CheckAllValue(item, 7);

                using (var context = new StreetContext())
                {
                    //街道

                    StreetUnit street = context.Streets.SingleOrDefault(s => s.Name == "徐家棚");

                    if (street == null)
                    {
                        street = new StreetUnit {
                            Name = "徐家棚"
                        };
                        context.Streets.Add(street);
                    }

                    //社区
                    var community = context.Communitys.SingleOrDefault(s => s.Name == item[0].Replace("社区", ""));
                    if (community == null)
                    {
                        //CheckValue(item,0);
                        community = new Community {
                            Name = item[0].Replace("社区", "")
                        };
                        community.Street = street;
                        //street.Communities.Add(community);
                        context.Communitys.Add(community);
                    }

                    //网格
                    var netGrid = context.NetGrids.SingleOrDefault(s => s.Community.Id == community.Id && s.Name == item[1].Replace("网格", ""));
                    if (netGrid == null)
                    {
                        // CheckValue(item, 1);
                        netGrid = new NetGrid {
                            Name = item[1].Replace("网格", "")
                        };
                        netGrid.Community = community;
                        context.NetGrids.Add(netGrid);
                    }


                    //小区
                    var subdivision = context.Subdivisions.SingleOrDefault(s => s.Name == item[3].Replace("小区", ""));
                    if (subdivision == null)
                    {
                        //CheckValue(item,3);
                        subdivision = new Subdivision {
                            Name = item[3].Replace("小区", "")
                        };
                        subdivision.Street = street;
                        context.Subdivisions.Add(subdivision);
                    }

                    //楼栋

                    //var building = netGrid.Buildings.SingleOrDefault(s => s.Name == item[4]);
                    var building = context.Buildings.SingleOrDefault(s => s.Subdivision.Id == subdivision.Id && s.Name == item[4].Replace("栋", ""));
                    if (building == null)
                    {
                        building = new Building
                        {
                            Name = item[4].Replace("栋", ""),
                            //房屋地址
                            Address = item[2],
                        };
                        building.NetGrid     = netGrid;
                        building.Subdivision = subdivision;
                        context.Buildings.Add(building);
                        //subdivision.Buildings.Add(building);
                    }

                    //房屋
                    string roomName = $"{item[5].Replace("单元", "")}-{item[6].Replace("号", "")}";
                    var    room     = context.Rooms.SingleOrDefault(r => r.Building.Id == building.Id && r.Name == roomName);
                    if (room == null)
                    {
                        room = new Room
                        {
                            Name     = roomName,
                            Category = item[7],
                            Use      = item[8],
                            Area     = item[10],
                            Other    = item[9],
                        };
                        room.Building = building;
                        context.Rooms.Add(room);
                    }

                    //单位信息
                    //  var companyinfo = new CompanyInfo { };
                    if (item[11] != "")
                    {
                        var companyinfo = new CompanyInfo
                        {
                            Name          = item[11],
                            Character     = item[12],
                            SocialId      = item[13],
                            ContactPerson = item[14],
                            PersonId      = item[15],
                            Phone         = item[16],
                            Area          = item[17]
                        };
                        companyinfo.Room = room;
                        context.CompanyInfos.Add(companyinfo);
                    }



                    //人
                    var person = context.Persons.SingleOrDefault(p => p.PersonId == item[20]);

                    //检测空名空身份证号
                    if (!CheckItem(item))
                    {
                        continue;
                    }
                    //检测同身份证号不同名
                    if (!CheckPerson(person, item))
                    {
                        continue;
                    }

                    if (person == null)
                    {
                        person = new Person
                        {
                            Name         = item[18],
                            EthnicGroups = item[19].Replace("族", ""),
                            PersonId     = item[20],
                            Phone        = item[21],
                            //户籍地址
                            DomicileAddress = item[22],

                            Company                = item[27],
                            PoliticalState         = item[28],
                            OrganizationalRelation = item[29],
                            IsOverseasChinese      = (item[30] == "是"),
                            MerriedStatus          = item[31],
                        };
                        // person.CompanyInfo = companyinfo;
                        context.Persons.Add(person);


                        //单位信息
                        //if (item[11] != "")
                        //{
                        //    var companyinfo = new CompanyInfo
                        //    {
                        //        Name = item[11],
                        //        Character = item[12],
                        //        SocialId = item[13],
                        //        ContactPerson = item[14],
                        //        PersonId = item[15],
                        //        Phone = item[16],
                        //        Area = item[17]
                        //    };
                        //    context.CompanyInfos.Add(companyinfo);
                        //}
                        //特殊人群

                        if (item[34] != "")
                        {
                            //var specialGroup = context.SpecialGroups.SingleOrDefault(s => s.PersonId == item[20]);
                            //if (specialGroup == null)
                            var specialGroup = new SpecialGroup {
                                PersonId = item[20], Type = item[34]
                            };
                            context.SpecialGroups.Add(specialGroup);
                        }

                        // 困难人群
                        if (item[35] != "")
                        {
                            var poorPeople = new PoorPeople
                            {
                                PersonId    = item[20],
                                Type        = item[35],
                                Child       = item[36],
                                Youngsters  = item[37],
                                SpecialHelp = item[38]
                            };
                            context.PoorPeoples.Add(poorPeople);
                        }
                        //服役状况
                        if (item[39] != "")
                        {
                            var militaryService = new MilitaryService {
                                PersonId = item[20], Type = item[39]
                            };
                            context.MilitaryService.Add(militaryService);
                        }

                        //残疾
                        //var disability = context.Disabilitys.SingleOrDefault(s => s.PersonId == item[20]);
                        //if (disability == null)
                        if (item[40] != "")
                        {
                            var disability = new Disability
                            {
                                PersonId = item[20],
                                Type     = item[40],
                                Class    = item[41],
                            };
                            context.Disability.Add(disability);
                        }

                        //其他信息
                        //var otherInfos = context.OtherInfos.SingleOrDefault(s => s.PersonId == item[20]);
                        // if (otherInfos == null)
                        if (item[42] != "")
                        {
                            var otherInfos = new OtherInfos
                            {
                                PersonId = item[20],
                                //Key = item[42],
                                Value = item[42],
                            };
                            context.OtherInfos.Add(otherInfos);
                        }
                    }
                    //personroom 人房信息
                    var personHouse = new PersonRoom
                    {
                        PersonId                = item[20],
                        IsHouseholder           = (item[23] == "是"),
                        RelationWithHouseholder = item[24],
                        IsOwner             = (item[25] == "是"),
                        IsLiveHere          = (item[26] == "是"),
                        PopulationCharacter = item[32],
                        LodgingReason       = item[33]
                    };

                    personHouse.Person = person;
                    personHouse.Room   = room;
                    context.PersonRooms.Add(personHouse);



                    context.SaveChanges();
                    _preItem = item;
                }
            }
            // tbInfo_err.Text = "";
            tbInfo.Text      = "Add personroomdata OK!";
            tbInfo_err.Text += _errorMessage;
        }