/// <summary>
 /// Aborts the import.
 /// </summary>
 /// <param name="importHistory">The import history.</param>
 private void AbortImport(IImportHistory importHistory)
 {
     try
     {
         IRepository <IImportHistory> rep        = EntityFactory.GetRepository <IImportHistory>();
         IQueryable         qry                  = (IQueryable)rep;
         IExpressionFactory ep                   = qry.GetExpressionFactory();
         Sage.Platform.Repository.ICriteria crit = qry.CreateCriteria();
         crit.Add(ep.Eq("Id", importHistory.Id));
         IProjections projections = qry.GetProjectionsFactory();
         crit.SetProjection(projections.Property("ProcessState"));
         object state = crit.UniqueResult();
         if (state != null)
         {
             ImportProcessState processState = (ImportProcessState)Enum.Parse(typeof(ImportProcessState), state.ToString());
             if (!processState.Equals(ImportProcessState.Completed) || !processState.Equals(ImportProcessState.Abort))
             {
                 SetProcessState(importHistory.Id.ToString(), Enum.GetName(typeof(ImportProcessState), ImportProcessState.Abort), "Aborted");
             }
         }
     }
     catch (Exception)
     {
         //throw new ApplicationException("Error getting process state");
     }
 }
    private Sage.Entity.Interfaces.IContact GetPrimaryContactFor(Sage.Entity.Interfaces.IAccount account)
    {
        Object result;
        IRepository <Sage.Entity.Interfaces.IContact> rep = Sage.Platform.EntityFactory.GetRepository <Sage.Entity.Interfaces.IContact>();
        IQueryable         qry = (IQueryable)rep;
        IExpressionFactory ep  = qry.GetExpressionFactory();

        Sage.Platform.Repository.ICriteria crit = qry.CreateCriteria();
        crit.Add(ep.Eq("Account", account));
        crit.Add(ep.Eq("IsPrimary", true));
        result = crit.UniqueResult <Sage.Entity.Interfaces.IContact>();
        return((result != null) ? (Sage.Entity.Interfaces.IContact)result : null);
    }
    /// <summary>
    /// Shows the sales process info.
    /// </summary>
    /// <param name="opportunity">The opportunity.</param>
    /// <returns></returns>
    private bool ShowSalesProcessInfo(IOpportunity opportunity)
    {
        bool result = false;

        if (GetOpportunityStatusMatch(opportunity, "Open") ||
            GetOpportunityStatusMatch(opportunity, "Inactive"))
        {
            IRepository <ISalesProcesses> rep = EntityFactory.GetRepository <ISalesProcesses>();
            IQueryable         qry            = (IQueryable)rep;
            IExpressionFactory ep             = qry.GetExpressionFactory();
            ICriteria          crit           = qry.CreateCriteria();
            crit.Add(ep.Eq("EntityId", opportunity.Id.ToString()));
            IProjection proj = qry.GetProjectionsFactory().Count("Id");
            crit.SetProjection(proj);
            int count = (int)crit.UniqueResult();
            result = (count > 0);
        }
        return(result);
    }