예제 #1
0
        /// <summary>
        /// Gets data for specified columns of an sobject
        /// </summary>
        public List <sObject> GetDataFromSObject(string sobjectName, List <string> colList, string filter)
        {
            LoginIfRequired();
            colList = RemoveSystemColumns(colList);
            string soql = BuildQuery(sobjectName, colList, filter);

            bool           allResultsReturned = false;
            List <sObject> allResults         = new List <sObject>();
            QueryResult    qr = _binding.query(soql);

            if (qr.size > 0)
            {
                while (!allResultsReturned)
                {
                    allResults.AddRange(qr.records);
                    if (qr.done)
                    {
                        allResultsReturned = true;
                    }
                    else
                    {
                        qr = _binding.queryMore(qr.queryLocator);
                    }
                }
            }

            return(allResults);
        }
        public JArray GetCampaigns(bool translate)
        {
            var entityType = "campaign";

            var fieldsQuery = getAllFieldsQuery(entityType);
            var query       = string.Format("SELECT {0} FROM {1}", fieldsQuery, entityType);
            var queryResult = binding.query(query);
            var entities    = prettiFyAndTranslate(queryResult, entityType, translate, new string[0]);

            return(entities);
        }
예제 #3
0
        public JArray GetCampaigns(bool translate)
        {
            var entityType = "campaign";

            var fieldsQuery = GetAllFieldsQuery(entityType);
            var query       = $"SELECT {fieldsQuery} FROM {entityType}";
            var queryResult = binding.query(query);
            var entities    = PrettiFyAndTranslate(queryResult, entityType, translate, new string[0]);

            return(entities);
        }
예제 #4
0
        private ArrayList SFQueryIds(string SFQuery, out ArrayList messages)
        {
            messages = new ArrayList();
            ArrayList ids = new ArrayList();

            try
            {
                QueryResult qr = null;
                binding.QueryOptionsValue                    = new QueryOptions();
                binding.QueryOptionsValue.batchSize          = 250;
                binding.QueryOptionsValue.batchSizeSpecified = true;

                qr = binding.query(SFQuery);

                bool done      = false;
                int  loopCount = 0;
                while (!done)
                {
                    Console.WriteLine("\nRecords in results set " +
                                      Convert.ToString(loopCount++)
                                      + " - ");
                    // Process the query results
                    if (qr.records == null)
                    {
                        return(ids);                    //return empty
                    }
                    for (int i = 0; i < qr.records.Length; i++)
                    {
                        sObject con = qr.records[i];
                        ids.Add(con.Any[0].InnerText);
                    }

                    if (qr.done)
                    {
                        done = true;
                    }
                    else
                    {
                        qr = binding.queryMore(qr.queryLocator);
                    }
                }
            }
            catch (SoapException e)
            {
                messages.Add("An unexpected error has occurred: " + e.Message +
                             " Stack trace: " + e.StackTrace);
            }
            Console.WriteLine("\nQuery execution completed.");

            return(ids);
        }
예제 #5
0
        public static List <SalesForceWebReference.Dealer_Lead__c> getApplications(SforceService _binding, string AccountId, string LastName)
        {
            QueryResult qr = null;

            //SalesForceWebReference.Account _account;

            ////qr = _binding.query("select Id, Account__c, Name, FirstName__c, LastName__c, CreatedDate from  from Dealer_Lead_c");

            string _query2 = _appQuery + " where Account__c = '" + AccountId + "' and Name like '%" + LastName + "%' and BRGCaseMail_OK_to_send__c = true  order by CreatedDate desc";

            qr = _binding.query(_query2);

            List <Dealer_Lead__c> _applications = new List <Dealer_Lead__c>();

            if (qr.records != null)
            {
                for (int i = 0; i < qr.records.Length; i++)
                {
                    _applications.Add(((Dealer_Lead__c)qr.records[i]));

                    //Debug.WriteLine(((Account)qr.records[i]).Name);
                }
            }

            return(_applications);
        }
