Beispiel #1
0
    //同步
    ABObject LoadAsset(Type t, string abName, string[] assetNames)
    {
        //abName = makeFullPath(abName);
        ABObject result = new ABObject();

        result.m_Id = --m_SyncLoadIndex;
        AssetBundleInfo abi = GetLoadedAssetBundle(abName);

        if (abi == null)
        {
            abi = OnLoadAssetBundle(abName);
        }
        //已经加载了
        AssetBundle ab = abi.m_AssetBundle;

        abi.m_ReferencedCount++;
        for (int j = 0; j < assetNames.Length; j++)
        {
            string             assetPath = assetNames[j];
            UnityEngine.Object obj       = ab.LoadAsset(assetPath);
#if UNITY_EDITOR
            if (obj is GameObject)
            {
                RecoveryShader((GameObject)obj);
            }
#endif
            result.m_UObjectList.Add(obj);
        }
        return(result);
    }
        private static string GetABProperty(ABObject addressBookObject, string airSyncPropertyName)
        {
            switch (airSyncPropertyName)
            {
            case "Alias":
                return(addressBookObject.Alias);

            case "DisplayName":
                return(addressBookObject.DisplayName);

            case "EmailAddress":
                return(addressBookObject.EmailAddress);

            case "Company":
            case "FirstName":
            case "HomePhone":
            case "LastName":
            case "MobilePhone":
            case "Office":
            case "Phone":
            case "Title":
                return(string.Empty);
            }
            throw new InvalidOperationException("Unexpected AirSync property name: " + airSyncPropertyName);
        }
Beispiel #3
0
        // Token: 0x06000370 RID: 880 RVA: 0x0001410C File Offset: 0x0001230C
        private AnrManager.LookupState GetNamesByAnrFromAD(string name, List <ResolvedRecipient> recipients)
        {
            IList <ABObject>            addressBookObjects          = null;
            OperationRetryManagerResult operationRetryManagerResult = AnrManager.retryManager.TryRun(delegate
            {
                addressBookObjects = this.GetAddressBookSession().FindByANR(name, 1000);
            });

            if (operationRetryManagerResult.Succeeded)
            {
                using (IEnumerator <ABObject> enumerator = addressBookObjects.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ABObject abobject = enumerator.Current;
                        if (abobject.CanEmail)
                        {
                            ResolvedRecipient resolvedRecipient = new ResolvedRecipient(new RecipientAddress
                            {
                                AddressOrigin  = AddressOrigin.Directory,
                                DisplayName    = abobject.DisplayName,
                                RoutingAddress = abobject.LegacyExchangeDN,
                                RoutingType    = "EX",
                                SmtpAddress    = abobject.EmailAddress
                            });
                            ABContact abcontact = abobject as ABContact;
                            if (abcontact != null)
                            {
                                resolvedRecipient.Picture = abcontact.Picture;
                            }
                            recipients.Add(resolvedRecipient);
                        }
                    }
                    goto IL_F7;
                }
            }
            AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.RequestTracer, 0, "AnrManager.GetNamesByAnrFromAD(): Exception thrown by FindByANR: {0}", operationRetryManagerResult.Exception);
IL_F7:
            switch (recipients.Count)
            {
            case 0:
                return(AnrManager.LookupState.FoundNone);

            case 1:
                return(AnrManager.LookupState.FoundExact);

            default:
                return(AnrManager.LookupState.FoundMany);
            }
        }
