// public static List<VPC.Entities.BatchType.BatchType> GetAllBatchTypes() // { // var batchTypes=new List<VPC.Entities.BatchType.BatchType>(); // IEnumerable<Type> types = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IBatchTypes)) && t.GetConstructor(Type.EmptyTypes) != null); // foreach (Type tType in types) // { // object[] ss = tType.GetCustomAttributes(true); // batchTypes.AddRange(from BatchTypeAttribute o in ss select // new VPC.Entities.BatchType.BatchType { Type.value = o.BatchType}); // } // return batchTypes; // } public static Type GetBatchTypeByContext(BatchTypeContextEnum context) { var types = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IBatchTypes)) && t.GetConstructor(Type.EmptyTypes) != null); Type myType = null; foreach (var t in from t in types let attr = (BatchTypeAttribute)t.GetCustomAttributes(true).FirstOrDefault() where attr != null where attr.BatchType == (int)context select t) { myType = t; } return(myType); }
private static VPC.Entities.BatchType.BatchType ReadBatchType(SqlDataReader reader) { var info = new VPC.Entities.BatchType.BatchType(); var tenantId = reader.IsDBNull(0) ? Guid.Empty : reader.GetGuid(0); var id = reader.IsDBNull(1) ? Guid.Empty : reader.GetGuid(1); BatchTypeContextEnum context = reader.IsDBNull(2) ? BatchTypeContextEnum.Email : (BatchTypeContextEnum)reader.GetInt16(2); BatchTypeEnum type = reader.IsDBNull(3) ? BatchTypeEnum.Indefinite : (BatchTypeEnum)reader.GetByte(3); byte?priority = reader.IsDBNull(4) ? (byte?)null : reader.GetByte(4); int? idleTime = reader.IsDBNull(5) ? (int?)null : reader.GetInt32(5); int? itemTimeOut = reader.IsDBNull(6) ? (int?)null : reader.GetInt32(6); int? itemRetryCount = reader.IsDBNull(7) ? (int?)null : reader.GetInt16(7); System.DateTime?startDate = reader.IsDBNull(8) ? (System.DateTime?)null : reader.GetDateTime(8); System.DateTime?endDate = reader.IsDBNull(9) ? (System.DateTime?)null : reader.GetDateTime(9); var schedulerId = reader.IsDBNull(10) ? Guid.Empty : reader.GetGuid(10); info.TenantId = new InternalId(); info.TenantId.Value = tenantId.ToString(); info.InternalId = new InternalId(); info.InternalId.Value = id.ToString(); info.Context = new PickList <BatchTypeContext>(); info.Context.Value = ((int)context).ToString(); info.Type = new PickList <BatchTypes>(); info.Type.Value = ((int)type).ToString(); info.Priority = new NumericType(); info.Priority.Value = priority.HasValue ? priority.ToString() : string.Empty; info.IdleTime = new NumericType(); info.IdleTime.Value = idleTime.HasValue ? idleTime.ToString() : string.Empty; info.ItemTimeout = new NumericType(); info.ItemTimeout.Value = itemTimeOut.HasValue ? itemTimeOut.ToString() : string.Empty; info.ItemRetryCount = new NumericType(); info.ItemRetryCount.Value = itemRetryCount.HasValue ? itemRetryCount.ToString() : string.Empty; info.StartDate = new VPC.Metadata.Business.DataTypes.DateTime(); info.StartDate.Value = startDate.ToString(); info.EndDate = new VPC.Metadata.Business.DataTypes.DateTime(); info.EndDate.Value = endDate.ToString(); info.Scheduler = new BatchTypeScheduler(); info.Scheduler.InternalId = new InternalId(); info.Scheduler.InternalId.Value = schedulerId.ToString(); return(info); }
VPC.Entities.BatchType.BatchType IReviewBatchType.GetBatchTypeByContext(Guid tenantId, BatchTypeContextEnum context) { return(_data.GetBatchTypeByContext(tenantId, context)); }
internal VPC.Entities.BatchType.BatchType GetBatchTypeByContext(Guid tenantId, BatchTypeContextEnum context) { VPC.Entities.BatchType.BatchType batche = null; try { SqlProcedureCommand cmd = CreateProcedureCommand("dbo.BatchType_GetByContext"); cmd.AppendGuid("@guidTenantId", tenantId); cmd.AppendSmallInt("@siContext", (short)context); using (SqlDataReader reader = ExecuteCommandAndReturnReader(cmd)) { while (reader.Read()) { batche = ReadBatchType(reader); } } } catch (SqlException e) { throw ReportAndTranslateException(e, "DataBatchType::BatchType_GetByContext"); } return(batche); }