Exemplo n.º 1
0
        public void EnableArchivingOnClass(ref IFeatureClass ifeatureClass_0)
        {
            bool flag  = false;
            bool flag2 = false;
            IVersionedObject3 versionedObject = (IVersionedObject3)ifeatureClass_0;

            versionedObject.GetVersionRegistrationInfo(out flag, out flag2);
            if (!flag)
            {
                versionedObject.RegisterAsVersioned3(false);
            }
            else if (flag2)
            {
                versionedObject.UnRegisterAsVersioned3(false);
                versionedObject.RegisterAsVersioned3(false);
            }
            IArchivableObject archivableObject = (IArchivableObject)versionedObject;

            if (archivableObject.IsArchiving)
            {
                archivableObject.DisableArchiving(true, true);
                archivableObject.EnableArchiving(null, null, true);
            }
            else
            {
                archivableObject.EnableArchiving(null, null, true);
            }
        }
Exemplo n.º 2
0
        public static bool Register(IFeatureClass ifeatureClass_0, string string_0)
        {
            bool result;

            if (ZDRegister.IsZDFeatureClass(ifeatureClass_0))
            {
                result = false;
            }
            else
            {
                string[] array = (ifeatureClass_0 as IDataset).Name.Split(new char[]
                {
                    '.'
                });
                ZDRegisterTable   zDRegisterTable  = new ZDRegisterTable();
                ITable            table            = AppConfigInfo.OpenTable("ZDInfos");
                IFeatureWorkspace featureWorkspace = (ifeatureClass_0 as IDataset).Workspace as IFeatureWorkspace;
                string            finalName        = WorkspaceOperator.GetFinalName2(featureWorkspace as IWorkspace,
                                                                                     esriDatasetType.esriDTFeatureClass, "", array[array.Length - 1], "_His");
                IRow row = table.CreateRow();
                RowOperator.SetFieldValue(row, zDRegisterTable.FeatureClassNameField, array[array.Length - 1]);
                RowOperator.SetFieldValue(row, zDRegisterTable.ZDBHFieldName, string_0);
                RowOperator.SetFieldValue(row, zDRegisterTable.RegisterDateFieldName, System.DateTime.Now);
                RowOperator.SetFieldValue(row, zDRegisterTable.HistoryFeatureClassName, finalName);
                string workspaceConnectInfo =
                    WorkspaceOperator.GetWorkspaceConnectInfo((ifeatureClass_0 as IDataset).Workspace);
                RowOperator.SetFieldValue(row, zDRegisterTable.GDBConnectInfoName, workspaceConnectInfo);
                RowOperator.SetFieldValue(row, zDRegisterTable.GuidName, System.Guid.NewGuid().ToString());
                row.Store();
                (ifeatureClass_0 as IDataset).Name.Split(new char[]
                {
                    '.'
                });
                IFields fields = (ifeatureClass_0.Fields as IClone).Clone() as IFields;
                IField  field  = new ESRI.ArcGIS.Geodatabase.Field();
                (field as IFieldEdit).Name_2      = "OriginOID_";
                (field as IFieldEdit).AliasName_2 = "原始宗地编号";
                (field as IFieldEdit).Type_2      = esriFieldType.esriFieldTypeInteger;
                (fields as IFieldsEdit).AddField(field);
                IFeatureClass featureClass = featureWorkspace.CreateFeatureClass(finalName, fields, null, null,
                                                                                 esriFeatureType.esriFTSimple, "shape", "");
                if ((featureWorkspace as IWorkspace).Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                {
                    IVersionedObject3 versionedObject = featureClass as IVersionedObject3;
                    if (versionedObject != null)
                    {
                        versionedObject.RegisterAsVersioned3(false);
                    }
                }
                result = true;
            }
            return(result);
        }
Exemplo n.º 3
0
        public static bool EnableAchive(string name, IFeatureWorkspace featureWorkspace)
        {
            IVersionedObject3 pVersionedObject  = null;
            IArchivableObject pArchivableObject = null;
            bool bRegistered                    = false;
            bool bMovingEditsToBase             = false;
            IFeatureWorkspace pFeatureWorkspace = featureWorkspace;

            try
            {
                pVersionedObject = pFeatureWorkspace.OpenFeatureClass(name) as IVersionedObject3;
                pVersionedObject.GetVersionRegistrationInfo(out bRegistered, out bMovingEditsToBase);

                //如果数据没有注册为版本,则进行注册
                if (!bRegistered)
                {
                    pVersionedObject.RegisterAsVersioned3(false);
                }
                else
                {
                    if (bMovingEditsToBase)
                    {
                        pVersionedObject.UnRegisterAsVersioned3(false);
                        pVersionedObject.RegisterAsVersioned3(false);
                    }
                }
                //获取归档对象、判断数据是否归档
                pArchivableObject = pVersionedObject as IArchivableObject;
                if (!pArchivableObject.IsArchiving)
                {
                    pArchivableObject.EnableArchiving(null, null, false);
                }
                return(true);
            }
            catch (Exception)
            {
            }
            return(false);
        }
Exemplo n.º 4
0
        public void CreateTable(IFeatureWorkspace ifeatureWorkspace_0)
        {
            ZDRegisterTableCreate zDRegisterTableCreate = new ZDRegisterTableCreate();

            zDRegisterTableCreate.CreateTable(ifeatureWorkspace_0);
            ZDHistoryTableCreate zDHistoryTableCreate = new ZDHistoryTableCreate();
            ITable table = zDHistoryTableCreate.CreateTable(ifeatureWorkspace_0);

            try
            {
                if ((ifeatureWorkspace_0 as IWorkspace).Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                {
                    IVersionedObject3 versionedObject = table as IVersionedObject3;
                    if (versionedObject != null)
                    {
                        versionedObject.RegisterAsVersioned3(false);
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 5
0
        public override void OnClick()
        {
            frmRegisterAsVersion frmRegisterAsVersion = new frmRegisterAsVersion();

            if (frmRegisterAsVersion.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    IVersionedObject3 versionedObject =
                        (((IGxSelection)_context.GxSelection).FirstObject as IGxDataset).Dataset as IVersionedObject3;
                    versionedObject.RegisterAsVersioned3(frmRegisterAsVersion.EditToBase);
                }
                catch (Exception ex2)
                {
                    COMException ex = ex2 as COMException;
                    if (ex != null)
                    {
                        if (ex.ErrorCode == -2147467259)
                        {
                            System.Windows.Forms.MessageBox.Show("表[" +
                                                                 (((IGxSelection)_context.GxSelection).FirstObject as
                                                                  IGxDataset).DatasetName + "]正在使用");
                        }
                        else
                        {
                            System.Windows.Forms.MessageBox.Show(ex2.Message);
                        }
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show(ex2.Message);
                    }
                    // CErrorLog.writeErrorLog(this, ex2, "");
                }
            }
        }