Beispiel #1
0
        //public  static ArrayList getTime()//得到曲线的时间集合
        //  {
        //      ArrayList ATime = new ArrayList();
        //      MySqlConnection mycon = new MySqlConnection();
        //      mycon = getMycon();

        //      try
        //      {
        //          //string sss = MainForm.getInstance().TimeList.Text;
        //          //String[] strs = sss.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
        //          for (int i = 0; i < MainForm.getInstance().GTimeList.Items.Count; i++)//将单项深度导入int数组,看是否正确
        //          {

        //              string str = "SELECT DISTINCT folderTime from allgrat_data WHERE folderTime >=  \'" + Convert.ToDateTime(MainForm.getInstance().GTimeList.Items[i]) + "\' order by folderTime";
        //              System.Data.DataTable dt = getDataTable(str, mycon);
        //              ATime.Add(dt.Rows[0]["folderTime"].ToString());
        //          }
        //      }
        //      catch //深度格式不正确
        //      {
        //          MessageBox.Show("单项时间输入格式不正确\n或输入的部分时间点不存在数据", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        //          bu = 1;
        //      }
        //      mycon.Close();
        //      return ATime;
        //  }
        //public static ArrayList getfolderTable()//得到曲线duozai表名称
        //  {
        //      ArrayList ATime = new ArrayList();
        //      MySqlConnection mycon = new MySqlConnection();
        //      mycon = getMycon();
        //          try
        //          {
        //              //string sss = MainForm.getInstance().TimeList.Text;
        //              //String[] strs = sss.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
        //              for (int i = 0; i < MainForm.getInstance().GTimeList.Items.Count; i++)//将单项深度导入int数组,看是否正确
        //              {

        //                  string str = "SELECT DISTINCT folderTable from allgrat_data WHERE folderTime >=  \'" + Convert.ToDateTime(MainForm.getInstance().GTimeList.Items[i]) + "\' order by folderTime";
        //                  System.Data.DataTable dt = getDataTable(str, mycon);
        //                  ATime.Add(dt.Rows[0]["folderTable"].ToString());
        //              }
        //          }
        //          catch //深度格式不正确
        //          {
        //              MessageBox.Show("单项时间输入格式不正确\n或输入时间不存在数据", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        //              bu = 1;
        //          }

        //      mycon.Close();
        //      return ATime;
        //  }
        public static DataTable getGTime(MySqlConnection mycon)//得到曲线的时间集合
        {
            DataTable dtTimeTable = new DataTable();

            dtTimeTable.Columns.Add("folderTime");
            dtTimeTable.Columns.Add("folderTable");
            messageError = null;
            for (int i = 0; i < MainForm.getInstance().GTimeList.Items.Count; i++)//将单项深度导入int数组,看是否正确
            {
                string str = "SELECT folderTime,folderTable  from allgrat_data WHERE folderTime >=  \'" + Convert.ToDateTime(MainForm.getInstance().GTimeList.Items[i]) + "\' order by folderTime  limit 1 ";
                System.Data.DataTable dt = getDataTable(str, mycon);
                if (dt.Rows.Count != 0)
                {
                    DataRow dr = dtTimeTable.NewRow();
                    dr["folderTime"]  = dt.Rows[0]["folderTime"];
                    dr["folderTable"] = dt.Rows[0]["folderTable"];
                    dtTimeTable.Rows.Add(dr);
                }
                else
                {
                    messageError += (MainForm.getInstance().GTimeList.Items[i]).ToString() + '\n';
                }
            }
            DataTable distinckTable = MyDataTable.getDistinckTable(dtTimeTable);

            return(distinckTable);
        }
