Exemplo n.º 1
0
        /// <summary>
        /// 向树目录中加载显示卫星观测结果列表
        /// </summary>
        /// <param name="tv"></param>
        public static void LoadSatelliteSchemeList(TreeView tv)
        {
            List <Core.Model.TASK_SCHEME_LIST> tsl;

            Core.DAL.TASK_SCHEME_LIST dal = new Core.DAL.TASK_SCHEME_LIST();
            try
            {
                tsl = dal.GetList();
                tv.Nodes.Clear();
                TreeNode node, node1, node2;
                foreach (Core.Model.TASK_SCHEME_LIST di in tsl)
                {
                    //观测方案信息
                    node                    = new TreeNode();
                    node.Text               = di.SCHEMENAME;
                    node.Tag                = "S0|" + di.SCHEMEID; //S--表示观测方案,对应一次灾害,0--表示未加载观测方案列表,后面跟记录ID
                    node.ImageIndex         = 0;
                    node.SelectedImageIndex = 1;
                    tv.Nodes.Add(node);

                    //观测任务信息
                    node1                    = new TreeNode();
                    node1.Text               = "无观测任务";
                    node1.Tag                = "T0|" + di.SCHEMEID; //S--表示观测任务,一次观测方案有一或多个观测任务,0表示未加载观测任务列表
                    node1.ImageIndex         = 2;
                    node1.SelectedImageIndex = 3;
                    node.Nodes.Add(node1);

                    //观测区域信息
                    node2                    = new TreeNode();
                    node2.Text               = "无观测区域";
                    node2.Tag                = "I0"; //I--表示观测结果,0表示未加载观测结果列表
                    node2.ImageIndex         = 4;
                    node2.SelectedImageIndex = 5;
                    node1.Nodes.Add(node2);
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                tsl = null;
                dal = null;
            }
        }
Exemplo n.º 2
0
        private void tvSatelliteResault_AfterSelect(object sender, TreeViewEventArgs e)
        {
            Main.MainInterface.SelectedNodeSat = e.Node;
            string tag = Main.MainInterface.SelectedNodeSat.Tag.ToString();

            Core.Model.TASK_SCHEME_LIST taskScheme           = new Core.Model.TASK_SCHEME_LIST();
            Core.DAL.TASK_SCHEME_LIST   dal_taskScheme       = new Core.DAL.TASK_SCHEME_LIST();
            Core.DAL.SatelliteResault   dal_satelliteResault = new Core.DAL.SatelliteResault();
            int schemeid = 0;

            if (tag.StartsWith("S")) //任务结点
            {
                int id;
                int.TryParse(tag.Substring(3), out id);
                schemeid = id;
            }
            else if (tag.StartsWith("T")) //任务结点
            {
                int id;
                int.TryParse(tag.Substring(3), out id);
                schemeid = dal_satelliteResault.getSchemeidByTaskid(id);
            }
            else if (tag.StartsWith("I")) //结果点
            {
                int id;
                int.TryParse(tag.Substring(3), out id);
                schemeid = dal_satelliteResault.getSchemeidByLstrseqid(id);
            }
            if (schemeid != 0)
            {
                taskScheme = dal_taskScheme.GetModel(schemeid);
                this.dateTimePicker1.MaxDate = DateTimePicker.MaximumDateTime;
                this.dateTimePicker1.MinDate = DateTimePicker.MinimumDateTime;
                this.dateTimePicker1.MaxDate = taskScheme.SCHEMEETIME;
                this.dateTimePicker1.MinDate = taskScheme.SCHEMEBTIME;
                this.dateTimePicker2.MaxDate = DateTimePicker.MaximumDateTime;
                this.dateTimePicker2.MinDate = DateTimePicker.MinimumDateTime;
                this.dateTimePicker2.MaxDate = taskScheme.SCHEMEETIME;
                this.dateTimePicker2.MinDate = taskScheme.SCHEMEBTIME;
                this.dateTimePicker1.Value   = taskScheme.SCHEMEBTIME;
                this.dateTimePicker2.Value   = taskScheme.SCHEMEETIME;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 导出数据,生成Excel表格
        /// </summary>
        /// <param name="path"></param>
        public void genExcel(string path)
        {
            Core.Model.TASK_SCHEME_LIST taskSchemeList = new Core.Model.TASK_SCHEME_LIST();

            Core.DAL.TASK_SCHEME_LIST dal_taskSchemeList = new Core.DAL.TASK_SCHEME_LIST();

            taskSchemeList = dal_taskSchemeList.GetModel(Convert.ToInt32(schemeid));

            string satSchemeName = taskSchemeList.SCHEMENAME;

            #region 可操作性验证
            //定义表格内数据的行数和列数
            int rowscount = this.dataGridViewTimewindow.Rows.Count;
            int colscount = dataGridViewTimewindow.Columns.Count;
            //行数必须大于0
            if (rowscount <= 0)
            {
                MessageBox.Show("没有数据可供保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //列数必须大于0
            if (colscount <= 0)
            {
                MessageBox.Show("没有数据可供保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //行数不可以大于65536
            if (rowscount > 65536)
            {
                MessageBox.Show("数据记录数太多(最多不能超过65536条),不能保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //列数不可以大于255
            if (colscount > 255)
            {
                MessageBox.Show("数据记录行数太多,不能保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            path += "\\" + satSchemeName + "规划结果" + DateTime.Now.ToString("yyyy年MM月dd日 HH时mm分ss秒") + ".xls";
            #endregion
            Excel.Application objExcel    = null;
            Excel.Workbook    objWorkbook = null;
            Excel.Worksheet   objsheet    = null;

            try
            {
                //申明对象
                objExcel    = new Microsoft.Office.Interop.Excel.Application();
                objWorkbook = objExcel.Workbooks.Add(Missing.Value);
                objsheet    = (Excel.Worksheet)objWorkbook.ActiveSheet;
                //设置EXCEL不可见
                objExcel.Visible = false;

                //向Excel中写入表格的表头
                int displayColumnsCount = 1;
                for (int i = 0; i < dataGridViewTimewindow.ColumnCount - 1; i++)
                {
                    if (dataGridViewTimewindow.Columns[i].Visible == true)
                    {
                        objExcel.Cells[1, displayColumnsCount] = dataGridViewTimewindow.Columns[i].HeaderText.Trim();
                        displayColumnsCount++;
                    }
                }
                //设置进度条
                tempProgressBar.Refresh();
                tempProgressBar.Visible = true;
                tempProgressBar.Minimum = 1;
                tempProgressBar.Maximum = dataGridViewTimewindow.RowCount;
                tempProgressBar.Step    = 1;
                int excelRow = 0;
                //向Excel中逐行逐列写入表格中的数据
                for (int row = 0; row <= dataGridViewTimewindow.RowCount - 1; row++)
                {
                    tempProgressBar.PerformStep();
                    if (((DataGridViewCheckBoxCell)dataGridViewTimewindow.Rows[row].Cells[15]).Value != null && (bool)((DataGridViewCheckBoxCell)dataGridViewTimewindow.Rows[row].Cells[15]).Value)
                    {
                        displayColumnsCount = 1;
                        for (int col = 0; col < colscount - 1; col++)
                        {
                            if (dataGridViewTimewindow.Columns[col].Visible == true)
                            {
                                try
                                {
                                    objExcel.Cells[excelRow + 2, displayColumnsCount] = dataGridViewTimewindow.Rows[row].Cells[col].Value.ToString().Trim();
                                    displayColumnsCount++;
                                }
                                catch (Exception)
                                {
                                }
                            }
                        }
                        excelRow++;
                    }
                }
                //隐藏进度条
                tempProgressBar.Visible = false;
                //保存文件
                objWorkbook.SaveAs(path, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
                                   Missing.Value, Excel.XlSaveAsAccessMode.xlShared, Missing.Value, Missing.Value, Missing.Value,
                                   Missing.Value, Missing.Value);
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message, "警告 ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            finally
            {
                //关闭Excel应用
                if (objWorkbook != null)
                {
                    objWorkbook.Close(Missing.Value, Missing.Value, Missing.Value);
                }
                if (objExcel.Workbooks != null)
                {
                    objExcel.Workbooks.Close();
                }
                if (objExcel != null)
                {
                    objExcel.Quit();
                }

                objsheet    = null;
                objWorkbook = null;
                objExcel    = null;
            }
            MessageBox.Show(path + "\n\n导出完毕! ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 生成word文档订单
        /// </summary>
        /// <param name="path"></param>
        public void genOrder(string path)
        {
            try
            {
                Core.Model.TASK_SCHEME_LIST               taskSchemeList = new Core.Model.TASK_SCHEME_LIST();
                List <Core.Model.TASK_LAYOUT_LIST>        taskLayoutList = new List <Core.Model.TASK_LAYOUT_LIST>();
                List <Core.Model.ImgLayoutTempTimewindow> resaultList    = new List <Core.Model.ImgLayoutTempTimewindow>();
                List <Core.Model.Satellite>               satelliteList  = new List <Core.Model.Satellite>();

                Core.DAL.TASK_SCHEME_LIST        dal_taskSchemeList          = new Core.DAL.TASK_SCHEME_LIST();
                Core.DAL.TASK_LAYOUT_LIST        dal_taskLayoutList          = new Core.DAL.TASK_LAYOUT_LIST();
                Core.DAL.ImgLayoutTempTimewindow dal_imgLayoutTempTimewindow = new Core.DAL.ImgLayoutTempTimewindow();
                Core.DAL.Satellite       dal_satellite       = new Core.DAL.Satellite();
                Core.DAL.SatelliteSensor dal_satelliteSensor = new Core.DAL.SatelliteSensor();
                taskSchemeList = dal_taskSchemeList.GetModel(Convert.ToInt32(schemeid));
                taskLayoutList = dal_taskLayoutList.GetList(Convert.ToInt32(schemeid));

                string satSchemeName  = taskSchemeList.SCHEMENAME;
                string satSchemeStart = taskSchemeList.SCHEMEBTIME.ToString("yyyy年MM月dd日 HH时mm分ss秒");
                string satSchemeEnd   = taskSchemeList.SCHEMEETIME.ToString("yyyy年MM月dd日 HH时mm分ss秒");
                string taskNum        = taskLayoutList.Count.ToString();

                string countryText = "";
                string timeText    = "";
                int    taskCount   = 1;
                //1.载入模板
                Task.WordHelper report = new Task.WordHelper();
                report.CreateNewDocument(System.Windows.Forms.Application.StartupPath + @"\\卫星订单模板.doc"); //模板路径

                //2.在卫星观测方案处插入值
                report.InsertValue("SatScheme", satSchemeName, 11, WdColor.wdColorBlack, 5, WdParagraphAlignment.wdAlignParagraphLeft);       //在书签“SatScheme”处插入值
                report.InsertValue("SatSchemeStart", satSchemeStart, 11, WdColor.wdColorBlack, 5, WdParagraphAlignment.wdAlignParagraphLeft); //在书签“SatScheme”处插入值
                report.InsertValue("SatSchemeEnd", satSchemeEnd, 11, WdColor.wdColorBlack, 5, WdParagraphAlignment.wdAlignParagraphLeft);     //在书签“SatScheme”处插入值
                report.InsertValue("SatSchemeDetail", taskNum, 11, WdColor.wdColorBlack, 5, WdParagraphAlignment.wdAlignParagraphLeft);
                //3.在卫星观测任务处插入值,首先创建一个表格
                int tableNum = 1;
                report.InsertValue("SatTask", "表" + tableNum + " 卫星观测任务详情", 11, WdColor.wdColorBlack, 5, WdParagraphAlignment.wdAlignParagraphCenter); //在书签“SatTask”处插入值
                Microsoft.Office.Interop.Word.Table tableTask = report.InsertTable("SatTask", 2, 4, 0);                                                //在书签“Bookmark_table”处插入2行4列行宽最大的表

                //合并单元格
                report.MergeCell(tableTask, 1, 1, 1, 4);           //表名,开始行号,开始列号,结束行号,结束列号
                //在单元格中插入值
                report.InsertCell(tableTask, 1, 1, satSchemeName); //表名,行号,列号,值
                //给表格插入一行数据
                string[] values = { "任务名称", "开始时间", "结束时间", "目标类型" };
                report.InsertCell(1, 2, 4, values); //给模板中第一个表格的第二行的4列分别插入数据
                int rowNum = 3;
                //设置进度条
                tempProgressBar.Refresh();
                tempProgressBar.Visible = true;
                tempProgressBar.Minimum = 1;
                tempProgressBar.Maximum = (dataGridViewTimewindow.RowCount * taskLayoutList.Count * 2);
                tempProgressBar.Step    = 1;
                foreach (Core.Model.TASK_LAYOUT_LIST tll in taskLayoutList)
                {
                    string[] tasks = new string[4];
                    tasks[0] = tll.TASKNAME;
                    tasks[1] = tll.STARTTIME.ToString("yyyy-MM-dd HH:mm:ss");
                    tasks[2] = tll.ENDTIME.ToString("yyyy-MM-dd HH:mm:ss");
                    tasks[3] = tll.TASKTYPE == 1 ? "区域目标" : "点目标:(" + tll.LON + "," + tll.LAT + ")";
                    report.AddRow(tableTask);               //表名
                    report.InsertCell(1, rowNum, 4, tasks); //给模板中第一个表格的第三行的4列分别插入数据
                    rowNum++;

                    //4.在卫星观测结果处插入值
                    #region 插入统计信息
                    #region 获取按国家排序的统计信息
                    //子标题
                    countryText += "(" + taskCount + ") " + tll.TASKNAME + "\r\n";
                    //查询卫星条件
                    strwhere = "SAT_ID IN (0,";
                    //查询当前任务id
                    string taskid = "";

                    //遍历dataGridView,获取选中数据的卫星id,存入查询卫星条件
                    for (int row = 0; row <= dataGridViewTimewindow.RowCount - 1; row++)
                    {
                        tempProgressBar.PerformStep();
                        taskid = dataGridViewTimewindow.Rows[row].Cells["TASK_ID"].Value.ToString().Trim();
                        if (((DataGridViewCheckBoxCell)dataGridViewTimewindow.Rows[row].Cells[15]).Value != null && (bool)((DataGridViewCheckBoxCell)dataGridViewTimewindow.Rows[row].Cells[15]).Value && taskid == tll.TASKID.ToString())
                        {
                            strwhere += dataGridViewTimewindow.Rows[row].Cells["SATID"].Value.ToString().Trim() + ",";
                        }
                    }
                    strwhere  = strwhere.Substring(0, strwhere.Length - 1);
                    strwhere += ")";
                    strwhere += " ORDER BY SAT_COUNTRY,SAT_SHORTNAME";

                    //获取卫星列表
                    satelliteList = dal_satellite.GetList(strwhere);
                    //临时国家标记,用于标记顺序遍历时国家是否变化
                    string countryName = "";
                    //遍历卫星列表,给插入值赋值
                    foreach (Core.Model.Satellite satellite in satelliteList)
                    {
                        if (countryName != satellite.SAT_COUNTRY)
                        {
                            countryName  = satellite.SAT_COUNTRY;
                            countryText += countryName + ":\r\n";
                        }
                        countryText += "    " + satellite.SAT_SHORTNAME + "\r\n";
                    }
                    #endregion 获取按国家排序的统计信息

                    #region 获取按时间的统计信息
                    timeText += "(" + taskCount + ")" + tll.TASKNAME + "\r\n";
                    strwhere  = "LSTR_SEQID IN (0,";

                    //遍历dataGridView,获取选中数据的卫星id,存入查询卫星条件
                    for (int row = 0; row <= dataGridViewTimewindow.RowCount - 1; row++)
                    {
                        tempProgressBar.PerformStep();
                        if (((DataGridViewCheckBoxCell)dataGridViewTimewindow.Rows[row].Cells[15]).Value != null && (bool)((DataGridViewCheckBoxCell)dataGridViewTimewindow.Rows[row].Cells[15]).Value)
                        {
                            strwhere += dataGridViewTimewindow.Rows[row].Cells[0].Value.ToString().Trim() + ",";
                        }
                    }
                    strwhere  = strwhere.Substring(0, strwhere.Length - 1);
                    strwhere += ")";
                    //获取时间窗口列表
                    resaultList = dal_imgLayoutTempTimewindow.GetListByTaskID(tll.TASKID, strwhere, "STARTTIME, SAT_STKNAME");

                    //临时国家标记,用于标记顺序遍历时国家是否变化
                    string timeDate = "";
                    //遍历卫星列表,给插入值赋值
                    foreach (Core.Model.ImgLayoutTempTimewindow resault in resaultList)
                    {
                        if (timeDate != resault.STARTTIME.ToShortDateString())
                        {
                            timeDate  = resault.STARTTIME.ToShortDateString();
                            timeText += timeDate + ":\r\n";
                        }
                        timeText += "    " + resault.SAT_STKNAME + "\r\n";
                    }

                    #endregion 获取按时间的统计信息

                    taskCount++;
                    #endregion 插入统计信息


                    #region 插入卫星任务规划表格

                    /***
                     * //按照卫星名称分类
                     * tableNum++;//表格计数加一
                     * report.InsertValue("SatResault" + (tableNum - 1).ToString(), "\r\n", 11, WdColor.wdColorBlack, 5, WdParagraphAlignment.wdAlignParagraphCenter);
                     * report.InsertValue("SatResault" + (tableNum - 1).ToString(), "表" + tableNum + " " + tll.TASKNAME + "(按卫星名称排序)", 11, WdColor.wdColorBlack, 5, WdParagraphAlignment.wdAlignParagraphCenter);//在书签“SatResault”处插入值
                     * Table tableResault = report.InsertTable("SatResault" + (tableNum - 1).ToString(), 1, 9, 0); //在书签“SatResault”处插入1行9列行宽最大的表
                     *
                     * //给表格插入一行数据
                     * string[] resaultValues = { "序号","卫星名称", "载荷名称", "开始时间", "结束时间", "时长(秒)", "倾斜角度(度)", "分辨率(米)", "灾后时间" };
                     * report.InsertCell(tableNum, 1, 9, resaultValues); //给模板中第一个表格的第二行的4列分别插入数据
                     * int tableResaultNum = 1;//表格行数计数
                     * //获取卫星观测结果列表
                     * resaultList = dal_imgLayoutTempTimewindow.GetListByTaskID(Convert.ToInt32(tll.TASKID), strwhere, "SAT_STKNAME,STARTTIME");
                     *
                     *
                     * //给观测结果表格填充内容
                     * foreach (Core.Model.ImgLayoutTempTimewindow iltt in resaultList)
                     * {
                     *  tempProgressBar.PerformStep();
                     *  report.AddRow(tableNum, 1);
                     *  string[] resault = new string[9];
                     *  resault[0] = tableResaultNum.ToString();
                     *  resault[1] = dal_satellite.GetModel(iltt.SATID).SAT_SHORTNAME;
                     *  resault[2] = dal_satelliteSensor.GetModel(iltt.SENSOR_ID.ToString()).SENSOR_NAME;
                     *  resault[3] = iltt.STARTTIME.ToString();
                     *  resault[4] = iltt.ENDTIME.ToString();
                     *  resault[5] = iltt.TIMELONG.ToString();
                     *  resault[6] = iltt.SANGLE.ToString();
                     *  resault[7] = iltt.GSD.ToString();
                     *  resault[8] = Convert.ToString(iltt.STARTTIME - tll.STARTTIME);
                     *  tableResaultNum++;
                     *  report.InsertCell(tableNum, tableResaultNum, 9, resault);
                     * }
                     * //按照时间顺序分类
                     * tableNum++;//表格计数加一
                     * report.InsertValue("SatResault" + (tableNum - 1).ToString(), "\r\n", 11, WdColor.wdColorBlack, 5, WdParagraphAlignment.wdAlignParagraphCenter);
                     * report.InsertValue("SatResault" + (tableNum - 1).ToString(), "表" + tableNum + " " + tll.TASKNAME + "(按时间排序)", 11, WdColor.wdColorBlack, 5, WdParagraphAlignment.wdAlignParagraphCenter);//在书签“SatResault”处插入值
                     * Table tableResault2 = report.InsertTable("SatResault" + (tableNum - 1).ToString(), 1, 9, 0); //在书签“SatResault”处插入1行8列行宽最大的表
                     *
                     * //给表格插入一行数据
                     * string[] resaultValues2 = { "序号", "卫星名称", "载荷名称", "开始时间", "结束时间", "时长(秒)", "倾斜角度(度)", "分辨率(米)", "灾后时间" };
                     * report.InsertCell(tableNum, 1, 9, resaultValues); //给模板中第一个表格的第二行的4列分别插入数据
                     * int tableResaultNum2 = 1;//表格行数计数
                     * //获取卫星观测结果列表
                     * resaultList = dal_imgLayoutTempTimewindow.GetListByTaskID(Convert.ToInt32(tll.TASKID), strwhere,"STARTTIME");
                     * //给观测结果表格填充内容
                     * foreach (Core.Model.ImgLayoutTempTimewindow iltt in resaultList)
                     * {
                     *  tempProgressBar.PerformStep();
                     *  report.AddRow(tableNum, 1);
                     *  string[] resault = new string[9];
                     *  resault[0] = tableResaultNum2.ToString();
                     *  resault[1] = dal_satellite.GetModel(iltt.SATID).SAT_SHORTNAME;
                     *  resault[2] = dal_satelliteSensor.GetModel(iltt.SENSOR_ID.ToString()).SENSOR_NAME;
                     *  resault[3] = iltt.STARTTIME.ToString();
                     *  resault[4] = iltt.ENDTIME.ToString();
                     *  resault[5] = iltt.TIMELONG.ToString();
                     *  resault[6] = iltt.SANGLE.ToString();
                     *  resault[7] = iltt.GSD.ToString();
                     *  resault[8] = Convert.ToString(iltt.STARTTIME - tll.STARTTIME);
                     *  tableResaultNum2++;
                     *  report.InsertCell(tableNum, tableResaultNum2, 9, resault);
                     * }
                     ***/
                    #endregion 插入卫星任务规划表格
                }
                report.InsertValue("SatResaultCountry", countryText, 11, WdColor.wdColorBlack, 1, WdParagraphAlignment.wdAlignParagraphLeft); //在书签“SatResaultCountry”处插入值
                report.InsertValue("SatResaultTime", timeText, 11, WdColor.wdColorBlack, 1, WdParagraphAlignment.wdAlignParagraphLeft);       //在书签“SatResaultCountry”处插入值

                //隐藏进度条
                tempProgressBar.Visible = false;
                //5.最后保存文档
                //string path = Server.MapPath(p_SavePath) + "\\Testing_" + DateTime.Now.ToShortDateString() + ".doc";
                path += "\\" + satSchemeName + "规划结果" + DateTime.Now.ToString("yyyy年MM月dd日 HH时mm分ss秒") + ".doc";
                report.SaveDocument(path);
                MessageBox.Show("订单生成成功!");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("订单生成失败!失败原因:" + ex.ToString());
            }
        }