예제 #6
0
        public static SalesForceWebReference.Account getBRGCaseMailAccount(SforceService _binding, string UserID, string Password)
        {
            QueryResult qr = null;

            //SalesForceWebReference.Account _account;

            ////qr = _binding.query("select Id, Account__c, Name, FirstName__c, LastName__c, CreatedDate from  from Dealer_Lead_c");

            qr = _binding.query(_accountQuery + " where BRGCaseMail_Password__c = '" + Password + "' and BRGCaseMail_User_ID__c = '" + UserID + "'");

            //List<Account> _accounts = new List<Account>();

            if (qr.records != null)
            {
                if (qr.records.Length > 0)
                {
                    return((Account)qr.records[0]);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
예제 #7
0
        internal IEnumerable <sObject> ExecuteQuery(string query)
        {
            var  items = new List <sObject>();
            bool done  = false;

            QueryResult queryResult = _sforceService.query(query);

            if (queryResult.size > 0)
            {
                while (!done)
                {
                    items.AddRange(queryResult.records);

                    if (queryResult.done)
                    {
                        done = true;
                    }
                    else
                    {
                        queryResult = _sforceService.queryMore(queryResult.queryLocator);
                    }
                }
            }
            else
            {
                throw new Exception("No records found. Query: " + query);
            }

            return(items);
        }
예제 #8
0
        public string GetSalesForceQualifiedAmbassadorsID(string Sponsorid = "")
        {
            QueryResult   qr          = new QueryResult();
            string        Ambassador  = string.Empty;
            SforceService SfdcBinding = SalesForceSession();

            try
            {
                string strQuery = (@"select id from Ambassador__c where AmbassadorID__c ='" + Sponsorid + "'");
                qr = SfdcBinding.query(strQuery);
                Common.SforceServices.sObject[] records = qr.records;
                if (records != null)
                {
                    foreach (Ambassador__c node in records)
                    {
                        Ambassador = node.Id;
                        break;
                    }
                }
                return(Ambassador);
            }
            catch (Exception)
            {
                return(Ambassador);
            }
        }
예제 #9
0
        /// <summary>
        /// Counts records of type.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="objectTypeName">Type of sObject.</param>
        /// <param name="whereClause">Where clause.</param>
        /// <returns>Count of records with where clause if it set otherwise all record.</returns>
        public int CountRecords(string objectTypeName, string whereClause = null)
        {
            if (CheckConnected())
            {
                string queryString = String.Format("select COUNT() from {0}", objectTypeName);

                if (!String.IsNullOrEmpty(whereClause))
                {
                    queryString = String.Format("{0} {1}", queryString, whereClause);
                }

                return(_binding.query(queryString).size);
            }

            return(0);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <SalesForceEvent> GetEvents()
        {
            List <SalesForceEvent> listEvents = new List <SalesForceEvent>();

            try
            {
                QueryResult queryResult = null;

                String SOQL = "";

                SOQL = "select subject,StartDateTime ,EndDateTime,Location, Description from event";

                queryResult = SfdcBinding.query(SOQL);


                for (int i = 0; i < queryResult.size; i++)
                {
                    SalesForceEvent sfEvent         = new SalesForceEvent();
                    Event           salesforceEvent = (Event)queryResult.records[i];
                    sfEvent.Subject     = salesforceEvent.Subject;
                    sfEvent.StartDate   = salesforceEvent.StartDateTime;
                    sfEvent.EndDate     = salesforceEvent.EndDateTime;;
                    sfEvent.Location    = salesforceEvent.Location;
                    sfEvent.Description = salesforceEvent.Description;
                    sfEvent.Id          = i;
                    listEvents.Add(sfEvent);
                }

                return(listEvents);
            }
            catch (Exception e)
            {
                return(listEvents);
            }
        }
예제 #11
0
        public void upLoad()
        {
            ServicePointManager.Expect100Continue = true;                       //Enables prolonged use
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12; //Sets needed security level

            var    list = new List <string>();                                  //List to hold case numbers that have been used
            string user = "";                                                   //Test salesforce user
            string pass = "";                                                   //Test salesforce pass

            binding         = new SforceService();                              //Initializs binding object
            binding.Timeout = 60000;                                            //Sets maximum time per binding
            WebReference.LoginResult lr;                                        //lr is my login result
            lr = binding.login(user, pass);                                     //Used lr to create credentials
            string authEndPoint = binding.Url;                                  //Not sure what this does honestly

            binding.Url = lr.serverUrl;                                         //Sets binding to correct server
            binding.SessionHeaderValue           = new SessionHeader();         //Header needed for API format
            binding.SessionHeaderValue.sessionId = lr.sessionId;                //Gives binder the session id

            try
            {
                Case          c     = new Case();
                Case[]        cases = new Case[1];
                CaseComment   com   = new CaseComment();
                CaseComment[] coms  = new CaseComment[1];

                //c.AccountId = "GBS Non Case Events";
                //c.Subject = "API Test";
                //c.Type = "MAC - Non-Billable";
                //c.Case_Product_Category__c = "Project";
                //c.Product_Subcategory__c = "Training";
                //c.Priority = "SLA - 5 - Client Request/Client Created Issue";
                //c.Origin = "Phone";
                //c.Reason = "Test Description";
                //c.Status = "Case Opened";
                //c.OwnerId = "Firaus Odeh";
                //c.ContactId = "";
                //c.Description = "Test";
                //c.IsEscalated = false;
                //c.SuppliedName = "Test Case";
                //c.SuppliedEmail = "";
                //c.SuppliedPhone = "";
                //c.SuppliedCompany = "";
                //SaveResult[] results = binding.create(cases);
                //Debug.WriteLine("valid Data");
                c.Id = "5000g000026SPQ8AAO";
                string      query1 = "Insert into Case (Comments) Value ('Test') Where CaseNumber = '00311360'";
                QueryResult result = binding.query(query1);
                com.Id          = result.ToString();
                c.Subject       = "Test";
                com.CommentBody = "Test comment";
                c.Comments      = "test";
                coms[0]         = com;
                SaveResult[] check = binding.create(coms);
            }
            catch
            {
                Debug.WriteLine("Invalid data");
            }
        }
예제 #12
0
        public ActionResult Query()
        {
            QueryResult queryResult = null;
            String      SOQL        = "";
            string      productid   = "";

            SOQL        = "    SELECT Id, Name, Email, AccountId FROM Contact";//where ProductCode = 'Test'";
            queryResult = sfdcBinding.query(SOQL);

            if (queryResult.size > 0)
            {
                //put some code in here to handle the records being returned
                int     i           = 0;
                Contact readContact = new Contact();
                for (i = 0; i < queryResult.records.Count(); i++)
                {
                    readContact = (Contact)queryResult.records[i];
                    string productName = readContact.Name;
                    productid = readContact.Id; // save id show we can use in update and delete product
                    Response.Write("<hr/> </br/> Contact Found!!<br/>");
                    Response.Write("Name:" + readContact.Name);
                    Response.Write("<br/>Email:" + readContact.Email);
                    Response.Write("<br/>ID:" + readContact.Id);
                }
            }
            else
            {
                //put some code in here to handle no records being returned
                string message = "No records returned.";
                Response.Write("<br/>" + message);
            }

            return(View());
        }
예제 #13
0
        public static void ImageDownload()
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;

            LoginResult   currentLoginResult = null;
            SforceService sfdcBinding        = new SforceService();

            currentLoginResult = sfdcBinding.login(UserName, Password + SecurityToken);

            //Change the binding to the new endpoint
            sfdcBinding.Url = currentLoginResult.serverUrl;
            //Create a new session header object and set the session id to that returned by the login
            sfdcBinding.SessionHeaderValue           = new SessionHeader();
            sfdcBinding.SessionHeaderValue.sessionId = currentLoginResult.sessionId;
            string      sfSessionId = currentLoginResult.sessionId;
            QueryResult queryResult = null;

            if (sfdcBinding != null)
            {
                //String SOQL = "SELECT id,IsProfilePhotoActive,FullPhotoUrl,LastName ,FirstName FROM User where isActive = true and IsProfilePhotoActive=true";
                String SOQL = "select Id, name, Phone__c,fee__c,Head_Master__c, City__c, Board__c,Languages_offered__c,State__c from School__c";
                queryResult = sfdcBinding.query(SOQL);
            }
            if (queryResult.size > 0)
            {
                // SFImages(queryResult, sfSessionId);
                SchoolData(queryResult);
            }
        }
예제 #14
0
        public int SalesForceLeadsCount(String FirstLastName)
        {
            try
            {
                QueryResult qr = new QueryResult();

                int       Leadcount = 0;
                DataTable dt        = new DataTable();
                using (var PubsConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["IHCharity"].ConnectionString.ToString()))
                {
                    SqlCommand testCMD = new SqlCommand("SalesForceBannerLeadFlag", PubsConn);
                    testCMD.CommandType = CommandType.StoredProcedure;
                    testCMD.Parameters.Add(new SqlParameter("@Name", FirstLastName));
                    PubsConn.Open();
                    SqlDataReader myReader = testCMD.ExecuteReader();
                    dt.Load(myReader);
                    PubsConn.Close();
                }
                if (dt.Rows.Count == 0)
                {
                    SforceService SfdcBinding     = SalesForceSession();
                    int           SalesForcecount = 0;
                    string        strQuery        = ("SELECT Id from Lead where Sponsor__c ='" + FirstLastName + "'");
                    qr = SfdcBinding.query(strQuery);
                    SalesForcecount = qr.records.Count();
                    if (SalesForcecount > 0)
                    {
                        using (var PubsConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["IHCharity"].ConnectionString.ToString()))
                        {
                            SqlCommand testCMD = new SqlCommand("InsertSalesForceLeadCount", PubsConn);
                            testCMD.CommandType = CommandType.StoredProcedure;
                            testCMD.Parameters.Add(new SqlParameter("@Name", FirstLastName));
                            testCMD.Parameters.Add(new SqlParameter("@Count", SalesForcecount));
                            PubsConn.Open();

                            SqlDataReader myReader = testCMD.ExecuteReader();
                            dt = new DataTable();
                            dt.Load(myReader);

                            PubsConn.Close();
                            foreach (DataRow row in dt.Rows)
                            {
                                Leadcount = int.Parse(row["Leads"].ToString());
                            }
                            return(Leadcount);
                        }
                    }
                    return(SalesForcecount);
                }
                foreach (DataRow row in dt.Rows)
                {
                    Leadcount = int.Parse(row["CountDiffernece"].ToString());
                }
                return(Leadcount);
            }
            catch (Exception)
            {
                return(0);
            }
        }
예제 #15
0
        public QueryResult GetSalesForceQualifiedAmbassadorslist(string whereClause = "")
        {
            QueryResult   qr          = new QueryResult();
            SforceService SfdcBinding = SalesForceSession();

            try
            {
                if (!string.IsNullOrEmpty(whereClause))
                {
                    whereClause = whereClause.Replace("QualifiedAmbassadorID", "AmbassadorID__c");
                    whereClause = whereClause.Replace("ReceivedLeads", "Available_To_Receive_Leads__c");
                    whereClause = whereClause.Replace("Zip", "Zip_Code__c");
                    whereClause = whereClause.Replace("Email", "Q_Ambassador_Email__c");
                    whereClause = whereClause.Replace("Mobile", "Mobile_Phone__c");
                    whereClause = whereClause.Replace("Phone", "Phone__c");
                    whereClause = whereClause.Replace("Sponsorid", "SponsorID__c");
                    whereClause = whereClause.Replace("LeaveDate", "LeaveDate__c");
                    whereClause = whereClause.Replace("JoinDate", "JoinDate__c");
                    whereClause = whereClause.Replace("''", "'");
                }
                string strQuery = (@"select id, Name, AmbassadorID__c, Mobile_Phone__c, Phone__c,JoinDate__c,LeaveDate__c, SponsorID__c, Q_Ambassador_Email__c, Zip_Code__c, Available_To_Receive_Leads__c, CreatedById from Ambassador__c where id !='' " + whereClause + @" order by AmbassadorID__c ");
                qr = SfdcBinding.query(strQuery);
                return(qr);
            }
            catch (Exception)
            {
                return(qr);
            }
        }
예제 #16
0
        /// <summary>
        /// Queries the specified soql query.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="soqlQuery">The soql query.</param>
        /// <returns>List&lt;T&gt;.</returns>
        public List <T> Query <T>(string soqlQuery) where T : sObject
        {
            QueryResult qr   = _binding.query(soqlQuery);
            bool        done = false;

            var l = new List <T>();

            if (qr.size <= 0)
            {
                return(l);
            }
            while (!done)
            {
                if (qr.records != null)
                {
                    l.AddRange(qr.records.Select(r => (T)r));
                }

                if (qr.done)
                {
                    done = true;
                }
                else
                {
                    qr = _binding.queryMore(qr.queryLocator);
                }
            }
            return(l);
        }
예제 #17
0
        public void loadUser(/*BackgroundWorker worker*/)
        {
            /* if (worker.IsBusy != true)
             * {
             *
             *   worker.RunWorkerAsync();*/

            Boolean done = false;
            String  user = "******" +
                           " Federationidentifier, Enterprise_ID__c, License_Type__c, Peoplekey__c, Inactivitydttm__c," +
                           " Inactivityind__c FROM User WHERE License_Type__c = 'Salesforce' and PeopleKey__c != null";
            QueryResult queryUser = connect.query(user);

            // "for" structure to store "queryResult" values into the "User" list collection ( in-memory objects)

            while (!done)
            {
                for (int j = 0; j < queryUser.records.Length; j++)
                {
                    sObject recordUser = queryUser.records[j]; // taking the first node or object.
                    User    u          = new User();           // instance of people

                    //add value to people properties
                    u.ID             = recordUser.Any[0].InnerText.ToString();
                    u.NAME           = recordUser.Any[1].InnerText.ToString();
                    u.ISACTIVE       = recordUser.Any[2].InnerText.ToString();
                    u.PROFILEID      = recordUser.Any[3].InnerText.ToString();
                    u.EMPLOYEENUMBER = recordUser.Any[4].InnerText.ToString();
                    if (!string.IsNullOrEmpty(recordUser.Any[5].InnerText.ToString()))
                    {
                        String result = recordUser.Any[5].InnerText.ToString().Substring(0, 10);
                        u.LASTLOGINDATE = DateTime.ParseExact(result, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        u.LASTLOGINDATE = DateTime.ParseExact("0001-01-01", "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
                    }
                    u.FEDERATIONIDENTIFIER = recordUser.Any[6].InnerText.ToString();
                    u.ENTERPRISE_ID__C     = recordUser.Any[7].InnerText.ToString();
                    u.LICENSE_TYPE__C      = recordUser.Any[8].InnerText.ToString();
                    u.PEOPLEKEY__C         = recordUser.Any[9].InnerText.ToString();
                    u.INACTIVITYDTTM__C    = recordUser.Any[10].InnerText.ToString();
                    u.INACTIVITYIND__C     = recordUser.Any[11].InnerText.ToString();

                    // add people object into people list.
                    sfUser.Add(u);
                }
                if (queryUser.done)
                {
                    done = true;
                }
                else
                {
                    queryUser = this.connect.queryMore(queryUser.queryLocator);
                }
            }
            //}
            // return true;
        }
예제 #18
0
        public static List <SalesForceWebReference.Account> getAccounts(SforceService _binding, string Id, string DealerName, bool ActiveOnly)
        {
            QueryResult qr = null;

            //SalesForceWebReference.Account _account;

            ////qr = _binding.query("select Id, Account__c, Name, FirstName__c, LastName__c, CreatedDate from  from Dealer_Lead_c");
            string query = _accountQuery;

            if (DealerName.Length > 0 || Id.Length > 0 || ActiveOnly == true)
            {
                query += " Where ";

                if (DealerName.Length > 0)
                {
                    query += " Name like '%" + DealerName + "%' ";

                    if (Id.Length > 0)
                    {
                        query += " AND Id = '" + Id + "' ";
                    }
                    if (ActiveOnly)
                    {
                        query += " AND BRGCaseMail_Active__c = true";
                    }
                }
                else if (Id.Length > 0)
                {
                    query += " Id = '" + Id + "' ";

                    if (ActiveOnly)
                    {
                        query += " AND BRGCaseMail_Active__c = true";
                    }
                }
                else if (ActiveOnly)
                {
                    query += " BRGCaseMail_Active__c = true ";
                }
            }

            query += " order by Name asc";

            qr = _binding.query(query);

            List <Account> _accounts = new List <Account>();

            if (qr.records != null)
            {
                for (int i = 0; i < qr.records.Length; i++)
                {
                    _accounts.Add(((Account)qr.records[i]));

                    //Debug.WriteLine(((Account)qr.records[i]).Name);
                }
            }
            return(_accounts);
        }
예제 #19
0
        private void querySample()
        {
            String soqlQuery = "SELECT FirstName, LastName FROM Contact";

            try
            {
                QueryResult qr   = binding.query(soqlQuery);
                bool        done = false;

                if (qr.size > 0)
                {
                    Console.WriteLine("Logged-in user can see "
                                      + qr.records.Length + " contact records.");

                    while (!done)
                    {
                        Console.WriteLine("");
                        sObject[] records = qr.records;
                        for (int i = 0; i < records.Length; i++)
                        {
                            Contact con   = (Contact)records[i];
                            string  fName = con.FirstName;
                            string  lName = con.LastName;
                            if (fName == null)
                            {
                                Console.WriteLine("Contact " + (i + 1) + ": " + lName);
                            }
                            else
                            {
                                Console.WriteLine("Contact " + (i + 1) + ": " + fName
                                                  + " " + lName);
                            }
                        }

                        if (qr.done)
                        {
                            done = true;
                        }
                        else
                        {
                            qr = binding.queryMore(qr.queryLocator);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("No records found.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("\nFailed to execute query succesfully," +
                                  "error message was: \n{0}", ex.Message);
            }
            Console.WriteLine("\nPress ENTER to continue...");
            Console.ReadLine();
        }
예제 #20
0
        public List <Case> search_rma()
        {
            string userName;
            string password;

            userName = "******";
            password = "******";
            //use default binding and address from app.config
            // string securityToken = "xxxxxxxxxxxxxxx";

            SforceService sfdcBinding        = null;
            LoginResult   currentLoginResult = null;

            sfdcBinding = new SforceService();
            try
            {
                currentLoginResult = sfdcBinding.login(userName, password);
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                // This is likley to be caused by bad username or password
                sfdcBinding = null;
                throw (ex);
            }
            catch (Exception ex)
            {
                // This is something else, probably comminication
                sfdcBinding = null;
                throw (ex);
            }


            //Change the binding to the new endpoint
            sfdcBinding.Url = currentLoginResult.serverUrl;

            //Create a new session header object and set the session id to that returned by the login
            sfdcBinding.SessionHeaderValue           = new SessionHeader();
            sfdcBinding.SessionHeaderValue.sessionId = currentLoginResult.sessionId;

            QueryResult queryResult = null;
            String      SOQL        = "";
            List <Case> case_result = new List <Case>();

            // SOQL = "SELECT Id,Return_Resolution__c,Description ,CaseNumber,IC_Barcodes__c,RMA_number__c,Production_Findings__c,Channel__c,CreatedDate FROM case where CreatedDate >=2017-01-01T12:00:00Z AND CreatedDate  <=2017-05-31T12:00:00Z";
            SOQL        = "SELECT Id,Return_Resolution__c,Description,CaseNumber,IC_Barcodes__c,RMA_number__c,Production_Findings__c,Channel__c,CreatedDate FROM case where CreatedDate = YESTERDAY";
            queryResult = sfdcBinding.query(SOQL);
            for (int i = 0; i < queryResult.size; i++)
            {
                case_result.Add((Case)queryResult.records[i]);
            }



            return(case_result);
        }
예제 #21
0
        public static SalesForceWebReference.Dealer_Lead__c getApplication(SforceService _binding, string ApplicationID)
        {
            QueryResult qr = null;

            qr = _binding.query(_appQuery + " Where Id = '" + ApplicationID + "'");

            if (qr.records != null && qr.records.Length > 0)
            {
                return((Dealer_Lead__c)qr.records[0]);
            }
            else
            {
                return(null);
            }
        }
예제 #22
0
        public QueryResult GetSalesForceQualifiedAmbassadorDetail(string Id)
        {
            QueryResult   qr          = new QueryResult();
            SforceService SfdcBinding = SalesForceSession();

            try
            {
                string strQuery = (@"select id, Name, AmbassadorID__c, Mobile_Phone__c, Phone__c, SponsorID__c, Q_Ambassador_Email__c, Zip_Code__c, Available_To_Receive_Leads__c, CreatedById from Ambassador__c where Id='" + Id + "'");
                qr = SfdcBinding.query(strQuery);
                return(qr);
            }
            catch (Exception)
            {
                return(qr);
            }
        }
예제 #23
0
        public QueryResult CurrentSalesForceQualifiedAmbassadorslist()
        {
            QueryResult   qr          = new QueryResult();
            SforceService SfdcBinding = SalesForceSession();

            try
            {
                string strQuery = (@"select id,AmbassadorID__c from Ambassador__c where id !='' order by AmbassadorID__c ");
                qr = SfdcBinding.query(strQuery);
                return(qr);
            }
            catch (Exception)
            {
                return(qr);
            }
        }
        static void Main(string[] args)
        {
            SforceService SfdcBinding        = null;
            LoginResult   CurrentLoginResult = null;

            SfdcBinding = new SforceService();
            try
            {
                System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
                CurrentLoginResult                       = SfdcBinding.login(Constants.USERNAME, Constants.PASSWORD + Constants.TOKEN);
                SfdcBinding.Url                          = CurrentLoginResult.serverUrl;
                SfdcBinding.SessionHeaderValue           = new SessionHeader();
                SfdcBinding.SessionHeaderValue.sessionId = CurrentLoginResult.sessionId;
                QueryResult queryResult = null;
                String      SOQL        = "";
                SOQL        = "select FirstName, LastName, Phone from Lead LIMIT 10";
                queryResult = SfdcBinding.query(SOQL);
                if (queryResult.size > 0)
                {
                    for (int i = 0; i < queryResult.records.Length; i++)
                    {
                        Lead   lead          = (Lead)queryResult.records[i];
                        string firstName     = lead.FirstName;
                        string lastName      = lead.LastName;
                        string businessPhone = lead.Phone;
                        Console.WriteLine("First Name " + firstName + ", Last Name " + lastName + ", Phone " + businessPhone);
                    }
                }
                else
                {
                    Console.WriteLine("No records returned.");
                }
            }
            catch (System.Web.Services.Protocols.SoapException e)
            {
                // This is likley to be caused by bad username or password
                SfdcBinding = null;
                Console.WriteLine("SOAP Exception occured " + e.Message.ToString());
            }
            catch (Exception e)
            {
                // This is something else, probably comminication
                SfdcBinding = null;
                Console.WriteLine("Exception occured " + e.Message.ToString());
            }
        }
예제 #25
0
        public QueryResult GetLeadDetail(string Id)
        {
            QueryResult   qr          = new QueryResult();
            SforceService SfdcBinding = SalesForceSession();


            try
            {
                string strQuery = ("SELECT Id,Created_Date_DB__c,FirstName,Account_Notes__c,LastName,Status,Email,MobilePhone,Phone,Address,LeadSource from Lead  where Id='" + Id + "'");
                qr = SfdcBinding.query(strQuery);

                return(qr);
            }
            catch (Exception)
            {
                return(qr);
            }
        }
예제 #26
0
        public QueryResult GetSalesForceLeadByEmail(String email, string phone)
        {
            QueryResult   qr          = new QueryResult();
            SforceService SfdcBinding = SalesForceSession();

            try
            {
                string strQuery = ("SELECT Id, FirstName,LastName,Email,Phone,Address,Street,City,State,Country,PostalCode from Lead where Email = '" + email + "' and Phone='" + phone + "'");
                // string strQuery = ("SELECT Id, FirstName,Account_Notes__c,LastName,Created_Date_DB__c,Status,Email,Phone,Address,LeadSource from Lead where Sponsor__c ='" + FirstLastID + "' " + whereClause);
                qr = SfdcBinding.query(strQuery);

                return(qr);
            }
            catch (Exception)
            {
                return(qr);
            }
        }
예제 #27
0
        executeQueryOnSalesforce(
            string queryStr)
        {
            QueryResult qr = null;

            try
            {
                qr = salesforceServiceClient.query(queryStr);
            }
            catch (Exception ex)
            {
                logger.ErrorException(
                    "Failed to execute the query on salesforce",
                    ex);
            }

            return(qr);
        }
예제 #28
0
        public QueryResult GetSalesForceLead(String ID, string whereClause = "")
        {
            QueryResult   qr          = new QueryResult();
            SforceService SfdcBinding = SalesForceSession();

            try
            {
                whereClause = whereClause.Replace("CreatedDate", "Created_Date_DB__c");

                string strQuery = ("SELECT Id, FirstName,Account_Notes__c,LastName,Created_Date_DB__c,Status,Email,Phone,Address,LeadSource from Lead where Ambassador__c ='" + ID + "' " + whereClause);
                qr = SfdcBinding.query(strQuery);

                return(qr);
            }
            catch (Exception)
            {
                return(qr);
            }
        }
예제 #29
0
        public QueryResult ExecuteSelectQuery(string filterClause, IEnumerable <string> selectColumnNames)
        {
            try
            {
                filterClause = filterClause.Replace("\"", "'");
                var querySelectClause = string.Join(", ", selectColumnNames);

                var query       = string.Format("SELECT {0} FROM ACCOUNT WHERE {1}", querySelectClause, filterClause);
                var queryResult = _salesforceService.query(query);

                return(queryResult);
            }
            catch (Exception exception)
            {
                throw new Exception("There was an error retrieving query from sales force.")
                      {
                          Source = exception.Source
                      };
            }
        }
예제 #30
0
        public static List <SalesForceWebReference.Account> getBRGCaseMailActiveAccounts(SforceService _binding)
        {
            QueryResult qr = null;

            //SalesForceWebReference.Account _account;

            ////qr = _binding.query("select Id, Account__c, Name, FirstName__c, LastName__c, CreatedDate from  from Dealer_Lead_c");

            qr = _binding.query(_accountQuery + " where BRGCaseMail_Active__c = true order by Name asc");

            List <Account> _accounts = new List <Account>();

            for (int i = 0; i < qr.records.Length; i++)
            {
                _accounts.Add(((Account)qr.records[i]));

                //Debug.WriteLine(((Account)qr.records[i]).Name);
            }

            return(_accounts);
        }