static void EntityType_AfterAdd(Xy.Data.ProcedureResult result, Xy.Data.Procedure procedure, Xy.Data.DataBase DB) { string _tableName = Convert.ToString(procedure.GetItem("Key")); short _parentTypeID = Convert.ToInt16(procedure.GetItem("ParentTypeID")); if (string.IsNullOrEmpty(_tableName)) throw new Exception("Empty type name"); StringBuilder _addTableProcedure = new StringBuilder(); _addTableProcedure.AppendLine(string.Format(_commandPartern_Add, "Entity_" + _tableName)); Xy.Data.Procedure _addBaseTable = new Xy.Data.Procedure("AddBaseTable", _addTableProcedure.ToString()); _addBaseTable.InvokeProcedure(DB); }
static void EntityType_AfterEditWebRelated(Xy.Data.ProcedureResult result, Xy.Data.Procedure procedure, Xy.Data.DataBase DB) { short _ID = Convert.ToInt16(procedure.GetItem("ID")); bool _isRelated = Convert.ToBoolean(procedure.GetItem("IsWebRelated")); EntityTypeCacheItem _cache = EntityTypeCache.GetInstance(_ID, DB); Xy.Data.Procedure _webRelatedProcedure; if (_isRelated) { _webRelatedProcedure = new Xy.Data.Procedure("AddWebRelated", string.Format(_commandPartern_AddWebRelated, "Entity_" + _cache.TypeInstance.Key)); } else { _webRelatedProcedure = new Xy.Data.Procedure("DelWebRelated", string.Format(_commandPartern_DelWebRelated, "Entity_" + _cache.TypeInstance.Key)); } _webRelatedProcedure.InvokeProcedure(DB); }
static void EntityType_BeforeDel(Xy.Data.Procedure procedure, Xy.Data.DataBase DB) { short inID = Convert.ToInt16(procedure.GetItem("ID")); EntityType _type = GetInstance(inID); System.Data.DataTable _childTypies = GetChildType(inID); foreach (System.Data.DataRow _childTypeRow in _childTypies.Rows) { EntityType _childType = new EntityType(); _childType.Fill(_childTypeRow); Del(_childType.ID); } StringBuilder _dropTableProcedure = new StringBuilder(); foreach (System.Data.DataRow _multiAttrsRow in EntityAttribute.GetByTypeID(inID).Rows) { EntityAttribute _attr = new EntityAttribute(); _attr.Fill(_multiAttrsRow); if (_attr.IsMultiple) { _dropTableProcedure.AppendLine(string.Format(_commandPartern_Del, "Entity_" + _type.Key + "_" + _attr.Key)); } } _dropTableProcedure.AppendLine(string.Format(_commandPartern_Del, "Entity_" + _type.Key)); Xy.Data.Procedure _deleteRelativeTable = new Xy.Data.Procedure("DeleteRelativeTable", _dropTableProcedure.ToString()); Xy.Data.Procedure _deleteRelativeEntityBase = new Xy.Data.Procedure("DeleteRelativeEntityBase", "Delete from [EntityBase] where [TypeID] = @ID", new Xy.Data.ProcedureParameter[] { new Xy.Data.ProcedureParameter("ID", System.Data.DbType.Int64) }); _deleteRelativeEntityBase.SetItem("ID", inID); _deleteRelativeTable.InvokeProcedure(DB); _deleteRelativeEntityBase.InvokeProcedure(DB); }
static void Del_BeforeInvoke(Xy.Data.Procedure produce, Xy.Data.DataBase DB) { PowerShip.DelByGroup(Convert.ToInt32(produce.GetItem("ID")), DB); }
static void User_BeforeInvoke(Xy.Data.Procedure produce, Xy.Data.DataBase DB) { long id = Convert.ToInt64(produce.GetItem("ID")); UserExtra.Del(id, DB); }
private static void EditUserGroup_BeforeInvoke(Xy.Data.Procedure produce, Xy.Data.DataBase DB) { int groupID = Convert.ToInt32(produce.GetItem("UserGroup").ToString()); if (groupID < 0) { produce.SetItem("UserGroup", DefaultUserGroupID); } }
private static void EditPassword_BeforeInvoke(Xy.Data.Procedure produce, Xy.Data.DataBase DB) { produce.SetItem("Password", Encrypt.Encrypt(produce.GetItem("Password").ToString())); }
private static void EntityAttribute_ValidateActive(Xy.Data.Procedure produce, Xy.Data.DataBase DB) { EntityType _type; if (produce.GetItem("TypeID") == null) { long _attrID = Convert.ToInt64(produce.GetItem("ID")); EntityAttribute _attr = GetInstance(_attrID, DB); _type = EntityType.GetInstance(_attr.TypeID); } else { _type = EntityType.GetInstance(Convert.ToInt16(produce.GetItem("TypeID"))); } if (_type.IsActive) throw new Exception("Cannot modify actived type"); EntityType.EditUpdateTime(_type.ID); }
static void EntityAttribute_BeforeEdit(Xy.Data.Procedure procedure, Xy.Data.DataBase DB) { EntityAttribute _oldAttr = EntityAttribute.GetInstance(Convert.ToInt64(procedure.GetItem("ID"))); bool _isMultiple = Convert.ToBoolean(procedure.GetItem("IsMultiple")); if (_oldAttr.IsMultiple != _isMultiple) throw new Exception("can not switch attribute multiple mode"); StringBuilder _editAttrCommand = new StringBuilder(); string _default = Convert.ToString(procedure.GetItem("Default")); if (!string.IsNullOrEmpty(_oldAttr.Default) && string.IsNullOrEmpty(_default)) { _editAttrCommand.AppendLine(string.Format(_commandPartern_DelConstraintDefault, _oldAttr.Table, _oldAttr.Key)); } if (!string.IsNullOrEmpty(_default)) { _editAttrCommand.AppendLine(string.Format(_commandPartern_UpdateDefault, _oldAttr.Table, _oldAttr.Key, _default)); _editAttrCommand.AppendLine(string.Format(_commandPartern_AddConstraintDefault, _oldAttr.Table, _oldAttr.Key, _default)); } string _editAttrDBType = GetTypeName(Convert.ToString(procedure.GetItem("Type"))); if (!Convert.ToBoolean(procedure.GetItem("IsNull"))) { _editAttrDBType += " NOT NULL"; } _editAttrCommand.AppendLine(string.Format(_commandPartern_EditAttribute, _oldAttr.Table, _oldAttr.Key, _editAttrDBType)); string _key = Convert.ToString(procedure.GetItem("Key")); if (string.Compare(_key, _oldAttr.Key) != 0) { _editAttrCommand.AppendLine(string.Format(_commandPartern_EditAttributeName, _oldAttr.Table, _oldAttr.Key, _key)); } Xy.Data.Procedure _editAttrColumn = new Xy.Data.Procedure("EditAttribute", _editAttrCommand.ToString()); _editAttrColumn.InvokeProcedure(); }
static void EntityAttribute_BeforeDel(Xy.Data.Procedure procedure, Xy.Data.DataBase DB) { long _attrID = Convert.ToInt64(procedure.GetItem("ID")); EntityAttribute _attr = GetInstance(_attrID); StringBuilder _delAttrCommand = new StringBuilder(); if (_attr.IsMultiple) { _delAttrCommand.AppendLine(string.Format(_commandPartern_DelAttributeTable, _attr.Table)); } else { _delAttrCommand.AppendLine(string.Format(_commandPartern_DelAttributeColumn, _attr.Table, _attr.Key)); } if (!string.IsNullOrEmpty(_attr.Default)) { _delAttrCommand.AppendLine(string.Format(_commandPartern_DelConstraintDefault, _attr.Table, _attr.Key)); } Xy.Data.Procedure _delAttrColumn = new Xy.Data.Procedure("DelAttribute", _delAttrCommand.ToString()); _delAttrColumn.InvokeProcedure(); }
private static void EntityAttribute_BeforeAdd(Xy.Data.Procedure produce, Xy.Data.DataBase DB) { string _attrName = Convert.ToString(produce.GetItem("Key")); EntityType _type = EntityType.GetInstance(Convert.ToInt16(produce.GetItem("TypeID"))); System.Data.DataTable _attrs = GetByTypeID(_type.ID); foreach (System.Data.DataRow _attr in _attrs.Rows) { if (string.Compare(_attr["Name"].ToString(), _attrName, true) == 0) throw new Exception(string.Format("\"{0}\" already existed", _attrName)); } string _addAttrCommand; if (Convert.ToBoolean(produce.GetItem("IsMultiple"))) { _addAttrCommand = _commandPartern_AddMultipleAttribute; } else { _addAttrCommand = _commandPartern_AddSimpleAttribute; } string _addAttrDBType = GetTypeName(Convert.ToString(produce.GetItem("Type"))); if (!Convert.ToBoolean(produce.GetItem("IsNull"))) { _addAttrDBType += " NOT NULL"; } _addAttrCommand = string.Format(_addAttrCommand, "Entity_" + _type.Key, _attrName, _addAttrDBType); Xy.Data.Procedure _addAttrColumn = new Xy.Data.Procedure("AddAttribute", _addAttrCommand); _addAttrColumn.InvokeProcedure(DB); }
private static void EntityAttribute_AfterGetByTypeID(Xy.Data.ProcedureResult result, Xy.Data.Procedure produce, Xy.Data.DataBase DB) { short _typeID = Convert.ToInt16(produce.GetItem("TypeID")); EntityType _type = EntityType.GetInstance(_typeID); if (_type != null && _type.ParentTypeID > 0) { System.Data.DataTable _parentAttrs = GetByTypeID(_type.ParentTypeID); foreach (System.Data.DataRow _row in _parentAttrs.Rows) { result.DataResult.ImportRow(_row); } } }