Пример #1
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (this.igxDataset_0 == null)
     {
         MessageBox.Show("请选择要装载的数据!");
     }
     else
     {
         this.panel1.Visible = true;
         ITable dataset = this.igxDataset_0.Dataset as ITable;
         this.progressBarFN.Minimum = 0;
         this.progressBarFN.Maximum = this.ilist_0.Count;
         Dataloaders dataloaders = new Dataloaders();
         dataloaders.Step += (new IFeatureProgress_StepEventHandler(this.method_3));
         System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
         for (int i = 0; i < this.ilist_0.Count; i++)
         {
             ITable table2 = (this.ilist_0[i] as IName).Open() as ITable;
             this.lblFN.Text = "处理" + (table2 as IDataset).Name + "...";
             this.progressBarFN.Increment(1);
             dataloaders.LoadData(dataset, null, table2, 500);
             Marshal.ReleaseComObject(table2);
             table2 = null;
         }
         System.Windows.Forms.Cursor.Current = Cursors.Default;
         this.btnOK.DialogResult             = DialogResult.OK;
         Marshal.ReleaseComObject(dataset);
         dataset = null;
         base.Close();
     }
 }
Пример #2
0
 public void Do()
 {
     try
     {
         this.panel1.Visible = true;
         Dataloaders dataloaders = new Dataloaders();
         (dataloaders.Converter as IFeatureProgress_Event).Step +=
             (new IFeatureProgress_StepEventHandler(this.method_12));
         this.progressBar1.Minimum = 0;
         this.progressBar1.Maximum = this.iarray_0.Count;
         for (int i = 0; i < this.iarray_0.Count; i++)
         {
             this.progressBar1.Increment(1);
             IDatasetName name = this.iarray_0.get_Element(i) as IDatasetName;
             this.method_4(this.method_1(name, "Point") as IName, dataloaders);
             this.method_4(this.method_1(name, "Polyline") as IName, dataloaders);
             this.method_4(this.method_1(name, "Polygon") as IName, dataloaders);
             this.method_4(this.method_1(name, "Annotation") as IName, dataloaders);
         }
         this.igxObject_1.Refresh();
         this.panel1.Visible = false;
     }
     catch (Exception exception)
     {
         Logger.Current.Error("", exception, "");
         MessageBox.Show(exception.Message);
     }
 }
Пример #3
0
        private void method_4(IName iname_2, Dataloaders dataloaders_0)
        {
            IWorkspace2 workspace;
            string      str2;
            int         num;
            string      name = (iname_2 as IDatasetName).Name;

            this.labelFeatureClass.Text = "转换:" + name;
            Application.DoEvents();
            if (this.iname_1 is IWorkspaceName)
            {
                if (((this.iname_1 as IWorkspaceName).Type == esriWorkspaceType.esriLocalDatabaseWorkspace) ||
                    ((this.iname_1 as IWorkspaceName).Type == esriWorkspaceType.esriRemoteDatabaseWorkspace))
                {
                    workspace = this.iname_1.Open() as IWorkspace2;
                    str2      = name;
                    num       = 1;
                    try
                    {
                        while (workspace.get_NameExists((iname_2 as IDatasetName).Type, str2))
                        {
                            str2 = name + "_" + num.ToString();
                            num++;
                        }
                    }
                    catch
                    {
                    }
                    name = str2;
                }
                else
                {
                    string str3 = (this.iname_1 as IWorkspaceName).PathName + @"\" + name;
                    str2 = str3 + ".shp";
                    for (num = 1; File.Exists(str2); num++)
                    {
                        str2 = str3 + "_" + num.ToString() + ".shp";
                    }
                    name = Path.GetFileNameWithoutExtension(str2);
                }
            }
            else if (this.iname_1 is IDatasetName)
            {
                workspace = (this.iname_1.Open() as IDataset).Workspace as IWorkspace2;
                str2      = name;
                for (num = 1; workspace.get_NameExists((iname_2 as IDatasetName).Type, str2); num++)
                {
                    str2 = name + "_" + num.ToString();
                }
                name = str2;
            }
            dataloaders_0.ConvertData(iname_2 as IDatasetName, this.iname_1, name, null);
        }
