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); }
public string Details(System.Web.UI.Page page, int nGameLogID) { Common.Web.Page oPage = page as Common.Web.Page; Common.Web.Core oDB = oPage.DBase; ApiControl oApi = Config.GetApIEngine(); if (nGameLogID > 0) { lblName.Text = "Game Log #: " + nGameLogID.ToString(); string txtHistory = oApi.GetPersonalHandHistory(nGameLogID, ApiMsg.msgForAction.GETPERSONALHANDHISTORYASTEXT); hdnLogData.Value = txtHistory; } oApi = null; return(""); }
/// <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(""); }
public string GetPageName() { string sPageName = string.Empty; Common.Web.Page oPage = (Page as Common.Web.Page); if (oPage != null) { sPageName = oPage.GetPageInfoName(); } else { InvalidCastException oEx = new InvalidCastException("Inherit your page class from Common.WebControls.Page"); oEx.Source = "PageHeader control"; throw(oEx); } return(sPageName); //return ((Common.WebControls.Page)Page).GetPageInfoName(); }
/// <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(""); }
public Skins(Page page, int _SkinsID) { SkinsID = _SkinsID; Common.Web.Page oPage = page as Common.Web.Page; oDB = oPage.DBase; }
/// <summary> /// Process saved file /// </summary> public string ProcessFile(Page page, int ContentTypeID, string filePath, string fileName, int fileSize, ref int fileID) { int originalFileID = fileID; string fileExtension = Path.GetExtension(filePath).Replace(".", ""); string uploadUrl = Config.GetAffiliatePath(AffID, false, true); if (!uploadUrl.Trim().EndsWith("/")) { uploadUrl += "/"; } string serverRoot = Config.GetAffiliatePath(AffID, false, false); if (!serverRoot.Trim().EndsWith("\\")) { serverRoot += "\\"; } //1. Update DB Common.Web.Page oPage = page as Common.Web.Page; Common.Web.Core oDB = oPage.DBase; SqlCommand oCmd = oDB.GetCommand(Config.DbSaveFile); SqlParameterCollection oParams = oCmd.Parameters; oParams.Add("@fileID", fileID); oParams.Add("@fileName", fileName); oParams.Add("@fileSize", fileSize); oParams.Add("@fileExtension", fileExtension); oParams.Add("@urlRoot", uploadUrl); oParams.Add("@ContentTypeID", ContentTypeID); oParams.Add("@AffID", AffID); SqlParameter oParam = new SqlParameter("@fileNameOld", System.Data.SqlDbType.VarChar, 250); oParam.Direction = ParameterDirection.Output; oParams.Add(oParam); fileID = oDB.ExecuteReturnInt(oCmd); string fileNameOld = oCmd.Parameters["@fileNameOld"].Value.ToString(); if (fileID <= 0) { try { File.Delete(filePath); }catch (Exception oEx) { Log.Write(this, "Fail to delete file. Error description: " + oEx.Message); } if (fileID < 0) { return("File with name " + fileName + " already exists. Please change name of file and try again. "); } else { return("Database error occured during saving file " + fileName + ". "); } } //Everything is ok. We can rename just uploaded file with permanent name //delete old file if (originalFileID > 0) { try { string filePathOld = serverRoot + fileNameOld; File.Delete(filePathOld); } catch (Exception oEx) { oDB.Execute(Config.DbDeleteFile, "@IDs", fileID); Log.Write(this, "Fail to delete old file. Error description: " + oEx.Message); return("Error occured during delete old file " + fileNameOld); } } //rename uploaded file to permanent name try { string filePathNew = serverRoot + fileName; if (File.Exists(filePathNew)) { File.Delete(filePathNew); } File.Move(filePath, filePathNew); } catch (Exception oEx) { oDB.Execute(Config.DbDeleteFile, "@IDs", fileID); Log.Write(this, "Fail to move file. Error description: " + oEx.Message); return("Error occured during moving file " + fileName + ". "); } return(""); }