Exemplo n.º 1
0
        public static void SaveToFfo <T>(Task task, T adObject, TenantSettingSyncLogType logType, string oldName = null) where T : ADObject, new()
        {
            bool flag = false;

            try
            {
                if (!DatacenterRegistry.IsForefrontForOffice() && !task.CurrentOrganizationId.Equals(OrganizationId.ForestWideOrgId) && DatacenterRegistry.IsDualWriteAllowed() && adObject != null)
                {
                    flag = true;
                    if (adObject.m_Session != null)
                    {
                        ComparisonFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, adObject.Name);
                        T t = adObject.m_Session.Find <T>(null, QueryScope.SubTree, filter, null, 0).FirstOrDefault <T>();
                        if (t != null)
                        {
                            adObject = t;
                        }
                    }
                    FfoDualWriter.FixTenantId(adObject);
                    FfoDualWriter.HandleRenaming(adObject, oldName);
                    FfoDualWriter.FfoDataProvider.Save(adObject);
                }
            }
            catch (Exception ex)
            {
                if (flag)
                {
                    FfoDualWriter.LogToFile <T>(adObject, logType, oldName);
                }
                FfoDualWriter.LogException(ex);
            }
        }
Exemplo n.º 2
0
 private static void LogToFile <T>(T adObject, TenantSettingSyncLogType logType, string oldName) where T : ADObject, new()
 {
     try
     {
         if (FfoDualWriter.HandleRenaming(adObject, oldName))
         {
             TenantSettingSyncLogGenerator.Instance.LogChangesForSave(adObject, logType, new Guid?(adObject.OrganizationalUnitRoot.ObjectGuid), null, new List <KeyValuePair <string, object> >
             {
                 new KeyValuePair <string, object>(FfoDualWriter.oldNameProp.Name, adObject[FfoDualWriter.oldNameProp])
             });
         }
         else
         {
             TenantSettingSyncLogGenerator.Instance.LogChangesForSave(adObject, logType, new Guid?(adObject.OrganizationalUnitRoot.ObjectGuid), null, null);
         }
     }
     catch (Exception ex)
     {
         FfoDualWriter.LogException(ex);
     }
 }
Exemplo n.º 3
0
        public static void DeleteFromFfo <T>(Task task, T adObject, TenantSettingSyncLogType logType) where T : ADObject, new()
        {
            bool flag = false;

            try
            {
                if (!DatacenterRegistry.IsForefrontForOffice() && !task.CurrentOrganizationId.Equals(OrganizationId.ForestWideOrgId) && DatacenterRegistry.IsDualWriteAllowed())
                {
                    flag = true;
                    FfoDualWriter.FixTenantId(adObject);
                    TenantSettingSyncLogGenerator.Instance.LogChangesForDelete(adObject, logType, new Guid?(adObject.OrganizationalUnitRoot.ObjectGuid));
                    FfoDualWriter.FfoDataProvider.Delete(adObject);
                }
            }
            catch (Exception ex)
            {
                if (flag)
                {
                    FfoDualWriter.LogToFile <T>(adObject, logType, null);
                }
                FfoDualWriter.LogException(ex);
            }
        }