Ejemplo n.º 1
0
        private void btnGetClipBoard_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                string[] cliparr = ActiveAudit.GetClipBoard("//my.dom.gosuslugi.ru/organization-cabinet/#!/passport/");

                if (cliparr == null)
                {
                    return;
                }

                elHouseAdapter.Insert(ActiveAudit.ID, ActiveAudit.ID_Company,
                                      (from s in cliparr where s.Contains("1. Дата формирования электронного паспорта") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.1. Адрес многоквартирного дома") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.2. Кадастровый номер") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.3. Ранее присвоенный государственный") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.4. Год ввода в эксплуатацию") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.5. Год постройки") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.6. Стадия жизненного цикла") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.7. Год проведения реконструкции") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.8. Серия, тип проекта здания") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.9.1. Количество этажей") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.9.2. Количество подземных этажей") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.10. Количество подъездов") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.11. Наличие приспособлений") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.12. Количество лифтов") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.13. Количество жилых помещений") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.14. Количество нежилых помещений") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.15. Площадь здания (многоквартирного дома)") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.15.1. Общая площадь жилых") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.15.2. Общая площадь нежилых помещений") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.15.3. Общая площадь помещений общего") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.16. Количество балконов") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.17. Количество лоджий") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.18. Наличие статуса объекта культурного") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.19.1. Основание признания многоквартирного дома") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.19.2. Дата документа, содержащего решение") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.19.3. Номер документа, содержащего решение") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.20. Класс энергетической эффективности") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.21. Дата проведения энергетического") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.22. Дата приватизации первого жилого") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.23. Общий износ здания") select HouseAtrValue(s)).First(),
                                      (from s in cliparr where s.Contains("2.24. Дата, на которую установлен износ") select HouseAtrValue(s)).First()
                                      );

                DataSet1.ElHouseDataTable elh = elHouseAdapter.GetDataByActiveAudit(ActiveAudit.ID, ActiveAudit.ID_Company);
                int lastID = ((DataSet1.ElHouseRow)elh.Rows[elh.Rows.Count - 1]).ID_ElHouse;
                grdElHouse.DataSource = elh;


                //ds.Tables[2].LoadDataRow(new object[44],true);//    .Select("").Count()

                //параметры дома
                //string[] houseparams = cliparr.Where( s=> rgx1.IsMatch(s,0) || rgx1.IsMatch(s,1)).ToArray<string>() ;

                string[] houseparams = cliparr.Skip(35).Where(s => !(s.IndexOf("17.") == 0 || s.IndexOf("17.") == 1 || s.IndexOf("17.") == 2 || s.IndexOf("17.") == 3) &&
                                                              !(s.IndexOf("18.") == 0 || s.IndexOf("18.") == 1 || s.IndexOf("18.") == 2 || s.IndexOf("18.") == 3)).ToArray();

                foreach (string par in houseparams)
                {
                    elHouseParamAdapter.Insert(
                        lastID,
                        ActiveAudit.ID, ActiveAudit.ID_Company,
                        ParVal(par)[0],
                        ParVal(par)[1]
                        );
                }


                /// показать пераметры паспорта
                grdElHouse.ClearSelection();//If you want
                int nRows = grdElHouse.Rows.Count - 1;
                grdElHouse.Rows[nRows].Selected = true;
                //In case if you want to scroll down as well.
                grdElHouse.FirstDisplayedScrollingRowIndex = nRows;

                int currID = (int)grdElHouse.CurrentRow.Cells[0].Value;
                grdParams.DataSource = elHouseParamAdapter.GetDataByCurrentHouse(ActiveAudit.ID, ActiveAudit.ID_Company, currID);
                /////////



                /*
                 * //Flats
                 * //string[] flats1 = cliparr.Where(a => System.Text.RegularExpressions.Regex.IsMatch(a, @"^(\t17)")).ToArray();
                 *
                 * string[] flats = cliparr.Where(c => c.Trim('\t').IndexOf("17.") == 3 ||
                 * c.Trim('\t').IndexOf("17.") == 2).ToArray();
                 *
                 * //System.Text.RegularExpressions.MatchCollection collection= System.Text.RegularExpressions.Regex.Matches(cliparr, @"17", System.Text.RegularExpressions.RegexOptions.Compiled)
                 *
                 * int skipf = 0;
                 * string[] x;
                 * while ((x = flats.Skip(skipf).Take(11).ToArray()).Count() != 0)
                 * {
                 *  skipf += 11;
                 *
                 *  elHouseFlatsAdapter.Insert(
                 *      lastID,
                 *       ActiveAudit.ID,
                 *       ActiveAudit.ID_Company,
                 *       x[0].Split('\t')[x[0].Split('\t').Count() - 1],
                 *       x[1].Split('\t')[x[1].Split('\t').Count() - 1],
                 *       x[2].Split('\t')[x[2].Split('\t').Count() - 1],
                 *       x[3].Split('\t')[x[3].Split('\t').Count() - 1],
                 *       x[4].Split('\t')[x[4].Split('\t').Count() - 1],
                 *       x[5].Split('\t')[x[5].Split('\t').Count() - 1],
                 *       x[6].Split('\t')[x[6].Split('\t').Count() - 1],
                 *       x[7].Split('\t')[x[7].Split('\t').Count() - 1],
                 *       x[8].Split('\t')[x[8].Split('\t').Count() - 1],
                 *       x[9].Split('\t')[x[9].Split('\t').Count() - 1],
                 *       x[10].Split('\t')[x[10].Split('\t').Count() - 1]);
                 * }
                 *
                 * //string[] noflats = cliparr.Where(s => s.Contains("\t18.")).ToArray();
                 *
                 * string[] noflats = cliparr.Where(c => c.Trim('\t').IndexOf("18.") == 3 ||
                 * c.Trim('\t').IndexOf("18.") == 2).ToArray();
                 *
                 *
                 * int skipn = 0;
                 * string[] z;
                 * while ((z = noflats.Skip(skipn).Take(5).ToArray()).Count() != 0)
                 * {
                 *  skipn += 5;
                 *  elHouseNoflatsAdapter.Insert(lastID,
                 *       ActiveAudit.ID,
                 *       ActiveAudit.ID_Company,
                 *       NoflatVal(z[0]),
                 *       NoflatVal(z[1]),
                 *       NoflatVal(z[2]),
                 *       NoflatVal(z[3]),
                 *       NoflatVal(z[4])
                 *       );
                 * }
                 * Cursor.Current = Cursors.Default;
                 */
                // }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Clipboard.Clear();
                Cursor.Current = Cursors.Default;
                ActiveAudit.CheckGrid(grdElHouse);
            }
        }