+ Start a Discussion
Rajesh SFDCRajesh SFDC 

how to avod duplicate records from salesforce TO TFS using c# code

  here my code.....
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using System.Web.Caching;
using System.Web.Services;
using System.Diagnostics;
using SFDCWebServices;
using CaseNotifications;  ==============> dis s outbound message wsdl file
using System.Data;
using Enterprise; ===api in salesforce...
using System.Web.Services.Protocols;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.TeamFoundation.Client;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.Linq;

/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService : INotificationBinding
    public static string strUserName = "expertsolution@sfdc.com";
    public static string strpassword = "welcome@123e2XWW2t07FUSpsdbbcYCFyxp";
    public SforceService binding;
    public static LoginResult lr;
    private LoginResult loginResult;
    public static bool isLogin = false;

    public string strCaseno = string.Empty;
    public string strOrigin = string.Empty;
    public string strTicketno = string.Empty;
    public string strTicketlink = string.Empty;
    public string strDeal = string.Empty;
    public string strState = string.Empty;
    public string strReason = string.Empty;
    public string strAssignto = string.Empty;
    DataTable dtXMLDetails = new DataTable();

    public string strField = string.Empty;

    public bool isSave = false;

    int strTFSID = 0;

    public WebService()

        //Uncomment the following line if using designed components

    #region INotificationBinding Members

    notificationsResponse INotificationBinding.notifications(notifications notifications1)
        CaseNotifications.CaseNotification[] cases = notifications1.Notification;

        notificationsResponse response = new notificationsResponse();


            DataTable dt = GetXMLToDataTable();


            for (int i = 0; i < cases.Length; i++)
                System.Diagnostics.Debug.WriteLine("Notification " + (i + 1));

                CaseNotifications.CaseNotification notification = cases[i];
                CaseNotifications.Case con = (CaseNotifications.Case)notification.sObject;
                strCaseno = con.CaseNumber;
                strOrigin = con.Origin;
                strTicketno = con.Title__c;
                strState = con.State__c;
                strReason = con.Reason__c;
                strTFSID = Convert.ToInt32(con.TFS_ID__c);
Hi , 

As the data resides in TFS, it would be recommended that you have the duplication check in C# before inserting it in TFS. 

See the below links, 

Finding Duplicate Code by using Code Clone Detection


Remove duplicate TFS groups