Esempio n. 1
0
        private void ManageWLConnectionAsync(Guid contactGuid, Guid abID, string inviteMessage,
                                             bool connection, bool presence, int action, int relType, int relRole,
                                             ManageWLConnectionCompletedEventHandler callback)
        {
            ManageWLConnectionRequestType wlconnectionRequest = new ManageWLConnectionRequestType();

            wlconnectionRequest.contactId  = contactGuid.ToString("D");
            wlconnectionRequest.connection = connection;
            wlconnectionRequest.presence   = presence;
            wlconnectionRequest.action     = action;

            wlconnectionRequest.relationshipType = relType;
            wlconnectionRequest.relationshipRole = relRole;

            if (!String.IsNullOrEmpty(inviteMessage))
            {
                Annotation anno = new Annotation();
                anno.Name  = AnnotationNames.MSN_IM_InviteMessage;
                anno.Value = inviteMessage;

                wlconnectionRequest.annotations = new Annotation[] { anno };
            }

            if (abID != Guid.Empty)
            {
                abHandleType abHandle = new abHandleType();
                abHandle.ABId = abID.ToString("D").ToLowerInvariant();
                abHandle.Puid = 0;
                abHandle.Cid  = 0;

                wlconnectionRequest.abHandle = abHandle;
            }

            MsnServiceState  manageWLConnectionObject = new MsnServiceState(abID == Guid.Empty ? PartnerScenario.ContactSave : PartnerScenario.CircleInvite, "ManageWLConnection", true);
            ABServiceBinding abServiceBinding         = (ABServiceBinding)CreateService(MsnServiceType.AB, manageWLConnectionObject);

            abServiceBinding.ManageWLConnectionCompleted += delegate(object wlcSender, ManageWLConnectionCompletedEventArgs e)
            {
                OnAfterCompleted(new ServiceOperationEventArgs(abServiceBinding, MsnServiceType.AB, e));

                if (e.Cancelled || NSMessageHandler.MSNTicket == MSNTicket.Empty)
                {
                    return;
                }

                if (callback != null)
                {
                    callback(wlcSender, e);
                }
            };

            RunAsyncMethod(new BeforeRunAsyncMethodEventArgs(abServiceBinding, MsnServiceType.AB, manageWLConnectionObject, wlconnectionRequest));
        }
Esempio n. 2
0
        private void ManageWLConnectionAsync(Guid contactGuid, Guid abID, string inviteMessage,
            bool connection, bool presence, int action, int relType, int relRole,
            ManageWLConnectionCompletedEventHandler callback)
        {
            ManageWLConnectionRequestType wlconnectionRequest = new ManageWLConnectionRequestType();

            wlconnectionRequest.contactId = contactGuid.ToString("D");
            wlconnectionRequest.connection = connection;
            wlconnectionRequest.presence = presence;
            wlconnectionRequest.action = action;

            wlconnectionRequest.relationshipType = relType;
            wlconnectionRequest.relationshipRole = relRole;

            if (!String.IsNullOrEmpty(inviteMessage))
            {
                Annotation anno = new Annotation();
                anno.Name = AnnotationNames.MSN_IM_InviteMessage;
                anno.Value = inviteMessage;

                wlconnectionRequest.annotations = new Annotation[] { anno };
            }

            if (abID != Guid.Empty)
            {
                abHandleType abHandle = new abHandleType();
                abHandle.ABId = abID.ToString("D").ToLowerInvariant();
                abHandle.Puid = 0;
                abHandle.Cid = 0;

                wlconnectionRequest.abHandle = abHandle;
            }

            MsnServiceState manageWLConnectionObject = new MsnServiceState(abID == Guid.Empty ? PartnerScenario.ContactSave : PartnerScenario.CircleInvite, "ManageWLConnection", true);
            ABServiceBinding abServiceBinding = (ABServiceBinding)CreateService(MsnServiceType.AB, manageWLConnectionObject);
            abServiceBinding.ManageWLConnectionCompleted += delegate(object wlcSender, ManageWLConnectionCompletedEventArgs e)
            {
                OnAfterCompleted(new ServiceOperationEventArgs(abServiceBinding, MsnServiceType.AB, e));

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

                if (callback != null)
                {
                    callback(wlcSender, e);
                }
            };

            RunAsyncMethod(new BeforeRunAsyncMethodEventArgs(abServiceBinding, MsnServiceType.AB, manageWLConnectionObject, wlconnectionRequest));
        }