Beispiel #1
0
        private int m_Interval = 0; //观测周期

        public DataTable ConvertExcelToDbs(string excelpath)
        {
            if (string.IsNullOrEmpty(excelpath))
                return null;

            NpoiCreator nct = new NpoiCreator();
            DirectoryInfo mydir = new DirectoryInfo(excelpath);
            if (mydir.GetFiles().Length > 0)
            {
                List<DataTable> dblist = new List<DataTable>();
                foreach (FileSystemInfo fsi in mydir.GetFileSystemInfos())
                {
                    if (fsi is FileInfo)//
                    {
                        FileInfo fi = (FileInfo)fsi;
                        if (fi.Extension.ToUpper() == ".XLS")//
                        {
                            dblist.Add(nct.ExportToDataTable(fi.FullName));
                        }
                    }
                }
                return ExportResult(dblist);
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 保存到工作区
        /// </summary>
        /// <param name="checkedNodes">选中的节点</param>
        public static bool SaveToWorkspace(List <LineBean> checkedNodes)
        {
            bool isScud = false;

            try
            {
                foreach (LineBean checkedLb in checkedNodes)
                {
                    DataTable dt = LineObsBll.Instance.GetDataTable("select obvdate,obvvalue from t_obsrvtntb where OBSLINECODE = '" + checkedLb.OBSLINECODE + "'");

                    NpoiCreator npcreator = new NpoiCreator();
                    string      savefile  = Application.StartupPath + "/远程信息库缓存";
                    npcreator.TemplateFile = savefile;
                    npcreator.NpoiExcel(dt, checkedLb.OBSLINECODE + ".xls", savefile + "/" + checkedLb.OBSLINECODE + ".xls");

                    TreeBean tb = new TreeBean();

                    tb.KeyFieldName    = checkedLb.OBSLINECODE;
                    tb.ParentFieldName = checkedLb.SITECODE;
                    tb.Caption         = checkedLb.OBSLINENAME;
                }
                isScud = true;
            }
            catch (Exception ex)
            {
                isScud = false;
                throw new Exception(ex.Message);
            }

            return(isScud);
        }
Beispiel #3
0
        public DataTable GetDataTable(string linecode, string path)
        {
            DataTable dt = null;

            string filename = path + "\\" + linecode + ".xls";

            if (File.Exists(filename))
            {
                NpoiCreator npcreator = new NpoiCreator();
                dt = npcreator.ExcelToDataTable_LineObs(filename, true);
                //dt = npcreator.ExportToObslineDataTable(filename);
            }
            else
            {
                dt = LineObsBll.Instance.GetDataTable("select DATE_FORMAT(obvdate,'%Y-%m-%d') as obvdate,obvvalue,note from t_obsrvtntb where OBSLINECODE = '" + linecode + "'");
                if (dt.Rows.Count > 0)
                {
                    NpoiCreator npcreator = new NpoiCreator();
                    npcreator.TemplateFile = path;
                    npcreator.NpoiExcel(dt, path + "/" + linecode + ".xls");
                }
            }

            return(dt);
        }
Beispiel #4
0
        private void btnDown_Click(object sender, EventArgs e)
        {
            if (this.gridView.GetSelectedRows().Length == 0)
            {
                XtraMessageBox.Show("未选中任何记录", "提示");
                return;
            }
            try
            {
                FolderBrowserDialog sfd = new FolderBrowserDialog();
                //sfd.Title = "请选择信息库下载路径";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    string    sitecode = (comboBoxEdit.SelectedItem as CheckedListBoxItem).Value.ToString();
                    DataTable dt       = SiteBll.Instance.GetDataTable("select * from t_siteinfodb where sitecode='" + sitecode + "'");

                    #region 创建信息库路径
                    string baseinfoPath = sfd.SelectedPath + "\\" + dt.Rows[0]["sitename"].ToString();
                    if (!Directory.Exists(baseinfoPath))
                    {
                        Directory.CreateDirectory(baseinfoPath);
                    }

                    string laytoutmapPath = baseinfoPath + "\\场地图";
                    if (!Directory.Exists(laytoutmapPath))
                    {
                        Directory.CreateDirectory(laytoutmapPath);
                    }

                    string remotemapPath = baseinfoPath + "\\卫星图";
                    if (!Directory.Exists(remotemapPath))
                    {
                        Directory.CreateDirectory(remotemapPath);
                    }


                    string linePath = baseinfoPath + "\\测线信息";
                    if (!Directory.Exists(linePath))
                    {
                        Directory.CreateDirectory(linePath);
                    }

                    string lineinfoPath = baseinfoPath + "\\测线信息\\测线基础信息";
                    if (!Directory.Exists(lineinfoPath))
                    {
                        Directory.CreateDirectory(lineinfoPath);
                    }

                    string lineobsPath = baseinfoPath + "\\测线信息\\观测数据";
                    if (!Directory.Exists(lineobsPath))
                    {
                        Directory.CreateDirectory(lineobsPath);
                    }

                    #endregion

                    #region 生成场地基础信息表

                    if (dt.Rows.Count > 0)
                    {
                        NpoiCreator npcreator = new NpoiCreator();
                        npcreator.TemplateFile = SystemInfo.DatabaseCache;
                        npcreator.NpoiExcel(dt, baseinfoPath + "\\场地基础信息.xls");
                    }
                    #endregion

                    #region 生成卫星图
                    List <RemoteMapBean> rblist = RemotemapBll.Instance.GetWhere(new { sitecode = sitecode }).ToList();
                    if (rblist.Count != 0)
                    {
                        for (int i = 0; i < rblist.Count; i++)
                        {
                            if (rblist[i].remotemap != null && rblist[i].remotemap.Length > 0)
                            {
                                MemoryStream stream = new MemoryStream();
                                stream.Write(rblist[i].remotemap, 0, rblist[i].remotemap.Length);

                                Bitmap bitMap = new Bitmap(stream);
                                bitMap.Save(remotemapPath + "\\" + rblist[i].remotemapname + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                            }
                        }
                    }

                    #endregion

                    #region 生成场地图

                    List <LayoutmapBean> lblist = LayoutmapBll.Instance.GetWhere(new { sitecode = sitecode }).ToList();
                    if (lblist.Count != 0)
                    {
                        for (int i = 0; i < lblist.Count; i++)
                        {
                            if (lblist[i].layoutmap != null && lblist[i].layoutmap.Length > 0)
                            {
                                MemoryStream stream = new MemoryStream();
                                stream.Write(lblist[i].layoutmap, 0, lblist[i].layoutmap.Length);

                                Bitmap bitMap = new Bitmap(stream);
                                bitMap.Save(laytoutmapPath + "\\" + lblist[i].layoutmapname + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                            }
                        }
                    }

                    #endregion


                    #region 生成测线信息表



                    DataTable dtline = LineBll.Instance.GetDataTable("select * from t_obslinetb where sitecode ='" + sitecode + "'");


                    foreach (DataRow dr in dt.Rows)
                    {
                        string    linecode     = dr["OBSLINECODE"].ToString();
                        DataTable dtmaxmindata = LineObsBll.Instance.GetDataTable("select max(OBVDATE) as maxdate,min(OBVDATE) as mindate from t_obsrvtntb where OBSLINECODE='" + linecode + "'");
                    }



                    #endregion
                }
                else
                {
                    return;
                }

                //设置一个最小值
                progressBarControl.Properties.Minimum = 0;
                //设置一个最大值
                progressBarControl.Properties.Maximum = this.gridView.GetSelectedRows().Length;
                //设置步长,即每次增加的数
                progressBarControl.Properties.Step = 1;

                //当前值
                progressBarControl.Position = 0;


                for (int i = 0; i < this.gridView.GetSelectedRows().Length; i++)
                {
                    int     rowindex  = this.gridView.GetSelectedRows()[i];
                    DataRow row       = gridView.GetDataRow(rowindex);
                    string  linecode  = LineBll.Instance.GetIdByName(row[0].ToString());
                    string  startdate = row[1].ToString();
                    string  enddate   = row[2].ToString();


                    DataTable dt = LineObsBll.Instance.GetDataTable("select obvdate,obvvalue,note from t_obsrvtntb where unix_timestamp(OBVDATE) between unix_timestamp('" + startdate + "') and unix_timestamp('" + enddate + "' ) and OBSLINECODE = '" + linecode + "'");
                    if (dt.Rows.Count > 0)
                    {
                        NpoiCreator npcreator = new NpoiCreator();
                        npcreator.TemplateFile = SystemInfo.DatabaseCache;
                        npcreator.NpoiExcel(dt, SystemInfo.DatabaseCache + "/" + linecode + ".xls");
                    }
                    Application.DoEvents();
                    progressBarControl.Position += 1;
                }
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                this.DialogResult = DialogResult.No;
                XtraMessageBox.Show("下载失败:" + ex.Message, "错误");
            }
        }
Beispiel #5
0
        private void wizardControl_SelectedPageChanged(object sender, DevExpress.XtraWizard.WizardPageChangedEventArgs e)
        {
            //装载原始数据
            if (e.Page.Name == "calculateSHPage")
            {
                if (txtJx1.Text == "" || btnFileSz1.Text == "" || btnFileJx2.Text == "" || btnFileSz2.Text == "" || txtJj1.Text == "" || txtJj2.Text == "")
                {
                    XtraMessageBox.Show("请填写完整信息再执行下一步", "提示");
                    return;
                }
                else
                {
                    jj1 = double.Parse(txtJj1.Text) * Math.PI / 180; //转化为弧度值
                    jj2 = double.Parse(txtJj2.Text) * Math.PI / 180; //转化为弧度值
                    NpoiCreator npcreator = new NpoiCreator();

                    jx1Dt_orgn = npcreator.ExportToDataTable(txtJx1.Text);
                    sz1Dt_orgn = npcreator.ExportToDataTable(txtSz1.Text);
                    jx2Dt_orgn = npcreator.ExportToDataTable(txtJx2.Text);
                    sz2Dt_orgn = npcreator.ExportToDataTable(txtSz2.Text);

                    //计算基准年数据
                    jx1Dt_jzn = GetJznDataTable(jx1Dt_orgn);
                    sz1Dt_jzn = GetJznDataTable(sz1Dt_orgn);
                    jx2Dt_jzn = GetJznDataTable(jx2Dt_orgn);
                    sz2Dt_jzn = GetJznDataTable(sz2Dt_orgn);

                    //计算基准值
                    //计算ΔS1、ΔS2、ΔH1、ΔH2(基线1变化量用ΔS1表示,基线2变化量用ΔS2表示,水准1变化量用ΔH1表示,水准2变化量用ΔH2表示)
                    jx1Dt_bhl = GetBhlDataTable(jx1Dt_orgn, jx1Dt_jzn);
                    sz1Dt_bhl = GetBhlDataTable(sz1Dt_orgn, sz1Dt_jzn);
                    jx2Dt_bhl = GetBhlDataTable(jx2Dt_orgn, jx2Dt_jzn);
                    sz2Dt_bhl = GetBhlDataTable(sz2Dt_orgn, sz2Dt_jzn);


                    gridControlS1.DataSource = jx1Dt_bhl;
                    gridControlS2.DataSource = jx2Dt_bhl;
                    gridControlH1.DataSource = sz1Dt_bhl;
                    gridControlH2.DataSource = sz2Dt_bhl;
                }
            }
            else if (e.Page.Name == "calculateBCDPage")
            {
                db = jx1Dt_bhl.Clone();
                dc = jx1Dt_bhl.Clone();
                bc = jx1Dt_bhl.Clone();
                for (int i = 0; i < jx1Dt_bhl.Rows.Count; i++)
                {
                    double s1_v = double.Parse(jx1Dt_bhl.Rows[i][1].ToString());
                    double s2_v = double.Parse(jx2Dt_bhl.Rows[i][1].ToString());

                    double h1_v = double.Parse(sz1Dt_bhl.Rows[i][1].ToString());
                    double h2_v = double.Parse(sz2Dt_bhl.Rows[i][1].ToString());

                    double d_v = (s1_v * Math.Sin(jj2) - s2_v * Math.Sin(jj1)) / (Math.Cos(jj1) * Math.Sin(jj2) - Math.Sin(jj1) * Math.Cos(jj2));
                    double b_v = (s1_v - d_v * Math.Cos(jj1)) / Math.Sin(jj1);
                    double c_v = (h1_v + h2_v) / 2;

                    double db_v = d_v / b_v;
                    double dc_v = d_v / c_v;
                    double bc_v = b_v / c_v;

                    string   date     = jx1Dt_bhl.Rows[i][0].ToString();
                    DateTime datetime = DateTime.ParseExact(date, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);

                    datetime.AddYears(int.Parse(date.Substring(0, 4)));

                    DataRow db_dr = db.NewRow();
                    db_dr[0] = datetime.ToShortDateString();
                    db_dr[1] = Math.Round(db_v, 4);
                    db.Rows.Add(db_dr);

                    DataRow dc_dr = dc.NewRow();
                    dc_dr[0] = datetime.ToShortDateString();
                    dc_dr[1] = Math.Round(dc_v, 4);
                    dc.Rows.Add(dc_dr);

                    DataRow bc_dr = bc.NewRow();
                    bc_dr[0] = datetime.ToShortDateString();
                    bc_dr[1] = Math.Round(bc_v, 4);
                    bc.Rows.Add(bc_dr);
                }

                gridControldb.DataSource = db;
                gridControldc.DataSource = dc;
                gridControlbc.DataSource = bc;
            }
        }