Esempio n. 1
0
    public void GetData(IRequest request)
    {
        int numberToDisplay = 5;

        Sage.SalesLogix.Security.SLXUserService slxUserService = ApplicationContext.Current.Services.Get <Sage.Platform.Security.IUserService>() as Sage.SalesLogix.Security.SLXUserService;
        string currentUserId            = slxUserService.GetUser().Id.ToString();
        IRepository <IOpportunity> oRep = EntityFactory.GetRepository <IOpportunity>();
        IExpressionFactory         ep   = ((IQueryable)oRep).GetExpressionFactory();
        ICriteria countCrit             = GetOpenOppCrit(oRep, ep, currentUserId);

        countCrit.SetProjection(((IQueryable)oRep).GetProjectionsFactory().RowCount());
        int totalCount = Convert.ToInt32(countCrit.UniqueResult());

        ICriteria crit = GetOpenOppCrit(oRep, ep, currentUserId);

        crit.AddOrder(ep.Asc("EstimatedClose"));
        crit.SetMaxResults(numberToDisplay);
        IList <IOpportunity> opps = crit.List <IOpportunity>();

        numberToDisplay = (totalCount < numberToDisplay) ? totalCount : numberToDisplay;

        var result = new Result();

        result.items   = new List <OpportunityRepresentation>();
        result.columns = new string[] { "id", "description", "estClose", "potential", "probability", "stage", "nextStep", "nextActivityId", "nextActivityName", "daysInStage", "daysSinceLastActivity" };
        for (int i = 0; i < numberToDisplay; i++)
        {
            result.items.Add(OpportunityRepresentation.from(opps[i]));
        }
        string groupId    = GetPluginIdFromFamilyAndName("Opportunity", "My Open Opps");
        int    groupCount = totalCount;

        result.openOppGroup    = groupId;
        result.openOppCount    = groupCount;
        result.numberToDisplay = numberToDisplay;

        request.Response.ContentType = MediaType.JSON;
        request.Response.Html        = JsonConvert.SerializeObject(result);
    }
Esempio n. 2
0
        public static OpportunityRepresentation from(IOpportunity opp)
        {
            OpportunityRepresentation or = new OpportunityRepresentation();

            or.ID                    = opp.Id.ToString();
            or.Description           = opp.Description;
            or.EstimatedClose        = opp.EstimatedClose ?? DateTime.Now;
            or.Potential             = opp.SalesPotential ?? 0;
            or.Probability           = opp.CloseProbability ?? 0;
            or.Stage                 = opp.Stage;
            or.NextStep              = opp.NextStep;
            or.DaysSinceLastActivity = opp.DaysSinceLastActivity;
            IActivity act = getNextActivity(opp.Id.ToString());

            if (act != null)
            {
                or.NextActivityId   = act.Id.ToString();
                or.NextActivityName = String.Format("{0} &lt;{1}&gt;", (act.Description ?? ""), act.StartDate.ToShortDateString());
            }
            ISalesProcesses sp = Sage.SalesLogix.SalesProcess.Helpers.GetSalesProcess(opp.Id.ToString());

            if (sp != null)
            {
                IList <ISalesProcessAudit> list = sp.GetSalesProcessAudits();
                foreach (ISalesProcessAudit spa in list)
                {
                    if ((spa.ProcessType == "STAGE") && (spa.IsCurrent != null) && ((bool)spa.IsCurrent))
                    {
                        or.DaysInStage = sp.DaysInStage(spa.StageId);
                        //break;
                    }
                    if ((spa.ProcessType == "STEP") && (spa.IsCurrent != null) && ((bool)spa.IsCurrent))
                    {
                        or.NextStep = spa.StepName;
                    }
                }
            }
            return(or);
        }
Esempio n. 3
0
 public static OpportunityRepresentation from(IOpportunity opp)
 {
     OpportunityRepresentation or = new OpportunityRepresentation();
     or.ID = opp.Id.ToString();
     or.Description = opp.Description;
     or.EstimatedClose = opp.EstimatedClose ?? DateTime.Now;
     or.Potential = opp.SalesPotential ?? 0;
     or.Probability = opp.CloseProbability ?? 0;
     or.Stage = opp.Stage;
     or.NextStep = opp.NextStep;
     or.DaysSinceLastActivity = opp.DaysSinceLastActivity;
     IActivity act = getNextActivity(opp.Id.ToString());
     if (act != null)
     {
         or.NextActivityId = act.Id.ToString();
         or.NextActivityName = String.Format("{0} &lt;{1}&gt;", (act.Description ?? ""), act.StartDate.ToShortDateString());
     }
     ISalesProcesses sp = Sage.SalesLogix.SalesProcess.Helpers.GetSalesProcess(opp.Id.ToString());
     if (sp != null)
     {
         IList<ISalesProcessAudit> list = sp.GetSalesProcessAudits();
         foreach (ISalesProcessAudit spa in list)
         {
             if ((spa.ProcessType == "STAGE") && (spa.IsCurrent != null) && ((bool)spa.IsCurrent))
             {
                 or.DaysInStage = sp.DaysInStage(spa.StageId);
                 //break;
             }
             if ((spa.ProcessType == "STEP") && (spa.IsCurrent != null) && ((bool)spa.IsCurrent))
             {
                 or.NextStep = spa.StepName;
             }
         }
     }
     return or;
 }