Пример #4
0
        private bool method_0()
        {
            Dataloaders dataloaders = new Dataloaders();
            SortedList <string, string> fieldMaps = this.fieldMatchCtrl_0.FieldMaps;
            List <ITable> loadTables = this.selectedDataLoaderCtrl_0.LoadTables;

            string where = this.setImportRecordCtrl_0.Where;
            base.Enabled = false;
            dataloaders.LoadData(loadTables, where, this.Table as ITable, fieldMaps, 500);
            base.Enabled = true;
            MessageBox.Show("数据导入成功!");
            return(true);
        }
Пример #5
0
 public void Transfer(IEnumNameMapping ienumNameMapping_0, IName iname_0)
 {
     if (!(ienumNameMapping_0 is IMyEnumNameMapping))
     {
         this.bool_0 = false;
         this.igeoDBDataTransfer_0.Transfer(ienumNameMapping_0, iname_0);
     }
     else
     {
         this.bool_0 = true;
         Dataloaders dataloader = new Dataloaders();
         ienumNameMapping_0.Reset();
         for (INameMapping i = ienumNameMapping_0.Next(); i != null; i = ienumNameMapping_0.Next())
         {
             this.method_1((i.SourceObject as IDatasetName).Name);
             dataloader.ConvertData(i.SourceObject as IDatasetName, iname_0, i.TargetName, null);
         }
     }
 }
Пример #6
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (this.igxDataset_1 == null)
     {
         MessageBox.Show("请选择要装载的数据!");
     }
     else
     {
         ITable dataset = this.igxDataset_1.Dataset as ITable;
         ITable table2  = this.igxDataset_0.Dataset as ITable;
         this.progressBar1.Visible = true;
         Dataloaders dataloaders = new Dataloaders();
         dataloaders.Step += (new IFeatureProgress_StepEventHandler(this.method_3));
         System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
         dataloaders.LoadData(dataset, null, table2, 500);
         System.Windows.Forms.Cursor.Current = Cursors.Default;
         this.btnOK.DialogResult             = DialogResult.OK;
         base.Close();
     }
 }
Пример #7
0
        public void ToShape(IMap pMap)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                List <IDataset> allDataset  = this.GetAllDataset(pMap);
                Dataloaders     dataloaders = new Dataloaders();
                IPropertySet    set         = new PropertySetClass();
                set.SetProperty("DATABASE", dialog.SelectedPath);
                IWorkspaceName name = new WorkspaceNameClass
                {
                    ConnectionProperties   = set,
                    WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory"
                };
                frmProgressBar1 bar = new frmProgressBar1
                {
                    progressBar1 = { Maximum = allDataset.Count, Value = 0 }
                };
                bar.Show();
                bar.Text = "导出shapefile";
                foreach (IDataset dataset in allDataset)
                {
                    string[] strArray = dataset.Name.Split(new char[] { '.' });
                    strArray          = strArray[strArray.Length - 1].Split(new char[] { '_' });
                    bar.Caption1.Text = string.Format("导出[{0}]", strArray[0]);
                    Application.DoEvents();
                    bar.progressBar1.Value++;
                    try
                    {
                        dataloaders.ConvertData(dataset.FullName as IDatasetName, name as IName, strArray[0], null);
                    }
                    catch
                    {
                    }
                }
                bar.Close();
                MessageBox.Show("导出完成!");
            }
        }
Пример #8
0
 public void Do()
 {
     try
     {
         IDatasetName name;
         this.panel1.Visible = true;
         Dataloaders dataloaders = new Dataloaders();
         (dataloaders.Converter as IFeatureProgress_Event).Step +=
             (new IFeatureProgress_StepEventHandler(this.method_6));
         IQueryFilter filter = null;
         if (this.txtWhere.Text.Length > 0)
         {
             filter = new QueryFilterClass
             {
                 WhereClause = this.txtWhere.Text
             };
         }
         dataloaders.ConvertData(this.iname_0 as IDatasetName, this.iname_1, this.txtOutFeatureClassName.Text,
                                 filter);
         IGxObject obj2 = null;
         this.method_0(this.igxObject_1);
         if (this.iname_1 is IWorkspaceName)
         {
             if ((this.iname_1 as IWorkspaceName).Type == esriWorkspaceType.esriFileSystemWorkspace)
             {
                 obj2 = new GxShapefileDataset();
             }
             else
             {
                 obj2 = new GxDataset();
             }
             if ((this.iname_0 as IDatasetName).Type == esriDatasetType.esriDTFeatureClass)
             {
                 name = new FeatureClassNameClass();
             }
             else
             {
                 name = new TableNameClass();
             }
             name.Name          = this.txtOutFeatureClassName.Text;
             name.WorkspaceName = this.iname_1 as IWorkspaceName;
             (obj2 as IGxDataset).DatasetName = name;
             this.igxObject_1.Refresh();
         }
         else if (this.iname_1 is IDatasetName)
         {
             obj2 = new GxDataset();
             if ((this.iname_0 as IDatasetName).Type == esriDatasetType.esriDTFeatureClass)
             {
                 name = new FeatureClassNameClass();
             }
             else
             {
                 name = new TableNameClass();
             }
             name.Name          = this.txtOutFeatureClassName.Text;
             name.WorkspaceName = (this.iname_1 as IDatasetName).WorkspaceName;
             (obj2 as IGxDataset).DatasetName = name;
             this.igxObject_1.Refresh();
         }
     }
     catch (Exception exception)
     {
         Logger.Current.Error("", exception, "");
     }
 }
