public static IEnumerable<PrintLogMeta> GetDocumentMeta(string type, DateTime fromDate, DateTime toDate)
        {
            RepositoryFactory repo = new RepositoryFactory();

            var results = repo.PrintLogs.AsQueryable()
                .Where(t => t.Type == type && t.PrintedDate >= fromDate && t.PrintedDate <= toDate)
                .Select(
                    p =>
                    new PrintLogMeta {ID = p.ID, PrintedDate = p.PrintedDate, Type = p.Type, Reference = p.Reference}).ToList();

            if (type == "STV")
            {

                foreach (var result in results)
                {
                    var log = repo.STVLogs.First(s => s.ID == result.Reference);
                    int? receivingUnitID = log.ReceivingUnitID;
                    if (receivingUnitID != null)
                    {
                        result.Description = repo.ReceivingUnits.First(f => f.ID == receivingUnitID).Name;
                        result.PrintedID = log.IDPrinted;
                    }

                }

            }

            return results;
        }
        public static IEnumerable<PrintLogMeta> GetDocumentMeta(int Reference)
        {
            RepositoryFactory repo = new RepositoryFactory();

            var results = repo.PrintLogs.AsQueryable()
                .Where(t => t.Reference == Reference && (t.Type =="GRV/IGRV" || t.Type == "CostAnalysis"))
                .Select(
                    p =>
                    new PrintLogMeta { ID = p.ID, PrintedDate = p.PrintedDate, Type = p.Type, Reference = p.Reference }).ToList();

            return results;
        }
        public static void SavePrintLogNoWait(MemoryStream stream, string type, bool isPrinted, int reference, int printedByUserID, DateTime dateTime)
        {
            //TODO: remove the try catch.
            try
            {
                // Save the stvReport in the database
                RepositoryFactory repo = new RepositoryFactory();

                var unitOfWork = repo.UnitOfWork;
                HCMIS.Concrete.Models.PrintLog pLog = new HCMIS.Concrete.Models.PrintLog();
                pLog.IsPrinted = isPrinted;
                pLog.PrintedBy = printedByUserID;
                pLog.PrintedDate = dateTime;
                pLog.Value = stream.ToArray();
                pLog.Type = type;
                pLog.Reference = reference;
                repo.PrintLogs.Insert(pLog);

                unitOfWork.Commit();
            }
            catch
            {
            }
        }
 public OrderDetailModel(RepositoryFactory _repo)
 {
     repo = _repo;
 }
 public JournalService(RepositoryFactory repository)
 {
     this.repository = repository;
 }
 public JournalService()
 {
     repository = new RepositoryFactory();
 }
 public static IEnumerable<string> GetDocumentTypes()
 {
     RepositoryFactory repo = new RepositoryFactory();
     return repo.PrintLogs.AsQueryable().Select(l => l.Type).Distinct();
 }
 public LedgerService()
 {
     repository = new RepositoryFactory();
 }
 public LedgerService(RepositoryFactory Repository)
 {
     repository = Repository;
 }
 public CostTierService()
 {
     repository = new RepositoryFactory();
 }
 public CostTierService(RepositoryFactory Repository)
 {
     repository = Repository;
 }