Exemplo n.º 1
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

        private ProtectedFiles InitProtectedFiles()
        {
            bool           debug          = true;
            ProtectedFiles protectedFiles = null;
            string         filePath       = SettingsApp.ProtectedFilesFileName;
            List <string>  fileList       = SettingsApp.ProtectedFilesList;

            //ReCreate File MODE
            if (SettingsApp.ProtectedFilesRecreateCSV)
            {
                protectedFiles = new ProtectedFiles(fileList, filePath);
                string md5FromFile = FrameworkUtils.MD5HashFile(filePath);
                //End Xpo Create Scheme and Fixtures, Terminate App and Request assign False to Developer Vars
                //string message = string.Format(@"ProtectedFiles '{1}' re-created with {2} files found!
                //    {0}- Assign false to 'SettingsApp.ProtectedFilesRecreateCsv'.
                //    {0}- Update logicpos.financial.library SettingsApp.ProtectedFilesFileHash with Hash: '{3}.'"
                //    , Environment.NewLine, filePath, fileList.Count, md5FromFile
                //);
                //_log.Debug(String.Format("Protected files: [{0}]", message));
                string message = string.Format(@"ProtectedFiles '{1}' re-created with {2} files found!{0}{0}Assign false to 'SettingsApp.ProtectedFilesRecreateCsv' and run app again.", Environment.NewLine, filePath, fileList.Count);

                ExportProtectedFiles(fileList);
                Utils.ShowMessageTouch(GlobalApp.WindowStartup, DialogFlags.Modal, new System.Drawing.Size(600, 350), MessageType.Info, ButtonsType.Ok, Resx.global_information, message);
                Environment.Exit(0);
            }
            //Dont check changed files if Developer, Uncomment to Enable
            //else if (SettingsApp.DeveloperMode)
            //{
            //    protectedFiles = new ProtectedFiles(filePath);
            //}
            //Use File
            else
            {
                protectedFiles = new ProtectedFiles(filePath);
                foreach (var item in protectedFiles)
                {
                    if (debug)
                    {
                        _log.Debug(string.Format("Message: [{0}], Valid: [{1}], IsValidFile: [{2}]", item.Key, item.Value.Valid, protectedFiles.IsValidFile(item.Key)));
                    }
                }

                List <string> getInvalidAndMissingFiles = protectedFiles.GetInvalidAndMissingFiles(fileList);

                if (getInvalidAndMissingFiles.Count > 0)
                {
                    string filesMessage = string.Empty;
                    for (int i = 0; i < getInvalidAndMissingFiles.Count; i++)
                    {
                        if (debug)
                        {
                            _log.Debug(string.Format("InvalidFile: [{0}]", getInvalidAndMissingFiles[i]));
                        }
                        filesMessage += string.Format("{0}{1}", getInvalidAndMissingFiles[i], Environment.NewLine);
                    }

                    //If Not IgnoreProtection, show alert and exit
                    if (!SettingsApp.ProtectedFilesIgnoreProtection)
                    {
                        Utils.ShowMessageTouch(GlobalApp.WindowStartup, DialogFlags.Modal, new Size(800, 400), MessageType.Error, ButtonsType.Close, Resx.global_error, string.Format(Resx.dialog_message_error_protected_files_invalid_files_detected, filesMessage));
                        Environment.Exit(0);
                    }
                }
            }

            return(protectedFiles);
        }