public void AddSystemAttribute(SystemAttribute attr) { lock (_synclock) { SystemAttributeCollection.Add(attr); } }
private List <string> GetSystemList(bool isUpdate) { List <string> list = new List <string>(); List <Type> systemTypes = LCReflect.GetClassByType <BaseSystem>(); for (int i = 0; i < systemTypes.Count; i++) { Type sysTy = systemTypes[i]; SystemAttribute attribute = LCReflect.GetTypeAttr <SystemAttribute>(sysTy); if (isUpdate) { if (attribute == null || attribute.InFixedUpdate == false) { list.Add(sysTy.FullName); } } else { if (attribute != null && attribute.InFixedUpdate == true) { list.Add(sysTy.FullName); } } } return(list); }
public static string Str(this SystemAttribute systemValue) { switch (systemValue) { case SystemAttribute.None: return(""); case SystemAttribute.Position: return("SV_Position"); case SystemAttribute.ClipDistance: return("SV_ClipDistance"); case SystemAttribute.CullDistance: return("SV_CullDistance"); case SystemAttribute.RTIndex: return("SV_RenderTargetIndex"); case SystemAttribute.ViewportIndex: return("SV_ViewportIndex"); case SystemAttribute.VertexIndex: return("SV_VertexID"); case SystemAttribute.PrimitiveIndex: return("SV_PrimitiveID"); case SystemAttribute.InstanceIndex: return("SV_InstanceID"); case SystemAttribute.DispatchThreadIndex: return("SV_DispatchThreadID"); case SystemAttribute.GroupIndex: return("SV_GroupID"); case SystemAttribute.GroupFlatIndex: return("SV_GroupIndex"); case SystemAttribute.GroupThreadIndex: return("SV_GroupThreadID"); case SystemAttribute.GSInstanceIndex: return("SV_GSInstanceID"); case SystemAttribute.OutputControlPointIndex: return("SV_OutputControlPointID"); case SystemAttribute.DomainLocation: return("SV_DomainLocation"); case SystemAttribute.IsFrontFace: return("SV_IsFrontFace"); case SystemAttribute.MSAACoverage: return("SV_Coverage"); case SystemAttribute.MSAASampleIndex: return("SV_SampleIndex"); case SystemAttribute.OuterTessFactor: return("SV_TessFactor"); case SystemAttribute.InsideTessFactor: return("SV_InsideTessFactor"); case SystemAttribute.ColourOutput: return("SV_Target"); case SystemAttribute.DepthOutput: return("SV_Depth"); case SystemAttribute.DepthOutputGreaterEqual: return("SV_DepthGreaterEqual"); case SystemAttribute.DepthOutputLessEqual: return("SV_DepthLessEqual"); } return("SV_Unknown"); }
public static int GetUniqueID(object Instance) { int ID = ((ReflectEntity)Instance).ID; if (ID > 0) { return(ID); } string Query = "SELECT [ID] FROM [dbo].[" + EncryptTableName(Instance.GetType().Name) + "]"; string Filter = "[IsDeleted] = 0"; foreach (System.Reflection.PropertyInfo SystemAttribute in Instance.GetType().GetProperties().Where(x => Attribute.IsDefined(x, typeof(UniqueAtrribute)))) { if (Attribute.IsDefined(SystemAttribute, typeof(RelationAttribute))) { foreach (System.Reflection.PropertyInfo RelatedAttribute in SystemAttribute.PropertyType.GetProperties()) { if (Attribute.IsDefined(RelatedAttribute, typeof(NoDataAttribute)) || Attribute.IsDefined(RelatedAttribute, typeof(NoRelationAttribute)) || Attribute.IsDefined(RelatedAttribute, typeof(RelationAttribute))) { continue; } else if (RelatedAttribute.PropertyType.Namespace.StartsWith("System") || RelatedAttribute.PropertyType.IsEnum) { if (RelatedAttribute.PropertyType.IsEnum || RelatedAttribute.GetValue(Instance, null) != null) { Filter += " AND [" + SystemAttribute.Name + "." + RelatedAttribute + "] = '" + (IsCryptable(RelatedAttribute) ? EncryptColumnValue(RelatedAttribute.GetValue(Instance, null).ToString()) : RelatedAttribute.GetValue(Instance, null)) + "'"; } } } } else if (SystemAttribute.PropertyType.Namespace.StartsWith("System") || SystemAttribute.PropertyType.IsEnum) { if (SystemAttribute.PropertyType.IsEnum || SystemAttribute.GetValue(Instance, null) != null) { Filter += " AND [" + SystemAttribute.Name + "] = '" + (IsCryptable(SystemAttribute) ? EncryptColumnValue(SystemAttribute.GetValue(Instance, null).ToString()) : SystemAttribute.GetValue(Instance, null)) + "'"; } } } if (Filter != "") { Query += " WHERE " + Filter; } try { ID = Database.Executor.PrintQuery(Query); } catch (Exception) { } return(ID); }
public HttpStatusCode CreatProduct(CreateProductDto createProductDto) { Subcategory subcategory = _ctx.Subcategories.FirstOrDefault(x => x.Id == createProductDto.SubcategoryId); if (subcategory == null) { return(HttpStatusCode.NotFound); } var systemAttributeModel = new SystemAttribute() { CreationDate = DateTime.Now, IsPublished = createProductDto.IsProductPublished, VersioNumber = Guid.NewGuid().ToString(), Version = 1, }; try { _ctx.SystemAttributes.Add(systemAttributeModel); _ctx.SaveChanges(); } catch (Exception ex) { throw ex; } var model = new Product() { Name = createProductDto.ProductName, IsPublished = createProductDto.IsProductPublished, Subcategory = subcategory, SubcategoryId = subcategory.Id, SystemAttribute = systemAttributeModel, SystemAttributeId = systemAttributeModel.Id, CreationDate = DateTime.Now }; try { _ctx.Products.Add(model); _ctx.SaveChanges(); } catch (Exception ex) { return(HttpStatusCode.InternalServerError); } return(HttpStatusCode.OK); }
public FormatElement(string Name, int buf, uint offs, bool pi, int ir, bool rowMat, uint matDim, ResourceFormat f, bool h) { name = Name; buffer = buf; offset = offs; format = f; perinstance = pi; instancerate = ir; rowmajor = rowMat; matrixdim = matDim; hex = h; systemValue = SystemAttribute.None; }
public FormatElement() { name = ""; buffer = 0; offset = 0; perinstance = false; instancerate = 1; rowmajor = false; matrixdim = 0; format = new ResourceFormat(); hex = false; systemValue = SystemAttribute.None; }
//注册系统 private void RegSystems() { List <Type> systemTypes = LCReflect.GetClassByType <BaseSystem>(); List <Type> updateSystems = new List <Type>(); List <Type> fixedUpdateSystems = new List <Type>(); //分组 for (int i = 0; i < systemTypes.Count; i++) { Type type = systemTypes[i]; SystemAttribute attr = LCReflect.GetTypeAttr <SystemAttribute>(type); if (attr == null) { //ECSLocate.ECSLog.Log("该系统没有设置系统特性>>>>>>", type.Name); updateSystems.Add(type); } else { if (attr.InFixedUpdate) { fixedUpdateSystems.Add(type); } else { updateSystems.Add(type); } } } //排序 updateSystems.Sort(SystemSortFunc); fixedUpdateSystems.Sort(SystemSortFunc); //注册 for (int i = 0; i < updateSystems.Count; i++) { Type type = updateSystems[i]; BaseSystem system = LCReflect.CreateInstanceByType <BaseSystem>(type.FullName); system.Init(); ECSLocate.ECS.RegUpdateSystem(system); } for (int i = 0; i < fixedUpdateSystems.Count; i++) { Type type = fixedUpdateSystems[i]; BaseSystem system = LCReflect.CreateInstanceByType <BaseSystem>(type.FullName); system.Init(); ECSLocate.ECS.RegFixedUpdateSystem(system); } }
public HttpStatusCode UpdateProduct(int productId, UpdateProductDto updateProductDto, string userId) { Product product = _ctx.Products.FirstOrDefault(f => f.Id == productId); product.Name = updateProductDto.ProductName; product.IsPublished = updateProductDto.IsProductPublished; product.LastModifiedDate = DateTime.Now; Subcategory subcategory = _ctx.Subcategories.FirstOrDefault(f => f.Id == updateProductDto.SubcategoryId); product.Subcategory = subcategory; product.SubcategoryId = subcategory.Id; try { _ctx.Entry(product).State = EntityState.Modified; _ctx.SaveChanges(); } catch (Exception ex) { return(HttpStatusCode.InternalServerError); } ApplicationUser user = _ctx.Users.FirstOrDefault(f => f.Id == userId); SystemAttribute systemAttribute = _ctx.SystemAttributes.FirstOrDefault(f => f.Id == product.SystemAttributeId); systemAttribute.IsPublished = updateProductDto.IsProductPublished; systemAttribute.LastModifiedBy = user.UserName; systemAttribute.LastModified = DateTime.Now; systemAttribute.VersioNumber = systemAttribute.VersioNumber; systemAttribute.Version++; try { _ctx.Entry(systemAttribute).State = EntityState.Modified; _ctx.SaveChanges(); } catch (Exception ex) { return(HttpStatusCode.InternalServerError); } return(HttpStatusCode.OK); }
public ReflectEntity(int ObjectID) { Dictionary <string, string> Parameters = new Dictionary <string, string>(); Parameters.Add("ID", ObjectID.ToString()); object Instance = Engine.GetSingleByParameters(this.GetType(), Parameters); foreach (System.Reflection.PropertyInfo SystemAttribute in this.GetType().GetProperties()) { try { SystemAttribute.SetValue(this, Instance.GetType().GetProperty(SystemAttribute.Name).GetValue(Instance)); } catch (Exception) { } } }
public ProductViewModel ProductToViewModel(Product product) { SystemAttribute systemAttribute = _ctx.SystemAttributes.FirstOrDefault(f => f.Id == product.SystemAttributeId); List <File> files = _ctx.Files.Where(w => w.ProductId == product.Id).ToList(); List <FileViewModel> fileViewModels = new List <FileViewModel>(); if (files.Count > 0) { string fileFolderName = _configuration.GetSection("FilesFolderPath")["Folder"]; files.ForEach(file => { FileViewModel fileViewModel = new FileViewModel(); fileViewModel = new FileViewModel() { FileId = file.Id, File = fileFolderName + file.FileName, FileType = file.FileType, IsMainFile = file.IsMainFile, IsPublished = file.IsPublished }; fileViewModels.Add(fileViewModel); }); } var viewModel = new ProductViewModel() { ProductId = product.Id, CreationDate = product.CreationDate, IsPublished = product.IsPublished, LastModified = product.LastModifiedDate, LastModifiedBy = systemAttribute.LastModifiedBy, ProductName = product.Name, VersioNumber = systemAttribute.VersioNumber, Version = systemAttribute.Version, Files = fileViewModels }; return(viewModel); }
public static List <object> ObjectsByDataSet(System.Type SystemType, DataSet Result) { if (Result.Tables.Count == 0) { return(new List <object>()); } if (Result.Tables[0].Rows.Count == 0) { return(new List <object>()); } List <object> ObjectList = new List <object>(); foreach (System.Data.DataRow DataRow in Result.Tables[0].Rows) { object Instance = Activator.CreateInstance(SystemType); foreach (System.Reflection.PropertyInfo SystemAttribute in SystemType.GetProperties()) { if (Attribute.IsDefined(SystemAttribute, typeof(NoDataAttribute))) { continue; } try { if (SystemAttribute.PropertyType.IsEnum) { SystemAttribute.SetValue(Instance, Enum.Parse(SystemAttribute.PropertyType, (IsCryptable(SystemAttribute) ? DecryptColumnValue(DataRow[EncryptColumnName(SystemAttribute.Name)].ToString()) : DataRow[EncryptColumnName(SystemAttribute.Name)]).ToString(), true), null); } else if (SystemAttribute.PropertyType == typeof(Guid)) { SystemAttribute.SetValue(Instance, Guid.Parse((IsCryptable(SystemAttribute) ? DecryptColumnValue(DataRow[EncryptColumnName(SystemAttribute.Name)].ToString()) : DataRow[EncryptColumnName(SystemAttribute.Name)]).ToString()), null); } else if (Attribute.IsDefined(SystemAttribute, typeof(RelationAttribute))) { object RelatedInstance = Activator.CreateInstance(SystemAttribute.PropertyType); foreach (System.Reflection.PropertyInfo RelatedAttribute in SystemAttribute.PropertyType.GetProperties()) { if (Attribute.IsDefined(RelatedAttribute, typeof(NoDataAttribute)) || Attribute.IsDefined(RelatedAttribute, typeof(RelationAttribute)) || Attribute.IsDefined(RelatedAttribute, typeof(NoRelationAttribute))) { continue; } RelatedAttribute.SetValue(RelatedInstance, (IsCryptable(RelatedAttribute) ? DecryptColumnValue(DataRow[EncryptColumnName(SystemAttribute.Name + "." + RelatedAttribute.Name)].ToString()) : DataRow[EncryptColumnName(SystemAttribute.Name + "." + RelatedAttribute.Name)]), null); } SystemAttribute.SetValue(Instance, RelatedInstance); } else { SystemAttribute.SetValue(Instance, (IsCryptable(SystemAttribute) ? DecryptColumnValue(DataRow[EncryptColumnName(SystemAttribute.Name)].ToString()) : DataRow[EncryptColumnName(SystemAttribute.Name)]), null); } } catch (Exception) { } } ObjectList.Add(Instance); } return(ObjectList); }
public void AddSystemAttribute(SystemAttribute attr) { SystemAttributeCollection.Add(attr); }
public static int Save(object Instance) { int ID = ((ReflectEntity)Instance).ID; ((ReflectEntity)Instance).UpdatedOn = DateTime.Now; if (Instance.GetType().IsSubclassOf(typeof(ReflectEntity))) { if (((ReflectEntity)Instance).ID == 0) { ((ReflectEntity)Instance).CreatedOn = DateTime.Now; string Columns = ""; string Values = ""; foreach (System.Reflection.PropertyInfo SystemAttribute in Instance.GetType().GetProperties()) { if (Attribute.IsDefined(SystemAttribute, typeof(NoDataAttribute))) { continue; } if (SystemAttribute.Name != "ID") { if (Attribute.IsDefined(SystemAttribute, typeof(RelationAttribute))) { foreach (System.Reflection.PropertyInfo RelatedAttribute in SystemAttribute.PropertyType.GetProperties()) { if (Attribute.IsDefined(RelatedAttribute, typeof(NoDataAttribute)) || Attribute.IsDefined(RelatedAttribute, typeof(NoRelationAttribute)) || Attribute.IsDefined(RelatedAttribute, typeof(RelationAttribute))) { continue; } if (RelatedAttribute.PropertyType.Namespace.StartsWith("System") || RelatedAttribute.PropertyType.IsEnum) { if (Columns != "") { Columns += ", "; } Columns += "[" + EncryptColumnName(SystemAttribute.Name + "." + RelatedAttribute.Name) + "]"; } } } else if (SystemAttribute.PropertyType.Namespace.StartsWith("System") || SystemAttribute.PropertyType.IsEnum) { if (Columns != "") { Columns += ", "; } Columns += "[" + EncryptColumnName(SystemAttribute.Name) + "]"; } if (!SystemAttribute.PropertyType.IsEnum && SystemAttribute.GetValue(Instance, null) == null) { if (Values != "") { Values += ", "; } Values += "NULL"; } else { if (SystemAttribute.PropertyType == typeof(DateTime)) { if (Values != "") { Values += ", "; } if (Convert.ToDateTime(SystemAttribute.GetValue(Instance, null)) == DateTime.MinValue) { Values += "NULL"; } else { Values += "'" + (IsCryptable(SystemAttribute) ? EncryptColumnValue(SystemAttribute.GetValue(Instance, null).ToString()) : new System.Data.SqlClient.SqlParameter("@var", SystemAttribute.GetValue(Instance, null)) { SqlDbType = SqlDbType.SmallDateTime }.SqlValue.ToString()) + "'"; } } else if (Attribute.IsDefined(SystemAttribute, typeof(RelationAttribute))) { foreach (System.Reflection.PropertyInfo RelatedAttribute in SystemAttribute.PropertyType.GetProperties()) { if (Attribute.IsDefined(RelatedAttribute, typeof(NoDataAttribute)) || Attribute.IsDefined(RelatedAttribute, typeof(NoRelationAttribute)) || Attribute.IsDefined(RelatedAttribute, typeof(RelationAttribute))) { continue; } else if (RelatedAttribute.PropertyType.Namespace.StartsWith("System") || RelatedAttribute.PropertyType.IsEnum) { if (Values != "") { Values += ", "; } if (RelatedAttribute.GetValue(Instance, null) == null) { Values += "[" + EncryptColumnName(SystemAttribute.Name + "." + RelatedAttribute.Name) + "] = NULL"; } else { Values += "[" + EncryptColumnName(SystemAttribute.Name + "." + RelatedAttribute.Name) + "] = '" + (IsCryptable(RelatedAttribute) ? EncryptColumnValue(RelatedAttribute.GetValue(Instance, null).ToString()) : RelatedAttribute.GetValue(Instance, null)) + "'"; } } } } else if (SystemAttribute.PropertyType.Namespace.StartsWith("System") || SystemAttribute.PropertyType.IsEnum) { if (Values != "") { Values += ", "; } Values += "'" + (IsCryptable(SystemAttribute) ? EncryptColumnValue(SystemAttribute.GetValue(Instance, null).ToString()) : SystemAttribute.GetValue(Instance, null)) + "'"; } } } } string Query = "INSERT INTO [dbo].[" + EncryptTableName(Instance.GetType().Name) + "] (" + Columns + ") VALUES (" + Values + "); SELECT SCOPE_IDENTITY();"; ID = Database.Executor.PrintQuery(Query); } else { string Values = ""; foreach (System.Reflection.PropertyInfo SystemAttribute in Instance.GetType().GetProperties()) { if (Attribute.IsDefined(SystemAttribute, typeof(NoDataAttribute))) { continue; } if (SystemAttribute.Name != "ID") { if (Values != "") { Values += ", "; } if (SystemAttribute.PropertyType == typeof(DateTime)) { if (Convert.ToDateTime(SystemAttribute.GetValue(Instance, null)) == DateTime.MinValue) { Values += "[" + SystemAttribute.Name + "] = NULL"; } else { Values += "[" + SystemAttribute.Name + "] = '" + (IsCryptable(SystemAttribute) ? EncryptColumnValue(SystemAttribute.GetValue(Instance, null).ToString()) : new System.Data.SqlClient.SqlParameter("@var", SystemAttribute.GetValue(Instance, null)) { SqlDbType = SqlDbType.SmallDateTime }.SqlValue.ToString()) + "'"; } } else if (Attribute.IsDefined(SystemAttribute, typeof(RelationAttribute))) { foreach (System.Reflection.PropertyInfo RelatedAttribute in SystemAttribute.PropertyType.GetProperties()) { if (Attribute.IsDefined(RelatedAttribute, typeof(NoDataAttribute)) || Attribute.IsDefined(RelatedAttribute, typeof(NoRelationAttribute)) || Attribute.IsDefined(RelatedAttribute, typeof(RelationAttribute))) { continue; } if (RelatedAttribute.PropertyType.Namespace.StartsWith("System") || RelatedAttribute.PropertyType.IsEnum) { if (!RelatedAttribute.PropertyType.IsEnum && RelatedAttribute.GetValue(Instance, null) == null) { Values += "[" + EncryptColumnName(SystemAttribute.Name + "." + RelatedAttribute.Name) + "]= NULL"; } else { Values += "[" + EncryptColumnName(SystemAttribute.Name + "." + RelatedAttribute.Name) + "]= '" + (IsCryptable(RelatedAttribute) ? EncryptColumnValue(RelatedAttribute.GetValue(Instance, null).ToString()) : RelatedAttribute.GetValue(Instance, null)) + "'"; } } } } else if (SystemAttribute.PropertyType.Namespace.StartsWith("System") || SystemAttribute.PropertyType.IsEnum) { if (!SystemAttribute.PropertyType.IsEnum && SystemAttribute.GetValue(Instance, null) == null) { Values += "[" + SystemAttribute.Name + "] = NULL"; } else { Values += "[" + SystemAttribute.Name + "] = '" + (IsCryptable(SystemAttribute) ? EncryptColumnValue(SystemAttribute.GetValue(Instance, null).ToString()) : SystemAttribute.GetValue(Instance, null)) + "'"; } } } } string Query = "UPDATE [dbo].[" + EncryptTableName(Instance.GetType().Name) + "] SET " + Values + " WHERE [ID] = '" + ((ReflectEntity)Instance).ID + "';"; Database.Executor.ExecuteQuery(Query); } } return(ID); }
protected void AddSystemInfo(SystemAttribute sa) { SystemAttributeContext.AddSystemAttribute(sa); }
protected void AddSystemInfo(string name, string value) { var sa = new SystemAttribute(name, value); AddSystemInfo(sa); }
public void Add(SystemAttribute sa) { SystemAttributeCollection.Add(sa); }
/// <summary> /// Adds any applicable system information to all started reporters /// </summary> /// <param name="name"></param> /// <param name="value"></param> public void AddSystemInfo(string name, string value) { SystemAttribute sa = new SystemAttribute(name, value); AddSystemAttribute(sa); }