Beispiel #1
0
        private void UpdateRegInfo(RegInfoFB info)
        {
            string jsonString1 = JsonHelper.ParseObjectToJSON <RegInfoFB>(info);
            string url         = string.Format("registrations-data/{0}-{1}", _clientInfo.SchoolId, _clientInfo.SessionString);

            FirebaseHelper.PatchData(jsonString1, url);
        }
Beispiel #2
0
        private LicenseValidationState ValidateLicenseNew(RegInfoFB firebaseRegistrationInfo, ClientInfo localClientInfo, string localMACAddress, out string errorMessage, out bool deleteVideos, out bool skipLoginScreen)
        {
            errorMessage = ""; deleteVideos = false; skipLoginScreen = false;
            LicenseValidationState licenseState = LicenseValidationState.None;

            // Licese already expired
            if (CommonAppStateDataHelper.ClientInfoObject.Expired)
            {
                deleteVideos = true;
                errorMessage = LicenseHelper.licenseExpiredMessage;
                licenseState = LicenseValidationState.Expired;
            }
            else if (firebaseRegistrationInfo == null && string.IsNullOrEmpty(localClientInfo.MacAddress) == true)
            {
                errorMessage = LicenseHelper.onlineConnectivityIsMust;
                licenseState = LicenseValidationState.ConnectivityRequiredForValidation;
            }
            else if (string.IsNullOrEmpty(localMACAddress) == true)
            {
                errorMessage = LicenseHelper.invalidLicenseMessage;
                licenseState = LicenseValidationState.EmptyMacAddress;
            }
            else
            {
                DateTime sessionEndDate = localClientInfo.SessionEndDate;

                if (firebaseRegistrationInfo != null)
                {
                    sessionEndDate = firebaseRegistrationInfo.ExpiryDate;
                }

                licenseState = LicenseHelper.CheckLicenseStateNew(localClientInfo.RegistrationDate, localClientInfo.SessionStartDate, sessionEndDate, out errorMessage, out deleteVideos);

                // Validate Firebase MacAddress Check
                if (licenseState == LicenseValidationState.Valid)
                {
                    licenseState = LicenseHelper.ValidateMacAddress(firebaseRegistrationInfo, localClientInfo, localMACAddress, out errorMessage, out deleteVideos, out skipLoginScreen);
                }
            }
            return(licenseState);
        }
