Example #1
0
        public bool _tab2(string string_0, IFeatureWorkspace ifeatureWorkspace_0)
        {
            bool          flag;
            bool          flag1;
            IFeatureClass featureClass  = null;
            IFeatureClass featureClass1 = null;
            IFeatureClass featureClass2 = null;
            IFeatureClass featureClass3 = null;
            IFeatureClass featureClass4 = null;
            string        string0       = string_0;

            if (File.Exists(string0))
            {
                IntPtr intPtr = TabRead._mitab_c_open(string0);
                if (intPtr.ToInt32() != 0)
                {
                    try
                    {
                        try
                        {
                            int num = TabRead._mitab_c_next_feature_id(intPtr, -1);
                            this.FeatureClass = null;
                            while (num != -1)
                            {
                                IntPtr intPtr1 = TabRead._mitab_c_read_feature(intPtr, num);
                                int    num1    = TabRead._mitab_c_get_type(intPtr1);
                                switch (num1)
                                {
                                case 1:
                                case 2:
                                case 3:
                                {
                                    if (featureClass == null)
                                    {
                                        featureClass = this.method_1(string0, num1, intPtr, ifeatureWorkspace_0,
                                                                     out flag1);
                                        if (flag1)
                                        {
                                            flag = false;
                                            return(flag);
                                        }
                                    }
                                    this.FeatureClass = featureClass;
                                    goto case 9;
                                }

                                case 4:
                                {
                                    if (featureClass4 == null)
                                    {
                                        featureClass4 = this.method_1(string0, num1, intPtr, ifeatureWorkspace_0,
                                                                      out flag1);
                                        if (flag1)
                                        {
                                            flag = false;
                                            return(flag);
                                        }
                                    }
                                    this.FeatureClass = featureClass4;
                                    goto case 9;
                                }

                                case 5:
                                case 6:
                                {
                                    if (featureClass2 == null)
                                    {
                                        featureClass2 = this.method_1(string0, num1, intPtr, ifeatureWorkspace_0,
                                                                      out flag1);
                                        if (flag1)
                                        {
                                            flag = false;
                                            return(flag);
                                        }
                                    }
                                    this.FeatureClass = featureClass2;
                                    goto case 9;
                                }

                                case 7:
                                {
                                    if (featureClass3 == null)
                                    {
                                        featureClass3 = this.method_1(string0, num1, intPtr, ifeatureWorkspace_0,
                                                                      out flag1);
                                        if (flag1)
                                        {
                                            flag = false;
                                            return(flag);
                                        }
                                    }
                                    this.FeatureClass = featureClass3;
                                    goto case 9;
                                }

                                case 8:
                                case 9:
                                {
                                    if (this.FeatureClass != null)
                                    {
                                        try
                                        {
                                            IFeature  feature  = this.FeatureClass.CreateFeature();
                                            IGeometry geometry = this.CreateGeometry(num1, intPtr1);
                                            if (geometry is ITopologicalOperator)
                                            {
                                                (geometry as ITopologicalOperator).Simplify();
                                            }
                                            try
                                            {
                                                this.method_2(intPtr1, feature);
                                            }
                                            catch (Exception exception)
                                            {
                                                Logger.Current.Error("", exception, "");
                                            }
                                            int num2 = TabRead._mitab_c_get_field_count(intPtr);
                                            feature.Fields.FindField("Shape");
                                            for (int i = 0; i < num2; i++)
                                            {
                                                string str  = TabRead._mitab_c_get_field_name(intPtr, i);
                                                int    num3 = TabRead._mitab_c_get_field_type(intPtr, i);
                                                string str1 = TabRead._mitab_c_get_field_as_string(intPtr1, i);
                                                int    num4 = feature.Fields.FindField(str);
                                                if (num4 == -1)
                                                {
                                                    try
                                                    {
                                                        if (num3 != 6)
                                                        {
                                                            feature.Value[num4] = str1;
                                                        }
                                                        else if (str1.Length == 8)
                                                        {
                                                            str1 = str1.Insert(6, "-");
                                                            str1 = str1.Insert(4, "-");
                                                            feature.Value[num4] = DateTime.Parse(str1);
                                                        }
                                                    }
                                                    catch
                                                    {
                                                    }
                                                }
                                                feature.Shape = geometry;
                                            }
                                            feature.Store();
                                        }
                                        catch (Exception exception1)
                                        {
                                            Logger.Current.Error("", exception1, "");
                                        }
                                        if (this.ifeatureProgress_StepEventHandler_0 != null)
                                        {
                                            this.ifeatureProgress_StepEventHandler_0();
                                        }
                                    }
                                    TabRead._mitab_c_destroy_feature(intPtr1);
                                    num = TabRead._mitab_c_next_feature_id(intPtr, num);
                                    continue;
                                }

                                case 10:
                                {
                                    if (featureClass1 == null)
                                    {
                                        featureClass1 = this.method_1(string0, num1, intPtr, ifeatureWorkspace_0,
                                                                      out flag1);
                                        if (flag1)
                                        {
                                            flag = false;
                                            return(flag);
                                        }
                                    }
                                    this.FeatureClass = featureClass1;
                                    goto case 9;
                                }

                                default:
                                {
                                    goto case 9;
                                }
                                }
                            }
                        }
                        catch (Exception exception2)
                        {
                            Logger.Current.Error("", exception2, "");
                        }
                    }
                    finally
                    {
                    }
                    TabRead._mitab_c_close(intPtr);
                    flag = true;
                }
                else
                {
                    MessageBox.Show(string.Concat("无法打开 -", string0, "- 文件"));
                    flag = false;
                }
            }
            else
            {
                flag = false;
            }
            return(flag);
        }