예제 #1
0
        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));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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");
        }
예제 #5
0
        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);
        }