示例#1
0
        /**
         * 解析出村庄GUID
         */

        private void parsePerson()
        {
            try
            {
                int newCount = 0, redo = 0, illegal = 0;

                foreach (var dragFile in dragFiles)
                {
                    ExcelHelper.ParseExcel(dragFile, "常住人口", (sheet) =>
                    {
                        int length = sheet.Rows.Count;

                        /**
                         * 第0列:户号。第1列:关系。第2列:名字。第3列:身份证号。第4列:住址。
                         */
                        int currentRowIndex = 0;
                        while (currentRowIndex < length)
                        {
                            this.Invoke(new FormControlInvoker(() =>
                            {
                                statusLabel.Text = dragFile + "," + (currentRowIndex + 1) + "行";
                            }));
                            string no       = sheet.Rows[currentRowIndex][0].ToString().Trim();
                            string ralation = sheet.Rows[currentRowIndex][1].ToString().Trim();
                            string name     = sheet.Rows[currentRowIndex][2].ToString().Trim();
                            string id       = sheet.Rows[currentRowIndex][3].ToString().Trim();
                            string address  = sheet.Rows[currentRowIndex][4].ToString().Trim();
                            currentRowIndex++;

                            if (no.Trim().Length != 9 || id.Trim().Length != 18)
                            {
                                illegal++;
                                continue;
                            }
                            if (!CensusContext.IsExistPersons(id))
                            {
                                newCount++;
                                CensusContext.AddPerson(new Person(ralation, name, id, "汉族", address));
                            }
                            else
                            {
                                redo++;
                            }
                        }
                    });
                }
                MessageBox.Show("新数据 " + newCount + " 条,重复数据 " + redo + " 条,不合格数据 " + illegal + " 条");
            }
            catch (Exception)
            {
            }
            finally
            {
                this.Invoke(new FormControlInvoker(() =>
                {
                    statusLabel.Text = "";
                }));
            }
        }
 public UserDTO Login(UserDTO u)
 {
     using (CensusContext dbContext = new CensusContext())
     {
         var user    = dbContext.Users.Where(x => x.Email == u.Email && x.Password == u.Password).Select(x => x).FirstOrDefault <User>() ?? null;
         var userDTO = UserMapper.EntitytoDTOUser(user);
         return(userDTO);
     }
 }
        protected override void Seed(CensusContext context)
        {
            User approver = new User {
                Email = "*****@*****.**", Password = "******", FirstName = "Aquib", LastName = "Chiniwala", AadharNumber = "123456789012", Role = Role.Volunteer
            };

            context.Users.Add(approver);
            context.SaveChanges();
        }
示例#4
0
        public Form1()
        {
            //string abc = "dzyslx= \"'>  d+ \" </ div > \"";
            //Regex reg = new Regex("(?<=dzyslx=.*>).{1,10}(?=</div>)");
            //var numberCollection = reg.Matches(abc);

            InitializeComponent();

            //string a = "https://msjw.gat.shandong.gov.cn/zayw/hkzd/stbb/zzsb.jsp?data=pVC3T2lZmIc4jlXXaJyILe5mZPxaaeqx9L43ge5lIGEZynQ860PsjuB9O9RTeDRDDd7uGjeiovBVYWXnFq7eP9BbvWenwLF4GtiXgcdDRyjwT42sYSdvrIEumJkdNvmzWajK9tYQDXfa7nbpvKwtQ11FBaTHxyEVYr1c1mefBapa9FyqcyMhKVGfcbYd%2BL5v58KJHHTREyHElKceWNCgQUd7IhmaglLkaiTu2Awqjq0%3D";
            //Process.Start(a);

            CensusContext.Connect();
            currentVillageList = CensusContext.GetVillages();
        }
 /// <summary>
 /// Authenticcate User
 /// </summary>
 /// <param name="email">email of the user to login</param>
 /// <param name="password"> password of the user to login</param>
 /// <returns></returns>
 public UserDTO AuthenticateUser(string email, string password)
 {
     using (CensusContext db = new CensusContext())
     {
         try
         {
             var user = db.Users.FirstOrDefault(s => s.Email.Equals(email) && s.Password.Equals(password));
             return(mapper.Map <UserDTO>(user));
         }
         catch (Exception ex)
         {
             throw new Exception("User does not exists..!" + ex.Message);
         }
     }
 }
