Beispiel #1
0
    private void SetDownloadCdandResult(GridViewRowEventArgs e, DataRowView drvCurrent)
    {
        try
        {
            var orderId                  = Convert.ToInt64(drvCurrent["OrderId"]);
            var eventId                  = Convert.ToInt64(drvCurrent["EventID"]);
            var orderRepository          = IoC.Resolve <IOrderRepository>();
            var orderController          = IoC.Resolve <IOrderController>();
            var shippingDetailRepository = IoC.Resolve <IShippingDetailRepository>();
            var cdTrackingRepository     = IoC.Resolve <ICdContentGeneratorTrackingRepository>();

            var order = orderRepository.GetOrder(orderId);
            if (order != null)
            {
                //var productPurchased = order.OrderDetails.Where(od => od.DetailType == OrderItemType.ProductItem && od.IsCompleted).Any();
                var cdTracking = cdTrackingRepository.GetByEventIdAndCustomerId(eventId, CustomerId);

                var producRepository = IoC.Resolve <IElectronicProductRepository>();
                var product          = producRepository.GetElectronicProductForOrder(eventId, CustomerId);
                var cdContainerDiv   = (HtmlGenericControl)e.Row.FindControl("CdContainerDiv");

                if (cdContainerDiv != null)
                {
                    if (product != null && product.Id == (long)Product.UltraSoundImages && cdTracking != null && cdTracking.IsContentGenerated)
                    {
                        var imageDownloadInstructions = (HtmlContainerControl)e.Row.FindControl("ImageDownloadInstructions");

                        cdContainerDiv.Style.Add(HtmlTextWriterStyle.Display, "block");

                        imageDownloadInstructions.Style.Add(HtmlTextWriterStyle.Display, "block");

                        var cdDownloadAnchor = (HtmlAnchor)e.Row.FindControl("CdDownloadAnchor");

                        var downloadUrl = "/DigitalDelivery.aspx?key=" + new DigitalDeliveryCryptographyService().GetKey(eventId, CustomerId, EPDFType.CdContent);

                        cdDownloadAnchor.HRef = downloadUrl;
                        cdDownloadAnchor.Attributes.Add("onclick", "updateDownloadInfo(" + cdTracking.Id + ");");
                    }
                    else
                    {
                        cdContainerDiv.Style.Add(HtmlTextWriterStyle.Display, "none");
                    }
                }

                var premiumReportContainerDiv = (HtmlGenericControl)e.Row.FindControl("PremiumReportContainerDiv");
                if (premiumReportContainerDiv != null)
                {
                    if (product != null && product.Id == (long)Product.PremiumVersionPdf)
                    {
                        premiumReportContainerDiv.Style.Add(HtmlTextWriterStyle.Display, "block");

                        var aPdfReportWithImages = (HtmlAnchor)e.Row.FindControl("aPdfReportWithImages");
                        var key = EPDFType.ResultPdfWithImages + "~" + eventId + "~" + CustomerId + "~" + "SINGLE";
                        key = new DigitalDeliveryCryptographyService().Encrypt(key);
                        aPdfReportWithImages.HRef = "javascript:showClinicalForm('" + key + "');";
                    }
                    else
                    {
                        premiumReportContainerDiv.Style.Add(HtmlTextWriterStyle.Display, "none");
                    }
                }

                if (product != null && (product.Id == (long)Product.PremiumVersionPdf || product.Id == (long)Product.UltraSoundImages))
                {
                    var viewResultsContainer = (HtmlGenericControl)e.Row.FindControl("ViewResults");
                    if (viewResultsContainer != null)
                    {
                        //viewResultsContainer.Style.Add(HtmlTextWriterStyle.Display, "block");
                        viewResultsContainer.Style.Add(HtmlTextWriterStyle.Display, Convert.ToBoolean(drvCurrent["DisplayResultPDF"]) == false ? "none" : "block");

                        var viewResultsLink = (HtmlAnchor)e.Row.FindControl("ViewResultsLink");
                        var key             = EPDFType.ViewResult + "~" + eventId + "~" + CustomerId + "~" + "SINGLE";
                        key = new DigitalDeliveryCryptographyService().Encrypt(key);
                        viewResultsLink.HRef = "javascript:showClinicalForm('" + key + "');";
                    }
                }
                else
                {
                    var viewResultsContainer = (HtmlGenericControl)e.Row.FindControl("ViewResults");
                    if (viewResultsContainer != null)
                    {
                        viewResultsContainer.Style.Add(HtmlTextWriterStyle.Display, "none");
                    }
                }

                //var activeOrderDetail = orderController.GetActiveOrderDetail(order);
                //var shippingDetails = shippingDetailRepository.GetShippingDetailsForCancellation(activeOrderDetail.Id);
                //var viewResultsContainer = (HtmlGenericControl)e.Row.FindControl("ViewResults");
                //if (viewResultsContainer != null)
                //{
                //    if (shippingDetails != null && shippingDetails.Count() > 0)
                //        viewResultsContainer.Style.Add(HtmlTextWriterStyle.Display, "block");
                //    else
                //        viewResultsContainer.Style.Add(HtmlTextWriterStyle.Display, "none");
                //}
            }
        }
        catch
        { }
    }
