예제 #1
0
        private void btnTXT_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog {
                RestoreDirectory = true, Filter = @"文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
            };

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var fileName = ofd.SafeFileName;

            if (fileName != null)
            {
                var strs            = fileName.Split('-');
                var miningAreaName  = strs[0];
                var workingFaceName = strs[1];
                var tunnelName      = strs[2].Split('.')[0];
                using (new SessionScope())
                {
                    var miningArea = MiningArea.FindOneByMiningAreaName(miningAreaName);
                    if (miningArea == null)
                    {
                        Alert.confirm("该采区不存在,请先添加采区");
                        return;
                    }
                    var workingFace = WorkingFace.FindByWorkingFaceNameAndMiningAreaId(workingFaceName, miningArea.MiningAreaId);
                    if (workingFace == null)
                    {
                        if (Alert.confirm("该工作面不存在,是否创建该工作面?"))
                        {
                            workingFace = AddWorkingFace(miningArea, workingFaceName);
                        }
                    }
                    if (workingFace == null)
                    {
                        return;
                    }
                    if (workingFace.Tunnels != null &&
                        workingFace.Tunnels.FirstOrDefault(u => u.TunnelName == tunnelName) != null)
                    {
                        var tunnel = workingFace.Tunnels.FirstOrDefault(u => u.TunnelName == tunnelName);
                        selectTunnelUserControl1.LoadData(tunnel);
                    }
                    else
                    {
                        if (Alert.confirm("该巷道不存在,是否创建该巷道?"))
                        {
                            if (Tunnel.ExistsByTunnelNameAndWorkingFaceId(tunnelName, workingFace.WorkingFaceId))
                            {
                                Alert.alert("该巷道已经存在");
                                return;
                            }
                            var tunnel = AddTunnel(workingFace, tunnelName);
                            selectTunnelUserControl1.LoadData(tunnel);
                        }
                    }
                }
                txtWireName.Text = tunnelName.Split('.').Length > 0
                    ? tunnelName.Split('.')[0] + "导线点"
                    : tunnelName + "导线点";
            }

            var    sr = new StreamReader(ofd.FileName, Encoding.GetEncoding("GB2312"));
            string duqu;

            while ((duqu = sr.ReadLine()) != null)
            {
                var temp1 = duqu.Split('|');
                if (temp1.Length == 1)
                {
                    continue;
                }
                var daoxianname = temp1[0];
                var daoxianx    = temp1[1];
                var daoxiany    = temp1[2];
                dgrdvWire.Rows.Add(1);
                dgrdvWire[0, dgrdvWire.Rows.Count - 2].Value = daoxianname;
                dgrdvWire[1, dgrdvWire.Rows.Count - 2].Value = daoxianx;
                dgrdvWire[2, dgrdvWire.Rows.Count - 2].Value = daoxiany;
                dgrdvWire[3, dgrdvWire.Rows.Count - 2].Value = "0";
                dgrdvWire[4, dgrdvWire.Rows.Count - 2].Value = "2.5";
                dgrdvWire[5, dgrdvWire.Rows.Count - 2].Value = "2.5";
            }
        }
