public static FunctionResult UpdateSettings(VideoPlayerSettings settings, UserInfo userInfo, string database, string table, string connectionString) { #region Preparation SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader(); FunctionResult result = new FunctionResult(); #endregion Preparation #region SQL statement string SQLCommand = string.Empty; SQLCommand = "USE " + database + ";"; SQLCommand += "UPDATE " + table + " SET "; SQLCommand += "VideoHeight=" + (int)settings.resolution + ", "; SQLCommand += "FrameRate=" + (int)settings.frameRate + ", "; SQLCommand += "BufferMode=" + (int)settings.bufferMode + ", "; SQLCommand += "PreloadFrames=" + (int)settings.preloadFrames + " WHERE "; SQLCommand += "UserID=" + userInfo.UserID + ";"; #endregion SQL statement if (!Peralatan.UbahDataDatabase(SQLCommand, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString)) { result.functionResult = Result.Fail; result.functionErrroInformation.errorMessage = Peralatan.PesanKesalahan; } else { result.functionResult = Result.Success; } return(result); }
/// <summary> /// Update specific column of a table /// </summary> /// <param name="database">Database of the item</param> /// <param name="table">Table of the item</param> /// <param name="target">Column (Key) and value (value) of target</param> /// <param name="reference">(Column (Key) and value (value) used as reference</param> /// <param name="connectionString">Connection string to connect to database</param> /// <returns>Bool</returns> public static bool UpdateSettings(string database, string table, string targetColumn, string targetValue, string referenceColumn, string referenceValue, string connectionString) { string SQLCommand = string.Empty; SQLCommand = "USE " + database + ";"; SQLCommand += "UPDATE " + table + " SET " + targetColumn + "=" + targetValue + " WHERE " + referenceColumn + "=" + referenceValue + ";"; return(Peralatan.UbahDataDatabase(SQLCommand, connectionString)); }
public static bool AddUser(string database, string userTable, string sessionID, string connectionString) { string SQLCommand = string.Empty; SQLCommand += "USE " + database + ";"; SQLCommand += "INSERT INTO " + userTable + " (SessionID) VALUES ('" + sessionID + "');"; bool result = Peralatan.TambahKeDatabase(SQLCommand, connectionString); if (!result) { throw new Exception(Peralatan.PesanKesalahan); } return(result); }
public static bool WriteLog(string sessionID, VideoPlayerSettings userSettings, string connectionString) { #region Preparation // SettingsInformation string ID = string.Empty; string userSettingsID = string.Empty; string SQLCommand = string.Empty; #endregion Preparation return(Peralatan.TambahKeDatabase(SQLCommand, connectionString)); }
public static UserInformation GetUserID(string SessionID) { ApplicationConfiguration applicationConfiguration = new ApplicationConfiguration(); string connectionString = ConfigurationManager.AppSettings["DatabaseConnectionString"]; UserInformation userInfo = new UserInformation(); string receivedValue = Peralatan.MintaDataDatabase("MediaPlayerDatabase", "UserID", "SessionInfo", "SessionID", SessionID, connectionString); userInfo.UserID = Convert.ToInt32(receivedValue); userInfo.UserSessionID = SessionID; #region Old worker //MintaDataDatabase mintaDataDatabase = new MintaDataDatabase("UserID", "SessionInfo", "SessionID", SessionID, connectionString); //userInfo.UserID = Convert.ToInt32(mintaDataDatabase.DataDiterima); //userInfo.UserSessionID = SessionID; #endregion Old worker return(userInfo); }
public static bool CreateNewSettings(string database, string table, UserInfo userInfo, string connectionString) { VideoPlayerSettings playerSettings = new VideoPlayerSettings(); playerSettings.bufferMode = BufferMode.SingleBuffer; playerSettings.frameRate = FrameRate._24fps; playerSettings.resolution = Resolution.SD_480p; playerSettings.preloadFrames = PreloadFrames.EnablePreload; string userID = userInfo.UserID.ToString(); string SQLCommand = string.Empty; SQLCommand += "USE " + database + ";"; SQLCommand += "INSERT INTO " + table + " (UserID, VideoWidth, VideoHeight, FrameRate, BufferMode, PreloadFrames) VALUES ("; SQLCommand += userID + ", 0, " + (int)playerSettings.resolution + ", " + (float)playerSettings.frameRate + ", " + (int)playerSettings.bufferMode + ", " + (int)playerSettings.preloadFrames + ");"; return(Peralatan.TambahKeDatabase(SQLCommand, connectionString)); }
public static Result WriteVideoActualEndFrame(UserInformation userInfo, ProcessedVideoInformation processedVideoInfo, string processID) { #region Preparation Result result = new Result(); string sourceFileName = Path.GetFileNameWithoutExtension(processedVideoInfo.source.Replace("\"", string.Empty)); string targetFolderName = processedVideoInfo.target.Replace("\"", string.Empty); #endregion Preapration #region Path recreation //if (processedVideoInfo.target.EndsWith("\\")) //{ // targetFolderName += processedVideoInfo.target.Replace("\"", string.Empty) + sourceFileName; //} //else //{ // targetFolderName += processedVideoInfo.target.Replace("\"", string.Empty) + "\\" + sourceFileName; //} #endregion Path recreation int totalFile = Directory.GetFiles(targetFolderName, "*.jpg").Length; #region Updater string SQLCommand = "USE MediaPlayerDatabase;"; SQLCommand += "UPDATE ProcessedVideoInfo SET VideoActualEndFrame=" + totalFile.ToString() + " WHERE ProcessID=" + processID + ";"; if (Peralatan.UbahDataDatabase(SQLCommand, ConfigurationManager.AppSettings["DatabaseConnectionString"])) { result.result = FunctionStatus.Success; } else { result.result = FunctionStatus.Fail; result.HasError = true; result.ErrorMessage = Peralatan.PesanKesalahan; } #endregion Updater return(result); }
public static Result VideoStatusUpdater(UserInformation userInfo, ProcessedVideoInformation videoInfo, string processID, VideoProcessStatus status) { Result result = new Result(); string connectionString = ConfigurationManager.AppSettings["DatabaseConnectionString"]; byte[] videoSourceInBytes = Encoding.UTF8.GetBytes(videoInfo.source); string SQLCommand = "USE MediaPlayerDatabase;"; SQLCommand += "UPDATE ProcessedVideoInfo SET VideoStatus=" + ((int)status).ToString(); SQLCommand += " WHERE UserID=" + userInfo.UserID + " AND ProcessID= " + processID + ";"; if (Peralatan.UbahDataDatabase(SQLCommand, connectionString)) { result.result = FunctionStatus.Success; } else { result.result = FunctionStatus.Fail; result.ErrorMessage = Peralatan.PesanKesalahan; } return(result); }
public static void WriteLogToDatabase(LogInformation information) { DatabaseConfiguration configuration = LoadDatabaseConfiguration(); string SQLCommand = "USE " + configuration.databaseName + ";"; SQLCommand += "INSERT INTO " + configuration.tableName + " ("; SQLCommand += "UserID, " + "RequestTime, " + "ProcessedVideoLocation, " + "IsDeleteWhenCompleteRequested, " + "IsOriginalFileDeleted, " + "TotalProcessingDuration, " + "AudioProcessingDuration, " + "VideoProcessingDuration, " + "OriginalVideoWidth, " + "OriginalVideoHeight, " + "OriginalFrameRate, " + "FPSRequest, " + "Scaled, " + "ScaledVideoWidth, " + "ScaledVideoHeight, " + "WithAudio, " + "VideoStartFrame, " + "VideoEndFrame, " + "VideoDuration, " + "VideoStatus, " + "ErrorCode, " + "ErrorMessage, " + "ProgramArguments, " + "FFmpegLocation, " + "FFProbeLocation, " + " VALUES " + information.userID + ", " + information.requestTime + ", " + //information.finishedTime + ", " + information.processedVideoLocation + ", "; if (information.isDeleteWhenCompleteRequested) { SQLCommand += "1, "; } else { SQLCommand += "0, "; } SQLCommand += information.isOriginalFileDeleted + ", " + information.originalVideoWidth + ", " + information.originalVideoHeight + ", " + information.originalFrameRate + ", " + information.scaled + ", " + information.withAudio + ", " + information.scaledVideoWidth + ", " + information.scaledVideoHeight + ", " + information.totalProcessingDuration.TotalSeconds + ", " + information.videoStartFrame + ", " + information.videoEndFrame + ", " + information.videoDuration + ", " + information.status + ", 0, " + information.errorMessage + ", " + information.programArguments + ", " + information.FFmpegLocation + ", " + information.FFProbeLocation + ";"; Peralatan.TambahKeDatabase(SQLCommand, configuration.databaseConnectionString); throw new NotImplementedException("Function is not completed yet"); }
public static LogInformation GenerateLog(ProcessedVideoInformation videoInfo, VideoInformation processedVideoInformation, ProcessingInformation processingInfo, UserInformation userInfo, Requester requester) { #region Preparation DatabaseConfiguration configuration = LoadDatabaseConfiguration(); LogInformation logInformation = new LogInformation(); FFmpegConfiguration applicationConfiguration = LoadApplicationConfiguration(); #endregion Preparation #region FFmpeg's log if (applicationConfiguration.useCustomFFmpeg) { logInformation.FFmpegLocation = applicationConfiguration.FFmpegLocation; } else { logInformation.FFmpegLocation = string.Empty; } #endregion FFmpeg's log #region FFProbe's log if (applicationConfiguration.useCustomFFProbe) { logInformation.FFProbeLocation = applicationConfiguration.FFProbeLocation; } else { logInformation.FFProbeLocation = string.Empty; } #endregion FFProbe's log #region Request time logInformation.requestTime = processingInfo.processingStartTime; logInformation.finishedTime = processingInfo.processingEndTime; #endregion Request time #region UserID string userID = string.Empty; if (Peralatan.PeriksaDataDatabase(userInfo.UserSessionID, "SessionID", configuration.databaseName, configuration.userTableName, configuration.databaseConnectionString)) { userID = Peralatan.MintaDataDatabase(configuration.databaseName, "UserID", configuration.userTableName, "SessionID", userInfo.UserSessionID, configuration.databaseConnectionString); } logInformation.userID = userID; #endregion UserID #region Processed video location logInformation.processedVideoLocation = videoInfo.target; #endregion Processed video location #region Delete original file logInformation.isDeleteWhenCompleteRequested = videoInfo.deleteOriginal; #endregion Delete original file #region Processing duration logInformation.totalProcessingDuration = processingInfo.totalVideoDuration; logInformation.audioProcessingDuration = processingInfo.processedAudioDuration; logInformation.videoProcessingDuration = processingInfo.processedVideoDuration; #endregion Processing duration #region Video information logInformation.originalVideoWidth = processedVideoInformation.videoHeight; logInformation.originalVideoHeight = processedVideoInformation.videoHeight; logInformation.videoDuration = processedVideoInformation.videoDuration; logInformation.scaledVideoWidth = videoInfo.width; logInformation.scaledVideoHeight = videoInfo.height; #endregion Video information return(logInformation); }
public static DatabaseProcessedInfo SetVideoInfo(VideoPlayerSettings settings, UserInfo userInfo, ProcessedVideo processedVideo) { #region Preparation DatabaseProcessedInfo result = new DatabaseProcessedInfo(); string SQLCommand = string.Empty; string connectionString = string.Empty; string UserID = string.Empty; string OriginalVideoURL = string.Empty; string OriginalTemporaryVideoLocation = string.Empty; string LocalProcessedVideoLocation = string.Empty; string NetworkProcessedVideoLocation = string.Empty; string OriginalVideoWidth = string.Empty; string OriginalVideoHeight = string.Empty; string VideoDuration = string.Empty; string VideoFrameRate = string.Empty; string VideoCalculatedEndFrame = string.Empty; string VideoActualEndFrame = string.Empty; string VideoTotalFrames = string.Empty; string Scaled = string.Empty; string ScaledWidth = string.Empty; string ScaledHeight = string.Empty; string WithAudio = string.Empty; string DateProcessed = string.Empty; string DateLastAccess = string.Empty; string VideoStatus = string.Empty; string LogID = string.Empty; #endregion Preparation // Info prefetch UserID = userInfo.UserID.ToString(); #region Data modification byte[] originalURLinBytes = Encoding.UTF8.GetBytes(processedVideo.videoSource); OriginalVideoURL = Convert.ToBase64String(originalURLinBytes); byte[] localFileinBytes = Encoding.UTF8.GetBytes(processedVideo.localAccessLocation); LocalProcessedVideoLocation = Convert.ToBase64String(localFileinBytes); byte[] networkFileinBytes = Encoding.UTF8.GetBytes(processedVideo.networkAccessLocation); NetworkProcessedVideoLocation = Convert.ToBase64String(networkFileinBytes); #endregion Data modification // Video info data SQLCommand = "USE MediaPlayerDatabase;"; SQLCommand += "INSERT INTO ProcessedVideoInfo ("; // Table column SQLCommand += "UserID, "; SQLCommand += "OriginalVideoURL, "; //SQLCommand += "OriginalTemporaryVideoFolder, "; SQLCommand += "LocalProcessedVideoFolder, "; SQLCommand += "NetworkProcessedVideoFolder, "; SQLCommand += "OriginalVideoWidth, "; SQLCommand += "OriginalVideoHeight, "; SQLCommand += "VideoDuration, "; SQLCommand += "VideoFrameRate, "; SQLCommand += "VideoCalculatedEndFrame, "; SQLCommand += "VideoActualEndFrame, "; //SQLCommand += "VideoTotalFrames, "; SQLCommand += "Scaled, "; SQLCommand += "ScaledWidth, "; SQLCommand += "ScaledHeight, "; SQLCommand += "WithAudio, "; //SQLCommand += "DateProcessed, "; //SQLCommand += "DateLastAccess, "; SQLCommand += "VideoStatus"; //SQLCommand += "LogID"; // End table column // Table value SQLCommand += ") VALUES ("; SQLCommand += UserID + ", "; SQLCommand += "'" + OriginalVideoURL + "', "; SQLCommand += "'" + LocalProcessedVideoLocation + "', "; SQLCommand += "'" + NetworkProcessedVideoLocation + "', "; SQLCommand += processedVideo.videoWidth + ", "; SQLCommand += processedVideo.videoHeight + ", "; SQLCommand += "'" + processedVideo.videoDuration + "', "; SQLCommand += "'" + processedVideo.frameRate + "', "; SQLCommand += processedVideo.endFrame + ", "; //SQLCommand += "0, "; SQLCommand += "0, "; if (settings.resolution == Resolution.Original) { SQLCommand += "FALSE, "; } else { SQLCommand += "1, "; SQLCommand += "0, "; SQLCommand += ((int)settings.resolution).ToString() + ", "; } SQLCommand += "1, "; SQLCommand += "1);"; if (Peralatan.TambahKeDatabase(SQLCommand, connectionString)) { result.videoStatus = ProcessedStatus.Processed; result.HasMessage = false; } else { result.HasMessage = true; result.Message = Peralatan.PesanKesalahan; } return(result); }
public static bool CheckSettings(string database, UserInfo userInfo, string settingsTable, string connectionString) { string userID = userInfo.UserID.ToString(); return(Peralatan.PeriksaDataDatabase(userID, "UserID", database, settingsTable, connectionString)); }
public static VideoPlayerSettings ReadPlayerSettings(string sessionID, string database, string table, string connectionString) { VideoPlayerSettings UserSettings = new VideoPlayerSettings(); string userID = Peralatan.MintaDataDatabase(database, "UserID", "SessionInfo", "SessionID", sessionID, connectionString); #region Video string receivedHeight = Peralatan.MintaDataDatabase(database, "VideoHeight", table, "UserID", userID, connectionString); if (receivedHeight == ((int)Resolution.Original).ToString()) { UserSettings.resolution = Resolution.Original; } else if (receivedHeight == ((int)Resolution.SD_360p).ToString()) { UserSettings.resolution = Resolution.SD_360p; } else if (receivedHeight == ((int)Resolution.SD_480p).ToString()) { UserSettings.resolution = Resolution.SD_480p; } else if (receivedHeight == ((int)Resolution.HD_720p).ToString()) { UserSettings.resolution = Resolution.HD_720p; } else if (receivedHeight == ((int)Resolution.HD_1080p).ToString()) { UserSettings.resolution = Resolution.HD_1080p; } else if (receivedHeight == ((int)Resolution.SUHD_1440p).ToString()) { UserSettings.resolution = Resolution.SUHD_1440p; } else { UserSettings.resolution = Resolution.SD_480p; } #endregion Video resolution #region Video framerate string receivedFrameRate = Peralatan.MintaDataDatabase(database, "FrameRate", table, "UserID", userID, connectionString); if (receivedFrameRate == ((int)FrameRate.Default).ToString()) { UserSettings.frameRate = FrameRate.Default; } else if (receivedFrameRate == ((int)FrameRate._24fps).ToString()) { UserSettings.frameRate = FrameRate._24fps; } else if (receivedFrameRate == ((int)FrameRate._30fps).ToString()) { UserSettings.frameRate = FrameRate._30fps; } else if (receivedFrameRate == ((int)FrameRate._60fps).ToString()) { UserSettings.frameRate = FrameRate._60fps; } else if (receivedFrameRate == ((int)FrameRate._120fps).ToString()) { UserSettings.frameRate = FrameRate._120fps; } else { UserSettings.frameRate = FrameRate.Default; } #endregion Video framerate #region Video buffer mode string receivedBufferMode = Peralatan.MintaDataDatabase(database, "BufferMode", table, "UserID", userID, connectionString); if (receivedBufferMode == ((int)BufferMode.SingleBuffer).ToString()) { UserSettings.bufferMode = BufferMode.SingleBuffer; } else if (receivedBufferMode == ((int)BufferMode.DoubleBuffer).ToString()) { UserSettings.bufferMode = BufferMode.DoubleBuffer; } else if (receivedBufferMode == ((int)BufferMode.TripleBuffer).ToString()) { UserSettings.bufferMode = BufferMode.TripleBuffer; } else { UserSettings.bufferMode = BufferMode.SingleBuffer; } #endregion Video buffer mode #region Video preload frames string receivedPreload = Peralatan.MintaDataDatabase(database, "PreloadFrames", table, "UserID", userID, connectionString); if (receivedPreload == ((int)PreloadFrames.DisablePreload).ToString()) { UserSettings.preloadFrames = PreloadFrames.DisablePreload; } else if (receivedPreload == ((int)PreloadFrames.EnablePreload).ToString()) { UserSettings.preloadFrames = PreloadFrames.EnablePreload; } else { UserSettings.preloadFrames = PreloadFrames.DisablePreload; } #endregion Video preload frames return(UserSettings); }
public static bool CheckUser(string database, string userTable, string sessionID, string connectionString) { return(Peralatan.PeriksaDataDatabase(sessionID, "SessionID", database, userTable, connectionString)); }