C#google联系人api删除联系人 [英] C# google contact api deleted contact

查看:148
本文介绍了C#google联系人api删除联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在撰写一个外观插件,用于同步前景的goolge联系人,但我必须涵盖一些特殊情况:

currently I´m writing on a outlook plugin for syncing goolge contacts with outlook but I have to cover some special case:

当一个联系人在google侧删除,我的应用程序检测到缺少的联系人,并根据前景的联系信息创建一个新的联系人。
有没有办法从谷歌获取一个事件或历史,告诉我一个用户删除了这个联系人?

When a contact gets deleted on google side, my application detects the missing contact and creates a new contact based on the contact info from the outlook one. Is there a way to get an event or history from google that tells me a user deleted this contact(s)?

编辑1:
这是我的代码如何访问联系人(什么是工作FINE):

Edit 1: Here is my code how I´m accessing the contacts (what is working FINE):

public GoogleAccessor()
{
    var parameters = new OAuth2Parameters()
    {
        ClientId = CLIENTID,
        ClientSecret = CLIENTSECRET,
        RedirectUri = REDIRECTURI,
        Scope = SCOPES
    };

    string url = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
    //An own webbrowser for processing the access tokens
    IAuthorizationCodeProvider authcodeProvider = new Presentation.BrowserAuthorizationCodeProvider(new Presentation.BrowserAuthentificatorVM());
    parameters.AccessCode = authcodeProvider.GetAuthorizationCode(url);

    if(parameters.AccessCode == null)
        throw new GoogleOAuthException("AccesCode returned 'null' and failed!");

    OAuthUtil.GetAccessToken(parameters);

    this._contactsRequest = new ContactsRequest(new RequestSettings(APPLICATIONNAME, parameters) {AutoPaging = true});
}
public IList<IContact> GetAllMappedContacts()
{
    Feed<Google.Contacts.Contact> f = _contactsRequest.GetContacts();
    this._feedUri = new Uri(f.AtomFeed.Feed);
    var photoList = new List<PhotoObject>();

    foreach (var entry in f.Entries)
    {
        var photoObject = GetContactPhoto(entry);
        if(photoObject != null)
            photoList.Add(photoObject);
    }
    _googleMapper = new GoogleMapper(f.Entries);
    return _googleMapper.MapToLocalContacts();;
}


推荐答案

同步通常意味着在一个方向上工作。

The thing about syncing in general is that syncing is normally meant to work in one direction.

源数据 - >数据流 - >接收数据。

Source Data -> Data Flow -> Received Data.

在这种情况下,Outlook是您的源数据,Google是您收到的数据。所有信息需要来自您的来源。由于这是一个Outlook加载项,您正在创建我的建议是将一个按钮添加到您的加载项功能区。你可以随便打电话给任何你喜欢的按钮(也许dontSyncButton),但它的目的是将您的联系人分类。

In this instance, Outlook is your source data and Google is your received data. All information needs to come from your source. Since this is an Outlook add-in you are creating my suggestion would be to add a button to your add-in ribbon. You can call the button whatever ever you like (maybe "dontSyncButton"), but it's purpose is going to be Categorization of your contact.

使其成为当选择联系人,然后点击该按钮时,该联系人被给予一个特殊的分类(可能是不要同步)。

Make it so that that when a contact is selected and then the button is clicked, the contact is given a special categorization (perhaps "Dont Sync").

现在给执行同步的代码提供一些逻辑,并且具有决定是否同步联系人的逻辑。另外,如果联系人包含特殊类别,请给出一些逻辑来告诉程序从Google中删除联系人。以下半伪代码:

Now give some logic to your code that executes the sync, and have that logic decide whether to sync the contact. Also, give some logic to tell the program to delete the contact out of Google for you if the contacts contains the special category. Semi-Pseudo Code below:

 if(contact.Categories.ToString() == "Dont Sync")
 {
     //Don't Sync Contact
     If(googleContact.Exists())
     {
         //Delete contact from Google if it exist
         googleContact.Delete();
     } 
 }
 else
 {
     //Sync Contact
 }

如果Outlook有许多可修改的属性对用户不可见,那么这是很好的,但是由于它不是真正的最好的选择之一,我可以想到。我这样做是将联系人从共享的Outlook文件夹同步到个人的文件夹,并且迄今为止已经运行良好。

It would be nice if Outlook had many modifiable properties that weren't visible to users, but since it does not this is really one of the best options I can think of. I do this to sync contacts from a shared Outlook folder to personal ones and it has worked well so far.

希望这有帮助!

这篇关于C#google联系人api删除联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