Beispiel #4
0
    //同步
    public ABObject LoadPrefab(Type t, string abName, string assetName)
    {
        abName = abName.ToLower();
        ABObject list = LoadAsset(t, abName, new string[] { assetName });

        if (list != null)
        {
            return(list);
        }
        else
        {
            return(null);
        }
    }
 public void BuildResponse(XmlElement responseNode)
 {
     try
     {
         int num = 0;
         this.numberResponses = 0;
         XmlNode xmlNode = responseNode.OwnerDocument.CreateElement("Status", "Search:");
         responseNode.AppendChild(xmlNode);
         xmlNode.InnerText = 1.ToString(CultureInfo.InvariantCulture);
         int num2 = this.minRange;
         while (this.addressBookObjects != null && num2 <= this.maxRange && num2 < this.addressBookObjects.Count)
         {
             ABObject abobject = this.addressBookObjects[num2];
             if (abobject != null)
             {
                 ABContact abcontact = abobject as ABContact;
                 XmlNode   xmlNode2  = responseNode.OwnerDocument.CreateElement("Result", "Search:");
                 XmlNode   xmlNode3  = responseNode.OwnerDocument.CreateElement("Properties", "Search:");
                 xmlNode2.AppendChild(xmlNode3);
                 for (int i = 0; i < GalSearchProvider.schema.Length; i++)
                 {
                     string abproperty;
                     if (abcontact == null)
                     {
                         abproperty = GalSearchProvider.GetABProperty(abobject, GalSearchProvider.schema[i]);
                     }
                     else
                     {
                         abproperty = GalSearchProvider.GetABProperty(abcontact, GalSearchProvider.schema[i]);
                     }
                     if (!string.IsNullOrEmpty(abproperty))
                     {
                         XmlNode xmlNode4 = responseNode.OwnerDocument.CreateElement(GalSearchProvider.schema[i], "Gal:");
                         xmlNode4.InnerText = abproperty;
                         xmlNode3.AppendChild(xmlNode4);
                     }
                 }
                 if (this.pictureOptions != null && abcontact != null)
                 {
                     StatusCode statusCode = StatusCode.Success;
                     byte[]     array      = null;
                     if (this.user.Features.IsEnabled(EasFeature.HDPhotos) && this.user.Context.Request.Version >= 160)
                     {
                         array = this.photoRetriever.EndGetThumbnailPhotoFromMailbox(abcontact.EmailAddress, GlobalSettings.MaxRequestExecutionTime - ExDateTime.Now.Subtract(Command.CurrentCommand.Context.RequestTime), this.pictureOptions.PhotoSize);
                         AirSyncDiagnostics.TraceDebug <bool, int>(ExTraceGlobals.RequestsTracer, this, "GalSearch Requesting user's HD picture. WasRetrived:{0}, size:{1}", array != null, (array == null) ? 0 : array.Length);
                     }
                     if (statusCode != StatusCode.Success || array == null)
                     {
                         AirSyncDiagnostics.TraceDebug <bool, int, StatusCode>(ExTraceGlobals.RequestsTracer, this, "User's HD photo is either null or was not requested, Using contact's picture from AD. :FeatureEnabled:{0}, RequestVersion:{1}, statusCode:{2}", this.user.Features.IsEnabled(EasFeature.HDPhotos), this.user.Context.Request.Version, statusCode);
                         array = abcontact.Picture;
                     }
                     bool    flag;
                     XmlNode newChild = this.pictureOptions.CreatePictureNode(responseNode.OwnerDocument, "Gal:", array, num >= this.pictureOptions.MaxPictures, out flag);
                     xmlNode3.AppendChild(newChild);
                     if (flag)
                     {
                         num++;
                     }
                 }
                 responseNode.AppendChild(xmlNode2);
                 this.numberResponses++;
             }
             num2++;
         }
         if (this.numberResponses == 0)
         {
             XmlNode newChild2 = responseNode.OwnerDocument.CreateElement("Result", "Search:");
             responseNode.AppendChild(newChild2);
         }
         else if (this.rangeSpecified)
         {
             XmlNode xmlNode5 = responseNode.OwnerDocument.CreateElement("Range", "Search:");
             XmlNode xmlNode6 = responseNode.OwnerDocument.CreateElement("Total", "Search:");
             xmlNode5.InnerText = this.minRange.ToString(CultureInfo.InvariantCulture) + "-" + (this.minRange + this.numberResponses - 1).ToString(CultureInfo.InvariantCulture);
             responseNode.AppendChild(xmlNode5);
             AirSyncDiagnostics.Assert(this.addressBookObjects.Count <= GlobalSettings.MaxGALSearchResults);
             xmlNode6.InnerText = this.addressBookObjects.Count.ToString(CultureInfo.InvariantCulture);
             responseNode.AppendChild(xmlNode6);
         }
     }
     finally
     {
         if (this.photoRetriever != null)
         {
             this.photoRetriever.Dispose();
             this.photoRetriever = null;
         }
     }
 }
        public void Execute()
        {
            Command.CurrentCommand.ProtocolLogger.SetValue(ProtocolLoggerData.SearchQueryLength, this.searchQuery.Length);
            if (this.user.IsConsumerOrganizationUser)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "GalSearch command not supported for consumer users");
                return;
            }
            if (this.minRange >= GlobalSettings.MaxGALSearchResults)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "GalSearch command min range specified is outside our configured maximum. No results will be returned");
                return;
            }
            UnicodeCategory unicodeCategory = char.GetUnicodeCategory(this.searchQuery, 0);

            if (this.searchQuery.Length < GlobalSettings.MinGALSearchLength && unicodeCategory != UnicodeCategory.OtherLetter)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "GalSearch search string is shorter than MinGALSearchLength. No results will be returned");
                Command.CurrentCommand.ProtocolLogger.SetValueIfNotSet(ProtocolLoggerData.Error, "SearchStringTooShort");
                return;
            }
            OperationRetryManagerResult operationRetryManagerResult = GalSearchProvider.retryManager.TryRun(delegate
            {
                IABSessionSettings sessionSettings = ABDiscoveryManager.GetSessionSettings(this.user.ExchangePrincipal, new int?(this.lcid), null, GlobalSettings.SyncLog, this.user.ClientSecurityContextWrapper.ClientSecurityContext);
                using (ABSession absession = ADABSession.Create(sessionSettings))
                {
                    this.addressBookObjects = absession.FindByANR(this.searchQuery, GlobalSettings.MaxGALSearchResults);
                }
            });

            if (operationRetryManagerResult.Succeeded)
            {
                if (this.pictureOptions != null && this.user.Features.IsEnabled(EasFeature.HDPhotos) && this.user.Context.Request.Version >= 160)
                {
                    this.photoRetriever = new AirSyncPhotoRetriever(this.user.Context);
                    List <string> list = new List <string>();
                    int           num  = this.minRange;
                    while (this.addressBookObjects != null && num <= this.maxRange && num < this.addressBookObjects.Count)
                    {
                        ABObject abobject = this.addressBookObjects[num];
                        if (abobject == null)
                        {
                            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ABSession.FindByAnr returned null  addresBookObject. Continue.");
                        }
                        else
                        {
                            ABContact abcontact = abobject as ABContact;
                            if (abcontact == null)
                            {
                                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ABSession.FindByAnr returned object that is not a \"ABContact\". Continue.");
                            }
                            else
                            {
                                list.Add(abcontact.EmailAddress);
                            }
                        }
                        num++;
                    }
                    this.photoRetriever.BeginGetThumbnailPhotoFromMailbox(list, this.pictureOptions.PhotoSize);
                }
                return;
            }
            if (operationRetryManagerResult.Exception is ABSubscriptionDisabledException)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, operationRetryManagerResult.Exception, false)
                      {
                          ErrorStringForProtocolLogger = "ABSubsDisabled"
                      };
            }
            if (operationRetryManagerResult.Exception is DataValidationException)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, operationRetryManagerResult.Exception, false)
                      {
                          ErrorStringForProtocolLogger = "BadADDataInGalSearch"
                      };
            }
            if (operationRetryManagerResult.Exception is DataSourceOperationException)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, operationRetryManagerResult.Exception, false)
                      {
                          ErrorStringForProtocolLogger = "BadADDataSource"
                      };
            }
            if (operationRetryManagerResult.Exception != null)
            {
                throw operationRetryManagerResult.Exception;
            }
            throw new InvalidOperationException("GalSearch failed with result code: " + operationRetryManagerResult.ResultCode);
        }
