Beispiel #1
0
 /// <remarks/>
 public void ABAddAsync(ABAddRequestType ABAdd1, object userState) {
     if ((this.ABAddOperationCompleted == null)) {
         this.ABAddOperationCompleted = new System.Threading.SendOrPostCallback(this.OnABAddOperationCompleted);
     }
     this.InvokeAsync("ABAdd", new object[] {
                 ABAdd1}, this.ABAddOperationCompleted, userState);
 }
        private void FindMembershipAsync(string partnerScenario, FindMembershipCompletedEventHandler findMembershipCallback)
        {
            if (NSMessageHandler.MSNTicket == MSNTicket.Empty || AddressBook == null)
            {
                OnServiceOperationFailed(this, new ServiceOperationFailedEventArgs("FindMembership", new MSNPSharpException("You don't have access right on this action anymore.")));
                return;
            }

            bool msdeltasOnly = false;
            DateTime serviceLastChange = WebServiceDateTimeConverter.ConvertToDateTime(WebServiceConstants.ZeroTime);
            DateTime msLastChange = WebServiceDateTimeConverter.ConvertToDateTime(AddressBook.MembershipLastChange);
            string strLastChange = WebServiceConstants.ZeroTime;

            if (msLastChange != serviceLastChange)
            {
                msdeltasOnly = true;
                strLastChange = AddressBook.MembershipLastChange;
            }

            FindMembershipRequestType request = new FindMembershipRequestType();
            request.view = "Full";  // NO default!
            request.deltasOnly = msdeltasOnly;
            request.lastChange = strLastChange;
            request.serviceFilter = new ServiceFilter();
            request.serviceFilter.Types = new ServiceName[]
            {
                ServiceName.Messenger,
                ServiceName.IMAvailability,
                ServiceName.SocialNetwork
            };

            MsnServiceState FindMembershipObject = new MsnServiceState(partnerScenario, "FindMembership", true);
            SharingServiceBinding sharingService = (SharingServiceBinding)CreateService(MsnServiceType.Sharing, FindMembershipObject);
            sharingService.FindMembershipCompleted += delegate(object sender, FindMembershipCompletedEventArgs e)
            {
                OnAfterCompleted(new ServiceOperationEventArgs(sharingService, MsnServiceType.Sharing, e));

                // Cancelled or signed off
                if (e.Cancelled || NSMessageHandler.MSNTicket == MSNTicket.Empty)
                    return;

                if (e.Error != null)
                {
                    // Handle errors and recall this method if necesarry.
                    if (e.Error.Message.ToLowerInvariant().Contains("need to do full sync")
                        || e.Error.Message.ToLowerInvariant().Contains("full sync required"))
                    {
                        // recursive Call -----------------------------
                        DeleteRecordFile(true);
                        FindMembershipAsync(partnerScenario, findMembershipCallback);
                    }
                    else if (e.Error.Message.ToLowerInvariant().Contains("address book does not exist"))
                    {
                        ABAddRequestType abAddRequest = new ABAddRequestType();
                        abAddRequest.abInfo = new abInfoType();
                        abAddRequest.abInfo.ownerEmail = NSMessageHandler.Owner.Account;
                        abAddRequest.abInfo.ownerPuid = 0;
                        abAddRequest.abInfo.fDefault = true;

                        MsnServiceState ABAddObject = new MsnServiceState(partnerScenario, "ABAdd", true);
                        ABServiceBinding abservice = (ABServiceBinding)CreateService(MsnServiceType.AB, ABAddObject);
                        abservice.ABAddCompleted += delegate(object srv, ABAddCompletedEventArgs abadd_e)
                        {
                            OnAfterCompleted(new ServiceOperationEventArgs(abservice, MsnServiceType.AB, abadd_e));

                            if (abadd_e.Cancelled || NSMessageHandler.MSNTicket == MSNTicket.Empty)
                                return;

                            if (abadd_e.Error == null)
                            {
                                // recursive Call -----------------------------
                                DeleteRecordFile(true);
                                FindMembershipAsync(partnerScenario, findMembershipCallback);
                            }
                        };
                        RunAsyncMethod(new BeforeRunAsyncMethodEventArgs(abservice, MsnServiceType.AB, ABAddObject, abAddRequest));
                    }
                    else
                    {
                        Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose,
                            "UNHANDLED ERROR: " + e.Error.Message.ToString(), GetType().Name);

                        // Pass to the callback
                        if (findMembershipCallback != null)
                        {
                            findMembershipCallback(sharingService, e);
                        }
                    }
                }
                else
                {
                    // No error, fire event handler.
                    if (findMembershipCallback != null)
                    {
                        findMembershipCallback(sharingService, e);
                    }
                }
            };

            RunAsyncMethod(new BeforeRunAsyncMethodEventArgs(sharingService, MsnServiceType.Sharing, FindMembershipObject, request));
        }
Beispiel #3
0
 /// <remarks/>
 public void ABAddAsync(ABAddRequestType ABAdd1) {
     this.ABAddAsync(ABAdd1, null);
 }