Example #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);
            }
        }
Example #2
0
 public override void OnClick()
 {
     if (this.Enabled)
     {
         try
         {
             IVersionedObject3 versionedObject =
                 (((IGxSelection)_context.GxSelection).FirstObject as IGxDataset).Dataset as IVersionedObject3;
             bool flag;
             bool flag2;
             versionedObject.GetVersionRegistrationInfo(out flag, out flag2);
             versionedObject.RegisterAsVersioned(false);
             if (flag)
             {
                 versionedObject.UnRegisterAsVersioned3(false);
             }
         }
         catch (Exception ex2)
         {
             COMException ex = ex2 as COMException;
             if (ex != null && ex.ErrorCode == -2147467259)
             {
                 System.Windows.Forms.MessageBox.Show("表[" +
                                                      (((IGxSelection)_context.GxSelection).FirstObject as
                                                       IGxDataset).DatasetName + "]正在使用");
             }
             // CErrorLog.writeErrorLog(this, ex2, "");
         }
     }
 }
Example #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);
        }