Esempio n. 1
0
        private bool UpdateDynamicItemSync(string scenario)
        {
            if (NSMessageHandler.MSNTicket != MSNTicket.Empty)
            {
                //9. UpdateDynamicItem
                MsnServiceState serviceState = new MsnServiceState(scenario, "UpdateDynamicItem", false);
                ABServiceBinding abService = (ABServiceBinding)CreateService(MsnServiceType.AB, serviceState);

                UpdateDynamicItemRequestType updateDyItemRequest = new UpdateDynamicItemRequestType();
                updateDyItemRequest.abId = Guid.Empty.ToString();

                PassportDynamicItem passportDyItem = new PassportDynamicItem();
                passportDyItem.Type = "Passport";
                passportDyItem.PassportName = NSMessageHandler.Owner.Account;
                passportDyItem.Changes = "Notifications";

                NotificationDataType notification = new NotificationDataType();
                notification.Status = "Exist Access";
                notification.InstanceId = "0";
                notification.Gleam = false;
                notification.LastChanged = NSMessageHandler.ContactService.Deltas.Profile.DateModified;

                ServiceType srvInfo = new ServiceType();
                srvInfo.Changes = "";

                HandleType srvHandle = new HandleType();
                srvHandle.ForeignId = "MyProfile";
                srvHandle.Id = "0";
                srvHandle.Type = ServiceName.Profile;

                InfoType info = new InfoType();
                info.Handle = srvHandle;
                info.IsBot = false;
                info.InverseRequired = false;

                srvInfo.Info = info;
                notification.StoreService = srvInfo;
                passportDyItem.Notifications = new NotificationDataType[] { notification };
                updateDyItemRequest.dynamicItems = new PassportDynamicItem[] { passportDyItem };
                try
                {

                    ChangeCacheKeyAndPreferredHostForSpecifiedMethod(abService, MsnServiceType.AB, serviceState, updateDyItemRequest);
                    abService.UpdateDynamicItem(updateDyItemRequest);
                }
                catch (Exception ex)
                {
                    OnServiceOperationFailed(abService, new ServiceOperationFailedEventArgs("UpdateDynamicItem", ex));
                    Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "UpdateDynamicItem error: You don't receive any contact updates, vice versa! " + ex.Message, GetType().Name);

                    AddDynamicItemRequestType addDynamicItemRequest = new AddDynamicItemRequestType();
                    addDynamicItemRequest.abId = updateDyItemRequest.abId;
                    addDynamicItemRequest.dynamicItems = updateDyItemRequest.dynamicItems;
                    foreach (BaseDynamicItemType dynamicItem in addDynamicItemRequest.dynamicItems)
                    {
                        dynamicItem.Notifications = null;
                        dynamicItem.Changes = null;
                        dynamicItem.LastChanged = null;
                    }

                    try
                    {
                        ChangeCacheKeyAndPreferredHostForSpecifiedMethod(abService, MsnServiceType.AB, serviceState, addDynamicItemRequest);
                        abService.AddDynamicItem(addDynamicItemRequest);
                    }
                    catch (Exception exAddDynamicItem)
                    {
                        OnServiceOperationFailed(abService, new ServiceOperationFailedEventArgs("AddDynamicItem", exAddDynamicItem));
                        Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "AddDynamicItem error: You don't receive any contact updates, vice versa! " + exAddDynamicItem.Message, GetType().Name);
                        return false;
                    }
                    return true;
                }
                return true;
            }

            return false;
        }
Esempio n. 2
0
        private bool AddDynamicItemSync(string scenario)
        {
            if (NSMessageHandler.MSNTicket != MSNTicket.Empty)
            {
                MsnServiceState serviceState = new MsnServiceState(scenario, "AddDynamicItem", false);
                ABServiceBinding abService = (ABServiceBinding)CreateService(MsnServiceType.AB, serviceState);

                PassportDynamicItem newDynamicItem = new PassportDynamicItem();
                newDynamicItem.Type = "Passport";
                newDynamicItem.PassportName = NSMessageHandler.Owner.Account;

                AddDynamicItemRequestType addDynamicItemRequest = new AddDynamicItemRequestType();
                addDynamicItemRequest.abId = WebServiceConstants.MessengerIndividualAddressBookId;
                addDynamicItemRequest.dynamicItems = new BaseDynamicItemType[] { newDynamicItem };

                try
                {

                    ChangeCacheKeyAndPreferredHostForSpecifiedMethod(abService, MsnServiceType.AB, serviceState, addDynamicItemRequest);
                    abService.AddDynamicItem(addDynamicItemRequest);
                }
                catch (Exception ex)
                {
                    OnServiceOperationFailed(abService, new ServiceOperationFailedEventArgs("AddDynamicItem", ex));
                    Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "AddDynamicItem error: " + ex.Message, GetType().Name);
                    return false;
                }
                return true;
            }

            return false;
        }