Beispiel #7
0
        // Token: 0x0600036E RID: 878 RVA: 0x00013D5C File Offset: 0x00011F5C
        private RecipientAddress ConstructStoreRecipientAddress(Participant participant, string displayName, StoreObjectId storeId)
        {
            RecipientAddress recipientAddress = new RecipientAddress();

            recipientAddress.DisplayName   = displayName;
            recipientAddress.AddressOrigin = AddressOrigin.Store;
            recipientAddress.RoutingType   = participant.RoutingType;
            if (!string.IsNullOrEmpty(participant.EmailAddress))
            {
                recipientAddress.RoutingAddress = participant.EmailAddress;
                if (string.Equals(recipientAddress.RoutingType, "EX", StringComparison.OrdinalIgnoreCase))
                {
                    string text = participant.TryGetProperty(ParticipantSchema.SmtpAddress) as string;
                    if (string.IsNullOrEmpty(text))
                    {
                        ABObject recipient = null;
                        OperationRetryManagerResult operationRetryManagerResult = AnrManager.retryManager.TryRun(delegate
                        {
                            recipient = this.GetAddressBookSession().FindByLegacyExchangeDN(recipientAddress.RoutingAddress);
                        });
                        if (!operationRetryManagerResult.Succeeded)
                        {
                            if (operationRetryManagerResult.Exception is ABProviderLoadException)
                            {
                                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, EASServerStrings.UnableToLoadAddressBookProvider, operationRetryManagerResult.Exception, true)
                                      {
                                          ErrorStringForProtocolLogger = "ABProviderNotFound"
                                      };
                            }
                            if (operationRetryManagerResult.Exception is ABSubscriptionDisabledException)
                            {
                                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, operationRetryManagerResult.Exception, false)
                                      {
                                          ErrorStringForProtocolLogger = "ABSubscriptionDisabled"
                                      };
                            }
                            if (operationRetryManagerResult.Exception is DataValidationException)
                            {
                                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, operationRetryManagerResult.Exception, false)
                                      {
                                          ErrorStringForProtocolLogger = "AnrError:ADDataInvalid"
                                      };
                            }
                            if (operationRetryManagerResult.Exception is ABOperationException)
                            {
                                ABOperationException ex = (ABOperationException)operationRetryManagerResult.Exception;
                                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, operationRetryManagerResult.Exception, false)
                                      {
                                          ErrorStringForProtocolLogger = "AnrError:ABOperationException"
                                      };
                            }
                            if (operationRetryManagerResult.Exception is ABTransientException)
                            {
                                AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestTracer, null, "AnrManager.ConstructStoreRecipientAddress(): ABTransientException was thrown by FindByLegacyExchangeDN: {0}", operationRetryManagerResult.Exception.Message);
                            }
                        }
                        if (recipient == null)
                        {
                            return(null);
                        }
                        recipientAddress.SmtpAddress = recipient.EmailAddress;
                    }
                    else
                    {
                        recipientAddress.SmtpAddress = text;
                    }
                }
                else
                {
                    if (!string.Equals(recipientAddress.RoutingType, "SMTP", StringComparison.OrdinalIgnoreCase))
                    {
                        return(null);
                    }
                    recipientAddress.SmtpAddress = recipientAddress.RoutingAddress;
                }
            }
            recipientAddress.StoreObjectId = storeId;
            return(recipientAddress);
        }
