Пример #1
0
 private void method_2(string string_2)
 {
     for (int i = 0; i < this.ifields_0.FieldCount; i++)
     {
         IField key = this.ifields_0.get_Field(i);
         if ((key.Editable &&
              ((((key.Type != esriFieldType.esriFieldTypeOID) &&
                 (key.Type != esriFieldType.esriFieldTypeGeometry)) &&
                (key.Type != esriFieldType.esriFieldTypeRaster)) && (key.Type != esriFieldType.esriFieldTypeBlob))) &&
             this.FieldDomains.ContainsKey(key))
         {
             CodeDomainEx ex = this.FieldDomains[key];
             if (ex != null)
             {
                 CodeDomainManage.AddFieldCodeDoaminMap(string_2, key.Name, ex.DomainID);
             }
             else
             {
                 CodeDomainManage.DeleteCodeDoaminMap(string_2, key.Name);
             }
         }
     }
 }
Пример #2
0
        public bool Apply()
        {
            int num;

            if (!(!this.bool_2 || this.bool_3))
            {
                return(true);
            }
            this.bool_3 = false;
            if (NewObjectClassHelper.m_pObjectClassHelper.ObjectClass != null)
            {
                COMException exception;
                Exception    exception2;
                this.itable_0 = NewObjectClassHelper.m_pObjectClassHelper.ObjectClass as ITable;
                string name = (this.itable_0 as IDataset).Name;
                try
                {
                    IField       field;
                    CodeDomainEx ex;
                    try
                    {
                        for (num = 0; num < this.ifieldsEdit_1.FieldCount; num++)
                        {
                            IFields fields = this.itable_0.Fields;
                            field = this.ifieldsEdit_1.get_Field(num);
                            int index = this.itable_0.FindField(field.Name);
                            if (index != -1)
                            {
                                this.itable_0.DeleteField(fields.get_Field(index));
                                if ((NewObjectClassHelper.m_pObjectClassHelper != null) &&
                                    NewObjectClassHelper.m_pObjectClassHelper.FieldDomains.ContainsKey(field))
                                {
                                    ex = NewObjectClassHelper.m_pObjectClassHelper.FieldDomains[field];
                                    if (ex != null)
                                    {
                                        CodeDomainManage.DeleteCodeDoaminMap(name, field.Name);
                                    }
                                }
                            }
                        }
                    }
                    catch (COMException exception1)
                    {
                        exception = exception1;
                        Logger.Current.Error("", exception, "");
                        MessageBox.Show(exception.Message);
                        return(false);
                    }
                    catch (Exception exception3)
                    {
                        exception2 = exception3;
                        Logger.Current.Error("", exception2, "");
                    }
                    try
                    {
                        for (num = 0; num < this.ifieldsEdit_0.FieldCount; num++)
                        {
                            IField key = this.ifieldsEdit_0.get_Field(num);
                            this.itable_0.AddField(this.ifieldsEdit_0.get_Field(num));
                            if ((NewObjectClassHelper.m_pObjectClassHelper != null) &&
                                NewObjectClassHelper.m_pObjectClassHelper.FieldDomains.ContainsKey(key))
                            {
                                ex = NewObjectClassHelper.m_pObjectClassHelper.FieldDomains[key];
                                if (ex != null)
                                {
                                    CodeDomainManage.AddFieldCodeDoaminMap(name, key.Name, ex.DomainID);
                                }
                            }
                        }
                    }
                    catch (COMException exception4)
                    {
                        exception = exception4;
                        if (exception.ErrorCode == -2147220969)
                        {
                            MessageBox.Show("不是对象的所有者,无法修改对象!");
                        }
                        else if (exception.ErrorCode == -2147219887)
                        {
                            MessageBox.Show("无法添加字段!");
                        }
                        else
                        {
                            Logger.Current.Error("", exception, "");
                            MessageBox.Show(exception.Message);
                        }
                    }
                    catch (Exception exception5)
                    {
                        exception2 = exception5;
                        Logger.Current.Error("", exception2, "");
                    }
                    if (!ObjectClassShareData.m_IsShapeFile)
                    {
                        IClassSchemaEdit edit = this.itable_0 as IClassSchemaEdit;
                        num = 0;
                        while (num < this.ilist_0.Count)
                        {
                            field = this.ilist_0[num];
                            try
                            {
                                if (((FieldChangeType)this.ilist_1[num]) == FieldChangeType.FCTAlias)
                                {
                                    edit.AlterFieldAliasName(field.Name, field.AliasName);
                                }
                                else if (((FieldChangeType)this.ilist_1[num]) == FieldChangeType.FCTDomain)
                                {
                                    edit.AlterDomain(field.Name, field.Domain);
                                    if ((NewObjectClassHelper.m_pObjectClassHelper != null) &&
                                        NewObjectClassHelper.m_pObjectClassHelper.FieldDomains.ContainsKey(field))
                                    {
                                        ex = NewObjectClassHelper.m_pObjectClassHelper.FieldDomains[field];
                                        if (ex != null)
                                        {
                                            CodeDomainManage.AddFieldCodeDoaminMap(name, field.Name, ex.DomainID);
                                        }
                                        else
                                        {
                                            CodeDomainManage.DeleteCodeDoaminMap(name, field.Name);
                                        }
                                    }
                                }
                            }
                            catch (COMException exception6)
                            {
                                exception = exception6;
                                (field as IFieldEdit).AliasName_2 = field.Name;
                                if (exception.ErrorCode == -2147220969)
                                {
                                    MessageBox.Show("不是对象的所有者,无法修改字段[" + field.Name + "]!");
                                }
                                else if (exception.ErrorCode == -2147219887)
                                {
                                    MessageBox.Show("无法修改字段[" + field.Name + "]!");
                                }
                                else
                                {
                                    Logger.Current.Error("", exception, "");
                                    MessageBox.Show(exception.Message);
                                }
                                return(false);
                            }
                            catch (Exception exception7)
                            {
                                exception2 = exception7;
                                Logger.Current.Error("", exception2, "");
                            }
                            num++;
                        }
                    }
                    if (!ObjectClassShareData.m_IsShapeFile)
                    {
                        (this.itable_0 as ISchemaLock).ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
                    }
                    this.ifieldsEdit_1.DeleteAllFields();
                    this.ifieldsEdit_0.DeleteAllFields();
                    this.ilist_0.Clear();
                    this.ilist_1.Clear();
                    this.ifields_0 = (this.itable_0.Fields as IClone).Clone() as IFields;
                    this.method_2(this.listView2, this.ifields_0);
                    this.listView2.LockRowCount = this.ifields_0.FieldCount;
                    goto Label_0512;
                }
                catch (COMException exception8)
                {
                    exception = exception8;
                    if (exception.ErrorCode == -2147220969)
                    {
                        MessageBox.Show("不是对象的所有者,无法修改对象!");
                    }
                    else
                    {
                        Logger.Current.Error("", exception, "");
                        MessageBox.Show(exception.Message);
                    }
                    return(false);
                }
                catch (Exception exception9)
                {
                    exception2 = exception9;
                    Logger.Current.Error("", exception2, "");
                    MessageBox.Show(exception2.Message);
                    return(false);
                }
            }
            if (this.ifields_0 != null)
            {
                for (num = 0; num < this.ifieldsEdit_0.FieldCount; num++)
                {
                    (this.ifields_0 as IFieldsEdit).AddField(this.ifieldsEdit_0.get_Field(num));
                }
            }
Label_0512:
            return(true);
        }