public string CreateTemplate(string name, string content, string userId) { string id = Guid.NewGuid().ToString(); TOP.Template.Domain.Template template = new TOP.Template.Domain.Template(); template.Name = name; template.Content = content; template.CreateUserId = userId; template.LastUpdateUserId = userId; #region 执行SQL以创建对象 TemplateManager manager = new TemplateManager(); string sqlCreate = manager.GetCreateSql(template); using (DbOperator dbOperator = new DbOperator(ConnString)) { try { dbOperator.BeginTran(); dbOperator.ExecSql(sqlCreate); dbOperator.CommintTran(); return id; } catch (Exception ex) { dbOperator.RollbackTran(); throw new FacadeException("创建模板发生异常 - ", ex); } } #endregion }
protected void btnUpdate_Click(object sender, EventArgs e) { string value = tvSchema.SelectedNode.Value; if (value != "table" && value != "view") { Type type = Type.GetType(value); string dbTypeId = ConfigurationManager.AppSettings["DbType"]; TOP.Common.DbHelper.DbType dbType = (TOP.Common.DbHelper.DbType)short.Parse(dbTypeId); string connString = ConfigurationManager.AppSettings["ConnString"]; string sqlDrop = string.Empty; string sqlCreate = string.Empty; string parent = tvSchema.SelectedNode.Parent.Value; if (parent.Equals("Table", StringComparison.OrdinalIgnoreCase)) { DbSqlCreater dbSqlCreater = DbSqlCreater.GetDbSqlCreater(dbType); sqlDrop = dbSqlCreater.GenerateDropTableSql(type); sqlCreate = dbSqlCreater.GenerateCreateTableSql(type); } else if (parent.Equals("View", StringComparison.OrdinalIgnoreCase)) { string baseDir = Server.MapPath("~"); baseDir += @"\..\..\Database\Scripts"; DbQuery dbQuery = DbQuery.GetDbQuery(dbType); sqlDrop = dbQuery.GenerateDropViewSql(type, baseDir); sqlCreate = dbQuery.GenerateCreateViewSql(type, baseDir); } else { throw new ArgumentException("不能更新的类型 - " + parent + " - " + value); } using (DbOperator dbOperator = new DbOperator(connString)) { try { dbOperator.BeginTran(); dbOperator.ExecSql(sqlDrop); dbOperator.ExecSql(sqlCreate); dbOperator.CommintTran(); lblMessage.Text = "更新成功 - " + parent + " - " + value; } catch { dbOperator.RollbackTran(); throw new Exception("更新数据库对象错误 - " + parent + " - " + value); } } } else { lblMessage.Text = "所选择对象无效,请选择要更新的数据库对象。"; } }
public string AddArea(string id, string areaId, string areaTypeId, string areaName, string parentId, string zip, string createUserId) { #region 构造要新增的对象 if (string.IsNullOrEmpty(id) || id == Guid.Empty.ToString()) { id = Guid.NewGuid().ToString(); } Area area = new Area(); area.Id = id; area.AreaId = areaId; area.AreaTypeId = areaTypeId; area.AreaName = areaName; area.ParentId = parentId; area.Zip = zip; area.CreateDate = DateTime.Now; area.CreateUserId = createUserId; area.LastUpdateDate = DateTime.Now; area.LastUpdateUserId = createUserId; #endregion #region 执行SQL以创建对象 AreaManager manager = new AreaManager(); string sqlCreate = manager.GetCreateSql(area); using (DbOperator dbOperator = new DbOperator(ConnString)) { try { dbOperator.BeginTran(); dbOperator.ExecSql(sqlCreate); dbOperator.CommintTran(); return id; } catch (Exception ex) { dbOperator.RollbackTran(); throw new FacadeException("新增区域发生异常 - ", ex); } } #endregion }
public void AddImportGroup(string groupId, string operatorUserId, string operatorUserName, int totalCount , string fromNick, string fromTitle, string fromImageUrl, string toNick, string toTitle , ImportorEnumerations.ImportType importType, string userId) { ImportGroup groupEntity = new ImportGroup(); groupEntity.Id = groupId; groupEntity.OperatorUserId = operatorUserId; groupEntity.OperatorUserName = operatorUserName; groupEntity.TotalCount = totalCount; groupEntity.SuccessCount = 0; groupEntity.FailCount = 0; groupEntity.ImportFormSellerNick = fromNick; groupEntity.ImportFormShopTitle = fromTitle; groupEntity.ImportFormShopImageUrl = fromImageUrl; groupEntity.ImportToSellerNick = toNick; groupEntity.ImportToShopTitle = toTitle; groupEntity.ImportType = importType; groupEntity.ImportState = ImportorEnumerations.ImportState.Waitting; groupEntity.ImportResult = ImportorEnumerations.ImportGroupResult.Pending; groupEntity.ListDateTime = DateTime.Now; groupEntity.StartDateTime = null; groupEntity.FinishDateTime = null; groupEntity.CreateDate = DateTime.Now; groupEntity.CreateUserId = userId; groupEntity.LastUpdateDate = DateTime.Now; groupEntity.LastUpdateUserId = userId; ImportGroupManager groupManager = new ImportGroupManager(); string sqlCreateGroup = groupManager.GetCreateSql(groupEntity); using (DbOperator dbOperator = new DbOperator(ConnString)) { try { dbOperator.BeginTran(); dbOperator.ExecSql(sqlCreateGroup); dbOperator.CommintTran(); } catch (Exception ex) { dbOperator.RollbackTran(); throw new FacadeException("添加导入组发生异常 - ", ex); } } }
public string AddItemCategory(string id, string categoryId, string parentId, string name, bool isParent, string status, int sortOrder) { #region 构造要新增的对象 if (string.IsNullOrEmpty(id) || id == Guid.Empty.ToString()) { id = Guid.NewGuid().ToString(); } ItemCategory category = new ItemCategory(); category.Id = id; category.CategoryId = categoryId; category.ParentId = parentId; category.Name = name; category.IsParent = isParent; category.Status = status; category.SortOrder = sortOrder; #endregion #region 执行SQL以创建对象 ItemCategoryManager manager = new ItemCategoryManager(); string sqlCreate = manager.GetCreateSql(category); using (DbOperator dbOperator = new DbOperator(ConnString)) { try { dbOperator.BeginTran(); dbOperator.ExecSql(sqlCreate); dbOperator.CommintTran(); return id; } catch (Exception ex) { dbOperator.RollbackTran(); throw new FacadeException("新增类目发生异常 - ", ex); } } #endregion }
public void DbInitialize() { string sqlDropTable = dbSqlCreater.GenerateDropTableSql(typeof(Area)); string sqlCreateTable = dbSqlCreater.GenerateCreateTableSql(typeof(Area)); using (DbOperator dbOperator = new DbOperator(connString)) { try { dbOperator.BeginTran(); dbOperator.ExecSql(sqlDropTable); dbOperator.ExecSql(sqlCreateTable); dbOperator.CommintTran(); } catch (Exception ex) { dbOperator.RollbackTran(); Assert.Fail("初始化数据库错误 - " + ex.Message); } } }
/// <summary> /// 注册新用户。返回用户Id。 /// </summary> /// <param name="id"></param> /// <param name="loginName">登录名</param> /// <param name="password">加密后的密码</param> /// <param name="userName">用户名</param> /// <returns></returns> public string Register(string id, string loginName, string password, string userName) { #region 构造要新增的对象 if (string.IsNullOrEmpty(id) || id == Guid.Empty.ToString()) { id = Guid.NewGuid().ToString(); } User _user = new User(); _user.Id = id; _user.LoginName = loginName; _user.Password = password; _user.UserName = userName; #endregion #region 执行SQL以创建对象 UserManager manager = new UserManager(); string sqlCreate = manager.GetCreateSql(_user); using (DbOperator dbOperator = new DbOperator(ConnString)) { try { dbOperator.BeginTran(); dbOperator.ExecSql(sqlCreate); dbOperator.CommintTran(); return id; } catch (Exception ex) { dbOperator.RollbackTran(); throw new FacadeException("注册用户发生异常 - ", ex); } } #endregion }
public void UpdateArea(string areaId, string areaTypeId, string areaName, string parentId, string zip, string updateUserId) { #region 构造要修改的对象 Area area = new Area(); area.AreaTypeId = areaTypeId; area.AreaName = areaName; area.ParentId = parentId; area.Zip = zip; area.LastUpdateDate = DateTime.Now; area.LastUpdateUserId = updateUserId; #endregion #region 执行SQL以修改对象 AreaManager manager = new AreaManager(); string sqlUpdate = manager.GetUpdateSql(area); sqlUpdate += string.Format("WHERE [AreaId] = N'{0}'", areaTypeId); using (DbOperator dbOperator = new DbOperator(ConnString)) { try { dbOperator.BeginTran(); dbOperator.ExecSql(sqlUpdate); dbOperator.CommintTran(); } catch (Exception ex) { dbOperator.RollbackTran(); throw new FacadeException("修改区域发生异常 - ", ex); } } #endregion }
public void AddImportItem(string itemId, string groupId, string operatorUserId, string operatorUserName , string fromItemIid, string fromItemTitle, string fromItemPrice, string fromSellerNick, string fromShopTitle, string userId) { ImportItem itemEntity = new ImportItem(); itemEntity.Id = itemId; itemEntity.OperatorUserId = operatorUserId; itemEntity.OperatorUserName = operatorUserName; itemEntity.ItsImportGroupId = groupId; itemEntity.ImportFormItemIid = fromItemIid; itemEntity.ImportFormItemTitle = fromItemTitle; itemEntity.ImportFormItemPrice = fromItemPrice; itemEntity.ImportFormSellerNick = fromSellerNick; itemEntity.ImportFormShopTitle = fromShopTitle; itemEntity.ImportState = ImportorEnumerations.ImportState.Waitting; itemEntity.ImportResult = ImportorEnumerations.ImportItemResult.Pending; itemEntity.ListDateTime = DateTime.Now; itemEntity.StartDateTime = null; itemEntity.FinishDateTime = null; itemEntity.CreateDate = DateTime.Now; itemEntity.CreateUserId = userId; itemEntity.LastUpdateDate = DateTime.Now; itemEntity.LastUpdateUserId = userId; ImportItemManager itemManager = new ImportItemManager(); string sqlCreateItem = itemManager.GetCreateSql(itemEntity); using (DbOperator dbOperator = new DbOperator(ConnString)) { try { dbOperator.BeginTran(); dbOperator.ExecSql(sqlCreateItem); dbOperator.CommintTran(); } catch (Exception ex) { dbOperator.RollbackTran(); throw new FacadeException("添加导入项发生异常 - ", ex); } } }
public void StartImportItem(string itemId, int version, string userId) { ImportItem itemEntity = new ImportItem(); itemEntity.Id = itemId; itemEntity.ImportState = ImportorEnumerations.ImportState.Importing; itemEntity.StartDateTime = DateTime.Now; itemEntity.LastUpdateDate = DateTime.Now; itemEntity.LastUpdateUserId = userId; itemEntity.CurrentVersion = version; ImportItemManager manager = new ImportItemManager(); string sqlUpdateItem = manager.GetUpdateSql(itemEntity, "ImportState", "StartDateTime"); #region 执行SQL以修改对象 using (DbOperator dbOperator = new DbOperator(ConnString)) { try { dbOperator.BeginTran(); dbOperator.ExecSql(sqlUpdateItem); dbOperator.CommintTran(); } catch (Exception ex) { dbOperator.RollbackTran(); throw new FacadeException("启动导入宝贝发生异常 - ", ex); } } #endregion }
public void StartImport(string groupId, int version, string userId) { ImportGroup groupEntity = new ImportGroup(); groupEntity.Id = groupId; groupEntity.ImportState = ImportorEnumerations.ImportState.Importing; groupEntity.LastUpdateDate = DateTime.Now; groupEntity.LastUpdateUserId = userId; groupEntity.CurrentVersion = version; #region 执行SQL以修改对象 ImportGroupManager manager = new ImportGroupManager(); string sqlUpdate = manager.GetUpdateSql(groupEntity, "ImportState"); using (DbOperator dbOperator = new DbOperator(ConnString)) { try { dbOperator.BeginTran(); dbOperator.ExecSql(sqlUpdate); dbOperator.CommintTran(); } catch (Exception ex) { dbOperator.RollbackTran(); throw new FacadeException("启动导入过程发生异常 - ", ex); } } #endregion }
public void FinishImportItem(string groupId, int groupVersion, string itemId, int itemVersion , ImportorEnumerations.ImportItemResult result , string toItemIid, string toItemTitle, string toItemPrice, string toSellerNick, string toShopTitle , int successCount, int failCount, string message, string userId) { ImportGroup groupEntity = new ImportGroup(); groupEntity.Id = groupId; groupEntity.SuccessCount = successCount; groupEntity.FailCount = failCount; groupEntity.LastUpdateDate = DateTime.Now; groupEntity.LastUpdateUserId = userId; groupEntity.CurrentVersion = groupVersion; ImportGroupManager managerGroup = new ImportGroupManager(); string sqlUpdateGroup = managerGroup.GetUpdateSql(groupEntity, "SuccessCount", "FailCount"); ImportItem itemEntity = new ImportItem(); itemEntity.Id = itemId; itemEntity.ImportState = ImportorEnumerations.ImportState.Finished; itemEntity.ImportResult = result; itemEntity.FinishDateTime = DateTime.Now; itemEntity.ImportToItemIid = toItemIid; itemEntity.ImportToItemTitle = toItemTitle; itemEntity.ImportToItemPrice = toItemPrice; itemEntity.ImportToSellerNick = toSellerNick; itemEntity.ImportToShopTitle = toShopTitle; itemEntity.ResultMessage = message; itemEntity.LastUpdateDate = DateTime.Now; itemEntity.LastUpdateUserId = userId; itemEntity.CurrentVersion = itemVersion; ImportItemManager managerItem = new ImportItemManager(); string sqlUpdateItem = managerItem.GetUpdateSql(itemEntity , "ImportState" , "ImportResult" , "FinishDateTime" , "ImportToItemIid" , "ImportToItemTitle" , "ImportToItemPrice" , "ImportToSellerNick" , "ImportToShopTitle" , "ResultMessage"); #region 执行SQL以修改对象 using (DbOperator dbOperator = new DbOperator(ConnString)) { try { dbOperator.BeginTran(); dbOperator.ExecSql(sqlUpdateGroup); dbOperator.ExecSql(sqlUpdateItem); dbOperator.CommintTran(); } catch (Exception ex) { dbOperator.RollbackTran(); throw new FacadeException("结束导入宝贝发生异常 - ", ex); } } #endregion }