public async Task Process()
        {
            var logConst = "UserScheduleProcessor-Process";

            try
            {
                CareStreamContextFactory apiContextFactory = new CareStreamContextFactory();

                _cc = apiContextFactory.CreateDbContext(new string[] { });

                if (_cc == null)
                {
                    return;
                }



                var bulkUserFiles = _cc.BulkUserFiles.Where(x => x.Status == CareStreamConst.Bulk_User_Loaded_Status ||
                                                            x.Status == CareStreamConst.Bulk_User_Started_Status).ToList();

                if (bulkUserFiles.Any())
                {
                    var _dbHelper = new DbHelper(_logger, _cc);
                    foreach (var bulkUserFile in bulkUserFiles)
                    {
                        try
                        {
                            _dbHelper.UpdateTable(bulkUserFile, CareStreamConst.Bulk_User_Started_Status);


                            var fileId = bulkUserFile.Id;

                            var bulkUsers = _cc.BulkUsers.Where(x => x.FileId == fileId &&
                                                                (x.Status == CareStreamConst.Bulk_User_Loaded_Status ||
                                                                 x.Status == CareStreamConst.Bulk_User_Started_Status ||
                                                                 x.Status == CareStreamConst.Bulk_User_InProgress_Status)).ToList();
                            if (bulkUsers.Any())
                            {
                                await ProcessUserAction(bulkUsers, bulkUserFile.Action);
                            }

                            _dbHelper.UpdateTable(bulkUserFile, CareStreamConst.Bulk_User_Completed_Status);
                        }
                        catch (Exception ex)
                        {
                            _logger.LogError($"{logConst}:error processing for file id {bulkUserFile.Id}");
                            _logger.LogError(ex);

                            bulkUserFile.Error = $"{ex.ToString()}. Message: {ex.Message}";
                            _dbHelper.UpdateTable(bulkUserFile, CareStreamConst.Bulk_User_Failed_Status);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"{logConst}:Exception occured while processing the bulk user...");
                _logger.LogError(ex);
            }
        }
Example #2
0
 public DbHelper(ILoggerManager logger, CareStreamContext cc)
 {
     _logger = logger;
     _cc     = cc;
 }
Example #3
0
 public UserCreate(ILoggerManager logger, CareStreamContext cc)
 {
     _logger   = logger;
     _cc       = cc;
     _dbHelper = new DbHelper(logger, cc);
 }