public static void createAccountBlock(Account account, int i, Transform parentTransform, Transform Block, SubRingDiskController subRingDiskCtrl)
    {
        Vector3 setRotation = parentTransform.rotation.eulerAngles;
        setRotation.x = -90.0f;

        float posX = (i < 1) ? 1.29f : 1.29f + (i * (1.29f * 0.14f));
        float posY = 0f;

        Transform currentBlock = (Transform)Instantiate(Block, new Vector3(0, 0, 0), Quaternion.identity);
        currentBlock.SetParent(parentTransform);
        currentBlock.localScale = new Vector3(0.5f, 0.5f, 0.5f);
        currentBlock.rotation = Quaternion.Euler(setRotation);
        currentBlock.localPosition = new Vector3(posX, posY, 0f);

        //get an instance of the component.
        Transform blockInstance = currentBlock.GetComponent<Transform>();

        BlockController blockController = blockInstance.GetComponent<BlockController>();

        blockController.speed = account.Priority;
        blockController.order = i;

        blockController.objectId = account.Id;
        blockController.objectName = account.Name;
        blockController.objectType = "Account";
        blockController.labels = new string[]{"Account Number", "Type", "Industry", "Customer Priority", "Upsell Opportunity"};
        blockController.fields = new string[]{account.AccountNumber, account.Type, account.Industry, account.CustomerPriority, account.UpsellOpportunity};
        blockController.description = account.Description;
        blockController.parentSubRingDiskController = subRingDiskCtrl;
        blockController.setText ("Account");
    }
    public static void createCampaignBlock(Campaign campaign, int i, Transform parentTransform, Transform Block, SubRingDiskController subRingDiskCtrl)
    {
        Vector3 setRotation = parentTransform.rotation.eulerAngles;
        setRotation.x = -90.0f;

        float posX = (i < 1) ? 1.29f : 1.29f + (i * (1.29f * 0.14f));
        float posY = 0f;

        Transform currentBlock = (Transform)Instantiate(Block, new Vector3(0, 0, 0), Quaternion.identity);
        currentBlock.SetParent(parentTransform);
        currentBlock.localScale = new Vector3(0.5f, 0.5f, 0.5f);
        currentBlock.rotation = Quaternion.Euler(setRotation);
        currentBlock.localPosition = new Vector3(posX, posY, 0f);

        //get an instance of the component.
        Transform blockInstance = currentBlock.GetComponent<Transform>();

        BlockController blockController = blockInstance.GetComponent<BlockController>();

        blockController.speed = campaign.Priority;
        blockController.order = i;

        blockController.objectId = campaign.Id;
        blockController.objectName = campaign.Name;
        blockController.objectType = "Campaign";
        blockController.labels = new string[]{"Type", "Status", "Start Date", "End Date", "Total Leads"};
        blockController.fields = new string[]{campaign.Type, campaign.Status, campaign.StartDate, campaign.EndDate, "" + campaign.NumberOfLeads + ""};
        blockController.description = campaign.Description;
        blockController.parentSubRingDiskController = subRingDiskCtrl;
        blockController.setText ("Campaign");
    }
    public static void createContractBlock(Contract contract, int i, Transform parentTransform, Transform Block, SubRingDiskController subRingDiskCtrl)
    {
        Vector3 setRotation = parentTransform.rotation.eulerAngles;
        setRotation.x = -90.0f;

        float posX = (i < 1) ? 1.29f : 1.29f + (i * (1.29f * 0.14f));
        float posY = 0f;

        Transform currentBlock = (Transform)Instantiate(Block, new Vector3(0, 0, 0), Quaternion.identity);
        currentBlock.SetParent(parentTransform);
        currentBlock.localScale = new Vector3(0.5f, 0.5f, 0.5f);
        currentBlock.rotation = Quaternion.Euler(setRotation);
        currentBlock.localPosition = new Vector3(posX, posY, 0f);

        //get an instance of the component.
        Transform blockInstance = currentBlock.GetComponent<Transform>();

        BlockController blockController = blockInstance.GetComponent<BlockController>();

        blockController.speed = contract.Priority;
        blockController.order = i;

        blockController.objectId = contract.Id;
        blockController.objectName = contract.ContractNumber;
        blockController.objectType = "Contract";
        blockController.labels = new string[]{"Status", "Start Date", "End Date", "Contract Term"};
        blockController.fields = new string[]{contract.Status, contract.StartDate, contract.EndDate, contract.ContractTerm + " months"};
        blockController.description = contract.Description;
        blockController.parentSubRingDiskController = subRingDiskCtrl;
        blockController.setText ("Contract");

        if (contract.SpecialTerms != null) {
            blockController.leftTitle = "Special Terms";
            blockController.leftText = contract.SpecialTerms;
        }
    }
    // creates a ring as needed for an opportunity
    private static void createRing(Opportunity opp, int i, Transform parentTransform, Transform Ring, Transform Block, Transform blockBox)
    {
        //Vector3 resetRotation = parentTransform.rotation.eulerAngles;
        //resetRotation.x = 90.0f;

        Transform currentRing = (Transform)Instantiate(Ring, new Vector3(0, 0, 0), Quaternion.identity);

        currentRing.SetParent(GameObject.Find("Rings").transform);
        currentRing.localScale = new Vector3(5, 5, 5);
        //currentRing.rotation = Quaternion.Euler(resetRotation);
        currentRing.localPosition = new Vector3(0, 0, i);

        //get an instance of the component.
        Transform ringInstance = currentRing.GetComponent <Transform>();

        RingController ringController = ringInstance.GetComponent <RingController>();

        ringController.speed              = opp.urgent;
        ringController.vertOrder          = (float)i + 1f;
        ringController.transform.position = currentRing.transform.position;
        ringController.originPosition     = new Vector3(0, 0, i);
        ringController.shiftedPosition    = new Vector3(0, 0, i);
        ringController.zone = i;

        // set the title of the current opportunity
        // used by the opportuntiy popup.
        ringController.titleTextValue = opp.oppName;

        // get reference to the subRingDisk controller
        // as the subObjects are built and rendered to the enviroment -
        // construct the subRingDisk object
        // This is used for rotation management based on priorit

        Transform subRingDisk = ringInstance.FindChild("subRingDisk");

        subRingDisk.SetParent(ringInstance);

        SubRingDiskController subRingDiskCtrl = subRingDisk.GetComponent <SubRingDiskController>();

        //subRingDisk.RotateAround(subRingDisk.position,Vector3.up, 180f);


        // create Account object and block
        if (opp.account != null)
        {
            Vector3 setRotation = parentTransform.rotation.eulerAngles;
            //setRotation.x = -90.0f;
            setRotation.y = 0.0f;

            Transform currentBlockBox = (Transform)Instantiate(blockBox, new Vector3(0, 0, 0), Quaternion.identity);
            currentBlockBox.SetParent(subRingDisk);
            currentBlockBox.localScale    = new Vector3(1f, 1f, 1f);
            currentBlockBox.rotation      = Quaternion.Euler(setRotation);
            currentBlockBox.localPosition = new Vector3(0f, 0f, 0f);

            SubObjectUtil.createAccountBlock(opp.account, 0, currentBlockBox, Block, subRingDiskCtrl);
            subRingDiskCtrl.accounts.Add(opp.account);
        }

        // create Opportunity Products objects and blocks
        if (opp.oppProducts != null)
        {
            int o = 0;

            Vector3 setRotation = parentTransform.rotation.eulerAngles;
            //setRotation.x = -90.0f;
            setRotation.y = 45.0f;

            Transform currentBlockBox = (Transform)Instantiate(blockBox, new Vector3(0, 0, 0), Quaternion.identity);
            currentBlockBox.SetParent(subRingDisk);
            currentBlockBox.localScale    = new Vector3(1f, 1f, 1f);
            currentBlockBox.rotation      = Quaternion.Euler(setRotation);
            currentBlockBox.localPosition = new Vector3(0f, 0f, 0f);

            foreach (OpportunityProduct oppProduct in opp.oppProducts)
            {
                SubObjectUtil.createOppProductBlock(oppProduct, o, currentBlockBox, Block, subRingDiskCtrl);
                subRingDiskCtrl.opportuniutyProducts.Add(oppProduct);
                o++;
            }
        }

        // create campaign object and block
        if (opp.campaign != null)
        {
            Vector3 setRotation = parentTransform.rotation.eulerAngles;
            //setRotation.x = -90.0f;
            setRotation.y = 180f;

            Transform currentBlockBox = (Transform)Instantiate(blockBox, new Vector3(0, 0, 0), Quaternion.identity);
            currentBlockBox.SetParent(subRingDisk);
            currentBlockBox.localScale    = new Vector3(1f, 1f, 1f);
            currentBlockBox.rotation      = Quaternion.Euler(setRotation);
            currentBlockBox.localPosition = new Vector3(0f, 0f, 0f);

            SubObjectUtil.createCampaignBlock(opp.campaign, 0, currentBlockBox, Block, subRingDiskCtrl);
            subRingDiskCtrl.campaigns.Add(opp.campaign);
        }

        if (opp.contract != null)
        {
            Vector3 setRotation = parentTransform.rotation.eulerAngles;
            //setRotation.x = -90.0f;
            setRotation.y = 270f;

            Transform currentBlockBox = (Transform)Instantiate(blockBox, new Vector3(0, 0, 0), Quaternion.identity);
            currentBlockBox.SetParent(subRingDisk);
            currentBlockBox.localScale    = new Vector3(1f, 1f, 1f);
            currentBlockBox.rotation      = Quaternion.Euler(setRotation);
            currentBlockBox.localPosition = new Vector3(0f, 0f, 0f);

            SubObjectUtil.createContractBlock(opp.contract, 0, currentBlockBox, Block, subRingDiskCtrl);
            subRingDiskCtrl.contracts.Add(opp.contract);
        }


        //TODO: figure out order query issue.
//		SubObjectUtil.createOrderBlock(4,currentRing,Block);

        //TODO: Write a query for this Events
//		SubObjectUtil.createEventBlock(4,currentRing,Block);



        //TODO: Write a query for Tasks
//		SubObjectUtil.createTaskBlock(7,currentRing,Block);

        //TODO: Write a query for Pricebooks
//		SubObjectUtil.createPriceBookBlock(1,currentRing,Block);
    }
    public static void createOppProductBlock(OpportunityProduct oppProduct, int i, Transform parentTransform, Transform Block, SubRingDiskController subRingDiskCtrl)
    {
        Vector3 setRotation = parentTransform.rotation.eulerAngles;

        setRotation.x = -90.0f;

        float posX = (i < 1) ? 1.29f : 1.29f + (i * (1.29f * 0.14f));;
        float posY = 0f;

        Transform currentBlock = (Transform)Instantiate(Block, new Vector3(0, 0, 0), Quaternion.identity);

        currentBlock.SetParent(parentTransform);
        currentBlock.localScale    = new Vector3(0.5f, 0.5f, 0.5f);;
        currentBlock.rotation      = Quaternion.Euler(setRotation);
        currentBlock.localPosition = new Vector3(posX, posY, 0f);



        //get an instance of the component.
        Transform blockInstance = currentBlock.GetComponent <Transform>();

        BlockController blockController = blockInstance.GetComponent <BlockController>();

        blockController.speed = oppProduct.Priority;
        blockController.order = i;

        blockController.objectId    = oppProduct.Id;
        blockController.objectName  = oppProduct.Name;
        blockController.objectType  = "OpportunityProduct";
        blockController.labels      = new string[] { "Product", "List Price", "Sales Price", "Quantity", "Total Price" };
        blockController.fields      = new string[] { oppProduct.Product, oppProduct.ListPrice.ToString("$0,0.00"), oppProduct.UnitPrice.ToString("$0,0.00"), "" + oppProduct.Quantity + "", oppProduct.TotalPrice.ToString("$0,0.00") };
        blockController.description = oppProduct.Description;
        blockController.parentSubRingDiskController = subRingDiskCtrl;
        blockController.setText("Opportunity Product");
    }
    public static void createCampaignBlock(Campaign campaign, int i, Transform parentTransform, Transform Block, SubRingDiskController subRingDiskCtrl)
    {
        Vector3 setRotation = parentTransform.rotation.eulerAngles;

        setRotation.x = -90.0f;

        float posX = (i < 1) ? 1.29f : 1.29f + (i * (1.29f * 0.14f));
        float posY = 0f;

        Transform currentBlock = (Transform)Instantiate(Block, new Vector3(0, 0, 0), Quaternion.identity);

        currentBlock.SetParent(parentTransform);
        currentBlock.localScale    = new Vector3(0.5f, 0.5f, 0.5f);
        currentBlock.rotation      = Quaternion.Euler(setRotation);
        currentBlock.localPosition = new Vector3(posX, posY, 0f);


        //get an instance of the component.
        Transform blockInstance = currentBlock.GetComponent <Transform>();

        BlockController blockController = blockInstance.GetComponent <BlockController>();

        blockController.speed = campaign.Priority;
        blockController.order = i;

        blockController.objectId    = campaign.Id;
        blockController.objectName  = campaign.Name;
        blockController.objectType  = "Campaign";
        blockController.labels      = new string[] { "Type", "Status", "Start Date", "End Date", "Total Leads" };
        blockController.fields      = new string[] { campaign.Type, campaign.Status, campaign.StartDate, campaign.EndDate, "" + campaign.NumberOfLeads + "" };
        blockController.description = campaign.Description;
        blockController.parentSubRingDiskController = subRingDiskCtrl;
        blockController.setText("Campaign");
    }
    public static void createAccountBlock(Account account, int i, Transform parentTransform, Transform Block, SubRingDiskController subRingDiskCtrl)
    {
        Vector3 setRotation = parentTransform.rotation.eulerAngles;

        setRotation.x = -90.0f;

        float posX = (i < 1) ? 1.29f : 1.29f + (i * (1.29f * 0.14f));
        float posY = 0f;

        Transform currentBlock = (Transform)Instantiate(Block, new Vector3(0, 0, 0), Quaternion.identity);

        currentBlock.SetParent(parentTransform);
        currentBlock.localScale    = new Vector3(0.5f, 0.5f, 0.5f);
        currentBlock.rotation      = Quaternion.Euler(setRotation);
        currentBlock.localPosition = new Vector3(posX, posY, 0f);


        //get an instance of the component.
        Transform blockInstance = currentBlock.GetComponent <Transform>();

        BlockController blockController = blockInstance.GetComponent <BlockController>();

        blockController.speed = account.Priority;
        blockController.order = i;

        blockController.objectId    = account.Id;
        blockController.objectName  = account.Name;
        blockController.objectType  = "Account";
        blockController.labels      = new string[] { "Account Number", "Type", "Industry", "Customer Priority", "Upsell Opportunity" };
        blockController.fields      = new string[] { account.AccountNumber, account.Type, account.Industry, account.CustomerPriority, account.UpsellOpportunity };
        blockController.description = account.Description;
        blockController.parentSubRingDiskController = subRingDiskCtrl;
        blockController.setText("Account");
    }
    public static void createContractBlock(Contract contract, int i, Transform parentTransform, Transform Block, SubRingDiskController subRingDiskCtrl)
    {
        Vector3 setRotation = parentTransform.rotation.eulerAngles;

        setRotation.x = -90.0f;

        float posX = (i < 1) ? 1.29f : 1.29f + (i * (1.29f * 0.14f));
        float posY = 0f;

        Transform currentBlock = (Transform)Instantiate(Block, new Vector3(0, 0, 0), Quaternion.identity);

        currentBlock.SetParent(parentTransform);
        currentBlock.localScale    = new Vector3(0.5f, 0.5f, 0.5f);
        currentBlock.rotation      = Quaternion.Euler(setRotation);
        currentBlock.localPosition = new Vector3(posX, posY, 0f);


        //get an instance of the component.
        Transform blockInstance = currentBlock.GetComponent <Transform>();

        BlockController blockController = blockInstance.GetComponent <BlockController>();

        blockController.speed = contract.Priority;
        blockController.order = i;

        blockController.objectId    = contract.Id;
        blockController.objectName  = contract.ContractNumber;
        blockController.objectType  = "Contract";
        blockController.labels      = new string[] { "Status", "Start Date", "End Date", "Contract Term" };
        blockController.fields      = new string[] { contract.Status, contract.StartDate, contract.EndDate, contract.ContractTerm + " months" };
        blockController.description = contract.Description;
        blockController.parentSubRingDiskController = subRingDiskCtrl;
        blockController.setText("Contract");

        if (contract.SpecialTerms != null)
        {
            blockController.leftTitle = "Special Terms";
            blockController.leftText  = contract.SpecialTerms;
        }
    }
    public static void createOppProductBlock(OpportunityProduct oppProduct, int i, Transform parentTransform, Transform Block, SubRingDiskController subRingDiskCtrl)
    {
        Vector3 setRotation = parentTransform.rotation.eulerAngles;
        setRotation.x = -90.0f;

        float posX = (i < 1) ? 1.29f : 1.29f + (i * (1.29f * 0.14f));;
        float posY = 0f;

        Transform currentBlock = (Transform)Instantiate(Block, new Vector3(0, 0, 0), Quaternion.identity);
        currentBlock.SetParent(parentTransform);
        currentBlock.localScale = new Vector3(0.5f, 0.5f, 0.5f);;
        currentBlock.rotation = Quaternion.Euler(setRotation);
        currentBlock.localPosition = new Vector3(posX, posY, 0f);

        //get an instance of the component.
        Transform blockInstance = currentBlock.GetComponent<Transform>();

        BlockController blockController = blockInstance.GetComponent<BlockController>();

        blockController.speed = oppProduct.Priority;
        blockController.order = i;

        blockController.objectId = oppProduct.Id;
        blockController.objectName = oppProduct.Name;
        blockController.objectType = "OpportunityProduct";
        blockController.labels = new string[]{"Product", "List Price", "Sales Price", "Quantity", "Total Price"};
        blockController.fields = new string[]{oppProduct.Product, oppProduct.ListPrice.ToString ("$0,0.00"), oppProduct.UnitPrice.ToString ("$0,0.00"), "" + oppProduct.Quantity + "", oppProduct.TotalPrice.ToString ("$0,0.00")};
        blockController.description = oppProduct.Description;
        blockController.parentSubRingDiskController = subRingDiskCtrl;
        blockController.setText ("Opportunity Product");
    }