コード例 #1
0
 protected bool UserLoader()
 {
     if (!HelperClass.CheckUser(database, sessionInfoTable, Session.SessionID, connectionString))
     {
         HelperClass.AddUser(database, sessionInfoTable, Session.SessionID, connectionString);
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CSSLoader();
            //savedSettings = HelperClass.ReadPlayerSettings(Session.SessionID, settingsDatabase, settingsTable, connectionString);

            #region Preparation

            #region System setting loading
            SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader();
            #endregion System setting loading

            #region User info loading
            UserInfo userInfo = new UserInfo {
                SessionID = Session.SessionID
            };

            // Try reading user information
            try
            {
                if (HelperClass.CheckUser("MediaPlayerDatabase", "SessionInfo", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                {
                    // Load user info
                    SQLClassPeralatan.MintaDataDatabase mintaDataDatabase = new SQLClassPeralatan.MintaDataDatabase("UserID", "SessionInfo", "SessionID", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString);
                    userInfo.UserID = Convert.ToInt32(mintaDataDatabase.DataDiterima);
                }
                else
                {
                    // Add user info
                    if (HelperClass.AddUser("MediaPlayerDatabase", "SessionInfo", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                    {
                        // Read user id
                        SQLClassPeralatan.MintaDataDatabase mintaDataDatabase = new SQLClassPeralatan.MintaDataDatabase("UserID", "SessionInfo", "SessionID", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString);
                        if (!mintaDataDatabase.TerdapatKesalahan)
                        {
                            userInfo.UserID = Convert.ToInt32(mintaDataDatabase.DataDiterima);
                        }
                        else
                        {
                            Response.Redirect("Error.aspx?id=21");
                        }
                    }
                    else
                    {
                        Response.Redirect("Error.aspx?id=23");
                    }
                }
            }
            catch (Exception err)
            {
                Response.Redirect("Error.aspx?id=21&message=" + err.Message);
            }
            #endregion User info loading

            #region User player configuration loading
            VideoPlayerSettings userPlayerSetting = new VideoPlayerSettings();

            try
            {
                if (!IsPostBack)
                {
                    // Check user player configuration
                    if (HelperClass.CheckSettings("MediaPlayerDatabase", userInfo, "UserSettings", systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                    {
                        userPlayerSetting = HelperClass.ReadPlayerSettings(userInfo.SessionID, "MediaPlayerDatabase", "UserSettings", systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString);
                    }
                    else
                    {
                        if (HelperClass.CreateNewSettings("MediaPlayerDatabase", "UserSettings", userInfo, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                        {
                            userPlayerSetting = HelperClass.ReadPlayerSettings(userInfo.SessionID, "MediaPlayerDatabase", "UserSettings", systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString);
                        }
                        else
                        {
                            Response.Redirect("Error.aspx?id=24&message=Maybe a server problem");
                        }
                    }
                }
            }
            catch (Exception err)
            {
                Response.Redirect("Error.aspx?id=24&message=" + err.Message);
            }
            #endregion User player configuration loading

            #endregion Preparation

            if (!IsPostBack)
            {
                lstVideoResolution.SelectedValue = ((int)userPlayerSetting.resolution).ToString();
                lstFrameRate.SelectedValue       = ((int)userPlayerSetting.frameRate).ToString();
                lstFrameBufferMode.SelectedValue = ((int)userPlayerSetting.bufferMode).ToString();
                lstFramePreload.SelectedValue    = ((int)userPlayerSetting.preloadFrames).ToString();
                lstPlayMode.SelectedIndex        = 0;
            }
        }
コード例 #3
0
        protected void btnUploadVideo_Click(object sender, EventArgs e)
        {
            #region Preparation

            #region Initialization

            #region Database configuration
            string databaseName  = "MediaPlayerDatabase";
            string userTableName = "SessionInfo";
            string settingsTable = "UserSettings";
            #endregion Database configuration

            #region Processor initialization
            Processor mainProcessor = new Processor();
            #endregion Processor initialization

            #region User information
            UserInfo userInfo = new UserInfo();
            #endregion User information

            #region Video processing information
            string                     videoName = string.Empty;
            string                     videoNameWithoutExtension  = string.Empty;
            ProcessedVideo             processedVideo             = new ProcessedVideo();
            VideoProcessingInformation videoProcessingInformation = new VideoProcessingInformation();
            #endregion Video processing information

            #endregion Initialization

            #region System configuration loader
            SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader();
            #endregion System configuration loader

            #region User information loader
            // Check for user information in database
            if (HelperClass.CheckUser(databaseName, userTableName, Session.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
            {
                userInfo.SessionID = Session.SessionID;
                try
                {
                    userInfo.UserID = HelperClass.ReadUserInfo(Session.SessionID).UserID;
                }
                catch (Exception err)
                {
                    Response.Redirect("Error.aspx?id=22&message=" + err.Message);
                }
            }
            else
            {
                userInfo.SessionID = Session.SessionID;
                if (!HelperClass.AddUser(databaseName, userTableName, userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                {
                    Response.Redirect("Error.aspx?id=23");
                }

                try
                {
                    userInfo.UserID = HelperClass.ReadUserInfo(Session.SessionID).UserID;
                }
                catch (Exception err)
                {
                    Response.Redirect("Error.aspx?id=22&message=" + err.Message);
                }
            }
            #endregion User information loader

            #region Player settings loader
            VideoPlayerSettings settings = new VideoPlayerSettings();

            if (HelperClass.CheckSettings(databaseName, userInfo, settingsTable, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
            {
                settings = HelperClass.ReadPlayerSettings(Session.SessionID, database, settingsTable, connectionString);
            }
            else
            {
                if (HelperClass.CreateNewSettings(databaseName, settingsTable, userInfo, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                {
                    settings = HelperClass.ReadPlayerSettings(Session.SessionID, database, settingsTable, connectionString);
                }
            }
            #endregion Player settings loader

            #region Video information preparation
            //processedVideo.videoName =  HttpUtility.UrlEncode(HelperClass.StringEncoderDecoder(Path.GetFileNameWithoutExtension(uplVideo.FileName), StringConversionMode.Encode));
            processedVideo.videoName = HttpUtility.UrlEncode(HelperClass.StringEncoderDecoder(Path.GetFileName(uplVideo.FileName), StringConversionMode.Encode));
            //processedVideo.processedVideoName = Convert.ToBase64String(Encoding.UTF8.GetBytes(processedVideo.videoName));
            #endregion Video information preparation

            #endregion Preparation

            #region File saving configuration

            //string saveLocation = string.Empty;

            bool requestDeleteFileAfterComplete = false;

            #region Temporary download location
            if (videoSaveLocation.EndsWith("\\"))
            {
                processedVideo.localAccessLocation = videoSaveLocation + Session.SessionID;
            }
            else
            {
                processedVideo.localAccessLocation = videoSaveLocation + "\\" + Session.SessionID;
            }

            // Path checking
            if (!Directory.Exists(processedVideo.localAccessLocation))
            {
                Directory.CreateDirectory(processedVideo.localAccessLocation);
            }

            if (processedVideo.localAccessLocation.EndsWith("\\"))
            {
                //processedVideo.localAccessLocation += processedVideo.processedVideoName + Path.GetExtension(uplVideo.FileName);
                processedVideo.localAccessLocation += Convert.ToBase64String(Encoding.UTF8.GetBytes(processedVideo.videoName)) + Path.GetExtension(uplVideo.FileName);
            }
            else
            {
                processedVideo.localAccessLocation += "\\" + Convert.ToBase64String(Encoding.UTF8.GetBytes(processedVideo.videoName)) + Path.GetExtension(uplVideo.FileName);;
            }
            #endregion Temporary download location


            #endregion File saving configuration

            #region Received info configuration
            string networkAccessLocation = string.Empty;
            //string videoName = string.Empty;
            string videoDuration = string.Empty;
            string frameRate     = string.Empty;
            string startFrame    = string.Empty;
            string endFrame      = string.Empty;
            string videoWidth    = string.Empty;
            string videoHeight   = string.Empty;

            #endregion Received info configuration

            #region Video saving
            uplVideo.SaveAs(processedVideo.localAccessLocation);

            //try
            //{
            //}
            //catch (Exception err)
            //{
            //    Response.Redirect("Error.aspx?id=202&message=" + err.Message);
            //    return;
            //}
            #endregion Video saving

            #region Information generation
            videoProcessingInformation.VideoLocations.VideoLocation            = processedVideo.localAccessLocation;
            videoProcessingInformation.VideoLocations.videoSaveLocation        = systemConfiguration.ProcessedVideoSaveLocation;
            videoProcessingInformation.VideoLocations.videoNetworkSaveLocation = systemConfiguration.NetworkProcessedVideoSaveLocation;
            videoProcessingInformation.VideoSetting.processedVideoResolution   = settings.resolution;
            videoProcessingInformation.VideoSetting.frameRate       = settings.frameRate;
            videoProcessingInformation.VideoSetting.audioProcessing = AudioProcessing.ProcessAudio;

            #endregion Information generation

            #region Video processing

            ProcessedVideo processedVideo2 = mainProcessor.ProcessVideo(videoProcessingInformation, systemConfiguration, userInfo, true);

            //VideoProcessingService.Service1Client client = new VideoProcessingService.Service1Client();
            //string[] receivedInfo = client.ProcessVideo2(saveLocation, true, Session.SessionID, true, 854, 480, 30);
            #endregion Video processing

            #region Result combination
            string temporaryData = processedVideo.videoName;
            processedVideo           = processedVideo2;
            processedVideo.videoName = temporaryData;
            #endregion Result combination

            #region Query string preparation
            string queryString = string.Empty;

            if (processedVideo.result == Result.Success)
            {
                queryString += "?new=true&";
                queryString += "mode=upload&";
                queryString += "path=" + processedVideo.networkAccessLocation + "&";
                queryString += "name=" + processedVideo.videoName + "&";
                queryString += "duration=" + processedVideo.videoDuration + "&";
                queryString += "framerate=" + processedVideo.frameRate + "&";
                queryString += "startframe=" + processedVideo.startFrame + "&";
                queryString += "endframe=" + processedVideo.endFrame + "&";
                queryString += "videoresolution=" + processedVideo.videoHeight + "&";
                queryString += "pid=" + processedVideo.processID;
                if (Convert.ToInt32(lstPlayingSpeed.SelectedValue) > 0)
                {
                    queryString += "&playspeed=" + lstPlayingSpeed.SelectedValue;
                }
                if (txtCustomPlayTime.Text != string.Empty)
                {
                    queryString += "&timeposition=" + txtCustomPlayTime.Text;
                }


                Response.Redirect("Player.aspx" + queryString);
            }
            else
            {
                Response.Redirect("Error.aspx?id=301");
            }

            #endregion Query string preparation

            // Transfer page
            Response.Redirect("Player.aspx" + queryString);
        }
コード例 #4
0
        protected void btnLoadURLVideo_Click(object sender, EventArgs e)
        {
            if (mode == AccessMode.Web || mode == AccessMode.External)
            {
                #region In line commands
                // Used to check for commands (wihtout additional information)
                if (txtURLSource.Text.ToLower() == "help" || txtURLSource.Text.ToLower() == "bantuan")
                {
                    Response.Redirect("Help.aspx");
                }
                else if (txtURLSource.Text.ToLower() == "error")
                {
                    Response.Redirect("Error.aspx?id=100");
                }
                else if (txtURLSource.Text.ToLower() == "setting" || txtURLSource.Text.ToLower() == "settings")
                {
                    Response.Redirect("Settings.aspx");
                }
                else if (txtURLSource.Text.ToLower() == "player")
                {
                    Response.Redirect("Player.aspx");
                }
                else if (txtURLSource.Text.ToLower() == "sample1" || txtURLSource.Text.ToLower() == "sample2" || txtURLSource.Text.ToLower() == "sample3" || txtURLSource.Text.ToLower() == "sample4" || txtURLSource.Text.ToLower() == "sample5")
                {
                    Response.Redirect("Error.aspx?id=2");
                }
                else if (txtURLSource.Text.ToLower() == "checker")
                {
                    Response.Redirect("Checker.aspx?mode=sample");
                }
                #endregion In line commands

                #region Validation
                if (HelperClass.CheckWebsite(txtURLSource.Text))
                {
                    Uri uri = new Uri(txtURLSource.Text);
                    Response.Redirect("Error.aspx?id=902&message=" + uri.Host);
                }
                #endregion Validation

                #region (Old) Main Processing

                //#region Old main processing
                //#region Service initialization
                //VideoProcessingService.Service1Client videoProcessor = new VideoProcessingService.Service1Client();
                //#endregion Service initialization

                //#region Main process
                //string[] receivedVideoInfo = videoProcessor.ProcessVideo2(txtURLSource.Text, true, Session.SessionID, true, 0, (int)settings.resolution, (float)settings.frameRate);
                //#endregion Main process
                //#endregion Old main processing

                //#region Result processor
                //Stopwatch waitTime = new Stopwatch();
                //waitTime.Start();

                //if (receivedVideoInfo.Length == 0)
                //{
                //    System.Threading.Thread.Sleep(1000);
                //    if (waitTime.ElapsedMilliseconds == 20000)
                //    {
                //        waitTime.Stop();
                //        Response.Redirect("Error.aspx");
                //    }
                //}
                //videoProcessor.Close();
                //if (receivedVideoInfo[0].ToLower().Contains("error"))
                //{
                //    Response.Redirect("Error.aspx?id=10a");
                //}
                //else
                //{
                //    string queryString = string.Empty;
                //    queryString += "?new=true&";
                //    queryString += "path=" + receivedVideoInfo[1] + "&";
                //    queryString += "name=" + receivedVideoInfo[2] + "&";
                //    queryString += "duration=" + receivedVideoInfo[3] + "&";
                //    queryString += "framerate=" + receivedVideoInfo[4] + "&";
                //    queryString += "startframe=" + receivedVideoInfo[5] + "&";
                //    queryString += "endframe=" + receivedVideoInfo[6] + "&";
                //    queryString += "videowidth=" + receivedVideoInfo[7];
                //    Response.Redirect("Player.aspx" + queryString);
                //}
                //#endregion Result processor
                #endregion (Old) Main Processing

                #region  New processing
                #region Preparation
                string databaseName  = "MediaPlayerDatabase";
                string userTableName = "SessionInfo";
                string settingsTable = "UserSettings";

                Processor mainProcessor = new Processor();
                UserInfo  userInfo      = new UserInfo();
                VideoProcessingInformation videoProcessingInformation = new VideoProcessingInformation();

                #region System configuration loader
                SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader();
                #endregion System configuration loader

                #region User information loader
                // Check for user information in database
                if (HelperClass.CheckUser(databaseName, userTableName, Session.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                {
                    userInfo.SessionID = Session.SessionID;
                    try
                    {
                        userInfo.UserID = HelperClass.ReadUserInfo(Session.SessionID).UserID;
                    }
                    catch (Exception err)
                    {
                        Response.Redirect("Error.aspx?id=22&message=" + err.Message);
                    }
                }
                else
                {
                    userInfo.SessionID = Session.SessionID;
                    if (!HelperClass.AddUser(databaseName, userTableName, userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                    {
                        Response.Redirect("Error.aspx?id=23");
                    }
                    try
                    {
                        userInfo.UserID = HelperClass.ReadUserInfo(Session.SessionID).UserID;
                    }
                    catch (Exception err)
                    {
                        Response.Redirect("Error.aspx?id=22&message=" + err.Message);
                    }
                }
                #endregion User information loader

                #region Player settings loader
                VideoPlayerSettings settings = new VideoPlayerSettings();
                // Check settings
                if (HelperClass.CheckSettings(databaseName, userInfo, settingsTable, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                {
                    settings = HelperClass.ReadPlayerSettings(Session.SessionID, database, settingsTable, connectionString);
                }
                else
                {
                    if (HelperClass.CreateNewSettings(databaseName, settingsTable, userInfo, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                    {
                        settings = HelperClass.ReadPlayerSettings(Session.SessionID, database, settingsTable, connectionString);
                    }
                }
                #endregion Player settings loader

                #endregion Preparation;

                #region Information generation
                videoProcessingInformation.VideoLocations.VideoLocation            = txtURLSource.Text;
                videoProcessingInformation.VideoLocations.videoSaveLocation        = systemConfiguration.ProcessedVideoSaveLocation;
                videoProcessingInformation.VideoLocations.videoNetworkSaveLocation = systemConfiguration.NetworkProcessedVideoSaveLocation;
                videoProcessingInformation.VideoSetting.processedVideoResolution   = settings.resolution;
                videoProcessingInformation.VideoSetting.frameRate       = settings.frameRate;
                videoProcessingInformation.VideoSetting.audioProcessing = AudioProcessing.ProcessAudio;

                userInfo.SessionID = Session.SessionID;
                #endregion Information generation

                #region Main process
                ProcessedVideo processedVideo = mainProcessor.ProcessVideo(videoProcessingInformation, systemConfiguration, userInfo);
                string         queryString    = string.Empty;
                if (processedVideo.result == Result.Success)
                {
                    queryString += "?new=true&";
                    queryString += "path=" + processedVideo.networkAccessLocation + "&";
                    queryString += "name=" + processedVideo.videoName + "&";
                    queryString += "duration=" + processedVideo.videoDuration + "&";
                    queryString += "framerate=" + processedVideo.frameRate + "&";
                    queryString += "startframe=" + processedVideo.startFrame + "&";
                    queryString += "endframe=" + processedVideo.endFrame + "&";
                    queryString += "videoresolution=" + processedVideo.videoHeight + "&";
                    queryString += "pid=" + processedVideo.processID;
                    if (Convert.ToInt32(lstPlayingSpeed.SelectedValue) > 0)
                    {
                        queryString += "&playspeed=" + lstPlayingSpeed.SelectedValue;
                    }
                    if (txtCustomPlayTime.Text != string.Empty)
                    {
                        queryString += "&timeposition=" + txtCustomPlayTime.Text;
                    }
                    Response.Redirect("Player.aspx" + queryString);
                }
                else
                {
                    Response.Redirect("Error.aspx?id=301&message=" + processedVideo.message);
                }
                #endregion Main process


                #endregion New processing
            }
            else if (mode == AccessMode.Other)
            {
                Server.Transfer("Error.aspx?id=96");
            }
        }