Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //RedirectToLoginIfNecessary();

            var contact = Contact;

            if (contact != null)
            {
                var homeAlertsSavedQuery = XrmContext.CreateQuery("savedquery").FirstOrDefault(query => query.GetAttributeValue <OptionSetValue>("statecode") != null && query.GetAttributeValue <OptionSetValue>("statecode").Value == 0 && query.GetAttributeValue <string>("name") == HomeAlertsSavedQueryName);

                var alerts = Opportunities.Where(opp => (opp.GetAttributeValue <OptionSetValue>("statuscode") != null && opp.GetAttributeValue <OptionSetValue>("statuscode").Value == (int)Adxstudio.Xrm.Partner.Enums.OpportunityStatusReason.Delivered) ||
                                                 XrmContext.GetOpportunityLatestStatusModifiedOn(opp) <= DateTime.Now.AddDays(-ServiceContext.GetInactiveDaysUntilOverdue(Website)))
                             .OrderByDescending(opp => GetAlertType(opp.Id)).ThenBy(opp => opp.GetRelatedEntity(XrmContext, new Relationship("opportunity_customer_accounts")).GetAttributeValue <string>("name"));

                var columnsGenerator = new SavedQueryColumnsGenerator(XrmContext, homeAlertsSavedQuery);

                Alerts.DataKeyNames     = new[] { "opportunityid" };
                Alerts.DataSource       = columnsGenerator.ToDataTable(alerts);
                Alerts.ColumnsGenerator = columnsGenerator;
                Alerts.DataBind();

                var newOpportunities = Opportunities.Where(opp => opp.GetAttributeValue <OptionSetValue>("statuscode") != null && opp.GetAttributeValue <OptionSetValue>("statuscode").Value ==
                                                           (int)Adxstudio.Xrm.Partner.Enums.OpportunityStatusReason.Delivered);

                NewOpportunityCount.Text = newOpportunities.Count().ToString();
                NewOpportunityValue.Text = newOpportunities.Where(o => o.GetAttributeValue <Money>("estimatedvalue") != null).Sum(opp => opp.GetAttributeValue <Money>("estimatedvalue").Value).ToString("C");

                var acceptedOpportunities = Opportunities.Where(opp => opp.GetAttributeValue <OptionSetValue>("statuscode") != null && opp.GetAttributeValue <OptionSetValue>("statuscode").Value !=
                                                                (int)Adxstudio.Xrm.Partner.Enums.OpportunityStatusReason.Delivered);

                AcceptedOpportunityCount.Text = acceptedOpportunities.Count().ToString();
                AcceptedOpportunityValue.Text = acceptedOpportunities.Where(o => o.GetAttributeValue <Money>("estimatedvalue") != null).Sum(opp => opp.GetAttributeValue <Money>("estimatedvalue").Value).ToString("C");
            }
            else
            {
                PartnerHomePanel.Visible = false;
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dataAdapter = new UserCasesDataAdapter(new PortalContextDataAdapterDependencies(Portal, PortalName, Request.RequestContext));

            if (!IsPostBack)
            {
                CaseDeflection.Visible = CaseDeflectionEnabled;
                CreateCase.Visible     = DirectCaseCreationEnabled;

                var permissionScopes = dataAdapter.SelectPermissionScopes();

                HideControlsBasedOnAccess(permissionScopes);
                PopulateCustomerFilter(permissionScopes);
            }

            var cases = GetCases(dataAdapter);

            var columnsGenerator = new SavedQueryColumnsGenerator(XrmContext, "incident", "Cases Web View");

            CaseList.DataKeyNames     = new[] { "incidentid" };
            CaseList.DataSource       = columnsGenerator.ToDataTable(cases.Select(c => c.Entity), "o", CultureInfo.InvariantCulture);
            CaseList.ColumnsGenerator = columnsGenerator;
            CaseList.DataBind();
        }