예제 #1
0
        void menuAZOVSTALIDSEquipmentListExport_Click(object sender, EventArgs e)
        {
            if (DatabaseManager.Databases.Count <= 0)
            {
                Flute.Service.MessageBoxWinForm.Error("设备清单导出", "程序还没有载入任何IDS数据库.", "");
                return;
            }

            DataSet             dataSet = DatabaseManager.Databases[DatabaseManager.CurrentKey].DatabaseSource;
            IDSSystemCollection systems = IDSHelper.CreateIDSSystems(dataSet.Tables[TblIDSLoop.TblName],
                                                                     dataSet.Tables[TblIDSHierarchy.TblName],
                                                                     dataSet.Tables[TblIDSEquipment.TblName],
                                                                     dataSet.Tables[TblIDSSubEquipment.TblName],
                                                                     dataSet.Tables[TblIDSRepository.TblName],
                                                                     dataSet.Tables[TblIDSCable.TblName],
                                                                     dataSet.Tables[TblIDSMountingScheme.TblName]);

            IDrawing azovstalEquipmentList = new AZOVSTALEquipmentList(systems);

            azovstalEquipmentList.Export("", "", IDSHelper.CreateIDSDesignInfo(dataSet.Tables[TblDesignInfo.TblName]));

            return;
        }
예제 #2
0
        // 载入IDS数据库
        private void menuOpenIDS_Click(object sender, EventArgs e)
        {
            string fileName = null;

            if (DatabaseManager.Databases.Count > 0)
            {
                if (DialogResult.Cancel == Flute.Service.MessageBoxWinForm.Confirm("打开IDS数据库", "您已打开一个IDS数据库, 确认打开新的IDS数据库吗?", ""))
                {
                    return;
                }
            }

            OpenFileDialog openFileDlg;

            openFileDlg = new OpenFileDialog();

            openFileDlg.Multiselect = false;
            openFileDlg.Title       = "选择IDS文件";
            openFileDlg.Filter      = "IDS文件 (*.IDS)|*.IDS|All Files (*.*)|*.*";

            DialogResult dlgResult;

            try {
                dlgResult = openFileDlg.ShowDialog();
            }
            catch (Exception ex) {
                Flute.Service.MessageBoxWinForm.Error("选择IDS数据库文件", ex.Message, "");
                return;
            }

            if (dlgResult == DialogResult.OK)
            {
                fileName = openFileDlg.FileName;
            }
            else
            {
                return;
            }

            DatabaseManager.Databases.Clear();

            //
            // Hard Code -- left for refactoring
            //
            DataSet ds = new DataSet();

            DatabaseConfigInfo dbConfigInfo = new DatabaseConfigInfo();

            dbConfigInfo.ConnectionString = DatabaseManager.CreateOleDbConnString(fileName, "", "");
            dbConfigInfo.TablePrefix      = "";
            dbConfigInfo.DbType           = "";

            IDbProvider dbProvider = DatabaseManager.GetProvider("Flute.Data.AccessProvider");

            try {
                ds = DatabaseHelper.CreateDataSet(dbConfigInfo.ConnectionString,
                                                  dbProvider,
                                                  TblDesignInfo.TblName,
                                                  TblIDSEquipment.TblName,
                                                  TblIDSSubEquipment.TblName,
                                                  TblIDSEquipingLocation.TblName,
                                                  TblIDSIOSignal.TblName,
                                                  TblIDSRepository.TblName,
                                                  TblIDSHierarchy.TblName,
                                                  TblIDSLoop.TblName,
                                                  TblIDSCabinet.TblName,
                                                  TblIDSEquipmentInCabinet.TblName,
                                                  TblIDSCable.TblName,
                                                  TblIDSMountingScheme.TblName,
                                                  TblIDSMountingSchemeMaterial.TblName);
            }
            catch (System.Data.Common.DbException ex) {
                Flute.Service.MessageBoxWinForm.Error("数据库IDS连接", "程序在加载数据库IDS时出错!", ex.Message + "\n\n" + ex.Source);
                return;
            }

            DatabaseManager.AddDatabase(new Database(ds, dbConfigInfo, dbProvider), "IDS" + "-" + fileName);
            DatabaseManager.SetCurrentKey("IDS" + "-" + fileName);

            DataSet dataSet = DatabaseManager.Databases[DatabaseManager.CurrentKey].DatabaseSource;

            this.IdsFrame.RepositoryCategories = IDSHelper.CreateIDSRepositoryCategories(dataSet.Tables[TblIDSHierarchy.TblName],
                                                                                         dataSet.Tables[TblIDSRepository.TblName]);
            this.IdsFrame.Systems = IDSHelper.CreateIDSSystems(dataSet.Tables[TblIDSLoop.TblName],
                                                               dataSet.Tables[TblIDSHierarchy.TblName],
                                                               dataSet.Tables[TblIDSEquipment.TblName],
                                                               dataSet.Tables[TblIDSSubEquipment.TblName],
                                                               dataSet.Tables[TblIDSEquipingLocation.TblName],
                                                               dataSet.Tables[TblIDSIOSignal.TblName],
                                                               dataSet.Tables[TblIDSRepository.TblName],
                                                               dataSet.Tables[TblIDSCable.TblName],
                                                               dataSet.Tables[TblIDSMountingScheme.TblName],
                                                               this.IdsFrame.RepositoryCategories);

            this.Text = System.IO.Path.GetFileName(fileName) + " -- " + caption;
            Flute.Service.MessageBoxWinForm.Info("成功", "成功载入IDS数据库文件", "路径:\n" + fileName);
        }