示例#6
0
        private void listBoxVillage_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.listBoxBuild.Items.Clear();
            this.dataGridViewPerson.Rows.Clear();
            var currentVillage = this.listBoxVillage.SelectedItem as Village;

            //currentVillage = villageList.First(model => model.name.Equals(vn));
            if (currentVillage != null)
            {
                Stopwatch sw = new Stopwatch();
                sw.Restart();
                currentBuildList = CensusContext.GetBuilds(currentVillage.guid);
                sw.Stop();
                var span = sw.ElapsedMilliseconds;

                foreach (var b in currentBuildList)
                {
                    this.listBoxBuild.Items.Add(b);
                }
            }
        }
示例#7
0
 /// <summary>
 /// check for the CHN in database
 /// </summary>
 /// <param name="chn">Census house number</param>
 /// <returns></returns>
 public bool CheckCHN(long?chn)
 {
     using (CensusContext db = new CensusContext())
     {
         try
         {
             HouseEntity house = db.Houses.FirstOrDefault(s => s.CensusHouseNumber == chn);
             if (house == null)
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         catch (Exception ex)
         {
             throw new DALException("Unable to Create House Listing" + ex.Message);
         }
     }
 }
 /// <summary>
 /// function to update user role
 /// </summary>
 /// <param name="userToUpdate">object of the user to be update</param>
 /// <returns></returns>
 public bool UpdateUser(UserDTO userToUpdate)
 {
     using (CensusContext db = new CensusContext())
     {
         try
         {
             UserEntity currentUser = mapper.Map <UserEntity>(userToUpdate);
             if (currentUser != null)
             {
                 db.Users.AddOrUpdate(currentUser);
                 db.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception ex)
         {
             throw new DALException("Unable to SignUp User" + ex.Message);
         }
     }
 }
 public UserOperations()
 {
     db = new CensusContext();
 }
示例#10
0
 public DataForm()
 {
     InitializeComponent();
     allVillageList = CensusContext.GetVillages();
 }
 public HouseOperations()
 {
     db = new CensusContext();
 }
示例#12
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     CensusContext.DisConnect();
 }
示例#13
0
        private void listBoxBuild_SelectedIndexChanged(object sender, EventArgs e)
        {
            step = 0;
            var currentBuild   = this.listBoxBuild.SelectedItem as Build;
            var currentVillage = this.listBoxVillage.SelectedItem as Village;

            this.dataGridViewPerson.Rows.Clear();
            url = "https://msjw.gat.shandong.gov.cn/zayw/hkzd/stbb/rysb.jsp?guid=" + currentBuild.guid;

            if (currentBuild != null)
            {
                currentPersonList = CensusContext.GetPersons(currentVillage.name, currentBuild.number);
                if (currentPersonList.Count <= 0)
                {
                    return;
                }

                StringBuilder funClearInfo = new StringBuilder();
                funClearInfo.Append("function funClearInfo() {");

                // 删除选择同住人div
                funClearInfo.Append("  $('.xshcyxx').hide(); $('.hjcyList').empty();");

                // 删除添加同住人div和img按钮
                funClearInfo.Append("  $(\"[class='sbrTit bbb vvv']\").remove();");
                funClearInfo.Append("  $(\"[class='addtzrBtn tianjia']\").remove();");

                // 清空所有个人信息
                funClearInfo.Append("  $('#hkwt_whcd').val('');");
                funClearInfo.Append("  $('#hkwt_whcd').attr('code', '');");
                funClearInfo.Append("  $('#hkwt_byzk').val('');");
                funClearInfo.Append("  $('#hkwt_byzk').attr('code', '');");
                funClearInfo.Append("  $('#hkwt_hyzk').val('');");
                funClearInfo.Append("  $('#hkwt_hyzk').attr('code', '');");
                funClearInfo.Append("  $('#hkwt_xx').val('');");
                funClearInfo.Append("  $('#hkwt_xx').attr('code', '');");
                funClearInfo.Append("  $('#hkwt_sg').val('');");
                funClearInfo.Append("  $('#hkwt_zy').val('');");
                funClearInfo.Append("  $('#hkwt_fwcs').val('');");
                funClearInfo.Append("}");

                /**
                 * 打开网页。设置身高999999,。开始watcher。
                 * 当身高!=999999并且step=0,说明第一次load数据完毕。执行{step=1,设置身高999999,并且getTHR()}
                 * 当身高!=999999并且step=1,说明第二次load数据完毕。执行{$('.xshcyxx').hide(); $('.hjcyList').empty(); doSubmits();window.clearInterval(watcherIndex);}
                 */

                StringBuilder funWatcher = new StringBuilder();
                funWatcher.Append("var watcherIndex=0; ");
                funWatcher.Append("var step=0; ");
                funWatcher.Append("var insertCount=0;");
                funWatcher.Append("function funWatcher() {");
                funWatcher.Append("  $('#hkwt_fwcs').val(999999);");
                funWatcher.Append("  watcherIndex = window.setInterval('aaa()',200);");
                funWatcher.Append("}");

                StringBuilder funAAA = new StringBuilder();
                funAAA.Append("function aaa() {");
                funAAA.Append("  if ($('#hkwt_fwcs').val() != 999999){");
                funAAA.Append("      if(step==0){");
                if (checkBox1.Checked)
                {
                    funAAA.Append("         step=1; $('#hkwt_fwcs').val(999999); getTHR();");
                    funAAA.Append("      }else if(step=1){");
                    funAAA.Append("         $('.xshcyxx').hide(); $('.hjcyList').empty();  ");
                    funAAA.Append("         doSubmits();");
                    funAAA.Append("         window.clearInterval(watcherIndex);");
                    //funAAA.Append("         window.postMessage('aaaa');");
                }
                else
                {
                    funAAA.Append("         funClearInfo();");
                    funAAA.Append("         doSubmits();");
                    funAAA.Append("         window.clearInterval(watcherIndex);");
                }
                funAAA.Append("      }");
                funAAA.Append("  }");
                funAAA.Append("}");


                StringBuilder funInit = new StringBuilder();
                funInit.Append("function funInit() {");

                // 切换是否本人
                funInit.Append("$('#mySwitch2').removeClass('mui-active');");
                funInit.Append("$('.mui-switch-handle').attr('style', 'transition-duration: 0.2s; transform: translate(0px, 0px);');");

                // 个人身份证只读去除
                funInit.Append("$('#pid').attr('readonly', false);");
                funInit.Append("$('#name').attr('readonly', false);");



                int i  = 0;
                int hz = 0;
                foreach (var b in currentPersonList)
                {
                    int index = this.dataGridViewPerson.Rows.Add();
                    this.dataGridViewPerson.Rows[index].Cells[0].Value = b.relation;
                    this.dataGridViewPerson.Rows[index].Cells[1].Value = b.name;
                    this.dataGridViewPerson.Rows[index].Cells[2].Value = b.id;
                    this.dataGridViewPerson.Rows[index].Cells[3].Value = b.address;
                    if (b.relation.Equals("户主") && hz == 0)
                    {
                        hz++;
                        DataGridViewCellStyle cs = new DataGridViewCellStyle();
                        cs.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                        this.dataGridViewPerson.Rows[index].Cells[0].Style = cs;
                        this.dataGridViewPerson.Rows[index].Cells[1].Style = cs;
                        this.dataGridViewPerson.Rows[index].Cells[2].Style = cs;
                        this.dataGridViewPerson.Rows[index].Cells[3].Style = cs;

                        funInit.Append($"$('#pid').val('{b.id}');");
                        funInit.Append($"$('#name').val('{b.name}');");
                    }
                    else
                    {
                        funInit.Append("$('.tianjia').trigger('tap');");
                        funInit.Append($" $('.addBox').eq({i}).find('.tzrPid').first().val('{b.id}');");
                        funInit.Append($" $('.addBox').eq({i}).find('.tzrName').first().val('{b.name}');");
                        i++;
                    }
                }
                funInit.Append("}");

                web.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(funInit.ToString());
                web.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(funClearInfo.ToString());
                //web.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(funAAA.ToString());
                //web.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(funWatcher.ToString());
                web.CoreWebView2.Navigate(url);

                web.CoreWebView2.Settings.IsWebMessageEnabled = true;
                web.CoreWebView2.WebMessageReceived          += CoreWebView2_WebMessageReceived;
                //web.CoreWebView2.ScriptDialogOpening += CoreWebView2_ScriptDialogOpening1;
                //web.CoreWebView2.ContainsFullScreenElementChanged += CoreWebView2_ContainsFullScreenElementChanged;
            }
        }
示例#14
0
        private void parseVillage()
        {
            StreamReader    reader    = null;
            List <MoveFile> moveFiles = new List <MoveFile>();

            try
            {
                int           newVillageCount = 0, newBuildCount = 0, oldVillageCount = 0, oldBuildCount = 0, fileCount = 0;
                StringBuilder sb = new StringBuilder();

                int ic = 0, size = dragFiles.Length;
                foreach (var dragFile in dragFiles)
                {
                    ic++;
                    this.Invoke(new FormControlInvoker(() =>
                    {
                        statusLabel.Text = $"{dragFile},{ic}/{size}";
                    }));
                    reader = File.OpenText(dragFile);
                    string content = reader.ReadToEnd();
                    Regex  reg     = new Regex("(?<=guid=)[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}");
                    var    villageGuidCollection = reg.Matches(content);
                    reg = new Regex("(?<=guid=\")[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}");
                    var guidCollection = reg.Matches(content);
                    reg = new Regex("(?<=dzyslx=[^>]{1,10}>)[^<]{0,10}");
                    var numberCollection = reg.Matches(content);
                    reg = new Regex("(?<=mid=\")[0-9]{21}");
                    var midCollection = reg.Matches(content);
                    reg = new Regex("(?<=<span>)[\u4E00-\u9FA5]+(?=</span>)");
                    var villageNameCollection = reg.Matches(content);

                    string fileNameEx = Path.GetFileName(dragFile), fileName = Path.GetFileNameWithoutExtension(dragFile);
                    if (!(numberCollection.Count == midCollection.Count && midCollection.Count == guidCollection.Count && villageGuidCollection.Count == 1 && villageNameCollection.Count == 1))
                    {
                        MessageBox.Show($"file : {fileName};village guid count : {villageGuidCollection.Count} ;village name count : {villageNameCollection.Count} ;guid count : {guidCollection.Count}; number count : {numberCollection.Count} ;mid count : {midCollection.Count} . ");
                        throw new Exception("【" + fileName + "】的房屋数据不平衡。");
                    }

                    if (numberCollection.Count == 0)
                    {
                        MessageBox.Show($"file : {dragFile}");
                        throw new Exception("【" + fileName + "】不存在数据。");
                    }

                    /**
                     * 解析村庄
                     * */
                    string villageName = villageNameCollection[0].Value.Trim();
                    string villageGuid = villageGuidCollection[0].Value.Trim();

                    Village village = CensusContext.GetVillage(villageName);
                    if (village == null)
                    {
                        village = new Village(villageGuid, villageName);
                        CensusContext.AddVillage(village);
                        newVillageCount++;
                    }
                    else
                    {
                        oldVillageCount++;
                    }

                    FileInfo fi = new FileInfo(dragFile);
                    MoveFile mf = new MoveFile();
                    mf.oldPath = dragFile;
                    mf.newPath = fi.Directory.FullName + "\\" + villageName.Replace("鲁权屯镇", "") + ".html";
                    moveFiles.Add(mf);

                    /**
                     * 解析房屋
                     * */
                    for (int i = 0; i < numberCollection.Count; i++)
                    {
                        string guid   = guidCollection[i].Value.Trim();
                        string mid    = midCollection[i].Value.Trim();
                        string number = numberCollection[i].Value.Trim();
                        if (!CensusContext.IsExistBuild(guid))
                        {
                            newBuildCount++;
                            //allBuildList.Add(new Build(guid, mid, Regex.Match(number, "[0-9]{1,4}号").Value, village.guid));
                            CensusContext.AddBuild(new Build(guid, mid, number, village.guid));
                        }
                        else
                        {
                            oldBuildCount++;
                        }
                    }

                    //saveBuild(allBuildList);
                    //sb.Append(village.name + "导入新数据 " + newCount + " 条,重复数据 " + redo + " 条\n\r");
                    fileCount++;
                }
                currentVillageList = CensusContext.GetVillages();
                this.Invoke(new FormControlInvoker(() =>
                {
                    listBoxVillage.Items.Clear();
                }));
                foreach (var v in currentVillageList)
                {
                    this.Invoke(new FormControlInvoker(() =>
                    {
                        this.listBoxVillage.Items.Add(new Village(v.guid, v.name.Replace("鲁权屯镇", "")));
                    }));
                }

                MessageBox.Show(sb.Append($"共导入{fileCount}个文件。\r\n{newVillageCount}个村庄新数据,{oldVillageCount}个已存在村庄数据。\r\n{newBuildCount}个房屋新数据,{oldBuildCount}个已存在房屋数据。").ToString());
            }
            catch (Exception e)
            {
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }

                foreach (var f in moveFiles)
                {
                    FileInfo fi = new FileInfo(f.oldPath);
                    if (!f.oldPath.Equals(f.newPath))
                    {
                        fi.MoveTo(f.newPath);
                    }
                }
                this.Invoke(new FormControlInvoker(() =>
                {
                    statusLabel.Text = "";
                }));
            }
            //
        }
        protected override void Seed(CensusContext context)
        {
            var approver = new UserEntity {
                FirstMidName = "Admin", LastName = "DashBoard", Email = "*****@*****.**", Password = "******", IsApprover = true, ProfileImage = "https://firebasestorage.googleapis.com/v0/b/demoproject-1287a.appspot.com/o/admin.png?alt=media&token=6290a56e-84bb-4909-93f1-131bf9ef9f66", AdhaarNumber = "232323232323", CurrentStatus = 0, ApprovedBy = 0
            };

            context.Users.AddOrUpdate(approver);
            context.SaveChanges();

            var house = new HouseEntity
            {
                ID = 1,
                BuildingAptNumber = "13AB",
                Line1             = "House No : 55",
                StreetName        = "King's Street",
                City              = "Delhi",
                State             = "Delhi",
                HeadOfFamily      = "Mr. AAA",
                OwnershipStatus   = Ownership.Owner,
                NumberOfFloor     = 3,
                NumberOfRooms     = 12,
                CreatedBy         = 1,
                CensusHouseNumber = 132011783695550347
            };

            context.Houses.AddOrUpdate(house);
            house = new HouseEntity
            {
                ID = 1,
                BuildingAptNumber = "15AB",
                Line1             = "Flat No : 55",
                StreetName        = "King's Street",
                City              = "Goa",
                State             = "Goa",
                HeadOfFamily      = "Mr. BBB",
                OwnershipStatus   = Ownership.Owner,
                NumberOfFloor     = 3,
                NumberOfRooms     = 12,
                CreatedBy         = 1,
                CensusHouseNumber = 0000000000000004
            };
            context.Houses.AddOrUpdate(house);
            house = new HouseEntity
            {
                ID = 1,
                BuildingAptNumber = "122AB",
                Line1             = "House No : 523",
                StreetName        = "King's Street",
                City              = "Ahemdabad",
                State             = "Gujrat",
                HeadOfFamily      = "Mr. XXX",
                OwnershipStatus   = Ownership.Owner,
                NumberOfFloor     = 3,
                NumberOfRooms     = 12,
                CreatedBy         = 1,
                CensusHouseNumber = 0000000000000002
            };
            context.Houses.AddOrUpdate(house);
            house = new HouseEntity
            {
                ID = 1,
                BuildingAptNumber = "122AB",
                Line1             = "House No : 120",
                StreetName        = "King's Street",
                City              = "Kanpur",
                State             = "Uttar Pradesh",
                HeadOfFamily      = "Mr. XYZ",
                OwnershipStatus   = Ownership.Owner,
                NumberOfFloor     = 3,
                NumberOfRooms     = 12,
                CreatedBy         = 1,
                CensusHouseNumber = 0000000000000003
            };
            context.Houses.AddOrUpdate(house);
            context.SaveChanges();


            //var person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 0000000000000003,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Male,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "Student",
            //    NatureOfWork = "studying",
            //    CreatedBy = 0
            //};
            //context.Persons.AddOrUpdate(person);
            //person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 0000000000000001,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Male,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "IT",
            //    NatureOfWork = "studying",
            //    CreatedBy = 0
            //};
            //context.Persons.AddOrUpdate(person);
            //person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 132011783695550347,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Female,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "Teacher",
            //    NatureOfWork = "Government Job",
            //    CreatedBy = 0
            //};

            //context.Persons.AddOrUpdate(person);
            //person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 132011783695550347,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Female,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "IT",
            //    NatureOfWork = "private job",
            //    CreatedBy = 0
            //};
            //context.Persons.AddOrUpdate(person);
            //person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 0000000000000002,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Male,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "IT",
            //    NatureOfWork = "private job",
            //    CreatedBy = 0
            //};
            //context.Persons.AddOrUpdate(person);
        }