Пример #1
0
    // Use this for initialization
    IEnumerator Start()
    {
        Cursor.visible = false;

        //init object
        sf = gameObject.AddComponent <Salesforce>();

        // login
        Debug.Log("Password + security token = " + password + " " + securityToken);
        sf.login(username, password + securityToken);

        // wait for Auth Token
        while (sf.token == null)
        {
            yield return(new WaitForSeconds(0.2f));
        }


        string mainQuery = "";

        mainQuery += "SELECT Id, IsDeleted, AccountId, IsPrivate, Name, Description, StageName, Amount, Probability, ExpectedRevenue,";
        mainQuery += " TotalOpportunityQuantity, CloseDate, Type, NextStep, LeadSource, IsClosed, IsWon, ForecastCategory,";
        mainQuery += " ForecastCategoryName, CampaignId, HasOpportunityLineItem, Pricebook2Id, OwnerId, CreatedDate, CreatedById,";
        mainQuery += " LastModifiedDate, LastModifiedById, SystemModstamp, LastActivityDate, FiscalQuarter, FiscalYear, Fiscal,";
        mainQuery += " LastViewedDate, LastReferencedDate, Urgent__c,";
        //Account
        mainQuery += " Account.Id, Account.Name, Account.AccountNumber, Account.Description, Account.Type, Account.Industry, Account.CustomerPriority__c, Account.UpsellOpportunity__c, Account.Priority__c,";

        //OppProducts
        mainQuery += " (SELECT Id, OpportunityId, SortOrder, PricebookEntryId, Product2.Name, ProductCode, Name, Quantity, TotalPrice, UnitPrice, ListPrice, ServiceDate, Description, Priority__c FROM OpportunityLineItems ORDER BY Priority__c DESC),";

        // Campaigns
        mainQuery += " Campaign.Id, Campaign.Name, Campaign.AmountWonOpportunities, Campaign.AmountAllOpportunities, Campaign.NumberOfWonOpportunities, Campaign.NumberOfOpportunities, Campaign.NumberOfResponses, Campaign.NumberOfContacts, Campaign.NumberOfConvertedLeads, Campaign.NumberOfLeads, Campaign.Description, Campaign.IsActive, Campaign.NumberSent, Campaign.ExpectedResponse, Campaign.ActualCost, Campaign.BudgetedCost, Campaign.ExpectedRevenue, Campaign.EndDate, Campaign.StartDate, Campaign.Status, Campaign.Type, Campaign.ParentId, Campaign.OwnerId, Campaign.Priority__c, ";

        // Contracts
        mainQuery += " Contract.Id, Contract.Status, Contract.StartDate, Contract.EndDate, Contract.ContractTerm, Contract.ContractNumber, Contract.Description, Contract.SpecialTerms, Contract.Priority__c ";

        mainQuery += " FROM Opportunity";

        sf.query(mainQuery);

        // wait for query results
        while (sf.response == null)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        Debug.Log("Response from Salesforce: " + sf.response);

        // Extract the JSON encoded value for the Store the procedure ID (Case) in a field
        // We are using the free add-in from the Unity3D Asset STore called BoomLagoon.

        // Using BoomLagoon, create a JSON Object from the Salesforce response.
        JSONObject json = JSONObject.Parse(sf.response);


        JSONArray records = json.GetArray("records");

        Debug.Log("records = " + records);

        OpportunityUtil.BuildOpportunityRings(records, transform, Ring, Block, blockBox);
    }
Пример #2
0
    // Use this for initialization
    IEnumerator Start()
    {
        //init object
        sf = gameObject.AddComponent <Salesforce>();

        // login
        sf.login(username, password + securityToken);

        // wait for Auth Token
        while (sf.token == null)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        // query: Retrieve the next closest scheduled surgery / procedure for the current patient
        sf.query("SELECT Id, Surgery_Type__c FROM Case WHERE ContactId = '" + patientID + "' ORDER BY Surgery_Date__c LIMIT 1");

        // wait for query results
        while (sf.response == null)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        Debug.Log("Retrieve Procedure (Case):" + sf.response);

        // Extract the JSON encoded value for the Store the procedure ID (Case) in a field
        // We are using the free add-in from the Unity3D Asset STore called BoomLagoon.


        // Using BoomLagoon, create a JSON Object from the Salesforce response.
        JSONObject json = JSONObject.Parse(sf.response);

        // Retrieve the records array (only one record is returned) and traverse that record's
        // attributes to get the case Id and Surgery Type
        JSONArray records = json.GetArray("records");

        Debug.Log("records = " + records);

        foreach (JSONValue row in records)
        {
            JSONObject rec = JSONObject.Parse(row.ToString());
            Debug.Log("Procedure (case) Id = " + rec.GetString("Id") +
                      "Surgery Type = " + rec.GetString("Surgery_Type__c"));

            // Assign the case and surgery type
            procedureID = rec.GetString("Id");
            surgeryType = rec.GetString("Surgery_Type__c");
        }

        // Get the number of X-Rays to load from the Playmaker FSM Global Variables.
        int numXrays = FsmVariables.GlobalVariables.FindFsmInt("numImagesToLoad").Value;

        // query: retrieve 5 images (attachments) from the proecdure (case) record
        sf.query("SELECT Id, Name, Body FROM Attachment WHERE ParentId = '" + procedureID + "' LIMIT " + numXrays);

        // wait for query results
        while (sf.response == null)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        Debug.Log("Xray Attachments = " + sf.response);

        // Using BoomLagoon, parse the JSON response .
        json = JSONObject.Parse(sf.response);

        // Retrieve the records array (up to five records are returned)
        // Traverse through each record to obtain the link to the attachment body
        records = json.GetArray("records");
        Debug.Log("records = " + records);

        int i = 1;         // X-Ray image ObjectName starts at xRay1

        foreach (JSONValue row in records)
        {
            JSONObject rec = JSONObject.Parse(row.ToString());
            Debug.Log("Body Link = " + rec.GetString("Body"));

            // get the attachment and store in the Texture Array
            sf.getAttachmentBody(rec.GetString("Body"), i);

            i++;
        }
    }