Beispiel #3
0
        private void frmLogin_Load(object sender, EventArgs e)
        {
            try
            {
                label11.Location = new System.Drawing.Point(panel4.Width / 2 - 150, 11);
                label2.Location  = new System.Drawing.Point(panel4.Width / 2 - 75, 15);


                this.progressBar1.Visible = true;
                this.progressBar1.Enabled = true;
                this.progressBar1.Value   = 10;
                //ClientHelper.GetClientThumbanailPath();

                _clientInfoFilePath = ClientHelper.GetClientInfoFilePath();

                if (!File.Exists(_clientInfoFilePath))
                {
                    MessageBox.Show("Invalid Configuration", "Configuration Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                    return;
                }

                this.progressBar1.Value = 30;

                CommonAppStateDataHelper.ClientInfoObject = Cryptograph.DecryptObject <ClientInfo>(_clientInfoFilePath);
                _clientInfo = CommonAppStateDataHelper.ClientInfoObject;

                this.progressBar1.Value = 70;

                if (_clientInfo != null)
                {
                    lblSessionYears.Text  = ClientHelper.GetSessionString(_clientInfo.SessionString);
                    lblSchoolWelcome.Text = ClientHelper.GetWelcomeString(_clientInfo.SchoolName, _clientInfo.SchoolCity, _clientInfo.SchoolId);
                    lblExpireDate.Text    = ClientHelper.GetExpiryDateString(_clientInfo.SessionEndDate);

                    _currentMacAddress = MacAddressHelper.GetMacAddress();
                    //_currentMacAddress = "B82A72A780B7";
                    _firebaseRegInfo = GetFirebaseRegistrationInformation();

                    string errorMessage    = "";
                    bool   deleteVideos    = false;
                    bool   skipLoginScreen = false;
                    // Check license session duraion
                    LicenseValidationState licenseState = ValidateLicenseNew(_firebaseRegInfo, _clientInfo, _currentMacAddress, out errorMessage, out deleteVideos, out skipLoginScreen);

                    TextFileLogger.Log("License State" + licenseState.ToString());

                    if (licenseState != LicenseValidationState.Valid)
                    {
                        OnAfterLicesseValidation(errorMessage, deleteVideos, licenseState);
                    }

                    _showLoginForm = !skipLoginScreen;

                    this.progressBar1.Value = 100;

                    //// update mac address in local client info file
                    //if (licenseState == LicenseValidationState.Valid)
                    //{
                    //    this.progressBar1.Value = 90;
                    //    //if (string.IsNullOrEmpty(CommonAppStateDataHelper.ClientInfoObject.MacAddress))
                    //    //{
                    //    //    _showLoginForm = true;
                    //    //}
                    //    //else
                    //    //{
                    //    //    _showLoginForm = false;
                    //    //}
                    //}
                    //else
                    //{
                    //    this.progressBar1.Value = 100;
                    //    Application.Exit();
                    //}
                }
                else
                {
                    throw new Exception("Invalid client info configuration.");
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
        public static LicenseValidationState ValidateMacAddress(RegInfoFB firebaseRegistrationInfo, ClientInfo localClientInfo, string localMacAddress, out string message, out bool deleteVideo, out bool skipLoginScreen)
        {
            //bool firebaseLicenseValidation = false;

            LicenseValidationState licenseState = LicenseValidationState.None;

            skipLoginScreen = false;
            deleteVideo     = false;
            message         = "";

            // Device is online
            if (firebaseRegistrationInfo != null)
            {
                //1)    localClientInfo.MacAddress <> '' AND localClientInfo.MacAddress is in FirebaseMacAddressList == True
                //          Allow to login without authentication
                if (string.IsNullOrEmpty(localClientInfo.MacAddress) == false)
                {
                    // If local mac address is not matching with saved mac address.
                    if (localClientInfo.MacAddress.ToLower().Equals(localMacAddress.ToLower()) == false)
                    {
                        licenseState    = LicenseValidationState.SavedMacAddressMismatched;
                        skipLoginScreen = false;
                        message         = invalidLicenseMessage;
                        deleteVideo     = true;
                    }

                    else if (firebaseRegistrationInfo.MacAddresses.Contains(localClientInfo.MacAddress) == true)
                    {
                        // maxlicense is valid and user already authenticated
                        skipLoginScreen = true;
                        licenseState    = LicenseValidationState.Valid;
                    }
                    else if (firebaseRegistrationInfo.MacAddresses.Contains(localClientInfo.MacAddress) == false)
                    {
                        // 2.1) If FirebaseMacAddressList.Count >= MaxLicenseCount
                        //        Raise Error and Exit Application
                        if (firebaseRegistrationInfo.MacAddresses.Count >= firebaseRegistrationInfo.NoOfPcs)
                        {
                            licenseState    = LicenseValidationState.MaxMacAddressLimitExceed;
                            skipLoginScreen = false;
                            message         = maxLicenseOccupiedMessage;
                            deleteVideo     = true;
                        }

                        // 2.2) IF FirebaseMacAddressList.Count < MaxLicenseCount
                        //        Add current macaddress in FirebaseMacAddressList and allow login
                        if (firebaseRegistrationInfo.MacAddresses.Count < firebaseRegistrationInfo.NoOfPcs)
                        {
                            licenseState = LicenseValidationState.Valid;
                            // Add current macaddress in FirebaseMacAddressList
                            //_addMacAddressInFirebase = true;
                            skipLoginScreen = false;
                        }
                    }
                }
                // 3)   If localClientInfo.MacAddress == '' Then
                else if (string.IsNullOrEmpty(localClientInfo.MacAddress))
                {
                    //    3.1) If FirebaseMacAddressList.Count >= MaxLicenseCount
                    //        Raise Error and Exit Application
                    if (firebaseRegistrationInfo.MacAddresses.Count >= firebaseRegistrationInfo.NoOfPcs)
                    {
                        licenseState    = LicenseValidationState.MaxMacAddressLimitExceed;
                        skipLoginScreen = false;
                        message         = maxLicenseOccupiedMessage;
                        deleteVideo     = true;
                    }
                    // 3.2) If FirebaseMacAddressList.Count < MaxLicenseCount
                    else if (firebaseRegistrationInfo.MacAddresses.Count < firebaseRegistrationInfo.NoOfPcs)
                    {
                        licenseState = LicenseValidationState.Valid;

                        //      On sucessful authentication, save local mac address to Firebase.
                        //      Save local mac address to local client info file
                        //_addMacAddressInFirebase = true;
                        //      Ask user to enter login credentials
                        skipLoginScreen = false;
                    }
                }
            }
            // Device is offline
            else
            {
                // 1) localClientInfo.MacAddress == ''
                //      Ask user for autentication
                if (string.IsNullOrEmpty(localClientInfo.MacAddress))
                {
                    skipLoginScreen = false;
                }
                //    2) localClientInfo.MacAddress <> ''
                //            Allow user to use application without authentication
                else if (string.IsNullOrEmpty(localClientInfo.MacAddress) == false)
                {
                    if (localClientInfo.MacAddress.ToLower().Equals(localMacAddress.ToLower()))
                    {
                        skipLoginScreen = true;
                        licenseState    = LicenseValidationState.Valid;
                    }
                    else
                    {
                        skipLoginScreen = false;
                        licenseState    = LicenseValidationState.ConnectivityRequiredForValidation;
                        message         = invalidLicenseMessage;
                    }

                    // Validate license date;
                }
            }

            return(licenseState);
        }
Beispiel #5
0
        private RegInfoFB SaveRegDataOnFireBase(string newMemoNumber)
        {
            RegInfoFB info = new RegInfoFB();

            info.RegDate    = DateTime.Now.ToString();
            info.LoginEmail = txtEmailId.Text;
            info.Password   = txtPwd.Text;
            info.SchoolName = txtSchoolName.Text;
            info.City       = txtSchoolCity.Text;
            info.Session    = cmbSchoolSession.Text;
            info.NoOfPcs    = Convert.ToInt32(txtNoOfPcs.Text);
            info.Classes    = new List <ClassFB>();
            info.MemoNumber = newMemoNumber;
            info.ExpiryDate = info.ExpiryDate = LicenseHelper.GetSessionEndDateBySessionString(cmbSchoolSession.SelectedItem.ToString());
            info.SchoolCode = txtSchoolCode.Text.Trim();

            for (int i = 0; i < chkListBooks.CheckedItems.Count; i++)
            {
                Book selectedBook = (chkListBooks.CheckedItems[i]) as Book;

                ClassFB selectedFBClass = info.Classes.Find(k => k.Name == selectedBook.ClassName);
                if (selectedFBClass == null)
                {
                    selectedFBClass      = new ClassFB();
                    selectedFBClass.Name = selectedBook.ClassName;
                    info.Classes.Add(selectedFBClass);
                }
                SeriesFB selectedFBSeries = selectedFBClass.Series.Find(k => k.Name == selectedBook.SeriesName);

                if (selectedFBSeries == null)
                {
                    selectedFBSeries      = new SeriesFB();
                    selectedFBSeries.Name = selectedBook.SeriesName;
                    selectedFBClass.Series.Add(selectedFBSeries);
                }

                SubjectFB selectedFBSubject = selectedFBSeries.Subjects.Find(k => k.Name == selectedBook.SubjectName);

                if (selectedFBSubject == null)
                {
                    selectedFBSubject      = new SubjectFB();
                    selectedFBSubject.Name = selectedBook.SubjectName;
                    selectedFBSeries.Subjects.Add(selectedFBSubject);
                }

                BookFB selectedFBBook = new BookFB();
                selectedFBBook.Name = selectedBook.BookName;
                selectedFBSubject.Books.Add(selectedFBBook);
            }

            try
            {
                string jsonString1 = JsonHelper.ParseObjectToJSON <RegInfoFB>(info);
                string url         = string.Format("registrations-data/{0}-{1}", txtSchoolCode.Text, cmbSchoolSession.Text);
                FirebaseHelper.PatchData(jsonString1, url);
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                throw new Exception("Internet connectivity issue.");
            }
            return(info);
        }
Beispiel #6
0
        private void CreateClientSchoolPackage()
        {
            string clientSchoolCodePath = "";

            try
            {
                progressBar1.Visible = true;
                progressBar1.Value   = 10;

                string schoolCode = txtSchoolCode.Text.Trim();
                clientSchoolCodePath = Path.Combine(_clientDistributionRootPath, schoolCode);
                string clientVideoPath = ClientHelper.GetRegisteredSchoolPackageVideoPath(schoolCode, txtSchoolCity.Text.Trim());
                // string clientThumbnailPath = ClientHelper.GetRegisteredSchoolPackageThumbnailPath(schoolCode); // Path.Combine(clientPacakgeFolderPath, "Thumbnails");
                string clientVideoFolderName = ClientHelper.GetClientVideoFolderName(schoolCode, txtSchoolCity.Text.Trim());

                List <VideoInfo> videoInfoList = new List <VideoInfo>();

                #region Create Folder Structure

                // Create client distribution root folder.
                if (Directory.Exists(_clientDistributionRootPath) == false)
                {
                    Directory.CreateDirectory(_clientDistributionRootPath);
                }

                // Define client pacakge root folder path i.e. school code
                if (Directory.Exists(clientSchoolCodePath) == false)
                {
                    Directory.CreateDirectory(clientSchoolCodePath);
                }

                // Delete all old directory and files
                else if (Directory.Exists(clientSchoolCodePath))
                {
                    string[] oldClientFiles = Directory.GetDirectories(clientSchoolCodePath);
                    for (int i = 0; i < oldClientFiles.Length; i++)
                    {
                        //System.IO.File.Delete(Path.Combine(clientSchoolCodeFolderPath, oldClientFiles[i]));
                        System.IO.Directory.Delete(oldClientFiles[i], true);
                    }
                    oldClientFiles = Directory.GetFiles(clientSchoolCodePath);
                    for (int i = 0; i < oldClientFiles.Length; i++)
                    {
                        System.IO.File.Delete(oldClientFiles[i]);
                    }
                }
                progressBar1.Value = 25;

                //// Define client pacakge folder path i.e. pacakage
                //string clientPacakgeFolderPath = ClientHelper.GetClientRegistrationPackagePath(schoolCode); // Path.Combine(clientSchoolCodeFolderPath, "Package");
                //if (Directory.Exists(clientPacakgeFolderPath) == false)
                //{
                //    Directory.CreateDirectory(clientPacakgeFolderPath);
                //}

                // Define client video folder path i.e. SchoolCode_City_LBFVideos
                if (Directory.Exists(clientVideoPath) == false)
                {
                    Directory.CreateDirectory(clientVideoPath);
                }

                // Make client video folder hidden
                DirectoryInfo clientVideoFolderInfo = new DirectoryInfo(clientVideoPath);
                clientVideoFolderInfo.Attributes = FileAttributes.Hidden;

                //if (Directory.Exists(clientThumbnailPath) == false)
                //{
                //    Directory.CreateDirectory(clientThumbnailPath);
                //}
                //DirectoryInfo clientPackageThumbnailPathDirInfo = new DirectoryInfo(clientThumbnailPath);
                //clientPackageThumbnailPathDirInfo.Attributes = FileAttributes.Hidden;

                progressBar1.Value = 30;

                #endregion

                #region Copy Client Distribution

                if (Directory.Exists(ConfigHelper.ClientDistributionPath))
                {
                    string[] clientDistributionFiles = Directory.GetFiles(ConfigHelper.ClientDistributionPath);
                    for (int i = 0; i < clientDistributionFiles.Length; i++)
                    {
                        string targetFilePath = Path.Combine(clientSchoolCodePath, Path.GetFileName(clientDistributionFiles[i]));

                        System.IO.File.Copy(Path.Combine(ConfigHelper.ClientDistributionPath, clientDistributionFiles[i]), targetFilePath, true);

                        if (_nonHiddenFiles.Contains(Path.GetFileName(targetFilePath).ToLower()) == false)
                        {
                            FileInfo targetFileInfo = new FileInfo(targetFilePath);
                            targetFileInfo.Attributes = FileAttributes.Hidden;
                        }
                    }

                    //// Create shortcut of exe.
                    //WshShellClass shell = new WshShellClass();
                    //IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(Path.Combine(clientSchoolCodeFolderPath, "LBSVideoLib.Client.exe.lnk"));
                    //shortcut.TargetPath = Path.Combine(clientPacakgeFolderPath, "LBSVideoLib.Client.exe");
                    //// add Description of Short cut
                    //shortcut.Description = "Run this exe to play LBF Video Library.";
                    //// save it / create
                    //shortcut.Save();
                }
                else
                {
                    MessageBox.Show("Unable to find client distribution on specified path.", "Error", MessageBoxButtons.OK);
                }

                progressBar1.Value = 45;

                for (int i = 0; i < chkListBooks.CheckedItems.Count; i++)
                {
                    Book selectedBook = (chkListBooks.CheckedItems[i]) as Book;

                    if (selectedBook.VideoList != null)
                    {
                        //   string[] selectedBookVideos =  Directory.GetFiles(selectedBook.BookId);

                        foreach (string selectedBookVideo in selectedBook.VideoList)
                        {
                            string clientTargetVideoPath   = Path.Combine(clientVideoPath, selectedBook.ClassName);
                            string clientVideoRelativePath = Path.Combine(clientVideoFolderName, selectedBook.ClassName);

                            if (Directory.Exists(clientTargetVideoPath) == false)
                            {
                                Directory.CreateDirectory(clientTargetVideoPath);
                            }

                            DirectoryInfo clientTargetVideoPathInfo = new DirectoryInfo(clientTargetVideoPath);
                            clientTargetVideoPathInfo.Attributes = FileAttributes.Hidden;

                            clientTargetVideoPath   = Path.Combine(clientTargetVideoPath, selectedBook.SeriesName);
                            clientVideoRelativePath = Path.Combine(clientVideoRelativePath, selectedBook.SeriesName);

                            if (Directory.Exists(clientTargetVideoPath) == false)
                            {
                                Directory.CreateDirectory(clientTargetVideoPath);
                            }
                            clientTargetVideoPathInfo            = new DirectoryInfo(clientTargetVideoPath);
                            clientTargetVideoPathInfo.Attributes = FileAttributes.Hidden;

                            clientTargetVideoPath   = Path.Combine(clientTargetVideoPath, selectedBook.SubjectName);
                            clientVideoRelativePath = Path.Combine(clientVideoRelativePath, selectedBook.SubjectName);

                            if (Directory.Exists(clientTargetVideoPath) == false)
                            {
                                Directory.CreateDirectory(clientTargetVideoPath);
                            }
                            clientTargetVideoPathInfo            = new DirectoryInfo(clientTargetVideoPath);
                            clientTargetVideoPathInfo.Attributes = FileAttributes.Hidden;

                            clientTargetVideoPath   = Path.Combine(clientTargetVideoPath, selectedBook.BookName);
                            clientVideoRelativePath = Path.Combine(clientVideoRelativePath, selectedBook.BookName);

                            if (Directory.Exists(clientTargetVideoPath) == false)
                            {
                                Directory.CreateDirectory(clientTargetVideoPath);
                            }
                            clientTargetVideoPathInfo            = new DirectoryInfo(clientTargetVideoPath);
                            clientTargetVideoPathInfo.Attributes = FileAttributes.Hidden;


                            if (Directory.Exists(clientTargetVideoPath) == false)
                            {
                                Directory.CreateDirectory(clientTargetVideoPath);
                            }
                            clientTargetVideoPathInfo            = new DirectoryInfo(clientTargetVideoPath);
                            clientTargetVideoPathInfo.Attributes = FileAttributes.Hidden;

                            VideoInfo videoInfo = new VideoInfo();
                            videoInfo.VideoName     = Path.GetFileName(selectedBookVideo);
                            videoInfo.ClassName     = selectedBook.ClassName;
                            videoInfo.SeriesName    = selectedBook.SeriesName;
                            videoInfo.Subject       = selectedBook.SubjectName;
                            videoInfo.Book          = selectedBook.BookName;
                            clientTargetVideoPath   = Path.Combine(clientTargetVideoPath, Path.GetFileName(selectedBookVideo));
                            clientVideoRelativePath = Path.Combine(clientVideoRelativePath, Path.GetFileName(selectedBookVideo));
                            //videoInfo.VideoFullUrl = clientTargetVideoPath;
                            videoInfo.VideoFullUrl     = clientVideoRelativePath;
                            videoInfo.VideoRelativeUrl = clientVideoRelativePath;

                            Cryptograph.EncryptFile(selectedBookVideo, clientTargetVideoPath);

                            // Nitin Start 03-Sep
                            // Copy thumbnail file
                            string targetThumbnailFilePath = ThumbnailHelper.GetThumbnailDirectoryPathByVideoPath(clientTargetVideoPath);

                            if (System.IO.File.Exists(targetThumbnailFilePath) == false)
                            {
                                if (Directory.Exists(targetThumbnailFilePath) == false)
                                {
                                    Directory.CreateDirectory(targetThumbnailFilePath);
                                }
                                string sourceThumbnailFilePath = ThumbnailHelper.GetThumbnailFilePathByVideoPath(selectedBookVideo);
                                targetThumbnailFilePath = Path.Combine(targetThumbnailFilePath, ThumbnailHelper.GetThumbnailFileNameByVideoPath(selectedBookVideo));
                                System.IO.File.Copy(sourceThumbnailFilePath, targetThumbnailFilePath, true);
                            }
                            // Nitin End 03-Sep

                            FileInfo clientTargetVideoPathFileInfo = new FileInfo(clientTargetVideoPath);
                            clientTargetVideoPathFileInfo.Attributes = FileAttributes.Hidden;

                            videoInfoList.Add(videoInfo);
                        }
                    }
                }

                // Nitin Start
                //string[] subjectThumbnailFiles = Directory.GetFiles(ClientHelper.GetSubjectThumbnailSourcePath());
                //for (int i = 0; i < subjectThumbnailFiles.Length; i++)
                //{
                //    string thumbnailFilePath = Path.Combine(clientThumbnailPath, Path.GetFileName(subjectThumbnailFiles[i]));
                //    System.IO.File.Copy(subjectThumbnailFiles[i], thumbnailFilePath, true);

                //    FileInfo thumbnailFilePathFileInfo = new FileInfo(thumbnailFilePath);
                //    thumbnailFilePathFileInfo.Attributes = FileAttributes.Hidden;
                //}
                // Nitin End
                #endregion

                progressBar1.Value = 70;

                string newMemoNumber = GenerateNewMemoNumber();

                // Save data on firebase
                RegInfoFB selectedClassList = SaveRegDataOnFireBase(newMemoNumber);

                string registeredSchoolInfo = Newtonsoft.Json.JsonConvert.SerializeObject(selectedClassList);

                // Nitin Start
                CreateRegisteredSchoolInfoFile(registeredSchoolInfo, schoolCode, txtSchoolCity.Text.Trim(), txtSchoolName.Text.Trim(), newMemoNumber);
                // Nitin End

                progressBar1.Value = 80;

                // Set client email, password and license date in client info class.
                ClientInfo clientInfo = new ClientInfo();
                clientInfo.EmailId              = txtEmailId.Text.ToLower().Trim();
                clientInfo.Password             = txtPwd.Text.Trim();
                clientInfo.RegistrationDate     = DateTime.Now;
                clientInfo.SessionStartDate     = LicenseHelper.GetSessionStartDateBySessionString(cmbSchoolSession.SelectedItem.ToString());
                clientInfo.SessionEndDate       = LicenseHelper.GetSessionEndDateBySessionString(cmbSchoolSession.SelectedItem.ToString());
                clientInfo.LastAccessEndTime    = clientInfo.SessionStartDate;
                clientInfo.SessionString        = cmbSchoolSession.SelectedItem.ToString();
                clientInfo.SchoolId             = this.txtSchoolCode.Text.Trim();
                clientInfo.SchoolName           = this.txtSchoolName.Text.Trim();
                clientInfo.SchoolCity           = txtSchoolCity.Text.Trim();
                clientInfo.SelectedVideoDetails = selectedClassList.Classes;
                clientInfo.VideoInfoList        = videoInfoList;
                clientInfo.MemoNumber           = newMemoNumber;

                // Generate client info json file and encrypt it.
                string clientInfoFilePath = Path.Combine(clientSchoolCodePath, _clientInfoFileName);
                Cryptograph.EncryptObject(clientInfo, clientInfoFilePath);
                FileInfo clientInfoFileInfo = new FileInfo(clientInfoFilePath);
                clientInfoFileInfo.Attributes = FileAttributes.Hidden;

                progressBar1.Value = 99;

                //string clientInfoPlainText = Newtonsoft.Json.JsonConvert.SerializeObject(clientInfo);
                //sw = System.IO.File.CreateText(Path.Combine(ClientHelper.GetRegisteredSchoolInfoFilePath(), this.txtSchoolCode.Text.Trim() + "-Plain.txt"));
                //sw.Write(clientInfoPlainText);
                //sw.Flush();
                //sw.Close();

                progressBar1.Value   = 100;
                progressBar1.Visible = false;

                // Copy client project bin folder to target location.
                MessageBox.Show("Registration completed successfully.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);

                InitializeRegistrationForm();
            }
            catch (Exception ex)
            {
                // Delete all file on folder
                if (Directory.Exists(clientSchoolCodePath))
                {
                    // Delete created package folder inside school code
                    System.IO.Directory.Delete(clientSchoolCodePath, true);
                }
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
            finally
            {
                progressBar1.Visible = false;
            }
        }