public List <DX_GetSecondaryAssayGraphData_Result> GetSecondaryAssayGraphData(string projectID, string assayID)
 {
     return(CBIS_DiscoveRx_Orders_ctx.DX_GetSecondaryAssayGraphData(projectID, assayID, "").OrderBy(d => d.Concentration).ToList());
 }
        public void GetOrderInfo()
        {
            order = CBIS_DiscoveRx_Orders_ctx.Orders.Where(o => o.AmbitOrderID.Contains(orderID)).FirstOrDefault();
            if (order != null)
            {
                orderID      = order.AmbitOrderID;
                commonID     = order.AmbitOrderID.Left(order.AmbitOrderID.NthIndexOf("-", 2));
                contractList = CBIS_HTSContracts_ctx.Contracts.Where(c => c.ContractID.Contains(commonID)).ToList();

                targetList         = string.Empty;
                assayModeList      = string.Empty;
                targetClassList    = string.Empty;
                assayTypeList      = string.Empty;
                targetAssayList    = string.Empty;
                quoteIDList        = string.Empty;
                primaryPlateID     = string.Empty;
                numberOfDatapoints = 0;
                numberOfCompounds  = order.NumberOfCompounds.ParseInt();
                numberOfAssays     = 0;



                if (contractList.Count > 0)
                {
                    this.contract = contractList[0];
                    GetServiceType(this.contract);

                    foreach (Contract contract in contractList)
                    {
                        quoteID      = contract.QuoteID;
                        quoteIDList += (quoteIDList == string.Empty) ? quoteID : "/ " + quoteID;
                        Dx_Request request = CBIS_KinomeScan_RequestManager_ctx.Dx_Request.Where(d => d.QuoteNumber == quoteID).FirstOrDefault();
                        if (request != null)
                        {
                            requestID       = request.Dx_RequestID;
                            assaySelectList = CBIS_KinomeScan_RequestManager_ctx.mtp_Dx_RequestAssaysSelect(requestID).ToList();
                            if (assaySelectList.Count > 0)
                            {
                                for (int i = 0; i < assaySelectList.Count; i++)
                                {
                                    if (!targetList.Contains(assaySelectList[i].Target))
                                    {
                                        targetList += assaySelectList[i].Target + ", ";
                                    }

                                    if (!assayModeList.Contains(assaySelectList[i].Mode))
                                    {
                                        assayModeList += assaySelectList[i].Mode + ", ";
                                    }

                                    if (!targetClassList.Contains(assaySelectList[i].Class))
                                    {
                                        targetClassList += assaySelectList[i].Class + ", ";
                                    }

                                    if (!assayTypeList.Contains(assaySelectList[i].Type))
                                    {
                                        assayTypeList += assaySelectList[i].Type.ToLower() + ", ";
                                    }

                                    targetAssayList += string.Format("{0} - {1} - {2}", assaySelectList[i].Target, assaySelectList[i].Type, assaySelectList[i].Mode) + "<br />";
                                    numberOfAssays  += 1;
                                }
                            }
                        }

                        Redundancies redundancies = 0;

                        if (Enum.TryParse(contract.Redundancy, out redundancies))
                        {
                            numberOfRedundancy = (int)redundancies;
                        }
                    }

                    targetList      = targetList.Left(targetList.Length - 2);
                    targetClassList = targetClassList.Left(targetClassList.Length - 2).ReplaceLastOccurrence(", ", " and ");
                    assayModeList   = assayModeList.Left(assayModeList.Length - 2).ReplaceLastOccurrence(", ", " and ");

                    if (order.AmbitOrderID.Contains("-d-"))
                    {
                        isPrimaryScreen = false;
                        Objective       = string.Format("{0} {1}", assayModeList, "Secondary Screen");
                    }
                    else if (order.AmbitOrderID.Contains("-c-"))
                    {
                        isPrimaryScreen = true;
                        Objective       = string.Format("{0} {1}", assayModeList, "Primary Screen");
                        //PrimaryAssayData = CBIS_DiscoveRx_Orders_ctx.DX_GetPrimaryAssayData(commonID).OrderBy(m => m.CompoundName).ThenBy(m => m.AssayTarget).ThenBy(m => m.AssayType).ThenBy(m => m.AssayFormat).ThenByDescending(m=>m.Concentration).ToList();
                        PrimaryAssayData = CBIS_DiscoveRx_Orders_ctx.DX_GetPrimaryAssayData(commonID).OrderBy(m => m.CompoundName).ThenBy(m => m.AssayTarget).ThenBy(m => m.ContainerID).ToList();

                        foreach (DX_GetPrimaryAssayData_Result data in PrimaryAssayData)
                        {
                            if (data.AssayTarget == "Various")
                            {
                                //data.AssayTarget = PrimaryAssayData.Where(p => p.CompoundName == data.CompoundName && p.AssayTarget != "Various").Count() > 0 ? PrimaryAssayData.Where(p => p.CompoundName == data.CompoundName && p.AssayTarget != "Various").First().AssayTarget : data.AssayTarget;
                            }

                            DX_GetPrimaryAssayData_Result NegControlData = PrimaryAssayData.Where(p => p.ContainerID == data.ContainerID && p.SubstanceID == "NegControl").Count() > 0 ? PrimaryAssayData.Where(p => p.ContainerID == data.ContainerID && p.SubstanceID == "NegControl").First(): null;
                            DX_GetPrimaryAssayData_Result PosControlData = PrimaryAssayData.Where(p => p.ContainerID == data.ContainerID && p.SubstanceID == "PosControl").Count() > 0 ? PrimaryAssayData.Where(p => p.ContainerID == data.ContainerID && p.SubstanceID == "PosControl").First(): null;

                            if (NegControlData != null)
                            {
                                data.NegControl          = NegControlData.AvgValue;
                                data.NegControlDeviation = NegControlData.SD;
                            }

                            if (PosControlData != null)
                            {
                                data.PosControl          = PosControlData.AvgValue;
                                data.PosControlDeviation = PosControlData.SD;
                            }
                        }

                        PrimaryPlateControl = CBIS_DiscoveRx_Orders_ctx.DX_GetPrimaryPlateControl(commonID).ToList();

                        if (PrimaryPlateControl.Count > 0)
                        {
                            primaryPlateID = PrimaryPlateControl.First().ContainerID;
                        }
                    }

                    if (contractList.Count > 1)
                    {
                        string noGreekSymbol = targetList.ReplaceGreekSymbol();
                        AssayReportSummary = CBIS_DiscoveRx_Orders_ctx.DX_GetAssayReportSummary(commonID).Where(m => (targetList.ToLower().Contains(m.AssayTarget.ToLower()) || (targetList.ReplaceGreekSymbol().ToLower().Contains(m.AssayTarget.ToLower())))).OrderBy(m => m.CompoundName).ThenBy(m => m.AssayTarget).ThenBy(m => m.AssayName).ThenBy(m => m.AssayFormat).ToList();
                        //AssayReportSummary = CBIS_DiscoveRx_Orders_ctx.DX_GetAssayReportSummary(commonID).OrderBy(m => m.CompoundName).ThenBy(m => m.AssayTarget).ThenBy(m => m.AssayName).ThenBy(m => m.AssayFormat).ToList();
                    }
                    else
                    {
                        AssayReportSummary = CBIS_DiscoveRx_Orders_ctx.DX_GetAssayReportSummary(orderID.Left(17)).Where(m => (targetList.ToLower().Contains(m.AssayTarget.ToLower()) || (targetList.ReplaceGreekSymbol().ToLower().Contains(m.AssayTarget.ToLower())))).OrderBy(m => m.CompoundName).ThenBy(m => m.AssayTarget).ThenBy(m => m.AssayName).ThenBy(m => m.AssayFormat).ToList();
                    }

                    if (isPrimaryScreen)
                    {
                        //numberOfCompounds += PrimaryAssayData.Where(a => a.CompoundName!=null).Select(a => a.CompoundName).Distinct().Count();
                        numberOfDatapoints += numberOfAssays * numberOfCompounds * numberOfRedundancy;
                    }
                    else
                    {
                        //numberOfCompounds += AssayReportSummary.Where(a => !a.AssayID.Contains("REF-")).Select(a=>a.CompoundName).Distinct().Count();
                        numberOfDatapoints += numberOfAssays * numberOfCompounds * 20;
                    }


                    if (!isExportPDF)
                    {
                        buildFigureLegend();
                    }
                }
            }
        }