private void GalleryCreateParamAdd(ref DbCommand cmd, GalleryCreateRequest request) { DbParameter param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@CategoryId"; param.DbType = DbType.Int32; param.Value = request.CategoryId; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@FileServerId"; param.DbType = DbType.Int32; param.Value = request.FileServerId; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@GalleryName"; param.DbType = DbType.String; param.Value = request.GalleryName; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@ConverRelativeFilePath"; param.DbType = DbType.String; param.Value = request.ConverRelativeFilePath; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@BundlingRelativeFilePath"; param.DbType = DbType.String; param.Value = request.BundlingRelativeFilePath; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@PageCount"; param.DbType = DbType.Int32; param.Value = request.PageCount; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@Introudce"; param.DbType = DbType.String; param.Value = request.Introudce; cmd.Parameters.Add(param); if(!request.IsExistVideo) { request.VideoRelativeFilePath = string.Empty; } param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@VideoRelativeFilePath"; param.DbType = DbType.String; param.Value = request.VideoRelativeFilePath; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@Designer"; param.DbType = DbType.String; param.Value = request.Designer; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@Address"; param.DbType = DbType.String; param.Value = request.Address; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@GalleryId"; param.DbType = DbType.Int32; param.Direction = ParameterDirection.Output; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@Result"; param.DbType = DbType.String; param.Size = 200; param.Direction = ParameterDirection.Output; cmd.Parameters.Add(param); }
private CommonResponse GalleryCreate(FolderInfo uploadFolderInfo) { string[] paths = uploadFolderInfo.LocalPath.Split(new char[] { '\\' }); string localDirectory = paths[paths.Length - 1]; GalleryCreateRequest request = new GalleryCreateRequest(); request.Token = ClientConfig.Token; request.Account = ClientConfig.Account; request.PassWord = ClientConfig.PassWord; request.CategoryId = uploadFolderInfo.CategoryId; request.FileServerId = _fileServerInfo.Id; request.GalleryName = uploadFolderInfo.GalleryName; request.ConverRelativeFilePath = "/Small" + uploadFolderInfo.LevelPath.Replace("|", "/") + "/" + localDirectory + "/Cover.jpg"; request.BundlingRelativeFilePath = "/Big" + uploadFolderInfo.LevelPath.Replace("|", "/") + "/" + localDirectory + "/Package.zip"; request.PageCount = uploadFolderInfo.PageCount; request.Introudce = uploadFolderInfo.Introudce; request.VideoRelativeFilePath = "/Big" + uploadFolderInfo.LevelPath.Replace("|", "/") + "/" + localDirectory + "/Video.rar"; request.Designer = uploadFolderInfo.Designer; request.Address = uploadFolderInfo.Address; request.OriginalAbsoluteFileDirectory = _fileServerInfo.OriginalFileServerRootDirectory + uploadFolderInfo.LevelPath.Replace("|", "\\\\") + "\\\\" + localDirectory; request.ThumbAbsoluteFileDirectory = _fileServerInfo.ThumbFileServerRootDirectory + uploadFolderInfo.LevelPath.Replace("|", "\\\\") + "\\\\" + localDirectory; request.StoreTableName = uploadFolderInfo.StoreTableName; string checkFile = Path.Combine(uploadFolderInfo.LocalPath, "video.rar"); request.IsExistVideo = File.Exists(checkFile); CommonResponse response = _proxy.GalleryCreate(request); return response; }
public CommonResponse GalleryCreate(GalleryCreateRequest request) { CommonResponse response = new CommonResponse(); response.IsSuccessful = false; try { bool isPermission = Authentication(request.Token, request.FileServerId, request.Account, request.PassWord); if (!isPermission) { response.IsSuccessful = false; response.ResultMessage = "您没有访问该文件服务器接口的权限!"; return response; } Directory.CreateDirectory(request.OriginalAbsoluteFileDirectory); Directory.CreateDirectory(request.ThumbAbsoluteFileDirectory); DbCommand cmd = _dataBaseAccess.CreateCommand(); GalleryCreateParamAdd(ref cmd, request); switch (request.StoreTableName) { case "Album_Brand": //品牌画册 { cmd.CommandText = "Proc_Album_Brand_InsertOrUpdate"; break; } case "Album_Magazine": //服装杂志 { cmd.CommandText = "Proc_Album_Magazine_InsertOrUpdate"; break; } case "Album_Book": //款式书籍 { cmd.CommandText = "Proc_Album_Book_InsertOrUpdate"; break; } case "Album_Confer": //发布会 { cmd.CommandText = "Proc_Album_Confer_InsertOrUpdate"; break; } default: { response.IsSuccessful = false; response.ResultMessage = string.Format("业务逻辑无法识别该表:{0}", request.StoreTableName); return response; } } _dataBaseAccess.ExecuteCommand(cmd); string galleryId = cmd.Parameters["@GalleryId"].Value.ToString(); string result = cmd.Parameters["@Result"].Value.ToString(); response.IsSuccessful = string.IsNullOrEmpty(result); response.ResultMessage = response.IsSuccessful ? galleryId : result; } catch (Exception ex) { response.IsSuccessful = false; response.ResultMessage = ex.ToString(); Tools.LogWrite(ex.ToString()); } return response; }