// 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); }
// 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++; } }
/* // For testing purposes. Loads images in from the app directly. void Start() { m_Thumbs = new List<Thumbnail>(); //#if UNITY_EDITOR for (int o = 0; o < 2; o++ ) { for ( int i = 0; i < 6; ++i ) { Thumbnail temp = new Thumbnail( Resources.Load( "Textures/Photosphere00" + i ) as Texture2D, "Textures/Photosphere00" + i, Country(), Date() ); m_Thumbs.Add( temp ); } } } */ public IEnumerator Start() { m_Thumbs = new List<Thumbnail>(); // Set up the Salesforce object sf = gameObject.AddComponent<Salesforce>(); username = "******"; password = ""; // login sf.login(username, password + securityToken); // wait for Auth Token while(sf.token == null) yield return new WaitForSeconds(0.1f); // Query all Pano records so that we can get their attachments later. sf.query("SELECT id FROM Panorama__c"); // wait for query results while(sf.response == null) yield return new WaitForSeconds(0.1f); //Debug.Log ("Panos:" + sf.response); // Extract the JSON encoded value for the Store the ID 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); attachmentIDString = ""; // Reset foreach (JSONValue row in records) { JSONObject rec = JSONObject.Parse(row.ToString()); //Debug.Log("Id: " + rec.GetString("Id")); // Get the ID attachmentID = rec.GetString("Id"); // Build the id string to use later in a SOQL query. attachmentIDString = attachmentIDString + "'" + attachmentID + "'" + ","; } // Remove trailing comma before using in the SOQL query below. attachmentIDString = attachmentIDString.TrimEnd(','); //Debug.Log ("attachmentIDString: " + attachmentIDString); int attachmentLimit = 10; // Query Salesforce for all Pano attachments. sf.query ("SELECT Id, Name, Body FROM Attachment WHERE ParentId IN (" + attachmentIDString + ") LIMIT " + attachmentLimit); // wait for query results while(sf.response == null) yield return new WaitForSeconds(0.1f); Debug.Log("Pano Attachments = " + sf.response); // Using BoomLagoon, parse the JSON response . json = JSONObject.Parse(sf.response); // Retrieve the records array // Traverse through each record to obtain the link to the attachment body records = json.GetArray ("records"); Debug.Log ("records = " + records); int i = 1; // Loop through all returned Pano links and get the body for each. 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 getAttachmentBody (rec.GetString("Body"),i); i++; } }