Exemplo n.º 1
0
        /// <summary>
        ///     根据钻孔点名查找钻孔点信息
        /// </summary>
        /// <params name="strDisplayName"></params>
        /// <returns></returns>
        private IPoint GetProspectingBoreholePointSelected(String strDisplayName)
        {
            try
            {
                var brehole = Borehole.FindAllByProperty("name", strDisplayName).FirstOrDefault();

                IPoint pt = new PointClass();
                if (brehole != null)
                {
                    pt.X = brehole.coordinate_x;
                    pt.Y = brehole.coordinate_x;
                    pt.Z = brehole.coordinate_z;
                }

                return(pt);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     提  交
        /// </summary>
        /// <params name="sender"></params>
        /// <params name="e"></params>
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            var borehole = Borehole.FindAllByProperty("name", txtBoreholeNumber.Text).FirstOrDefault() ??
                           new Borehole {
                bid = IdGenerator.NewBindingId()
            };

            borehole.name              = txtBoreholeNumber.Text.Trim();
            borehole.ground_elevation  = Convert.ToDouble(txtGroundElevation.Text.Trim());
            borehole.coordinate_x      = Convert.ToDouble(txtCoordinateX.Text.Trim());
            borehole.coordinate_y      = Convert.ToDouble(txtCoordinateY.Text.Trim());
            borehole.coordinate_z      = Convert.ToDouble(txtCoordinateZ.Text.Trim());
            borehole.coal_seam_texture = string.Empty;
            borehole.Save();
            var subBorehole = new SubBorehole();

            for (var i = 0; i < gvCoalSeamsTexture.RowCount; i++)
            {
                // 最后一行为空行时,跳出循环
                if (i == gvCoalSeamsTexture.RowCount - 1)
                {
                    break;
                }

                // 创建钻孔岩性实体
                subBorehole = new SubBorehole
                {
                    floor_elevation = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[1].Value),
                    thickness       = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[2].Value),
                    coal_seam       = gvCoalSeamsTexture.Rows[i].Cells[3].Value.ToString(),
                    coordinate_x    = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[4].Value),
                    coordinate_y    = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[5].Value),
                    coordinate_z    = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[6].Value),
                    lithology       = gvCoalSeamsTexture.Rows[i].Cells[0].Value.ToString(),
                    borehole        = borehole
                };
                subBorehole.Save();
            }

            var          drawspecial     = new DrawSpecialCommon();
            const string sLayerAliasName = LayerNames.DEFALUT_BOREHOLE; //“钻孔”图层
            var          featureLayer    = drawspecial.GetFeatureLayerByName(sLayerAliasName);

            if (featureLayer == null)
            {
                MessageBox.Show(@"未找到" + sLayerAliasName + @"图层,无法删钻孔图元。");
                return;
            }

            if (borehole.id != 0)
            {
                DataEditCommon.DeleteFeatureByBId(featureLayer, borehole.bid);
            }

            var dlgResult = MessageBox.Show(@"是:见煤钻孔,否:未见煤钻孔,取消:不绘制钻孔",
                                            @"绘制钻孔", MessageBoxButtons.YesNoCancel);

            borehole = Borehole.FindAllByProperty("name", borehole.name).First();
            switch (dlgResult)
            {
            case DialogResult.Yes:
                DrawZuanKong(borehole, subBorehole);
                break;

            case DialogResult.No:
                DrawZuanKong(borehole);
                break;

            case DialogResult.Cancel:
                break;
            }
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 3
0
        private void btnReadMultTxt_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog
            {
                RestoreDirectory = true,
                Filter           = @"文本文件(*.txt)|*.txt|所有文件(*.*)|*.*",
                Multiselect      = true
            };

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            _errorMsg       = @"失败文件名:";
            pbCount.Maximum = ofd.FileNames.Length;
            pbCount.Value   = 0;
            lblTotal.Text   = ofd.FileNames.Length.ToString(CultureInfo.InvariantCulture);
            foreach (var fileName in ofd.FileNames)
            {
                var encoder = TxtFileEncoding.GetEncoding(fileName, Encoding.GetEncoding("GB2312"));

                var    sr = new StreamReader(fileName, encoder);
                string duqu;
                while ((duqu = sr.ReadLine()) != null)
                {
                    try
                    {
                        var str      = duqu.Split('|');
                        var borehole = Borehole.FindAllByProperty("name", str[0]).FirstOrDefault() ??
                                       new Borehole {
                            bid = IdGenerator.NewBindingId()
                        };

                        borehole.name              = str[0];
                        borehole.ground_elevation  = Convert.ToDouble(str[3]);
                        borehole.coordinate_x      = Convert.ToDouble(str[1].Split(',')[0]);
                        borehole.coordinate_y      = Convert.ToDouble(str[1].Split(',')[1]);
                        borehole.coordinate_z      = 0;
                        borehole.coal_seam_texture = String.Empty;
                        // 创建钻孔岩性实体
                        var boreholeLithology = new SubBorehole
                        {
                            borehole        = borehole,
                            lithology       = "煤层",
                            floor_elevation = Convert.ToDouble(str[4]),
                            coal_seam       = ConfigHelper.current_seam.name,
                            thickness       = Convert.ToDouble(str[2]),
                            coordinate_x    = Convert.ToDouble(str[1].Split(',')[0]),
                            coordinate_y    = Convert.ToDouble(str[1].Split(',')[1]),
                            coordinate_z    = 0
                        };

                        borehole.sub_boreholes = new[] { boreholeLithology };
                        DrawZuanKong(borehole, boreholeLithology);
                        borehole.Save();
                    }
                    catch (Exception)
                    {
                        lblError.Text =
                            (Convert.ToInt32(lblError.Text) + 1).ToString(CultureInfo.InvariantCulture);
                        lblSuccessed.Text =
                            (Convert.ToInt32(lblSuccessed.Text) - 1).ToString(CultureInfo.InvariantCulture);
                        _errorMsg         += fileName.Substring(fileName.LastIndexOf(@"\", StringComparison.Ordinal) + 1) + "\n";
                        btnDetails.Enabled = true;
                    }
                }
                lblSuccessed.Text =
                    (Convert.ToInt32(lblSuccessed.Text) + 1).ToString(CultureInfo.InvariantCulture);
                pbCount.Value++;
            }
            Alert.AlertMsg("导入成功!");
        }