예제 #2
0
        ///// <param name="verticesBtmRet">Vector3_DW数据</param>
        /// <summary>
        ///     根据导线点坐标绘制巷道
        /// </summary>
        /// <summary>
        ///     获得导线边线点坐标集
        /// </summary>
        /// <returns>导线边线点坐标集List</returns>
        //private List<IPoint> GetTunnelPts(Vector3_DW[] verticesBtmRet)
        //{
        //    var lstBtmRet = new List<IPoint>();
        //    try
        //    {
        //        Vector3_DW vector3dw;
        //        IPoint pt;
        //        for (int i = 0; i < verticesBtmRet.Length; i++)
        //        {
        //            vector3dw = new Vector3_DW();
        //            vector3dw = verticesBtmRet[i];
        //            pt = new PointClass();
        //            pt.X = vector3dw.X;
        //            pt.Y = vector3dw.Y;
        //            pt.Z = vector3dw.Z;
        //            if (!lstBtmRet.Contains(pt))
        //            {
        //                lstBtmRet.Add(pt);
        //            }
        //        }

        //        return lstBtmRet;
        //    }
        //    catch
        //    {
        //        return null;
        //    }
        //}

        #endregion 绘制导线点和巷道图形
        private void btnMultTxt_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog
            {
                RestoreDirectory = true,
                Multiselect      = true,
                Filter           = @"文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
            };

            _errorMsg = @"失败文件名:";
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var fileCount = ofd.FileNames.Length;

            pbCount.Maximum = fileCount * 2;
            pbCount.Value   = 0;
            foreach (var fileName in ofd.FileNames)
            {
                lblTotal.Text = fileCount.ToString(CultureInfo.InvariantCulture);
                string safeFileName = null;
                try
                {
                    using (new SessionScope())
                    {
                        safeFileName = fileName.Substring(fileName.LastIndexOf(@"\", StringComparison.Ordinal) + 1);
                        var strs            = safeFileName.Split('-');
                        var miningAreaName  = strs[0];
                        var workingFaceName = strs[1];
                        var tunnelName      = strs[2].Split('.')[0];

                        var miningArea = MiningArea.FindOneByMiningAreaName(miningAreaName);
                        if (miningArea == null)
                        {
                            Alert.confirm("该采区不存在,请先添加采区");
                            return;
                        }
                        var workingFace = WorkingFace.FindByWorkingFaceNameAndMiningAreaId(workingFaceName, miningArea.MiningAreaId);
                        if (workingFace == null)
                        {
                            workingFace = AddWorkingFace(miningArea, workingFaceName);
                        }
                        if (workingFace == null)
                        {
                            return;
                        }
                        Tunnel tunnel;
                        if (workingFace.Tunnels != null &&
                            workingFace.Tunnels.FirstOrDefault(u => u.TunnelName == tunnelName) != null)
                        {
                            tunnel = workingFace.Tunnels.FirstOrDefault(u => u.TunnelName == tunnelName);
                        }
                        else
                        {
                            tunnel = AddTunnel(workingFace, tunnelName);
                        }

                        var    sr = new StreamReader(fileName, Encoding.GetEncoding("GB2312"));
                        string fileContent;
                        var    wirePoints = new List <WirePoint>();
                        while ((fileContent = sr.ReadLine()) != null)
                        {
                            if (String.IsNullOrEmpty(fileContent))
                            {
                                continue;
                            }
                            var temp1     = fileContent.Split('|');
                            var pointName = temp1[0];
                            var pointX    = temp1[1];
                            var pointY    = temp1[2];

                            wirePoints.Add(new WirePoint
                            {
                                BindingId     = IDGenerator.NewBindingID(),
                                WirePointName = pointName,
                                CoordinateX   = Convert.ToDouble(pointX),
                                CoordinateY   = Convert.ToDouble(pointY),
                                CoordinateZ   = 0,
                                LeftDis       = 2.5,
                                RightDis      = 2.5,
                                TopDis        = 0,
                                BottomDis     = 0
                            });
                        }
                        if (wirePoints.Count < 2)
                        {
                            Alert.alert(Const_GM.WIRE_INFO_MSG_POINT_MUST_MORE_THAN_TWO);
                            throw new Exception();
                        }
                        var wire = Wire.FindOneByTunnelId(tunnel.TunnelId);

                        if (wire != null)
                        {
                            wire.WireName = tunnelName.Split('.').Length > 0
                                ? tunnelName.Split('.')[0] + "导线点"
                                : tunnelName + "导线点";
                            wire.WirePoints = wirePoints;
                        }
                        else
                        {
                            wire = new Wire
                            {
                                Tunnel      = tunnel,
                                CheckDate   = DateTime.Now,
                                MeasureDate = DateTime.Now,
                                CountDate   = DateTime.Now,
                                WireName    =
                                    tunnelName.Split('.').Length > 0
                                        ? tunnelName.Split('.')[0] + "导线点"
                                        : tunnelName + "导线点",
                                WirePoints = wirePoints
                            };
                        }
                        wire.Save();
                        pbCount.Value++;
                        DrawWirePoint(wirePoints, "CHANGE");
                        double hdwid;
                        _dics = ConstructDics(tunnel, out hdwid);
                        UpdateHdbyPnts(tunnel.TunnelId, wirePoints, _dics, hdwid);
                        pbCount.Value++;
                        lblSuccessed.Text =
                            (Convert.ToInt32(lblSuccessed.Text) + 1).ToString(CultureInfo.InvariantCulture);
                    }
                }
                catch
                {
                    pbCount.Value++;
                    lblError.Text =
                        (Convert.ToInt32(lblError.Text) + 1).ToString(CultureInfo.InvariantCulture);
                    _errorMsg         += safeFileName + "\n";
                    btnDetails.Enabled = true;
                }
            }
            UpdateWarningDataMsg msg;

            if (selectTunnelUserControl1.SelectedTunnel != null)
            {
                msg = new UpdateWarningDataMsg(Const.INVALID_ID, selectTunnelUserControl1.SelectedTunnel.TunnelId,
                                               Wire.TableName, OPERATION_TYPE.ADD, DateTime.Now);
            }
            else
            {
                msg = new UpdateWarningDataMsg(Const.INVALID_ID, 0,
                                               Wire.TableName, OPERATION_TYPE.ADD, DateTime.Now);
            }
            SocketUtil.SendMsg2Server(msg);
            Alert.alert("导入完成");
        }