public string Details(System.Web.UI.Page page, int nTournamentID) { Common.Web.Page oPage = page as Common.Web.Page; Common.Web.Core oDB = oPage.DBase; string sError = ""; if (nTournamentID > 0) { DataRow oDR = oDB.GetFirstRow(Config.DbGetTournamentDetails, new object[] { "@ID", nTournamentID }); if (oDR != null) { lblName.Text = "Tournament Name: " + oDR["TournamentName"].ToString(); } } return(sError); }
/// <summary> /// Delete specified file from database and file system. /// </summary> public string DeleteFile(Page page, string fileIDs) { if (fileIDs.Length == 0) { return("File is not specified"); } string [] s = fileIDs.Split(','); string sRez = ""; foreach (string sfile in s) { Common.Web.Page oPage = page as Common.Web.Page; Common.Web.Core oDB = oPage.DBase; DataRow oDR = oDB.GetFirstRow(Config.DbGetPushingContentFileDetails, "@ID", Utils.GetInt(sfile)); if ((oDR == null) || (oDR["Name"] == System.DBNull.Value) || (oDR["Name"].ToString() == String.Empty)) { return("File name not found."); } string fileName = oDR["Name"].ToString(); string serverRoot = Config.GetPushingContentPath(ContentID, false); if (!serverRoot.Trim().EndsWith("\\")) { serverRoot += "\\"; } string filePath = serverRoot + fileName; try { //first - delete from DB then delete from file system int iRet = oDB.Execute(Config.DbDeletePushingContentFile, "@IDs", Utils.GetInt(sfile)); if (iRet == 0) { sRez += "File " + fileName + " could not be deleted; "; } else { File.Delete(filePath); } } catch (Exception oEx) { Log.Write(this, "Fail to delete File. Error description: " + oEx.Message); sRez += "Error occured during deleting file " + fileName; } } return(sRez); }
/// <summary> /// Delete specified file from database and file system. /// </summary> public string DeleteFile(Page page, int fileID) { if (fileID <= 0) { return("File is not specified"); } Common.Web.Page oPage = page as Common.Web.Page; Common.Web.Core oDB = oPage.DBase; DataRow oDR = oDB.GetFirstRow(Config.DbGetFileDetails, "@ID", fileID); if ((oDR == null) || (oDR["FileName"] == System.DBNull.Value)) { return("File name not found."); } string fileName = oDR["FileName"].ToString(); string serverRoot = Config.GetAffiliatePath(AffID, false, false); if (!serverRoot.Trim().EndsWith("\\")) { serverRoot += "\\"; } string filePath = serverRoot + fileName; try { //first - delete from DB then delete from file system int iRet = oDB.Execute(Config.DbDeleteFileRelated, "@IDs", fileID); if (iRet == 0) { return("File " + fileName + " could not be deleted"); } else { File.Delete(filePath); } } catch (Exception oEx) { Log.Write(this, "Fail to delete File. Error description: " + oEx.Message); return("Error occured during deleting file " + fileName); } return(""); }
/// <summary> /// Process saved file /// </summary> public string ProcessFile(Page page, string fileName, int fileSize, int Width, int Height, int contentType, ref int fileID) { string uploadUrl = Config.GetPushingContentPath(ContentID, true); if (!uploadUrl.Trim().EndsWith("/")) { uploadUrl += "/"; } string serverRoot = Config.GetPushingContentPath(ContentID, false); if (!serverRoot.Trim().EndsWith("\\")) { serverRoot += "\\"; } Common.Web.Page oPage = page as Common.Web.Page; Common.Web.Core oDB = oPage.DBase; string oldFile = ""; int Version = -1; if (fileID >= 0) { DataRow oDR = oDB.GetFirstRow(Config.DbGetPushingContentFileDetails, "@ID", fileID); if ((oDR != null) && (oDR["Name"] != System.DBNull.Value) && (oDR["Name"].ToString() != String.Empty)) { oldFile = oDR["Name"].ToString(); } if (fileName == String.Empty) { fileName = oldFile; uploadUrl = oDR["URL"].ToString(); fileSize = Utils.GetInt(oDR["FileSize"]); Version = Utils.GetInt(oDR["Version"]); } } //1. Update DB int NewfileID = oDB.ExecuteReturnInt(Config.DbSavePushingContentFile, "@ID", fileID, "@Name", fileName, "@URL", uploadUrl, "@PushingContentID", ContentID, "@FileSize", fileSize, "@Width", Width, "@Height", Height, "@Version", Version, "@ContentTypeID", contentType); if (NewfileID <= 0) { try { if (File.Exists(serverRoot + fileName)) { File.Delete(serverRoot + fileName); } }catch (Exception oEx) { Log.Write(this, "Fail to delete file. Error description: " + oEx.Message); } return("Database error occured during saving file " + fileName + ". "); } if (oldFile != fileName) { if (File.Exists(serverRoot + oldFile)) { File.Delete(serverRoot + oldFile); } } return(""); }