Example #1
0
        public static HlidacStatu.Lib.OCR.Api.Result AddNewTask(ItemToOcrType itemType, string itemId, string itemSubType = null, int priority = 5)
        {
            using (DbEntities db = new DbEntities())
            {
                IQueryable <ItemToOcrQueue> sql = CreateQuery(db, itemType, itemSubType);
                sql = sql.Where(m => m.itemId == itemId);
                if (sql.Any()) //already in the queue
                {
                    return new OCR.Api.Result()
                           {
                               IsValid = OCR.Api.Result.ResultStatus.InQueueWithCallback,
                               Id      = "uknown"
                           }
                }
                ;

                ItemToOcrQueue i = new ItemToOcrQueue();
                i.created     = DateTime.Now;
                i.itemId      = itemId;
                i.itemType    = itemType.ToString();
                i.itemSubType = itemSubType;
                i.priority    = priority;
                db.ItemToOcrQueue.Add(i);
                db.SaveChanges();
                return(new OCR.Api.Result()
                {
                    IsValid = OCR.Api.Result.ResultStatus.InQueueWithCallback,
                    Id = "uknown"
                });
            }
        }
 public static void SetDone(int taskItemId, bool success, string result = null)
 {
     using (DbEntities db = new DbEntities())
     {
         ItemToOcrQueue i = db.ItemToOcrQueue.Where(m => m.pk == taskItemId).FirstOrDefault();
         if (i != null)
         {
             i.done    = DateTime.Now;
             i.success = success ? 1 : 0;
             i.result  = result;
             db.SaveChanges();
         }
     }
 }
 public static void ResetTask(int taskItemId)
 {
     using (DbEntities db = new DbEntities())
     {
         ItemToOcrQueue i = db.ItemToOcrQueue.Where(m => m.pk == taskItemId).FirstOrDefault();
         if (i != null)
         {
             i.done    = null;
             i.started = null;
             i.success = null;
             i.result  = null;
             db.SaveChanges();
         }
     }
 }
 public static HlidacStatu.Lib.OCR.Api.Result AddNewTask(ItemToOcrType itemType, string itemId, string itemSubType = null, HlidacStatu.Lib.OCR.Api.Client.TaskPriority priority = OCR.Api.Client.TaskPriority.Standard)
 {
     using (DbEntities db = new DbEntities())
     {
         ItemToOcrQueue i = new ItemToOcrQueue();
         i.created     = DateTime.Now;
         i.itemId      = itemId;
         i.itemType    = itemType.ToString();
         i.itemSubType = itemSubType;
         i.priority    = (int)OCR.Api.Client.TaskPriority.Standard;
         db.ItemToOcrQueue.Add(i);
         db.SaveChanges();
         return(new OCR.Api.Result()
         {
             IsValid = OCR.Api.Result.ResultStatus.InQueueWithCallback,
             Id = "uknown"
         });
     }
 }
Example #5
0
        public static void ResetTask(int taskItemId, bool decreasePriority = true)
        {
            using (DbEntities db = new DbEntities())
            {
                ItemToOcrQueue i = db.ItemToOcrQueue.Where(m => m.pk == taskItemId).FirstOrDefault();
                if (i != null)
                {
                    i.done = null;

                    i.started = null;
                    i.success = null;
                    i.result  = null;
                    if (decreasePriority)
                    {
                        i.priority--;
                        if (i.priority < 1)
                        {
                            i.priority = 1;
                        }
                    }
                    db.SaveChanges();
                }
            }
        }