Beispiel #2
0
    /// <summary>
    /// Set the grid view row alternate color. and set the button for different options
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void grdCustomerEvents_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var divmain     = (HtmlContainerControl)e.Row.FindControl("divmain");
            var divbottom   = (HtmlContainerControl)e.Row.FindControl("divbottom");
            var spEventName = (HtmlContainerControl)e.Row.FindControl("spEventName");
            var spDiscount  = (HtmlContainerControl)e.Row.FindControl("spDiscount");

            var drvCurrent = e.Row.DataItem as DataRowView;

            var divHighRiskPanel = (Panel)e.Row.FindControl("divHighRiskPanel");

            if (drvCurrent != null)
            {
                var orderId         = Convert.ToInt64(drvCurrent["OrderId"]);
                var eventId         = Convert.ToInt64(drvCurrent["EventID"]);
                var orderRepository = IoC.Resolve <IOrderRepository>();
                var order           = orderRepository.GetOrder(orderId);
                var orderDetail     =
                    order.OrderDetails.SingleOrDefault(
                        od =>
                        (od.DetailType == OrderItemType.EventPackageItem ||
                         od.DetailType == OrderItemType.EventTestItem) &&
                        od.EventCustomerOrderDetail != null && od.EventCustomerOrderDetail.IsActive &&
                        od.IsCompleted);

                var refundRequestRepository = IoC.Resolve <IRefundRequestRepository>();
                var refundRequests          = refundRequestRepository.GetbyOrderId(orderId);

                var corporateAccountRepository = IoC.Resolve <ICorporateAccountRepository>();
                var account = corporateAccountRepository.GetbyEventId(eventId);

                var isPaid = Convert.ToBoolean(((DataRowView)(e.Row.DataItem)).Row["IsPaid"]);
                divHighRiskPanel.Style.Add(HtmlTextWriterStyle.Display,
                                           drvCurrent["AssociatedPhoneNumber"].ToString().Length < 1 ? "none" : "block");

                if ((e.Row.RowIndex % 2) > 0)
                {
                    divbottom.Attributes["class"]   = "divorngboxbotbg_cd";
                    divmain.Attributes["class"]     = "divorngboxbodybg_cd";
                    spEventName.Attributes["class"] = "orngtxt14ptbold_cd";
                }
                else
                {
                    divbottom.Attributes["class"]   = "divbluboxbotbg_cd";
                    divmain.Attributes["class"]     = "divbluboxbodybg_cd";
                    spEventName.Attributes["class"] = "blutxt14ptbold_cd";
                }
                var dtEventDate = Convert.ToDateTime(((DataRowView)(e.Row.DataItem)).Row["EventDate"]);
                var diffResult  = dtEventDate - DateTime.Now.Date;

                var imgReschedule   = (ImageButton)e.Row.FindControl("imgReschedule");
                var spimgReschedule = (HtmlContainerControl)e.Row.FindControl("spimgReschedule");
                if (!DisplayRescheduleAppointment || diffResult.Days <= 0)
                {
                    imgReschedule.Enabled = false;
                    spimgReschedule.Style[HtmlTextWriterStyle.Display] = "none";
                }
                else
                {
                    imgReschedule.Enabled = true;
                    spimgReschedule.Style[HtmlTextWriterStyle.Display] = "block";
                }

                var downlodAdobeReaderDiv = (HtmlContainerControl)e.Row.FindControl("DownlodAdobeReaderDiv");

                if (Convert.ToBoolean(drvCurrent["TestResultReady"]) && isPaid)
                {
                    downlodAdobeReaderDiv.Style.Add(HtmlTextWriterStyle.Display, "block");

                    if (DisplayPremiumVersion)
                    {
                        var divGeneratePdf = (HtmlContainerControl)e.Row.FindControl("divGeneratePdf");
                        divGeneratePdf.Style.Add(HtmlTextWriterStyle.Display,
                                                 Convert.ToBoolean(drvCurrent["DisplayResultPDF"]) == false ? "none" : "block");
                    }

                    if (Convert.ToBoolean(drvCurrent["DisplayResultPDF"]) == false)
                    {
                        ClientScript.RegisterStartupScript(typeof(string), "jscript_regenrating_message",
                                                           "alert('We are regenerating your result packet. This may take few minutes.');", true);
                    }

                    var aPdfReport = (HtmlAnchor)e.Row.FindControl("aPDFReport");
                    var key        = new DigitalDeliveryCryptographyService().GetKey(eventId, CustomerId, EPDFType.ResultPdf);
                    aPdfReport.HRef = "javascript:showClinicalForm('" + key + "');";

                    SetDownloadCdandResult(e, drvCurrent);
                }
                else
                {
                    downlodAdobeReaderDiv.Style.Add(HtmlTextWriterStyle.Display, "none");

                    var divGeneratePdf = (HtmlContainerControl)e.Row.FindControl("divGeneratePdf");
                    divGeneratePdf.Style.Add(HtmlTextWriterStyle.Display, "none");
                }

                if (((DataRowView)(e.Row.DataItem)).Row["Discount"].ToString() == "")
                {
                    spDiscount.Style["display"] = "none";
                }

                ///// string eventDate = Convert.ToDateTime(drvCurrent["EventDate"]).ToString("dddd, MMMM dd, yyyy");

                var aReciept      = (HtmlAnchor)e.Row.FindControl("aReciept");
                var aSmallReciept = (HtmlAnchor)e.Row.FindControl("aSmallReciept");
                aReciept.HRef = "javascript:popupmenu2('/Communication/AppointmentConfirmation?eventId=" +
                                Convert.ToString(drvCurrent["EventID"]) + "&customerId=" + CustomerId + "',925,925)";


                var shippingOptionAnchor     = e.Row.FindControl("ShippingOptionAnchor") as HtmlAnchor;
                var shippingOptionDiv        = e.Row.FindControl("ShippingOptionDiv") as HtmlContainerControl;
                var shippingOptionRepository = IoC.Resolve <IShippingOptionRepository>();
                var shippingDetailRepository = IoC.Resolve <IShippingDetailRepository>();

                var shippingOption =
                    (shippingOptionRepository.GetAllShippingOptionsForBuyingProcess()
                     .Where(s => s.Price > 0)
                     .Select(s => s)
                     .Any());
                var hideResultPurchase = IoC.Resolve <ISettings>().HideResultPurchase;

                if (shippingOptionAnchor != null && shippingOptionDiv != null)
                {
                    if (hideResultPurchase || !shippingOption)
                    {
                        shippingOptionAnchor.Style.Add(HtmlTextWriterStyle.Display, "none");
                        shippingOptionDiv.Style.Add(HtmlTextWriterStyle.Display, "none");
                    }
                    else
                    {
                        shippingOptionAnchor.Style.Add(HtmlTextWriterStyle.Display, "block");
                        shippingOptionDiv.Style.Add(HtmlTextWriterStyle.Display, "block");


                        var shippingDetails = shippingDetailRepository.GetShippingDetailsForCancellation(orderDetail.Id);
                        shippingDetails =
                            shippingDetails.Where(sd => sd.ActualPrice > 0 && sd.Status == ShipmentStatus.Processing)
                            .Select(sd => sd)
                            .ToArray();
                        if (shippingDetails.Count() > 0)
                        {
                            shippingOptionAnchor.HRef = "javascript:void(0);";
                            shippingOptionAnchor.Attributes.Add("onclick", "ShowFullfillmentMessage();");
                        }
                        else if (!refundRequests.IsNullOrEmpty() &&
                                 refundRequests.Where(
                                     rr =>
                                     rr.RefundRequestType == RefundRequestType.CancelShipping &&
                                     rr.RequestStatus == (long)RequestStatus.Pending).Any())
                        {
                            shippingOptionAnchor.HRef = "Javascript:void(0);";
                            shippingOptionAnchor.Attributes.Add("onclick", "ShowRefundRequestShippingMessage();");
                        }
                        else
                        {
                            shippingOptionAnchor.HRef = "CustomerFullfillmentOption.aspx?CustomerId=" +
                                                        CustomerId + "&EventCustomerId=" +
                                                        drvCurrent["EventCustomerID"] +
                                                        "&EventId=" + drvCurrent["EventID"];
                        }
                    }
                }
                var hideProductPurchase = IoC.Resolve <ISettings>().HideProductPurchase;

                var productRepository  = IoC.Resolve <IElectronicProductRepository>();
                var products           = productRepository.GetAllProductsForEvent(eventId);
                var imagesOptionDiv    = e.Row.FindControl("ImagesOptionDiv") as HtmlContainerControl;
                var imagesOptionAnchor = e.Row.FindControl("ImagesOptionAnchor") as HtmlAnchor;
                if (imagesOptionDiv != null && imagesOptionAnchor != null)
                {
                    if (!hideProductPurchase && products != null && products.Count > 0)
                    {
                        imagesOptionAnchor.Style.Add(HtmlTextWriterStyle.Display, "block");
                        imagesOptionDiv.Style.Add(HtmlTextWriterStyle.Display, "block");

                        var hasPurchasedProduct =
                            order.OrderDetails.Where(
                                od =>
                                od.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess &&
                                od.DetailType == OrderItemType.ProductItem).Count() > 0
                                ? true
                                : false;
                        var cdShippingDetails =
                            shippingDetailRepository.GetProductShippingDetailsForCancellation(orderDetail.Id);
                        var hasUnShippedCd = false;
                        if (!cdShippingDetails.IsNullOrEmpty())
                        {
                            hasUnShippedCd =
                                cdShippingDetails.Where(sd => sd.Status == ShipmentStatus.Processing)
                                .Select(sd => sd)
                                .Any();
                        }

                        if (!refundRequests.IsNullOrEmpty() &&
                            refundRequests.Where(
                                rr =>
                                rr.RefundRequestType == RefundRequestType.CDRemoval &&
                                rr.RequestStatus == (long)RequestStatus.Pending).Any())
                        {
                            imagesOptionAnchor.HRef = "javascript:void(0);";
                            imagesOptionAnchor.Attributes.Add("onclick", "ShowRefundRequestProductMessage();");
                        }
                        else if ((hasPurchasedProduct && cdShippingDetails.IsNullOrEmpty()) || hasUnShippedCd)
                        {
                            imagesOptionAnchor.HRef = "javascript:void(0);";
                            imagesOptionAnchor.Attributes.Add("onclick", "ShowAddOnProductMessage();");
                        }
                        else
                        {
                            imagesOptionAnchor.HRef = "/App/Customer/CustomerAddOnProduct.aspx?CustomerId=" + CustomerId +
                                                      "&EventCustomerId=" + drvCurrent["EventCustomerID"] + "&EventId=" +
                                                      drvCurrent["EventID"];
                        }
                    }
                    else
                    {
                        imagesOptionAnchor.Style.Add(HtmlTextWriterStyle.Display, "none");
                        imagesOptionDiv.Style.Add(HtmlTextWriterStyle.Display, "none");
                    }
                }
                if (isPaid)
                {
                    aSmallReciept.HRef =
                        "javascript:popupmenu2('/Config/Content/Controls/SmallPrintReciept.aspx?CustomerID=" +
                        Convert.ToString(CustomerId) + "&EventID=" +
                        Convert.ToString(drvCurrent["EventID"]) + "',320,535)";

                    SetPaymentAndShippingAnchors(e, drvCurrent, true, order);
                    var spnPaymentDetails =
                        (HtmlContainerControl)e.Row.FindControl("spAcceptPayment");
                    spnPaymentDetails.Style.Add(HtmlTextWriterStyle.Display, "block");
                    spnPaymentDetails.InnerText = "(Paid)";
                }
                else
                {
                    aSmallReciept.HRef = "javascript:alert('Not paid yet.');";
                    var spnPaymentDetails =
                        (HtmlContainerControl)e.Row.FindControl("spAcceptPayment");

                    spnPaymentDetails.InnerHtml =
                        "[ <a href='javascript:popupmenu3(\"/App/Franchisee/Technician/AcceptPayment.aspx?EventCustomerID=" +
                        Convert.ToString(drvCurrent["EventCustomerID"]) + "&CustomerID=" + Convert.ToString(CustomerId) +
                        "&EventID=" + Convert.ToString(drvCurrent["EventID"]) +
                        "&PageCallBackFrom=CustomerDashboard" +
                        "\", 695, 680);' style=\"font-size:8pt;\"> Make Payment </a> ]";

                    SetPaymentAndShippingAnchors(e, drvCurrent, false, order);
                }

                var customerHealthInfo      = IoC.Resolve <IHealthAssessmentRepository>().Get(CustomerId, eventId);
                var healthAssessmentHelper  = IoC.Resolve <IKynHealthAssessmentHelper>();
                var iskynPrefilled          = healthAssessmentHelper.CheckHafPrefilled(eventId, CustomerId);
                var amedicalhistory         = (HtmlAnchor)e.Row.FindControl("amedicalhistory");
                var spMedicalHistory        = (HtmlContainerControl)e.Row.FindControl("spMedicalHistory");
                var medicalHistoryContainer = (HtmlContainerControl)e.Row.FindControl("medicalHistoryContainer");
                if (medicalHistoryContainer != null)
                {
                    if (account == null || account.CaptureHaf)
                    {
                        if (amedicalhistory != null && spMedicalHistory != null)
                        {
                            if (iskynPrefilled)
                            {
                                spMedicalHistory.InnerHtml = "Filled";
                                //amedicalhistory.InnerHtml = "Update";
                                amedicalhistory.InnerHtml = "<input type='button' value='Update' class='anchor-button'/>";
                                amedicalhistory.HRef      = "/App/Customer/NewMedicalHistory.aspx?CustomerID=" + CustomerId + "&EventId=" + eventId + "&Edit=true";

                                var answer          = customerHealthInfo.First();
                                var eventRepository = IoC.Resolve <IEventRepository>();
                                var organizationRoleUserRepository = IoC.Resolve <IOrganizationRoleUserRepository>();

                                var eventData = eventRepository.GetById(eventId);

                                if (answer.DataRecorderMetaData != null && answer.DataRecorderMetaData.DataRecorderCreator != null && answer.DataRecorderMetaData.DataRecorderCreator.Id > 0)
                                {
                                    var orgRoleUser = organizationRoleUserRepository.GetOrganizationRoleUser(answer.DataRecorderMetaData.DataRecorderCreator.Id);
                                    if (answer.DataRecorderMetaData.DateCreated.Date >= eventData.EventDate.Date && orgRoleUser.RoleId != (long)Roles.Customer)
                                    {
                                        //amedicalhistory.InnerHtml = "View";
                                        amedicalhistory.InnerHtml = "<input type='button' value='View' class='anchor-button'/>";
                                    }
                                }
                            }
                            else
                            {
                                spMedicalHistory.InnerText = "Not Filled";
                                //amedicalhistory.InnerHtml = "Fill";
                                amedicalhistory.InnerHtml = "<input type='button' value='Fill Now' class='anchor-button'/>";
                                amedicalhistory.HRef      = "/App/Customer/NewMedicalHistory.aspx?CustomerID=" + CustomerId + "&EventId=" + eventId + "&Edit=true";
                            }
                        }
                    }
                    else
                    {
                        medicalHistoryContainer.Style.Add(HtmlTextWriterStyle.Display, "none");
                    }
                }

                long eventcustomerid = Convert.ToInt64(drvCurrent["EventCustomerID"]);


                var mspHistoryForm          = (HtmlAnchor)e.Row.FindControl("mspHistoryForm");
                var mspHistoryFormContainer = (HtmlGenericControl)e.Row.FindControl("mspformContainer");
                var mspHistorySpan          = (HtmlGenericControl)e.Row.FindControl("mspHistory");
                if (mspHistoryFormContainer != null || mspHistoryForm != null && mspHistorySpan != null)
                {
                    var customerMedicareQestionService = IoC.Resolve <ICustomerMedicareQuestionService>();
                    var isPurchsed = customerMedicareQestionService.IsTestPurchased(eventId, CustomerId, new[] { (long)TestType.Medicare, (long)TestType.AwvSubsequent, (long)TestType.AWV });

                    if (isPurchsed)
                    {
                        var getCustomerAnswer = customerMedicareQestionService.GetAnswersByEventCustomerId(eventcustomerid);
                        var FilledStatus      = getCustomerAnswer.IsNullOrEmpty() ? "Not Filled" : "Filled";

                        mspHistorySpan.InnerText = FilledStatus;
                        mspHistoryForm.InnerText = getCustomerAnswer.IsNullOrEmpty() ? "Fill" : "Update";
                        mspHistoryForm.HRef      = "/medical/medicareQuestion/update?eventcustomerid=" + eventcustomerid;
                    }
                    else
                    {
                        mspHistoryFormContainer.Visible = false;
                        mspHistoryForm.Visible          = false;
                    }
                }
            }
        }
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ISystemInformationRepository systemInformationRepository = new SystemInformationRepository();
                VersionNumber = systemInformationRepository.GetBuildNumber();

                var current = IoC.Resolve <ISessionContext>().UserSession.CurrentOrganizationRole;
                if (current.CheckRole((long)Roles.Customer))
                {
                    this.Page.Form.Action = Request.Url.AbsolutePath;
                }

                var key = Request.QueryString["key"];
                if (!string.IsNullOrEmpty(key))
                {
                    key = key.Replace(" ", "+");
                    CryptographyService cryptographyService = new DigitalDeliveryCryptographyService();
                    string decryptedKey = cryptographyService.Decrypt(key);

                    string[] allKeys;
                    allKeys = decryptedKey.Split('~');

                    EventId    = Convert.ToInt64(allKeys[0]);
                    CustomerId = Convert.ToInt64(allKeys[1]);
                    Server.Transfer("/App/Common/Results.aspx?EventId=" + EventId + "&CustomerId=" + CustomerId);
                }
                else
                {
                    long s = 0;
                    if (Request.QueryString["EventId"] != null && long.TryParse(Request.QueryString["EventId"], out s))
                    {
                        EventId = s;
                    }

                    s = 0;
                    if (Request.QueryString["CustomerId"] != null && long.TryParse(Request.QueryString["CustomerId"], out s))
                    {
                        CustomerId = s;
                    }
                    IsMedicare = Request.QueryString["IsMedicare"] != null && Convert.ToBoolean(Request.QueryString["IsMedicare"]);
                }

                if (!current.CheckRole((long)Roles.Customer))
                {
                    var eventCustomerResult = IoC.Resolve <IEventCustomerResultRepository>().GetByCustomerIdAndEventId(CustomerId, EventId);
                    if (eventCustomerResult != null)
                    {
                        var priorityInQueue = IoC.Resolve <IPriorityInQueueRepository>().GetByEventCustomerResultId(eventCustomerResult.Id);
                        if (priorityInQueue != null && priorityInQueue.InQueuePriority > 0 && priorityInQueue.NoteId != null)
                        {
                            var noteText = IoC.Resolve <INotesRepository>().Get(priorityInQueue.NoteId.Value);
                            if (noteText != null && !string.IsNullOrEmpty(noteText.Text))
                            {
                                PriorityInQueueMessage.ShowSuccessMessage("<b><u>Priority In Queue Reason:</u> </b>" + noteText.Text);
                                PriorityInQueueMessage.Visible = true;
                            }
                        }
                    }
                }

                var mediaLocation = IoC.Resolve <IMediaRepository>().GetResultMediaFileLocation(CustomerId, EventId);
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "js_Location_Url", "function getLocationPrefix() { return '" + mediaLocation.PhysicalPath.Replace("\\", "\\\\") + "'; } function getUrlPrefix() { return '" + mediaLocation.Url + "'; }", true);

                GetConductedbyData();
                var eventsRepository        = IoC.Resolve <IEventRepository>();
                var eventData               = eventsRepository.GetById(EventId);
                var settings                = IoC.Resolve <ISettings>();
                var basicBiometricCutOfDate = settings.BasicBiometricCutOfDate;
                var hideBasicBiometric      = (eventData.EventDate.Date >= basicBiometricCutOfDate);

                ShowHideFastingStatus = (eventData.EventDate.Date >= settings.FastingStatusDate);

                BasicBiometric.ShowByCutOffDate = !hideBasicBiometric;
                TestSection.SetSectionShowHide(hideBasicBiometric);

                ContainTestForEvaluation = TestSection.ContainsReviewableTests;

                GetPcpInformation();

                CreateIfjsArrays();
                CreateJsArrayforIfuCs();
            }
        }
        public void PollForSendNotification()
        {
            try
            {
                _logger.Info("Starting the Polling Agent to Send Notification to Nurse Practitioner after evaluation.");

                var eventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultByResultState((int)NewTestResultStateNumber.Evaluated, false, _settings.ResultFlowChangeDate);
                if (eventCustomerResults.IsNullOrEmpty())
                {
                    _logger.Info("No record found to send notification."); return;
                }

                var cryptographyService = new DigitalDeliveryCryptographyService();
                _logger.Info("Total Customer: " + eventCustomerResults.Count());

                var appUrl         = _settings.AppUrl;
                var medicareAppUrl = _settings.MedicareAppUrl;

                foreach (var eventCustomerResult in eventCustomerResults)
                {
                    try
                    {
                        _logger.Info("sending Notification to Np customer Id: " + eventCustomerResult.CustomerId + "event Id: " + eventCustomerResult.EventId);

                        var eventCustomer = _eventCustomerRepository.GetRegisteredEventForUser(eventCustomerResult.CustomerId, eventCustomerResult.EventId);
                        if (eventCustomer.AwvVisitId.HasValue)
                        {
                            var model = new EhrReadyForReEvaluation
                            {
                                EventId              = eventCustomerResult.EventId,
                                HfCustomerId         = eventCustomerResult.CustomerId,
                                Message              = "",
                                ReadyForReEvaluation = true
                            };

                            _logger.Info(string.Format("Sending for Sync ready for Reevaluation to HRA for NursePractitionerId: {0} for CustomerId: {1} and EventId: {2}", eventCustomerResult.SignedOffBy.Value, eventCustomerResult.CustomerId, eventCustomerResult.EventId));

                            var isSynced = _newResultFlowStateService.SyncReadyForEvaluation(model, eventCustomerResult.DataRecorderMetaData.DataRecorderModifier.Id, "Calling from polling agent PollForSendNotification");

                            if (isSynced)
                            {
                                _logger.Info(string.Format(" Synced Notification send To NP and HRA has been updated NursePractitionerId: {0} for CustomerId: {1} and EventId: {2}", eventCustomerResult.SignedOffBy.Value, eventCustomerResult.CustomerId, eventCustomerResult.EventId));

                                var orgRoleUser = _organizationRoleUserRepository.GetOrganizationRoleUser(eventCustomerResult.SignedOffBy.Value);

                                var urlTestDocumentation            = appUrl + string.Format("/App/Common/Results.aspx?key={0}", cryptographyService.Encrypt(eventCustomerResult.EventId + "~" + eventCustomerResult.CustomerId));
                                var urlUnlockAssessment             = medicareAppUrl + string.Format("/mailauth/{0}", eventCustomer.AwvVisitId);
                                var urlTriggersReadyForCodingStatus = ""; // need to write code for this url variables

                                var notificationModel = _emailNotificationModelsFactory.GetNPfordiagnosingwithlinkNotificationViewModel(eventCustomerResult.CustomerId, eventCustomerResult.EventId, urlTestDocumentation, urlUnlockAssessment, urlTriggersReadyForCodingStatus);

                                _notifier.NotifySubscribersViaEmail(NotificationTypeAlias.NPfordiagnosingwithlinkNotification, EmailTemplateAlias.NPfordiagnosingwithlinkNotification, notificationModel, orgRoleUser.UserId, _RequestedByOrgRoleUserId, "SendNotiificationToNursePractitionerPollingAgent");

                                _logger.Info(string.Format("Notification sent to NursePractitionerId: {0} for CustomerId: {1} and EventId: {2}", eventCustomerResult.SignedOffBy.Value, eventCustomerResult.CustomerId, eventCustomerResult.EventId));

                                _testResultService.SetResultstoState(eventCustomerResult.EventId, eventCustomerResult.CustomerId, (int)NewTestResultStateNumber.NpNotificationSent, false, eventCustomerResult.DataRecorderMetaData.DataRecorderModifier.Id);
                                _logger.Info(string.Format(" Result State has been update for CustomerId: {0} and EventId: {1}", eventCustomerResult.CustomerId, eventCustomerResult.EventId));
                            }

                            _logger.Info(string.Format("Synced To NP and HRA NursePractitionerId: {0} for CustomerId: {1} and EventId: {2} and hra Result {3}", eventCustomerResult.SignedOffBy.Value, eventCustomerResult.CustomerId, eventCustomerResult.EventId, isSynced));
                        }
                        else
                        {
                            _logger.Error(string.Format("AwvVisitId is null for CustomerId: {0} and EventId: {1}", eventCustomerResult.CustomerId, eventCustomerResult.EventId));
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(string.Format("System failure: For NursePractitionerId: {0}, CustomerId: {1} and EventId: {2}", eventCustomerResult.SignedOffBy.Value, eventCustomerResult.CustomerId, eventCustomerResult.EventId));
                        _logger.Error("Error Message: " + ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Exception occurred on execution of SendNotiificationToNursePractitionerPollingAgent.");
                _logger.Error("Error Message: " + ex.Message);
            }
        }
        protected void ShippingDetailsGrid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            switch (e.Row.RowType)
            {
            case DataControlRowType.DataRow:
            {
                var eventCustomerShippingDetailViewData = e.Row.DataItem as EventCustomerShippingDetailViewData;
                if (eventCustomerShippingDetailViewData != null)
                {
                    var anchorResultPdf = e.Row.FindControl("ResultPdfAnchor") as HtmlAnchor;

                    if (anchorResultPdf != null)
                    {
                        if (eventCustomerShippingDetailViewData.IsResultPdfGenerated)
                        {
                            var mediaRepository           = IoC.Resolve <IMediaRepository>();
                            var productRepository         = IoC.Resolve <IElectronicProductRepository>();
                            var isPremiumVersionPurchased = productRepository.IsProductPurchased(eventCustomerShippingDetailViewData.EventId, eventCustomerShippingDetailViewData.CustomerId, Product.PremiumVersionPdf);


                            var key = new DigitalDeliveryCryptographyService().GetKey(eventCustomerShippingDetailViewData.EventId, eventCustomerShippingDetailViewData.CustomerId, EPDFType.ResultPdf);
                            if (isPremiumVersionPurchased)
                            {
                                key = new DigitalDeliveryCryptographyService().GetKey(eventCustomerShippingDetailViewData.EventId, eventCustomerShippingDetailViewData.CustomerId, EPDFType.ResultPdfWithImages);
                            }
                            else
                            {
                                var resultPdfLocation = mediaRepository.GetPremiumVersionResultPdfLocation(eventCustomerShippingDetailViewData.EventId, eventCustomerShippingDetailViewData.CustomerId, false).PhysicalPath;
                                if (eventCustomerShippingDetailViewData.ShippingOptionName.ToLower().Contains("pcp"))
                                {
                                    var pcpResultPdfPath = resultPdfLocation + mediaRepository.GetPdfFileNameForPcpResultReport();
                                    if (File.Exists(pcpResultPdfPath))
                                    {
                                        key = new DigitalDeliveryCryptographyService().GetKey(eventCustomerShippingDetailViewData.EventId, eventCustomerShippingDetailViewData.CustomerId, EPDFType.PcpResultReport);
                                    }
                                }
                                else
                                {
                                    var customerResultPdfPath = resultPdfLocation + mediaRepository.GetPdfFileNameForResultReport();
                                    if (File.Exists(customerResultPdfPath))
                                    {
                                        key = new DigitalDeliveryCryptographyService().GetKey(eventCustomerShippingDetailViewData.EventId, eventCustomerShippingDetailViewData.CustomerId, EPDFType.ResultPdf);
                                    }
                                    else
                                    {
                                        var pcpResultPdfPath = resultPdfLocation + mediaRepository.GetPdfFileNameForPcpResultReport();
                                        if (File.Exists(pcpResultPdfPath))
                                        {
                                            key = new DigitalDeliveryCryptographyService().GetKey(eventCustomerShippingDetailViewData.EventId, eventCustomerShippingDetailViewData.CustomerId, EPDFType.PcpResultReport);
                                        }
                                    }
                                }
                            }

                            anchorResultPdf.HRef = " javascript:ShowPdf('/DigitalDelivery.aspx?key=" + key + "');";
                        }
                        else
                        {
                            anchorResultPdf.HRef = "javascript:alert('Not generated yet.');";
                        }
                    }

                    var statusItemLiteral = e.Row.FindControl("StatusItemLiteral") as Literal;
                    if (statusItemLiteral != null)
                    {
                        statusItemLiteral.Text = eventCustomerShippingDetailViewData.Status.ToString();
                    }
                    var shippingStatus =
                        e.Row.FindControl("ShipmentStatusDropDown") as DropDownList;
                    if (shippingStatus != null)
                    {
                        BindStatusDropDown(((int)eventCustomerShippingDetailViewData.Status).ToString(), shippingStatus);
                    }
                    var nameLiteral = e.Row.FindControl("NameItemLiteral") as Literal;
                    if (nameLiteral != null)
                    {
                        var customerDetail = "<a href='/App/Franchisor/FranchisorCustomerDetails.aspx?CustomerID=" + eventCustomerShippingDetailViewData.CustomerId + "'>" + eventCustomerShippingDetailViewData.CustomerId + "</a>";
                        if (CurrentOrgRole.CheckRole((long)Roles.OperationManager))
                        {
                            customerDetail = eventCustomerShippingDetailViewData.CustomerId.ToString();
                        }

                        nameLiteral.Text = eventCustomerShippingDetailViewData.CustomerName + " [" +
                                           customerDetail + "]" + "<br />" +
                                           CommonCode.AddressMultiLine(
                            eventCustomerShippingDetailViewData.CustomerStreetAddressLine1,
                            eventCustomerShippingDetailViewData.CustomerStreetAddressLine2,
                            eventCustomerShippingDetailViewData.CustomerCity,
                            eventCustomerShippingDetailViewData.CustomerState,
                            eventCustomerShippingDetailViewData.CustomerZip)
                                           + "<br />" + eventCustomerShippingDetailViewData.CustomerEmail;
                    }
                    var packageNameItemLiteral = e.Row.FindControl("PackageNameItemLiteral") as Literal;

                    if (packageNameItemLiteral != null)
                    {
                        packageNameItemLiteral.Text = eventCustomerShippingDetailViewData.PackageName;
                        packageNameItemLiteral.Text = string.IsNullOrEmpty(packageNameItemLiteral.Text)
                                                                  ? eventCustomerShippingDetailViewData.AdditionalTest
                                                                  : packageNameItemLiteral.Text +
                                                      (string.IsNullOrEmpty(eventCustomerShippingDetailViewData.AdditionalTest)
                                                                         ? string.Empty
                                                                         : ", " +
                                                       eventCustomerShippingDetailViewData.
                                                       AdditionalTest);
                        if (!string.IsNullOrEmpty(eventCustomerShippingDetailViewData.ProductName))
                        {
                            packageNameItemLiteral.Text = packageNameItemLiteral.Text + "<br /> + " + eventCustomerShippingDetailViewData.ProductName;
                        }
                    }

                    var unpiadDiv = e.Row.FindControl("UnpiadDiv") as HtmlGenericControl;
                    if (unpiadDiv != null)
                    {
                        unpiadDiv.Style.Add(HtmlTextWriterStyle.Display, eventCustomerShippingDetailViewData.IsPaid ? "none" : "block");
                    }
                }
            }
            break;
            }
        }