Beispiel #2
0
 public void insertData(object ob)//分表多线程导入数据的方法
 {
     try
     {
         //连接数据库
         MySqlConnection mycon = getMycon();
         DataTable       dt    = (DataTable)ob;
         string          name  = dt.Rows[0][2].ToString();//表名称
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             DateTime Time      = Convert.ToDateTime(dt.Rows[i][1].ToString()); //时间
             string   filename1 = dt.Rows[i][0].ToString();                     //路径
             //判断是否已经导入数据库
             // string StrYN = "select count(*) from  alltemporpary_data where  folderTime='" + Time + "'";//如果等于‘1’下面的代码不执行。
             DateTime Time1 = Time.AddMinutes(+5);
             DateTime Time2 = Time.AddMinutes(-5);
             string   StrYN = "select  COUNT(*) from alltemporpary_data where folderTime > '" + Time2 + " ' and folderTime <'" + Time1 + "'";
             int      count = getSqlObj(StrYN, mycon);
             if (count != 0)
             {
                 continue;
             }
             else
             {
                 DataTable table1 = MyDataTable.getTraDatatable(filename1);
                 if (table1.Rows.Count != 0)
                 {
                     string str3, sum3 = null;
                     for (int h = 0; h < table1.Rows.Count; h++)                                                                                             //依照辛工的要求,修改成具体数值,并修改下面代码
                     {
                         str3 = "('" + Time + "','" + float.Parse(table1.Rows[h][1].ToString()) + "','" + float.Parse(table1.Rows[h][2].ToString()) + "'),"; //有几个字段就写几个,行(i)是不变的,列值累加
                         sum3 = sum3 + str3;
                     }
                     str3 = "insert into " + name + "(RecordTime,Depth,TM) values" + sum3;
                     str3 = str3.Substring(0, str3.LastIndexOf(",")); //获取SQL语句
                     doStrmycon(str3, mycon);
                     filename1 = filename1.Replace("\\", "\\\\");     //为了保存路径到数据库,不许进行的操作。
                     string strA3 = "insert into alltemporpary_data(folderUrl,folderTime,folderTable) values ('" + filename1 + "','" + Time + "','" + name + "')";
                     doStrmycon(strA3, mycon);
                 }
             }
         }
         mycon.Close();
         mycon.Dispose();
     }
     catch (Exception ex)
     {
         // writelog.WriteLog("" + ex);//说明可能出现的错误
         MessageBox.Show("" + ex);
     }
 }