Пример #9
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            ITable table = null;

            switch (this.radioGroup1.SelectedIndex)
            {
            case 0:
                if (this.txtWorkspaceName.Tag != null)
                {
                    IGxDataset      dataset;
                    IFields         fields;
                    IFieldChecker   checker;
                    IEnumFieldError error;
                    IFields         fields2;
                    if (this.txtDatasetName.Text.Trim() == "")
                    {
                        MessageBox.Show("请选择新建数据集的名称!");
                        return;
                    }
                    if (this.SourceDatalistBox.Items.Count == 0)
                    {
                        MessageBox.Show("请选择要合并的数据集!");
                        return;
                    }
                    if (this.rdoDatasetType.SelectedIndex == 0)
                    {
                        if (this.method_0(this.iworkspace_0, esriDatasetType.esriDTFeatureClass,
                                          this.txtDatasetName.Text.Trim()))
                        {
                            MessageBox.Show("指定的要素类名已存在,请输入其它名字!");
                            return;
                        }
                        dataset = this.SourceDatalistBox.Items[0] as IGxDataset;
                        if (dataset.Type != esriDatasetType.esriDTFeatureClass)
                        {
                            MessageBox.Show("要导入的数据集数组中存在和目标数据集不一致数据集,无法完成导入!");
                            return;
                        }
                        if (!this.method_1(dataset.Dataset))
                        {
                            MessageBox.Show("要导入的数据集数组中存在和目标数据集不一致数据集,无法完成导入!");
                            return;
                        }
                        fields  = (dataset.Dataset as ITable).Fields;
                        checker = new FieldCheckerClass
                        {
                            ValidateWorkspace = this.iworkspace_0
                        };
                        checker.Validate(fields, out error, out fields2);
                        table =
                            (this.iworkspace_0 as IFeatureWorkspace).CreateFeatureClass(
                                this.txtDatasetName.Text.Trim(), fields2, null, null, esriFeatureType.esriFTSimple,
                                "Shape", "") as ITable;
                    }
                    else
                    {
                        if (this.method_0(this.iworkspace_0, esriDatasetType.esriDTTable,
                                          this.txtDatasetName.Text.Trim()))
                        {
                            MessageBox.Show("指定的表名已存在,请输入其它名字!");
                            return;
                        }
                        dataset = this.SourceDatalistBox.Items[0] as IGxDataset;
                        if (dataset.Type != esriDatasetType.esriDTTable)
                        {
                            MessageBox.Show("要导入的数据集数组中存在和目标数据集不一致数据集,无法完成导入!");
                            return;
                        }
                        if (this.method_1(dataset.Dataset))
                        {
                            MessageBox.Show("要导入的数据集数组中存在和目标数据集不一致数据集,无法完成导入!");
                            return;
                        }
                        fields  = (dataset.Dataset as ITable).Fields;
                        checker = new FieldCheckerClass
                        {
                            ValidateWorkspace = this.iworkspace_0
                        };
                        checker.Validate(fields, out error, out fields2);
                        table = (this.iworkspace_0 as IFeatureWorkspace).CreateTable(
                            this.txtDatasetName.Text.Trim(), fields2, null, null, "");
                    }
                    break;
                }
                MessageBox.Show("请选择新建数据集所在工作空间!");
                return;

            case 1:
                if (this.txtOutDataset.Tag != null)
                {
                    if (this.SourceDatalistBox.Items.Count == 0)
                    {
                        MessageBox.Show("请选择要合并的数据集!");
                        return;
                    }
                    IDataset dataset2 = (this.txtOutDataset.Tag as IGxDataset).Dataset;
                    if (this.method_1(dataset2))
                    {
                        MessageBox.Show("要导入的数据集数组中存在和目标数据集不一致数据集,无法完成导入!");
                        return;
                    }
                    table = dataset2 as ITable;
                    break;
                }
                MessageBox.Show("请选择数据导入的目标数据集!");
                return;
            }
            IList       items       = this.SourceDatalistBox.Items;
            Dataloaders dataloaders = new Dataloaders();

            for (int i = 0; i < items.Count; i++)
            {
                this.lblProcess.Text = "开始导入 " + (items[i] as IGxObject).FullName + " ...";
                ITable table2 = (items[i] as IGxObject).InternalObjectName.Open() as ITable;
                dataloaders.LoadData(table2, null, table, 800);
                Marshal.ReleaseComObject(table2);
                table2 = null;
            }
            MessageBox.Show("数据合并完成!");
            base.DialogResult = DialogResult.OK;
            base.Close();
        }
        public void Do()
        {
            Exception exception;

            try
            {
                this.panel1.Visible = true;
                Dataloaders dataloaders = new Dataloaders();
                (dataloaders.Converter as IFeatureProgress_Event).Step +=
                    (new IFeatureProgress_StepEventHandler(this.method_10));
                this.progressBar1.Minimum = 0;
                this.progressBar1.Maximum = this.iarray_0.Count;
                int index = 0;
                while (true)
                {
                    if (index >= this.iarray_0.Count)
                    {
                        break;
                    }
                    this.int_0 = 0;
                    this.progressBar1.Increment(1);
                    IName  name = this.iarray_0.get_Element(index) as IName;
                    string fileNameWithoutExtension = (name as IDatasetName).Name;
                    this.labelFeatureClass.Text = "转换:" + fileNameWithoutExtension;
                    string[] strArray = fileNameWithoutExtension.Split(new char[] { '.' });
                    fileNameWithoutExtension = strArray[strArray.Length - 1];
                    Application.DoEvents();
                    try
                    {
                        IWorkspace workspace;
                        string     str2;
                        int        num2;
                        if (this.iname_1 is IWorkspaceName)
                        {
                            if (((this.iname_1 as IWorkspaceName).Type == esriWorkspaceType.esriLocalDatabaseWorkspace) ||
                                ((this.iname_1 as IWorkspaceName).Type == esriWorkspaceType.esriRemoteDatabaseWorkspace))
                            {
                                workspace = this.iname_1.Open() as IWorkspace;
                                str2      = fileNameWithoutExtension;
                                num2      = 1;
                                while (this.method_1(workspace, (name as IDatasetName).Type, str2.ToLower()))
                                {
                                    str2 = fileNameWithoutExtension + "_" + num2.ToString();
                                    num2++;
                                }
                                fileNameWithoutExtension = str2;
                            }
                            else
                            {
                                string str3 = (this.iname_1 as IWorkspaceName).PathName + @"\" +
                                              fileNameWithoutExtension;
                                str2 = str3 + ".shp";
                                num2 = 1;
                                while (File.Exists(str2))
                                {
                                    str2 = str3 + "_" + num2.ToString() + ".shp";
                                    num2++;
                                }
                                fileNameWithoutExtension = Path.GetFileNameWithoutExtension(str2);
                            }
                        }
                        else if (this.iname_1 is IDatasetName)
                        {
                            workspace = (this.iname_1.Open() as IDataset).Workspace;
                            str2      = fileNameWithoutExtension;
                            for (num2 = 1;
                                 this.method_1(workspace, (name as IDatasetName).Type, str2.ToLower());
                                 num2++)
                            {
                                str2 = fileNameWithoutExtension + "_" + num2.ToString();
                            }
                            fileNameWithoutExtension = str2;
                        }
                        try
                        {
                            if (this.bool_0)
                            {
                                double num3 = double.Parse(this.txtScale.Text.Trim());
                                dataloaders.Scale = num3;
                            }
                        }
                        catch
                        {
                        }
                        dataloaders.ConvertData(name as IDatasetName, this.iname_1, fileNameWithoutExtension, null);
                    }
                    catch (Exception exception1)
                    {
                        exception = exception1;
                        Logger.Current.Error("", exception, "");
                    }
                    index++;
                }
                this.igxObject_1.Refresh();
            }
            catch (Exception exception2)
            {
                exception = exception2;
                Logger.Current.Error("", exception, "");
                MessageBox.Show(exception.Message);
            }
        }