Exemple #1
0
        private void RenameClassObject(IDataset dsCurrent, int standardID)
        {
            if (dsCurrent == null)
            {
                return;
            }

            Hy.Check.Define.StandardLayer standardLayer = LayerReader.GetLayerByName(dsCurrent.Name, standardID);
            //string strAliasName = Hy.Check.Rule.Helper.LayerReader.GetAliasName(dsCurrent.Name, standardID);
            if (standardLayer != null)// dsCurrent.Name != strAliasName)
            {
                ISchemaLock schemaLock = dsCurrent as ISchemaLock;
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);

                IClassSchemaEdit classSchemaEdit = dsCurrent as IClassSchemaEdit;
                if (classSchemaEdit != null)
                {
                    classSchemaEdit.AlterAliasName(standardLayer.AliasName);

                    ITable tCurrent = dsCurrent as ITable;
                    if (tCurrent != null)
                    {
                        List <Hy.Check.Define.StandardField> fields = FieldReader.GetFieldsByLayer(standardLayer.ID);
                        for (int i = 0; i < fields.Count; i++)
                        {
                            if (tCurrent.Fields.FindField(fields[i].Name) > -1)
                            {
                                classSchemaEdit.AlterFieldAliasName(fields[i].Name, fields[i].AliasName);
                            }
                        }
                    }
                }
            }
        }
        //更改要素类中字段别名 函数
        public static bool AlterFieldAliasName(IFeatureClass fc, string FieldName, string NewAliasName)
        {
            bool             rbc    = false;
            ISchemaLock      sLock  = fc as ISchemaLock;
            IClassSchemaEdit csEdit = fc as IClassSchemaEdit;

            if (sLock != null && csEdit != null)
            {
                sLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
                //改变要素类中字段别名
                csEdit.AlterFieldAliasName(FieldName, NewAliasName);
                //释放锁定
                sLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
                rbc = true;
            }
            return(rbc);
        }
Exemple #3
0
        public bool Apply()
        {
            int num;

            if (this.itable_0 != null)
            {
                Exception exception;
                try
                {
                    try
                    {
                        IField field;
                        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));
                            }
                        }
                        for (num = 0; num < this.ifieldsEdit_0.FieldCount; num++)
                        {
                            this.itable_0.AddField(this.ifieldsEdit_0.get_Field(num));
                        }
                        if (!ObjectClassShareData.m_IsShapeFile)
                        {
                            IClassSchemaEdit edit = this.itable_0 as IClassSchemaEdit;
                            num = 0;
                            while (num < this.ifields_0.FieldCount)
                            {
                                field = this.ifields_0.get_Field(num);
                                edit.AlterFieldAliasName(field.Name, field.AliasName);
                                if (((field.Name != "SHAPE.area") && !(field.Name == "SHAPE.len")) &&
                                    (((((field.Type == esriFieldType.esriFieldTypeDouble) ||
                                        (field.Type == esriFieldType.esriFieldTypeInteger)) ||
                                       ((field.Type == esriFieldType.esriFieldTypeSingle) ||
                                        (field.Type == esriFieldType.esriFieldTypeSmallInteger))) ||
                                      (field.Type == esriFieldType.esriFieldTypeDate)) ||
                                     (field.Type == esriFieldType.esriFieldTypeString)))
                                {
                                    edit.AlterDomain(field.Name, field.Domain);
                                }
                                num++;
                            }
                        }
                    }
                    catch (Exception exception1)
                    {
                        exception = exception1;
                        Logger.Current.Error("", exception, "");
                    }
                    this.ifieldsEdit_1.DeleteAllFields();
                    this.ifieldsEdit_0.DeleteAllFields();
                    this.ifields_0 = (this.itable_0.Fields as IClone).Clone() as IFields;
                    this.method_0(this.listView2, this.ifields_0);
                    this.listView2.LockRowCount = this.ifields_0.FieldCount;
                    goto Label_023C;
                }
                catch (Exception exception2)
                {
                    exception = exception2;
                    Logger.Current.Error("", exception, "");
                    MessageBox.Show(exception.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_023C:
            return(true);
        }
        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);
        }