Beispiel #3
0
        /*向表中添加路径信息*/
        private static void getDrawTable(string filename)
        {
            DataTable ob = MyDataTable.getTraDatatable(filename);                                                                                    //存数据到内存表

            if (ob.Rows.Count == 0)                                                                                                                  //如果是空的table则不存入列表
            {
                string   timestr = filename.Substring(filename.LastIndexOf("\\") + 1, filename.LastIndexOf(".") - (filename.LastIndexOf("\\") + 1)); //去除后缀
                string   str     = timestr.Remove(0, timestr.Length - 14);                                                                           //取去除后缀的文件名称的后14位数据。
                DateTime dt      = DateTime.ParseExact(str, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
                //如果文件数据未能存入内存表(如文件数据错误等原因),不进行数据存储到list中
                //bool a = true;
                //MainForm.getInstance().errorDTS.Text = "警告:"+dt.ToString()+"的文档不正确(乱码)!";
                //MainForm.getInstance().errorDTS.Visible = true;
            }
            else
            {
                MainForm.getInstance().errorDTS.Text = " ";
                //MainForm.getInstance().errorDTS.Visible = false;
                list.Add(ob);
                DataRow dr = DTStable.NewRow(); //创建数据行
                dr["fa"] = filename;
                DTStable.Rows.Add(dr);          //将创建的数据行添加到table中
            }
        }
Beispiel #4
0
        public static void DrawingDep()//画时间温度曲线
        {
            //获取时间的查询条件
            string          messageError = null;
            String          SQLstr       = getSQLstr();
            MySqlConnection mycon        = new MySqlConnection();

            mycon = getMycon();
            //获取井口位置
            float wellzero = ZedGraphClass.getWellZero();
            //获取循环(单循环还是多循环)
            string button = MainForm.getInstance().number.Text;

            //画图图禁止菜单和画图区域
            MainForm.getInstance().groupBox2.Enabled = false;
            MainForm.getInstance().zgcDep.Enabled = false;
            //新建数据库连接
            string DsingleDepth = MainForm.getInstance().DsingleDepth.Text;

            if (SQLstr != null)
            {
                DataTable SQLName = getTNameTable(DintervalTime1, DintervalTime2);//获取需要使用的表名称
                if (SQLName.Rows.Count != 0)
                {
                    ArrayList SQLList = MyDataTable.getDepth(wellzero, DsingleDepth); //获取深度值
                    if (SQLList.Count <= 15 && SQLList.Count > 0)                     //15条线之内
                    {
                        SQLList = ZedGraphClass.getNewDepth(SQLList);                 //去重
                        ZedGraph.GraphPane gp = MainForm.getInstance().zgcDep.GraphPane;
                        //gp.CurveList.Clear();//清除上一步画的图
                        gp.GraphObjList.Clear();
                        gp.CurveList.Clear();
                        //是否X、Y轴缩放的定义
                        if (MainForm.getInstance().label1.Text == "1")
                        {
                            MainForm.getInstance().zgcDep.IsEnableVZoom = true;    //Y轴缩放
                            MainForm.getInstance().zgcDep.IsEnableHZoom = true;    //x轴缩放
                        }
                        else
                        {
                            MainForm.getInstance().zgcDep.IsEnableVZoom = false;                                                                      //禁止Y轴缩放
                            MainForm.getInstance().zgcDep.IsEnableHZoom = true;                                                                       //x轴缩放
                        }
                        MainForm.getInstance().zgcDep.PointValueEvent += new ZedGraphControl.PointValueHandler(ZedGraphClass.MyPointValueHandlerDep); //设置节点信息显示样式
                        MainForm.getInstance().zgcDep.MouseMove += zedGraphControl1_MouseMove;                                                        //鼠标在图上移动出现x虚线
                        MainForm.getInstance().zgcDep.IsShowPointValues = true;                                                                       //显示节点坐标值
                        MainForm.getInstance().zgcDep.IsZoomOnMouseCenter = false;                                                                    //使用滚轮时以鼠标所在点进行缩放还是以图形中心进行缩放。
                        if (MainForm.getInstance().DintervalTM1.Text != "" && MainForm.getInstance().DintervalTM2.Text != "")
                        {
                            gp.YAxis.Scale.Min = float.Parse(MainForm.getInstance().DintervalTM1.Text);
                            gp.YAxis.Scale.Max = float.Parse(MainForm.getInstance().DintervalTM2.Text);
                        }
                        else
                        {
                            gp.YAxis.Scale.MaxAuto = true;    //自动设置大小
                            gp.YAxis.Scale.MinAuto = true;
                        }
                        MainForm.getInstance().zgcDep.IsAutoScrollRange = false;
                        //坐标轴刻度格式
                        gp.XAxis.Scale.Format = "yyyy-MM-dd HH:mm:ss"; //横轴格式
                        gp.XAxis.Type         = AxisType.Date;         //格式
                        string[] hn = new string[SQLList.Count];       //折线的标签
                        if (button == "two")                           //循环作图
                        {
                            for (int xunhuan = 0; xunhuan < 4; xunhuan++)
                            {
                                //清除上一步画的图
                                gp.GraphObjList.Clear();
                                gp.CurveList.Clear();

                                for (int i = 0; i < SQLList.Count; i++)
                                {
                                    System.Threading.Thread.Sleep(1000);
                                    PointPairList list1   = new PointPairList();
                                    DataTable     dtValue = new DataTable();
                                    string        SQLque  = "RecordTime";
                                    dtValue = MyDataTable.getDataTable(SQLName, Convert.ToInt32(SQLList[i]), SQLstr, SQLque, mycon);
                                    float e = Convert.ToInt32(SQLList[i].ToString()) - wellzero;
                                    hn[i] = e + "m";
                                    for (int k = 0; k < dtValue.Rows.Count; k++)
                                    {
                                        int bili = 1;
                                        if (dtValue.Rows.Count > 1000)
                                        {
                                            bili = dtValue.Rows.Count / 500;
                                        }
                                        if (k % bili == 0)
                                        {
                                            double x = (double)new XDate((DateTime)dtValue.Rows[k]["RecordTime"]);
                                            string a = dtValue.Rows[k]["RecordTime"].ToString();
                                            double y = double.Parse(dtValue.Rows[k]["TM"].ToString());
                                            list1.Add(x, y);
                                        }
                                    }
                                    if (list1.Count == 0 && xunhuan == 0)    //如果曲线没有数据
                                    {
                                        messageError += "深度" + SQLList[i] + "m无数据\n";
                                        continue;
                                    }
                                    else
                                    {
                                        Color    co         = ZedGraphClass.GetColor(i);
                                        LineItem _lineitem2 = gp.AddCurve(hn[i], list1, co, SymbolType.Circle);
                                        _lineitem2.Line.Width = 2.0F;    //线的宽度
                                        //节点设置
                                        if (drawAttribute.Linenum == 2)
                                        {
                                            _lineitem2.Line.IsVisible = false;
                                        }
                                        _lineitem2.Symbol.Size = 2.4F;         //线上节点的大小
                                        _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色
                                        gp.AxisChange();
                                        MainForm.getInstance().zgcDep.Refresh();
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < SQLList.Count; i++)
                            {
                                PointPairList list1   = new PointPairList();
                                DataTable     dtValue = new DataTable();
                                string        SQLque  = "RecordTime";
                                dtValue = MyDataTable.getDataTable(SQLName, Convert.ToInt32(SQLList[i]), SQLstr, SQLque, mycon);
                                float e = Convert.ToInt32(SQLList[i].ToString()) - wellzero;
                                hn[i] = e + "m";
                                for (int k = 0; k < dtValue.Rows.Count; k++)
                                {
                                    int bili = 1;
                                    if (dtValue.Rows.Count > 1000)
                                    {
                                        bili = dtValue.Rows.Count / 500;
                                    }
                                    if (k % bili == 0)
                                    {
                                        double x = (double)new XDate((DateTime)dtValue.Rows[k]["RecordTime"]);
                                        string a = dtValue.Rows[k]["RecordTime"].ToString();
                                        double y = double.Parse(dtValue.Rows[k]["TM"].ToString());
                                        list1.Add(x, y);
                                    }
                                }
                                if (list1.Count == 0)    //如果曲线没有数据
                                {
                                    messageError += "深度" + SQLList[i] + "m无数据\n";
                                    continue;
                                }
                                else
                                {
                                    Color    co         = ZedGraphClass.GetColor(i);
                                    LineItem _lineitem2 = gp.AddCurve(hn[i], list1, co, SymbolType.Circle);
                                    _lineitem2.Line.Width = 2.0F;    //线的宽度
                                    //节点设置
                                    if (drawAttribute.Linenum == 2)
                                    {
                                        _lineitem2.Line.IsVisible = false;
                                    }
                                    _lineitem2.Symbol.Size = 2.4F;         //线上节点的大小
                                    _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色
                                    gp.AxisChange();
                                    MainForm.getInstance().zgcDep.Refresh();
                                }
                            }
                        }
                    }
                    else if (SQLList.Count > 15)
                    {
                        //MessageBox.Show("深度区间太大,曲线条数大于15");
                        MessageBox.Show("深度区间太大,曲线条数大于15!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        // MessageBox.Show("在所选时间区间内数据库中无数据");//表中无数据
                        MessageBox.Show("请填写深度!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    //  MessageBox.Show("所选时间区间内没有数据,请更改时间区域!"); //没有表
                    MessageBox.Show("所选时间区间内没有数据,请更改时间区域!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (messageError != null)
                {
                    MessageBox.Show("以下深度点无数据!\n" + messageError, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                // MessageBox.Show("时间区间选择不正确,请修改!");
                MessageBox.Show("时间区间选择不正确,请修改!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            MainForm.getInstance().groupBox2.Enabled = true;
            MainForm.getInstance().zgcDep.Enabled = true;
            mycon.Close();
            mycon.Dispose();
            SQLstr = null;
        }
Beispiel #5
0
        public static void DrawingGratDep()//画时间温度曲线
        {
            MyThread myt = new MyThread();

            string messageError = null;
            string GratDepth    = MainForm.getInstance().textBox3.Text;
            String SQLstr       = getstr();//获取str

            MainForm.getInstance().groupBox1.Enabled = false;
            MainForm.getInstance().GDep.Enabled = false;
            MySqlConnection mycon = new MySqlConnection();

            mycon = getMycon();
            string button   = MainForm.getInstance().number.Text;
            float  wellzero = ZedGraphClass.getWellZero();

            if (SQLstr != null)
            {
                DataTable SQLName = getTNameTable(GratDepTime1, GratDepTime2);//获取需要使用的表名称
                if (SQLName.Rows.Count != 0)
                {
                    ArrayList SQLList = MyDataTable.getDepth(wellzero, GratDepth);//获取深度值
                    if (SQLList.Count != 0)
                    {
                        SQLList = ZedGraphClass.getNewDepth(SQLList);//去重
                        ZedGraph.GraphPane gp = MainForm.getInstance().GDep.GraphPane;
                        gp.GraphObjList.Clear();
                        gp.CurveList.Clear();
                        if (MainForm.getInstance().label1.Text == "1")
                        {
                            MainForm.getInstance().GDep.IsEnableVZoom = true; //Y轴缩放
                            MainForm.getInstance().GDep.IsEnableHZoom = true; //x轴缩放
                        }
                        else
                        {
                            MainForm.getInstance().GDep.IsEnableVZoom = false;                                                                      //禁止Y轴缩放
                            MainForm.getInstance().GDep.IsEnableHZoom = true;                                                                       //x轴缩放
                        }
                        MainForm.getInstance().GDep.PointValueEvent += new ZedGraphControl.PointValueHandler(ZedGraphClass.MyPointValueHandlerDep); //设置节点信息显示样式
                        //MainForm.getInstance().GDep.IsShowHScrollBar = true;  //是否显示横向滚动条。
                        //MainForm.getInstance().GDep.ZoomStepFraction = 0;//不允许鼠标放大缩小
                        MainForm.getInstance().GDep.MouseMove += zedGraphControl1_MouseMove; //鼠标在图上移动出现x虚线
                        MainForm.getInstance().GDep.IsShowPointValues = true;                //显示节点坐标值
                        MainForm.getInstance().GDep.IsZoomOnMouseCenter = false;             //使用滚轮时以鼠标所在点进行缩放还是以图形中心进行缩放。
                        if (MainForm.getInstance().GratDepTM1.Text != "" && MainForm.getInstance().GratDepTM2.Text != "")
                        {
                            gp.YAxis.Scale.Min = float.Parse(MainForm.getInstance().GratDepTM1.Text);
                            gp.YAxis.Scale.Max = float.Parse(MainForm.getInstance().GratDepTM2.Text);
                        }
                        else
                        {
                            gp.YAxis.Scale.MaxAuto = true;//自动设置大小
                            gp.YAxis.Scale.MinAuto = true;
                        }
                        MainForm.getInstance().GDep.IsAutoScrollRange = false;
                        gp.XAxis.Scale.Format = "yyyy-MM-dd HH:mm:ss"; //横轴格式
                        gp.XAxis.Type         = AxisType.Date;         //格式
                        string[] hn = new string[SQLList.Count];       //折现的标签
                        if (button == "two")
                        {
                            for (int k = 0; k < 4; k++)
                            {
                                gp.GraphObjList.Clear();
                                gp.CurveList.Clear();//清除上一步画的图

                                for (int i = 0; i < SQLList.Count; i++)
                                {
                                    System.Threading.Thread.Sleep(1000);
                                    DataTable dtValue = new DataTable();
                                    string    SQLque  = "RecordTime";
                                    dtValue = MyDataTable.getDataTable(SQLName, Convert.ToInt32(SQLList[i]), SQLstr, SQLque, mycon);
                                    float e = Convert.ToInt32(SQLList[i].ToString()) - wellzero;
                                    hn[i] = e + "m";
                                    //hn[i] = SQLList[i] + "m";
                                    PointPairList list1 = new PointPairList();
                                    for (int j = 0; j < dtValue.Rows.Count; j++)
                                    {
                                        int bili = 1;
                                        if (dtValue.Rows.Count > 1000)
                                        {
                                            bili = dtValue.Rows.Count / 500;
                                        }
                                        if (j % bili == 0)
                                        {
                                            // string a = dt.Rows[j]["RecordTime"].ToString();
                                            double x = (double)new XDate((DateTime)dtValue.Rows[j]["RecordTime"]);
                                            //double x = (double)new XDate((DateTime)dt.Rows[j]["RecordTime"]);
                                            float y = float.Parse(dtValue.Rows[j]["TM"].ToString());
                                            list1.Add(x, y);
                                        }
                                        //TextObj text = new TextObj("shiji", x, y);
                                        //gp.GraphObjList.Add(text);
                                    }

                                    if (list1.Count == 0 && k == 0)//如果曲线没有数据或缺少数据
                                    {
                                        //MessageBox.Show("曲线不存在");
                                        messageError += "深度" + SQLList[i] + "m无数据\n";
                                        continue;
                                    }
                                    else
                                    {
                                        Color    co         = ZedGraphClass.GetColor(i);
                                        LineItem _lineitem2 = gp.AddCurve(hn[i], list1, ZedGraphClass.GetColor(i), SymbolType.Circle);
                                        //_lineitem2.Label.IsVisible = false;//名称不见的一种形式
                                        _lineitem2.Line.Width = 2.0F;//线的宽度
                                        //节点设置
                                        if (drawAttribute.Linenum == 2)
                                        {
                                            _lineitem2.Line.IsVisible = false;
                                        }
                                        _lineitem2.Symbol.Size = 2.4F;         //线上节点的大小
                                        _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色
                                        gp.AxisChange();
                                        MainForm.getInstance().GDep.Refresh();
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < SQLList.Count; i++)//先做深度循环
                            {
                                DataTable dtValue = new DataTable();
                                string    SQLque  = "RecordTime";
                                dtValue = MyDataTable.getDataTable(SQLName, Convert.ToInt32(SQLList[i]), SQLstr, SQLque, mycon);
                                float e = Convert.ToInt32(SQLList[i].ToString()) - wellzero;
                                hn[i] = e + "m";
                                PointPairList list1 = new PointPairList();
                                for (int j = 0; j < dtValue.Rows.Count; j++)
                                {
                                    int bili = 1;
                                    if (dtValue.Rows.Count > 1000)
                                    {
                                        bili = dtValue.Rows.Count / 500;
                                    }
                                    if (j % bili == 0)
                                    {
                                        double x = (double)new XDate((DateTime)dtValue.Rows[j]["RecordTime"]);
                                        //  string a = dt.Rows[j]["RecordTime"].ToString();
                                        double y = double.Parse(dtValue.Rows[j]["TM"].ToString());

                                        list1.Add(x, y);
                                    }
                                }
                                if (list1.Count == 0)//如果曲线没有数据
                                {
                                    messageError += "深度" + SQLList[i] + "m无数据\n";
                                    continue;
                                }
                                else
                                {
                                    Color    co         = ZedGraphClass.GetColor(i);
                                    LineItem _lineitem2 = gp.AddCurve(hn[i], list1, co, SymbolType.Circle);
                                    _lineitem2.Line.Width = 2.0F;//线的宽度
                                    string la = _lineitem2.Label.Text.ToString();
                                    //节点设置
                                    if (drawAttribute.Linenum == 2)
                                    {
                                        _lineitem2.Line.IsVisible = false;
                                    }
                                    _lineitem2.Symbol.Size = 2.4F;         //线上节点的大小
                                    _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色
                                    gp.AxisChange();
                                    MainForm.getInstance().GDep.Refresh();
                                }
                            }
                        }
                    }
                    else
                    {
                        //MessageBox.Show("深度输入不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MessageBox.Show("请填写深度!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    //MessageBox.Show("所选时间区间内没有数据,请更改时间区域!"); //没有表
                    MessageBox.Show("所选时间区间内没有数据,请更改时间区域!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (messageError != null)
                {
                    MessageBox.Show("以下深度点无数据!\n" + messageError, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("时间区间选择不正确,请修改!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            MainForm.getInstance().groupBox1.Enabled = true;
            MainForm.getInstance().GDep.Enabled = true;
            mycon.Close();
            mycon.Dispose();
            SQLstr = null;
        }
Beispiel #6
0
        public static System.Data.DataTable getDepcdsql(MySqlConnection mycon)//的到菜单导出SQL
        {
            //获取井深
            float     wellzero = ZedGraphClass.getWellZero();
            DataTable dtValue  = new DataTable();

            System.Data.DataTable dt = new DataTable();
            string SQLstr            = null;                           //获取部分SQL语句
            string strSql            = null;                           //获取全部的SQL

            if (MainForm.getInstance().tabControl1.SelectedIndex == 0) //如果是DTSDep页面
            {
                string    DsingleDepth   = MainForm.getInstance().DsingleDepth.Text;
                DateTime  DintervalTime1 = MainForm.getInstance().DintervalTime1.Value;
                DateTime  DintervalTime2 = MainForm.getInstance().DintervalTime2.Value;
                DataTable tableName      = drawingDTSDep.getTNameTable(DintervalTime1, DintervalTime2);//获取需要使用的表名称
                SQLstr = drawingDTSDep.getSQLstr();
                if (SQLstr != null)
                {
                    ArrayList h = MyDataTable.getDepth(wellzero, DsingleDepth);
                    string    DepString;
                    if (h.Count != 0)
                    {
                        DepString = "\'" + h[0].ToString() + "\'";
                        for (int i = 1; i < h.Count; i++)
                        {
                            DepString = DepString + ",\'" + h[i].ToString() + "\'";
                        }
                        for (int j = 0; j < tableName.Rows.Count; j++)
                        {
                            strSql = null;
                            strSql = "SELECT Depth,RecordTime,TM from " + tableName.Rows[j][0] + " " + SQLstr + " and  Depth  in (" + DepString + ") ORDER BY RecordTime";
                            dt     = getDataTable(strSql, mycon);
                            dtValue.Merge(dt);
                        }

                        return(dtValue);
                    }
                    else
                    {
                        return(dtValue);
                    }
                }
                else
                {
                    return(null);
                }
            }
            else if (MainForm.getInstance().tabControl1.SelectedIndex == 1)//如果是DTSTime页面
            {
                SQLstr = drawingzgcTime.getstrT(wellzero);
                if (SQLstr != null)
                {
                    DataTable SQLTableTime = drawingzgcTime.getTime(mycon);

                    if (SQLTableTime.Rows.Count != 0)
                    {
                        for (int i = 0; i < SQLTableTime.Rows.Count; i++)
                        {
                            strSql = null;
                            strSql = "SELECT Depth,RecordTime,TM from " + SQLTableTime.Rows[i]["folderTable"] + " " + SQLstr + " and  RecordTime = '" + SQLTableTime.Rows[i]["folderTime"] + "'ORDER BY RecordTime";
                            dt     = getDataTable(strSql, mycon);
                            dtValue.Merge(dt);
                        }
                        return(dtValue);
                    }
                    else
                    {
                        return(null);
                    }
                }

                else
                {
                    return(null);
                }
            }
            else if (MainForm.getInstance().tabControl1.SelectedIndex == 2)//如果是DTSTime页面
            {
                string    GratDepth    = MainForm.getInstance().textBox3.Text;
                DateTime  GratDepTime1 = MainForm.getInstance().GratDepTime1.Value;
                DateTime  GratDepTime2 = MainForm.getInstance().GratDepTime2.Value;
                DataTable tableName    = drawingGDep.getTNameTable(GratDepTime1, GratDepTime2); //获取需要使用的表名称
                SQLstr = drawingGDep.getstr();                                                  //获取str
                if (SQLstr != null)
                {
                    ArrayList h = MyDataTable.getDepth(wellzero, GratDepth);
                    h = getNewDepth(h);
                    // string str1 = null, Strnum = null;
                    string DepString;
                    if (h.Count != 0)
                    {
                        DepString = "\'" + h[0].ToString() + "\'";
                        for (int i = 1; i < h.Count; i++)
                        {
                            DepString = DepString + ",\'" + h[i].ToString() + "\'";
                        }
                        // str1 = str + " and  Depth in (" + DepString + ")";
                        for (int j = 0; j < tableName.Rows.Count; j++)
                        {
                            strSql = null;
                            strSql = "SELECT Depth,RecordTime,TM from " + tableName.Rows[j][0] + " " + SQLstr + " and  Depth  in (" + DepString + ") ORDER BY RecordTime";
                            dt     = getDataTable(strSql, mycon);
                            dtValue.Merge(dt);
                        }

                        return(dtValue);
                    }
                    else
                    {
                        return(null);
                    }
                }

                else
                {
                    return(null);
                }
            }
            else if (MainForm.getInstance().tabControl1.SelectedIndex == 3)//如果是DTSTime页面
            {
                DataTable SQLTableTime = drawingGTime.getGTime(mycon);
                if (SQLTableTime.Rows.Count != 0)
                {
                    for (int i = 0; i < SQLTableTime.Rows.Count; i++)
                    {
                        strSql = null;
                        strSql = "SELECT Depth,RecordTime,TM from " + SQLTableTime.Rows[i]["folderTable"] + " where  RecordTime = '" + SQLTableTime.Rows[i]["folderTime"] + "'ORDER BY RecordTime";
                        dt     = getDataTable(strSql, mycon);
                        dtValue.Merge(dt);
                    }
                    return(dtValue);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                //MessageBox.Show("此图形数据无导出功能");

                return(dtValue);
            }
        }
Beispiel #7
0
        //当出现文件变动时 发生的事情。
        private static void m_Watcher_Changed(object sender, System.IO.FileSystemEventArgs e)
        {
            //MessageBox.Show("文件被监控到了");
            System.Threading.Thread.Sleep(5000);
            if (listdraw.Count == 0)
            {
                DateTime  t      = MainForm.getInstance().jizhunTime.Value;
                DataTable jizhun = getJtable(t);
                if (jizhun != null)
                {
                    listdraw.Add(jizhun);
                }
            }


            //MessageBox.Show("文件写入完成了");
            try
            {
                string NewFile = moveFile(e.FullPath, MainForm.getInstance().realDTS2.Text);//移动文件并得到新的路径
                //将数据添加到list中,将路径添加到table中
                getDrawTable(NewFile);
                //存数据到list
                if (list.Count <= 10)
                {
                }
                else
                {
                    /*
                     * 1 若数据正常达到11的话,删除最初的列表。并作图。
                     * 2 若数据不正常,则list不会增加到11 coun也不会变化,会继续判断list.Count
                     *是否为0,此时肯定不为0,而是10(其实是已经使用过的数据)
                     *则绘图图形不变,若导入,判断是否重复(重复)
                     */
                    list.RemoveAt(0);
                    DTStable.Rows[0].Delete();
                    coun++;
                    if (coun > 9)
                    {
                        coun = 0;
                        string name = DTStable.Rows[0][0].ToString();
                        importDTSReal(list[0], name);//需要去重复,以为list[]不变,下面代码还会做一次对比,然后数据库导入
                    }
                }
                if (list.Count != 0)                                          //防止第一个文件是空的
                {
                    DataTable jizhun1 = MyDataTable.getTraDatatable(NewFile); //最新存数据到内存表
                    importRealDTS(list);
                    if (jizhun1.Rows.Count != 0)
                    {
                        if (listdraw.Count != 0)
                        {
                            string Str      = null;
                            float  yujingTM = getFloat(listdraw[0], jizhun1);
                            int    du1      = 0;
                            if (MainForm.getInstance().yujignTMC.Text != "")
                            {
                                du1 = Convert.ToInt32(MainForm.getInstance().yujignTMC.Text);//对比的数值;
                            }
                            if (yujingTM > du1)
                            {
                                //最多画两个图
                                listdraw.Add(jizhun1);
                                if (listdraw.Count == 2)//表示开始进行蒸汽上返预警
                                {
                                    Str = "基准时间点:" + listdraw[0].Rows[0][0].ToString() + " 蒸汽上返异常开始时间点:" + jizhun1.Rows[0][0].ToString();
                                }
                                if (listdraw.Count == 4)
                                {
                                    listdraw.RemoveAt(2);
                                }
                                /*警报发出来,并且给出警报,并且完成*/
                                if (Str != null)
                                {
                                    shangfan(Str, yujingTM);
                                }
                                drawingRealDTS.drawRealDTS(listdraw);
                            }
                            else
                            {
                                //最多画一个图
                                if (listdraw.Count == 3)
                                {
                                    listdraw.RemoveAt(2);//必须2 咋前面删除
                                    listdraw.RemoveAt(1);

                                    Str = "基准时间点:" + listdraw[0].Rows[0][0].ToString() + " 蒸汽上返异常结束时间点:" + jizhun1.Rows[0][0].ToString();
                                }
                                if (listdraw.Count == 2)
                                {
                                    listdraw.RemoveAt(1);
                                    Str = "基准时间点:" + listdraw[0].Rows[0][0].ToString() + " 蒸汽上返异常结束时间点:" + jizhun1.Rows[0][0].ToString();
                                    // listdraw.RemoveAt(2);
                                }
                                //listdraw.Add(jizhun1);
                                //drawingRealDTS.drawRealDTS(listdraw);
                                if (Str != null)
                                {
                                    shangfan(Str, yujingTM);
                                }
                                drawingRealDTS.drawRealDTS1(jizhun1);
                            }
                        }

                        else
                        {
                            drawingRealDTS.drawRealDTS1(jizhun1);
                        }
                    }



                    if (importGratreal.Gratlist.Count != 0)
                    {
                        DTSFBGdata();//数据对比
                    }
                    else
                    {
                        //两个list任意一个为空,就不进行数据对比。
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("实时监控出错,请联系开发人员" + ex);
                //writelog.WriteLog("" + ex);
            }
        }