Beispiel #8
0
    IEnumerator OnLoadAsset(Type t, string abName)
    {
        //为了确保异步,强制添加一个返回
        yield return(null);

        List <LoadAssetRequest> list = null;

        AssetBundleInfo bundleInfo = GetLoadedAssetBundle(abName);

        if (bundleInfo == null)
        {
            yield return(StartCoroutine(OnLoadAssetBundle(abName, t)));

            bundleInfo = GetLoadedAssetBundle(abName);

            if (bundleInfo == null)
            {
                //加载资源失败了
                if (m_LoadRequests.TryGetValue(abName, out list))
                {
                    if (list != null)
                    {
                        int count = list.Count;
                        for (int i = 0; i < count; ++i)
                        {
                            LoadAssetRequest r = list[i];
                            if (r.sharpFunc != null)
                            {
                                //r.sharpFunc(null);
                                //r.sharpFunc = null;
                                r.Error   = true;
                                r.ObjList = null;
                                m_CallBackList.Add(list[i]);
                                //m_CallBackList.Sort(OnSortCallList);
                            }
                        }
                    }
                    m_LoadRequests.Remove(abName);
                }
                Debug.LogError("OnLoadAsset--->>>" + abName);
                yield break;
            }
        }

        //这个位置的异常处理可能有问题,没有合理通知逻辑层资源有问题。
        if (!m_LoadRequests.TryGetValue(abName, out list))
        {
            yield break;
        }
        else
        {
            if (list == null)
            {
                m_LoadRequests.Remove(abName);
                yield break;
            }
        }


        for (int i = 0; i < list.Count; i++)
        {
            string[] assetNames = list[i].assetNames;
            //List<UnityEngine.Object> result = new List<UnityEngine.Object>();
            ABObject result = PooledClassManager <ABObject> .CreateClass();

            AssetBundle ab = bundleInfo.m_AssetBundle;

            for (int j = 0; j < assetNames.Length; j++)
            {
                string assetPath = assetNames[j];

                AssetBundleRequest request = ab.LoadAssetAsync(assetPath, list[i].assetType);
                yield return(request);

                UnityEngine.Object obj = request.asset;
#if UNITY_EDITOR
                if (obj is GameObject)
                {
                    RecoveryShader((GameObject)obj);
                }
#endif
                result.m_UObjectList.Add(obj);
            }
            //Debug.Log("OnLoadAsset " + abName);
            bundleInfo.m_ReferencedCount++;
            //处理依赖
            string[] deps = null;
            if (m_Dependencies.TryGetValue(abName, out deps))
            {
                foreach (var dependency in deps)
                {
                    AssetBundleInfo depABInfo = GetLoadedAssetBundle(dependency);
                    depABInfo.m_ReferencedCount++;
                }
            }

            //将加载完成的id和abName绑定
            m_LoadedIdABName.Add(list[i].LoadIndex, abName);


            //这段代码不能去掉,因为我们的AssetBundleManifest依赖它来回调
            if (list[i].sharpFunc != null)
            {
                //list[i].sharpFunc(result);
                //list[i].sharpFunc = null;
                list[i].ObjList = result;
                m_CallBackList.Add(list[i]);
                //m_CallBackList.Sort(OnSortCallList);
            }
        }

        m_LoadRequests.Remove(abName);

        string[] Dependencies = null;
        if (m_Dependencies.TryGetValue(abName, out Dependencies))
        {
            foreach (var dependency in Dependencies)
            {
                //释放依赖AB
                //AssetBundleInfo depABInfo = GetLoadedAssetBundle(dependency);
                //depABInfo.m_ReferencedCount++;
                m_LoadRequests.Remove(dependency);
            }
        }
    }