Пример #1
0
        /// <summary>
        /// Open up the readme in the display
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void readmeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // initialize and display the readme
            Readme readme = new Readme();

            readme.Show();
        }
Пример #2
0
 public ReadmeViewModel Init(string repositoryOwner, string repositoryName, Readme readme = null)
 {
     RepositoryOwner = repositoryOwner;
     RepositoryName  = repositoryName;
     ContentModel    = readme;
     return(this);
 }
            public async Task ReturnsReadmeWithRepositoryId()
            {
                string encodedContent = Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello world"));
                var readmeInfo = new ReadmeResponse(
                    encodedContent,
                    "README.md",
                    "https://github.example.com/readme",
                    "https://github.example.com/readme.md",
                    "base64");

                var gitHubClient = Substitute.For<IGitHubClient>();
                var apiConnection = Substitute.For<IApiConnection>();
                apiConnection.GetHtml(new Uri(readmeInfo.Url)).Returns(Task.FromResult("<html>README</html>"));
                var readmeFake = new Readme(readmeInfo, apiConnection);
                var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);

                gitHubClient.Repository.Content.GetReadme(1).Returns(Task.FromResult(readmeFake));

                IApiResponse<string> apiResponse = new ApiResponse<string>(new Response(), "<html>README</html>");
                gitHubClient.Connection.GetHtml(Args.Uri, null)
                    .Returns(Task.FromResult(apiResponse));

                var readme = await contentsClient.GetReadme(1);

                Assert.Equal("README.md", readme.Name);

                gitHubClient.Repository.Content.Received(1).GetReadme(1);
                gitHubClient.Connection.DidNotReceive().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme"),
                    Args.EmptyDictionary);

                var htmlReadme = await readme.GetHtmlContent();
                Assert.Equal("<html>README</html>", htmlReadme);
                apiConnection.Received().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme.md"), null);
            }
Пример #4
0
        /// <summary>
        ///   Builds a premade fomod pack using the given information.
        /// </summary>
        /// <remarks>
        ///   This method uses a <see cref="BackgroundWorkerProgressDialog" /> to display progress and
        ///   allow cancellation.
        /// </remarks>
        /// <param name="p_strFileName">The name of the fomod file, excluding extension.</param>
        /// <param name="p_strVersion">The version of the fomod for which we are creating the PFP.</param>
        /// <param name="p_strMachineVersion">The machine version of the fomod for which we are creating the PFP.</param>
        /// <param name="p_lstCopyInstructions">The list of files to copy into the fomod.</param>
        /// <param name="p_lstSourceFiles">The list of source files.</param>
        /// <param name="p_rmeReadme">The fomod readme.</param>
        /// <param name="p_xmlInfo">The fomod info file.</param>
        /// <param name="p_booSetScreenshot">Whether or not to set the fomod's screenshot.</param>
        /// <param name="p_shtScreenshot">The fomod screenshot.</param>
        /// <param name="p_fscScript">The fomod install script.</param>
        /// <param name="p_strPFPPath">The path where the Premade Fomod Pack will be created.</param>
        /// <returns>The path to the new premade fomod pack if it was successfully built; <lang langref="null" /> otherwise.</returns>
        public string BuildPFP(string p_strFileName, string p_strVersion, string p_strMachineVersion,
                               IList <KeyValuePair <string, string> > p_lstCopyInstructions, IList <SourceFile> p_lstSourceFiles,
                               string p_strCustomHowToSteps, Readme p_rmeReadme, XmlDocument p_xmlInfo,
                               bool p_booSetScreenshot, Screenshot p_shtScreenshot, FomodScript p_fscScript,
                               string p_strPFPPath)
        {
            string strPFPExtension;

            switch (Settings.Default.pfpCompressionFormat)
            {
            case OutArchiveFormat.BZip2:
                strPFPExtension = ".bz2";
                break;

            case OutArchiveFormat.GZip:
                strPFPExtension = ".gz";
                break;

            case OutArchiveFormat.SevenZip:
                strPFPExtension = ".7z";
                break;

            case OutArchiveFormat.Tar:
                strPFPExtension = ".tar";
                break;

            case OutArchiveFormat.XZ:
                strPFPExtension = ".xz";
                break;

            case OutArchiveFormat.Zip:
                strPFPExtension = ".zip";
                break;

            default:
                throw new Exception("Unrecognized value for OutArchiveFormat enum.");
            }
            var strVersion = p_strVersion;

            if (strVersion.Length > 8)
            {
                strVersion = p_strMachineVersion;
            }
            var strPFPPath = Path.Combine(p_strPFPPath,
                                          String.Format("{0} {1}{2}", p_strFileName, strVersion, strPFPExtension));

            strPFPPath = GenerateFomod(new BuildPFPArgs(p_strFileName,
                                                        p_lstCopyInstructions,
                                                        p_lstSourceFiles,
                                                        p_strCustomHowToSteps,
                                                        p_rmeReadme,
                                                        p_xmlInfo,
                                                        p_booSetScreenshot,
                                                        p_shtScreenshot,
                                                        p_fscScript,
                                                        strPFPPath
                                                        ));
            return(strPFPPath);
        }
Пример #5
0
        /// <summary>
        ///   If no readme has been entered, this method looks for a readme file in the selected
        ///   files, and, if one is found, uses it to populate the readme editor.
        /// </summary>
        protected void SetReadmeDefault()
        {
            if (redReadmeEditor.Readme == null)
            {
                List <KeyValuePair <string, string> > lstReadmes = null;
                foreach (var strExtension in Readme.ValidExtensions)
                {
                    lstReadmes = ffsFileStructure.FindFomodFiles("readme - " + tbxFomodFileName.Text + strExtension);
                    if (lstReadmes.Count > 0)
                    {
                        break;
                    }
                }
                if (lstReadmes.Count == 0)
                {
                    foreach (var strExtension in Readme.ValidExtensions)
                    {
                        lstReadmes = ffsFileStructure.FindFomodFiles("*readme*" + strExtension);
                        if (lstReadmes.Count > 0)
                        {
                            break;
                        }
                    }
                }
                if (lstReadmes.Count == 0)
                {
                    foreach (var strExtension in Readme.ValidExtensions)
                    {
                        lstReadmes = ffsFileStructure.FindFomodFiles("*" + strExtension);
                        if (lstReadmes.Count > 0)
                        {
                            break;
                        }
                    }
                }

                Readme rmeReadme = null;
                foreach (var kvpReadme in lstReadmes)
                {
                    if (Readme.IsValidReadme(kvpReadme.Key))
                    {
                        string strReadme = null;
                        if (kvpReadme.Value.StartsWith(Archive.ARCHIVE_PREFIX))
                        {
                            var kvpArchiveInfo = Archive.ParseArchivePath(kvpReadme.Value);
                            var arcArchive     = new Archive(kvpArchiveInfo.Key);
                            strReadme = TextUtil.ByteToString(arcArchive.GetFileContents(kvpArchiveInfo.Value));
                        }
                        else if (File.Exists(kvpReadme.Value))
                        {
                            strReadme = File.ReadAllText(kvpReadme.Value);
                        }
                        rmeReadme = new Readme(kvpReadme.Key, strReadme);
                        break;
                    }
                }
                redReadmeEditor.Readme = rmeReadme ?? new Readme(ReadmeFormat.PlainText, null);
            }
        }
Пример #6
0
        /// <summary>
        /// Loads the project from a file.
        /// </summary>
        /// <param name="p_strPath">The path to the file from which to load the project.</param>
        protected void Load(string p_strPath)
        {
            XmlDocument xmlProject = new XmlDocument();

            xmlProject.Load(p_strPath);

            XmlNode xndRoot = xmlProject.SelectSingleNode("modProject");

            XmlNode xndInfo = xndRoot.SelectSingleNode("info");

            this.LoadInfo(xndInfo);

            XmlNode xndScript = xndRoot.SelectSingleNode("InstallScript");

            if (xndScript != null)
            {
                IScriptType stpType = ScriptTypeRegistry.GetType(xndScript.Attributes["type"].Value);
                if (stpType == null)
                {
                    throw new Exception("Unrecognized script type: " + xndScript.Attributes["type"].Value);
                }
                InstallScript = stpType.LoadScript(xndScript.InnerXml);
            }

            XmlNode xndReadme = xndRoot.SelectSingleNode("ModReadme");

            if (xndReadme != null)
            {
                string       strFormat = xndReadme.Attributes["format"].Value;
                ReadmeFormat fmtFormat = ReadmeFormat.PlainText;
                if (Enum.GetNames(typeof(ReadmeFormat)).Contains(x => x.Equals(strFormat, StringComparison.InvariantCultureIgnoreCase)))
                {
                    fmtFormat = (ReadmeFormat)Enum.Parse(typeof(ReadmeFormat), strFormat);
                }
                ModReadme = new Readme(fmtFormat, xndReadme.InnerText);
            }

            XmlNode xndFiles = xndRoot.SelectSingleNode("ModFiles");

            if (xndFiles != null)
            {
                foreach (XmlNode xndFile in xndFiles.ChildNodes)
                {
                    bool booIsDirectory = false;
                    if (!bool.TryParse(xndFile.Attributes["IsDirectory"].Value, out booIsDirectory))
                    {
                        booIsDirectory = false;
                    }
                    ModFiles.Add(new VirtualFileSystemItem(xndFile.Attributes["Source"].Value, xndFile.Attributes["Path"].Value, booIsDirectory));
                }
            }
            FilePath = p_strPath;
            IsDirty  = false;
        }
Пример #7
0
        private async Task GetReadme(GitHubClient client, Repo repo, Repository repos)
        {
            try {
                Readme readme =
                    await client.Repository.Content.GetReadme(repos.Id);

                repo.Readme = readme;
            } catch (Exception) {
                repo.Readme = null;
            }
        }
Пример #8
0
 protected void AddReadmeButton_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         Readme readme = new Readme();
         readme.DisplayName = AddReadmeName.Text;
         readme.ReadmeText  = string.Empty;
         readme.Save();
         Response.Redirect("EditReadme.aspx?ReadmeId=" + readme.Id);
     }
 }
Пример #9
0
 /// <summary>
 ///   A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_strFomodName">The value with which to initialize the <see cref="FomodName" /> property.</param>
 /// <param name="p_lstCopyInstructions">The value with which to initialize the <see cref="CopyInstructions" /> property.</param>
 /// <param name="p_lstSourceFiles">The value with which to initialize the <see cref="SourceFiles" /> property.</param>
 /// <param name="p_strCustomHowToSteps">Custom howto steps that should be included in the PFP HowTo.</param>
 /// <param name="p_rmeReadme">The value with which to initialize the <see cref="Readme" /> property.</param>
 /// <param name="p_xmlInfo">The value with which to initialize the <see cref="Info" /> property.</param>
 /// <param name="p_booSetScreenshot">The value with which to initialize the <see cref="SetScreenshot" /> property.</param>
 /// <param name="p_shtScreenshot">The value with which to initialize the <see cref="Screenshot" /> property.</param>
 /// <param name="p_fscScript">The value with which to initialize the <see cref="Script" /> property.</param>
 /// <param name="p_strPackedPath">The value with which to initialize the <see cref="PackedPath" /> property.</param>
 public BuildPFPArgs(string p_strFomodName, IList<KeyValuePair<string, string>> p_lstCopyInstructions,
                     IList<SourceFile> p_lstSourceFiles, string p_strCustomHowToSteps, Readme p_rmeReadme,
                     XmlDocument p_xmlInfo, bool p_booSetScreenshot, Screenshot p_shtScreenshot,
                     FomodScript p_fscScript, string p_strPackedPath)
   : base(
     p_strFomodName, p_lstCopyInstructions, p_rmeReadme, p_xmlInfo, p_booSetScreenshot, p_shtScreenshot,
     p_fscScript, p_strPackedPath)
 {
   SourceFiles = p_lstSourceFiles;
   CustomHowToSteps = p_strCustomHowToSteps;
 }
Пример #10
0
    protected override void OnHeaderGUI()
    {
        InitializeStyles();

        Readme readme    = (Readme)target;
        float  iconWidth = Mathf.Min(EditorGUIUtility.currentViewWidth / 3f - 20f, 128f);

        GUILayout.BeginHorizontal("In BigTitle");
        GUILayout.Label(readme.header.icon, GUILayout.Width(iconWidth), GUILayout.Height(iconWidth));
        GUILayout.Label(readme.header.title, titleStyle);
        GUILayout.EndHorizontal();
    }
Пример #11
0
        /// <summary>
        /// Verifies if the readme file exists in the archive and saves it to the ReadMe folder.
        /// </summary>
        /// <param name="p_strArchivePath">The path to the mod archive.</param>
        public bool VerifyReadMeFile(TxFileManager p_tfmFileManager, string p_strArchivePath)
        {
            try
            {
                Archive       arcFile        = new Archive(p_strArchivePath);
                List <string> lstFiles       = GetFileList(arcFile, true);
                string        strReadMePath  = m_strReadMePath;
                string        strFileName    = String.Empty;
                string        strReadMeFile  = String.Empty;
                string        strModFile     = Path.GetFileName(p_strArchivePath);
                string        strArchiveFile = Path.GetFileNameWithoutExtension(strModFile) + ".7z";
                byte[]        bteData        = null;

                PurgeTempFolder();

                for (int i = 0; i < lstFiles.Count; i++)
                {
                    strFileName = lstFiles[i].ToString();
                    if (Readme.IsValidReadme(strFileName))
                    {
                        bteData = arcFile.GetFileContents(lstFiles[i]);
                        if (bteData.Length > 0)
                        {
                            strReadMeFile = Path.GetFileName(strFileName);
                            strReadMePath = Path.Combine(ReadMeTempPath, strReadMeFile);
                            p_tfmFileManager.WriteAllBytes(strReadMePath, bteData);

                            break;
                        }
                    }
                }
                string[] strFilesToCompress = Directory.GetFiles(ReadMeTempPath, "*.*", SearchOption.AllDirectories);
                if (strFilesToCompress.Length > 0)
                {
                    if (CreateReadMeArchive(strArchiveFile, strFilesToCompress))
                    {
                        for (int i = 0; i < strFilesToCompress.Length; i++)
                        {
                            strFilesToCompress[i] = Path.GetFileName(strFilesToCompress[i]);
                        }

                        m_dicReadMeFiles.Add(Path.GetFileNameWithoutExtension(strArchiveFile), strFilesToCompress);
                    }
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Пример #12
0
        protected int GetProductCount(object dataItem)
        {
            Readme m = (Readme)dataItem;

            if (_ProductCounts.ContainsKey(m.Id))
            {
                return(_ProductCounts[m.Id]);
            }
            int count = DigitalGoodDataSource.CountForReadme(m.Id);

            _ProductCounts[m.Id] = count;
            return(count);
        }
Пример #13
0
 /// <summary>
 ///   A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_strFomodName">The value with which to initialize the <see cref="FomodName" /> property.</param>
 /// <param name="p_lstCopyPaths">The value with which to initialize the <see cref="CopyPaths" /> property.</param>
 /// <param name="p_rmeReadme">The value with which to initialize the <see cref="Readme" /> property.</param>
 /// <param name="p_xmlInfo">The value with which to initialize the <see cref="Info" /> property.</param>
 /// <param name="p_booSetScreenshot">The value with which to initialize the <see cref="SetScreenshot" /> property.</param>
 /// <param name="p_shtScreenshot">The value with which to initialize the <see cref="Screenshot" /> property.</param>
 /// <param name="p_fscScript">The value with which to initialize the <see cref="Script" /> property.</param>
 /// <param name="p_strPackedPath">The value with which to initialize the <see cref="PackedPath" /> property.</param>
 public BuildFomodArgs(string p_strFomodName, IList<KeyValuePair<string, string>> p_lstCopyPaths,
                       Readme p_rmeReadme, XmlDocument p_xmlInfo, bool p_booSetScreenshot,
                       Screenshot p_shtScreenshot, FomodScript p_fscScript, string p_strPackedPath)
   : base(p_strPackedPath)
 {
   FomodName = p_strFomodName;
   CopyInstructions = p_lstCopyPaths;
   Readme = p_rmeReadme;
   InfoFile = p_xmlInfo;
   SetScreenshot = p_booSetScreenshot;
   Screenshot = p_shtScreenshot;
   Script = p_fscScript;
 }
Пример #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int    readmeId = AlwaysConvert.ToInt(Request.QueryString["ReadmeId"]);
            Readme readme   = ReadmeDataSource.Load(readmeId);

            if (readme == null)
            {
                Response.Redirect(ReturnUrl);
            }
            Page.Title           = readme.DisplayName;
            ReadmeText.Text      = readme.ReadmeText;
            OkButton.NavigateUrl = ReturnUrl;
        }
Пример #15
0
 /// <summary>
 ///   A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_strFomodName">The value with which to initialize the <see cref="FomodName" /> property.</param>
 /// <param name="p_lstCopyPaths">The value with which to initialize the <see cref="CopyPaths" /> property.</param>
 /// <param name="p_rmeReadme">The value with which to initialize the <see cref="Readme" /> property.</param>
 /// <param name="p_xmlInfo">The value with which to initialize the <see cref="Info" /> property.</param>
 /// <param name="p_booSetScreenshot">The value with which to initialize the <see cref="SetScreenshot" /> property.</param>
 /// <param name="p_shtScreenshot">The value with which to initialize the <see cref="Screenshot" /> property.</param>
 /// <param name="p_fscScript">The value with which to initialize the <see cref="Script" /> property.</param>
 /// <param name="p_strPackedPath">The value with which to initialize the <see cref="PackedPath" /> property.</param>
 public BuildFomodArgs(string p_strFomodName, IList <KeyValuePair <string, string> > p_lstCopyPaths,
                       Readme p_rmeReadme, XmlDocument p_xmlInfo, bool p_booSetScreenshot,
                       Screenshot p_shtScreenshot, FomodScript p_fscScript, string p_strPackedPath)
     : base(p_strPackedPath)
 {
     FomodName        = p_strFomodName;
     CopyInstructions = p_lstCopyPaths;
     Readme           = p_rmeReadme;
     InfoFile         = p_xmlInfo;
     SetScreenshot    = p_booSetScreenshot;
     Screenshot       = p_shtScreenshot;
     Script           = p_fscScript;
 }
Пример #16
0
 /// <summary>
 /// Builds a fomod using the given information.
 /// </summary>
 /// <remarks>
 /// This method uses a <see cref="BackgroundWorkerProgressDialog"/> to display progress and
 /// allow cancellation.
 /// </remarks>
 /// <param name="p_strFileName">The name of the fomod file, excluding extension.</param>
 /// <param name="p_lstCopyInstructions">The list of files to copy into the fomod.</param>
 /// <param name="p_rmeReadme">The fomod readme.</param>
 /// <param name="p_xmlInfo">The fomod info file.</param>
 /// <param name="p_booSetScreenshot">Whether or not to set the fomod's screenshot.</param>
 /// <param name="p_shtScreenshot">The fomod screenshot.</param>
 /// <param name="p_fscScript">The fomod install script.</param>
 /// <returns>The path to the new fomod if it was successfully built; <lang cref="null"/> otherwise.</returns>
 public string BuildFomod(string p_strFileName, IList<KeyValuePair<string, string>> p_lstCopyInstructions, Readme p_rmeReadme, XmlDocument p_xmlInfo, bool p_booSetScreenshot, Screenshot p_shtScreenshot, FomodScript p_fscScript)
 {
     string strFomodPath = Path.Combine(Program.GameMode.ModDirectory, p_strFileName + ".fomod");
     strFomodPath = GenerateFomod(new BuildFomodArgs(p_strFileName,
                                                         p_lstCopyInstructions,
                                                         p_rmeReadme,
                                                         p_xmlInfo,
                                                         p_booSetScreenshot,
                                                         p_shtScreenshot,
                                                         p_fscScript,
                                                         strFomodPath
                                                         ));
     return strFomodPath;
 }
Пример #17
0
 protected void Page_Init(object sender, System.EventArgs e)
 {
     _ReadmeId = AlwaysConvert.ToInt(Request.QueryString["ReadmeId"]);
     _Readme   = ReadmeDataSource.Load(_ReadmeId);
     if (_Readme == null)
     {
         Response.Redirect("Default.aspx");
     }
     Caption.Text         = string.Format(Caption.Text, _Readme.DisplayName);
     InstructionText.Text = string.Format(InstructionText.Text, _Readme.DisplayName);
     BindReadmes();
     ProductsGrid.DataSource = _Readme.DigitalGoods;
     ProductsGrid.DataBind();
 }
Пример #18
0
 public override void PreLoadContent()
 {
     antivirus        = new FileIcon(graphicsDevice, this);
     taskBar          = new TaskBar(graphicsDevice, this);
     startMenu        = new StartMenu(graphicsDevice, this);
     warning          = new Warning(graphicsDevice, this);
     hacking          = new Hacking(graphicsDevice, this);
     readme           = new Readme(graphicsDevice, this);
     message          = new Label(graphicsDevice, this);
     message.TextSize = 24f;
     message.Text     = "Startボタンでスキャン\r\nBackボタンでシャットダウン\r\nAボタンで確認\r\nBボタンでキャンセル";
     message.Location = new Point(Size.Width - message.Size.Width, 0);
     new WarningMessage(graphicsDevice, this, antivirus);
     EventRegist();
     base.PreLoadContent();
 }
Пример #19
0
        /// <summary>
        /// The method that is called to start the backgound task.
        /// </summary>
        /// <remarks>
        /// This method installs all of the files in the <see cref="IMod"/> being installed.
        /// </remarks>
        /// <param name="p_objArgs">Arguments to for the task execution.</param>
        /// <returns>A return value.</returns>
        protected override object DoWork(object[] p_objArgs)
        {
            char[]        chrDirectorySeperators = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
            bool          booSecondaryInstall    = false;
            List <string> lstFiles = Mod.GetFileList();

            OverallProgressMaximum = lstFiles.Count;

            if (GameMode.RequiresModFileMerge)
            {
                GameMode.ModFileMerge(ActiveMods, Mod, false);
            }

            if (GameMode.HasSecondaryInstallPath)
            {
                booSecondaryInstall = GameMode.CheckSecondaryInstall(Mod);
            }

            foreach (string strFile in lstFiles)
            {
                if (Status == TaskStatus.Cancelling)
                {
                    return(false);
                }
                string strFixedPath = GameMode.GetModFormatAdjustedPath(Mod.Format, strFile, Mod);

                if (!string.IsNullOrEmpty(strFixedPath))
                {
                    if (!(GameMode.RequiresModFileMerge && (Path.GetFileName(strFile) == GameMode.MergedFileName)))
                    {
                        if (!(SkipReadme && Readme.IsValidExtension(Path.GetExtension(strFile).ToLower()) && (Path.GetDirectoryName(strFixedPath) == Path.GetFileName(GameMode.PluginDirectory))))
                        {
                            if (FileInstaller.InstallFileFromMod(strFile, strFixedPath, booSecondaryInstall))
                            {
                                if ((GameMode.UsesPlugins) && (PluginManager.IsActivatiblePluginFile(strFixedPath)))
                                {
                                    PluginManager.ActivatePlugin(strFixedPath);
                                }
                            }
                        }
                    }
                }
                StepOverallProgress();
            }
            return(true);
        }
Пример #20
0
        /// <summary>
        ///   Builds a fomod using the given information.
        /// </summary>
        /// <remarks>
        ///   This method uses a <see cref="BackgroundWorkerProgressDialog" /> to display progress and
        ///   allow cancellation.
        /// </remarks>
        /// <param name="p_strFileName">The name of the fomod file, excluding extension.</param>
        /// <param name="p_lstCopyInstructions">The list of files to copy into the fomod.</param>
        /// <param name="p_rmeReadme">The fomod readme.</param>
        /// <param name="p_xmlInfo">The fomod info file.</param>
        /// <param name="p_booSetScreenshot">Whether or not to set the fomod's screenshot.</param>
        /// <param name="p_shtScreenshot">The fomod screenshot.</param>
        /// <param name="p_fscScript">The fomod install script.</param>
        /// <returns>The path to the new fomod if it was successfully built; <lang langref="null" /> otherwise.</returns>
        public string BuildFomod(string p_strFileName, IList <KeyValuePair <string, string> > p_lstCopyInstructions,
                                 Readme p_rmeReadme, XmlDocument p_xmlInfo, bool p_booSetScreenshot,
                                 Screenshot p_shtScreenshot, FomodScript p_fscScript)
        {
            var strFomodPath = Path.Combine(Program.GameMode.ModDirectory, p_strFileName + ".fomod");

            strFomodPath = GenerateFomod(new BuildFomodArgs(p_strFileName,
                                                            p_lstCopyInstructions,
                                                            p_rmeReadme,
                                                            p_xmlInfo,
                                                            p_booSetScreenshot,
                                                            p_shtScreenshot,
                                                            p_fscScript,
                                                            strFomodPath
                                                            ));
            return(strFomodPath);
        }
Пример #21
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     _ReadmeId = AlwaysConvert.ToInt(Request.QueryString["ReadmeId"]);
     _Readme   = ReadmeDataSource.Load(_ReadmeId);
     if (_Readme == null)
     {
         Response.Redirect("Default.aspx");
     }
     if (!Page.IsPostBack)
     {
         DisplayName.Text = _Readme.DisplayName;
         IsHtml.Checked   = _Readme.IsHTML;
         ReadmeText.Text  = _Readme.ReadmeText;
     }
     DigitalGoodsGrid.DataSource = _Readme.DigitalGoods;
     DigitalGoodsGrid.DataBind();
     Caption.Text = string.Format(Caption.Text, _Readme.DisplayName);
     AbleCommerce.Code.PageHelper.SetHtmlEditor(ReadmeText, HtmlButton);
 }
Пример #22
0
 /// <summary>
 /// Builds a premade fomod pack using the given information.
 /// </summary>
 /// <remarks>
 /// This method uses a <see cref="BackgroundWorkerProgressDialog"/> to display progress and
 /// allow cancellation.
 /// </remarks>
 /// <param name="p_strFileName">The name of the fomod file, excluding extension.</param>
 /// <param name="p_strVersion">The version of the fomod for which we are creating the PFP.</param>
 /// <param name="p_strMachineVersion">The machine version of the fomod for which we are creating the PFP.</param>
 /// <param name="p_lstCopyInstructions">The list of files to copy into the fomod.</param>
 /// <param name="p_lstSourceFiles">The list of source files.</param>
 /// <param name="p_rmeReadme">The fomod readme.</param>
 /// <param name="p_xmlInfo">The fomod info file.</param>
 /// <param name="p_booSetScreenshot">Whether or not to set the fomod's screenshot.</param>
 /// <param name="p_shtScreenshot">The fomod screenshot.</param>
 /// <param name="p_fscScript">The fomod install script.</param>
 /// <param name="p_strPFPPath">The path where the Premade Fomod Pack will be created.</param>
 /// <returns>The path to the new premade fomod pack if it was successfully built; <lang cref="null"/> otherwise.</returns>
 public string BuildPFP(string p_strFileName, string p_strVersion, string p_strMachineVersion, IList<KeyValuePair<string, string>> p_lstCopyInstructions, IList<SourceFile> p_lstSourceFiles, string p_strCustomHowToSteps, Readme p_rmeReadme, XmlDocument p_xmlInfo, bool p_booSetScreenshot, Screenshot p_shtScreenshot, FomodScript p_fscScript, string p_strPFPPath)
 {
     string strPFPExtension = null;
     switch (Properties.Settings.Default.pfpCompressionFormat)
     {
         case OutArchiveFormat.BZip2:
             strPFPExtension = ".bz2";
             break;
         case OutArchiveFormat.GZip:
             strPFPExtension = ".gz";
             break;
         case OutArchiveFormat.SevenZip:
             strPFPExtension = ".7z";
             break;
         case OutArchiveFormat.Tar:
             strPFPExtension = ".tar";
             break;
         case OutArchiveFormat.XZ:
             strPFPExtension = ".xz";
             break;
         case OutArchiveFormat.Zip:
             strPFPExtension = ".zip";
             break;
         default:
             throw new Exception("Unrecognized value for OutArchiveFormat enum.");
     }
     string strVersion = p_strVersion;
     if (strVersion.Length > 8)
         strVersion = p_strMachineVersion;
     string strPFPPath = Path.Combine(p_strPFPPath, String.Format("{0} {1}{2}", p_strFileName, strVersion, strPFPExtension));
     strPFPPath = GenerateFomod(new BuildPFPArgs(p_strFileName,
                                                         p_lstCopyInstructions,
                                                         p_lstSourceFiles,
                                                         p_strCustomHowToSteps,
                                                         p_rmeReadme,
                                                         p_xmlInfo,
                                                         p_booSetScreenshot,
                                                         p_shtScreenshot,
                                                         p_fscScript,
                                                         strPFPPath
                                                         ));
     return strPFPPath;
 }
Пример #23
0
        /// <summary>
        /// Gets all assets for a product regardless of variant.
        /// </summary>
        /// <param name="page">Page context</param>
        /// <param name="product">Product to get assets for</param>
        /// <param name="returnUrl">URL to use for the return location when pages visited.</param>
        /// <returns></returns>
        public static List <AbleCommerce.Code.ProductAssetWrapper> GetAssets(Page page, Product product, string returnUrl)
        {
            // BUILD LIST OF ASSETS
            List <string> assetTracker = new List <string>();
            string        encodedReturnUrl;

            if (!string.IsNullOrEmpty(returnUrl))
            {
                encodedReturnUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(returnUrl));
            }
            else
            {
                encodedReturnUrl = string.Empty;
            }
            List <AbleCommerce.Code.ProductAssetWrapper> assetList = new List <AbleCommerce.Code.ProductAssetWrapper>();
            string agreeUrl    = page.ResolveUrl("~/ViewLicenseAgreement.aspx") + "?id={0}&ReturnUrl=" + encodedReturnUrl;
            string agreePopup  = agreeUrl + "\" onclick=\"" + AbleCommerce.Code.PageHelper.GetPopUpScript(agreeUrl, "license", 640, 480, "resizable=1,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no") + ";return false";
            string readmeUrl   = page.ResolveUrl("~/ViewReadme.aspx") + "?ReadmeId={0}&ReturnUrl=" + encodedReturnUrl;
            string readmePopup = readmeUrl + "\" onclick=\"" + AbleCommerce.Code.PageHelper.GetPopUpScript(readmeUrl, "readme", 640, 480, "resizable=1,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no") + ";return false";

            foreach (ProductDigitalGood pdg in product.DigitalGoods)
            {
                DigitalGood digitalGood = pdg.DigitalGood;
                Readme      readme      = digitalGood.Readme;
                if (readme != null && assetTracker.IndexOf("R" + readme.Id.ToString()) < 0)
                {
                    assetList.Add(new AbleCommerce.Code.ProductAssetWrapper(string.Format(readmePopup, readme.Id), readme.DisplayName));
                    assetTracker.Add("R" + readme.Id.ToString());
                }
                LicenseAgreement agreement = digitalGood.LicenseAgreement;
                if (agreement != null && assetTracker.IndexOf("L" + agreement.Id.ToString()) < 0)
                {
                    assetList.Add(new AbleCommerce.Code.ProductAssetWrapper(string.Format(agreePopup, agreement.Id), agreement.DisplayName));
                    assetTracker.Add("L" + agreement.Id.ToString());
                }
            }
            return(assetList);
        }
Пример #24
0
            public async Task ReturnsReadmeWithRepositoryId()
            {
                string encodedContent = Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello world"));
                var    readmeInfo     = new ReadmeResponse(
                    encodedContent,
                    "README.md",
                    "https://github.example.com/readme",
                    "https://github.example.com/readme.md",
                    "base64");

                var gitHubClient  = Substitute.For <IGitHubClient>();
                var apiConnection = Substitute.For <IApiConnection>();

                apiConnection.GetHtml(new Uri(readmeInfo.Url)).Returns(Task.FromResult("<html>README</html>"));
                var readmeFake     = new Readme(readmeInfo, apiConnection);
                var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);

                gitHubClient.Repository.Content.GetReadme(1).Returns(Task.FromResult(readmeFake));

                IApiResponse <string> apiResponse = new ApiResponse <string>(new Response(), "<html>README</html>");

                gitHubClient.Connection.GetHtml(Args.Uri, null)
                .Returns(Task.FromResult(apiResponse));

                var readme = await contentsClient.GetReadme(1);

                Assert.Equal("README.md", readme.Name);

                gitHubClient.Repository.Content.Received(1).GetReadme(1);
                gitHubClient.Connection.DidNotReceive().GetHtml(Arg.Is <Uri>(u => u.ToString() == "https://github.example.com/readme"),
                                                                Args.EmptyDictionary);

                var htmlReadme = await readme.GetHtmlContent();

                Assert.Equal("<html>README</html>", htmlReadme);
                apiConnection.Received().GetHtml(Arg.Is <Uri>(u => u.ToString() == "https://github.example.com/readme.md"), null);
            }
Пример #25
0
        /// <summary>
        /// Checks if there's an XML with the list of files to install for the current mod, if present the list of files will be returned.
        /// </summary>
        protected List <KeyValuePair <string, string> > LoadXMLModFilesToInstall(string p_strPath)
        {
            string strModFilesPath = p_strPath;

            if (File.Exists(strModFilesPath))
            {
                XDocument docScripted = XDocument.Load(strModFilesPath);

                try
                {
                    XElement xelFileList = docScripted.Descendants("FileList").FirstOrDefault();
                    if ((xelFileList != null) && xelFileList.HasElements)
                    {
                        List <KeyValuePair <string, string> > dicFiles = new List <KeyValuePair <string, string> >();

                        foreach (XElement xelModFile in xelFileList.Elements("File"))
                        {
                            string strFileFrom = xelModFile.Attribute("FileFrom").Value;
                            string strFileTo   = xelModFile.Attribute("FileTo").Value;
                            if (!String.IsNullOrWhiteSpace(strFileFrom) && !Readme.IsValidExtension(Path.GetExtension(strFileFrom)))
                            {
                                dicFiles.Add(new KeyValuePair <string, string>(strFileFrom, strFileTo));
                            }
                        }

                        if (dicFiles.Count > 0)
                        {
                            return(dicFiles);
                        }
                    }
                }
                catch
                { }
            }

            return(null);
        }
Пример #26
0
        private void Readme_Click(object sender, RoutedEventArgs e)
        {
            Readme readme = new Readme();

            readme.Show();
        }
Пример #27
0
        /// <summary>
        /// The method that is called to start the backgound task.
        /// </summary>
        /// <remarks>
        /// This method installs all of the files in the <see cref="IMod"/> being installed.
        /// </remarks>
        /// <param name="args">Arguments to for the task execution.</param>
        /// <returns>A return value.</returns>
        protected override object DoWork(object[] args)
        {
            IModLinkInstaller ModLinkInstaller = VirtualModActivator.GetModLinkInstaller();

            char[] chrDirectorySeperators = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
            List <KeyValuePair <string, string> > lstFiles       = (FilesToInstall == null) ? Mod.GetFileList().Select(x => new KeyValuePair <string, string>(x, null)).ToList() : FilesToInstall;
            List <KeyValuePair <string, string> > lstFilesToLink = new List <KeyValuePair <string, string> >();

            OverallProgressMaximum = lstFiles.Count * 2;

            if (GameMode.RequiresSpecialFileInstallation && GameMode.IsSpecialFile(Mod.GetFileList()))
            {
                lstFiles = GameMode.SpecialFileInstall(Mod).Select(x => new KeyValuePair <string, string>(x, null)).ToList();
            }

            if (GameMode.RequiresModFileMerge)
            {
                GameMode.ModFileMerge(ActiveMods, Mod, false);
            }

            foreach (KeyValuePair <string, string> File in lstFiles)
            {
                string strFileTo = File.Value;
                if (string.IsNullOrWhiteSpace(strFileTo))
                {
                    strFileTo = File.Key;
                }


                if (Status == TaskStatus.Cancelling)
                {
                    return(false);
                }
                string strFixedPath = GameMode.GetModFormatAdjustedPath(Mod.Format, strFileTo, Mod, false);
                if (string.IsNullOrEmpty(strFixedPath))
                {
                    continue;
                }

                string strModFilenamePath   = Path.Combine(VirtualModActivator.VirtualPath, Path.GetFileNameWithoutExtension(Mod.Filename), GameMode.GetModFormatAdjustedPath(Mod.Format, strFileTo, true));
                string strModDownloadIDPath = (string.IsNullOrWhiteSpace(Mod.DownloadId) || (Mod.DownloadId.Length <= 1) || Mod.DownloadId.Equals("-1", StringComparison.OrdinalIgnoreCase)) ? string.Empty : Path.Combine(VirtualModActivator.VirtualPath, Mod.DownloadId, GameMode.GetModFormatAdjustedPath(Mod.Format, strFileTo, true));
                string strVirtualPath       = strModFilenamePath;

                if (!string.IsNullOrWhiteSpace(strModDownloadIDPath))
                {
                    strVirtualPath = strModDownloadIDPath;
                }

                string strLinkPath = string.Empty;
                if (VirtualModActivator.MultiHDMode)
                {
                    string strModFilenameLink   = Path.Combine(VirtualModActivator.HDLinkFolder, Path.GetFileNameWithoutExtension(Mod.Filename), GameMode.GetModFormatAdjustedPath(Mod.Format, strFileTo, true));
                    string strModDownloadIDLink = (string.IsNullOrWhiteSpace(Mod.DownloadId) || (Mod.DownloadId.Length <= 1) || Mod.DownloadId.Equals("-1", StringComparison.OrdinalIgnoreCase)) ? string.Empty : Path.Combine(VirtualModActivator.HDLinkFolder, Mod.DownloadId, GameMode.GetModFormatAdjustedPath(Mod.Format, strFileTo, true));
                    strLinkPath = strModFilenameLink;

                    if (!string.IsNullOrWhiteSpace(strModDownloadIDLink))
                    {
                        strLinkPath = strModDownloadIDLink;
                    }
                }

                string strFileType = Path.GetExtension(File.Key);
                if (!strFileType.StartsWith("."))
                {
                    strFileType = "." + strFileType;
                }
                bool booHardLinkFile = (VirtualModActivator.MultiHDMode && (GameMode.HardlinkRequiredFilesType(File.Key) || strFileType.Equals(".exe", StringComparison.InvariantCultureIgnoreCase) || strFileType.Equals(".jar", StringComparison.InvariantCultureIgnoreCase)));

                if (!string.IsNullOrEmpty(strFixedPath))
                {
                    if (!(GameMode.RequiresModFileMerge && (Path.GetFileName(File.Key) == GameMode.MergedFileName)))
                    {
                        if (!(SkipReadme && Readme.IsValidExtension(Path.GetExtension(File.Key).ToLower()) && Path.GetDirectoryName(strFixedPath).Equals(Path.GetFileName(GameMode.PluginDirectory), StringComparison.CurrentCultureIgnoreCase)))
                        {
                            FileInstaller.InstallFileFromMod(File.Key, ((booHardLinkFile) ? strLinkPath : strVirtualPath));
                            lstFilesToLink.Add(new KeyValuePair <string, string>(strFileTo, (booHardLinkFile) ? strLinkPath : strVirtualPath));
                        }
                    }
                }
                StepOverallProgress();
            }

            if ((lstFiles.Count > 0) && (lstFilesToLink.Count <= 0))
            {
                throw new InvalidDataException(string.Format("This mod does not have the correct file structure for a {0} mod that NMM can use. It will not work with NMM.", GameMode.Name));
            }

            foreach (KeyValuePair <string, string> strLink in lstFilesToLink)
            {
                if (!VirtualModActivator.DisableLinkCreation)
                {
                    string strFileLink = ModLinkInstaller.AddFileLink(Mod, strLink.Key, strLink.Value, false);

                    if (!string.IsNullOrEmpty(strFileLink))
                    {
                        ActivatePlugin(strFileLink);
                    }
                }
                StepOverallProgress();
            }

            VirtualModActivator.SaveList();
            return(true);
        }
Пример #28
0
 public ReadmeFixture()
 {
     Readme = new Readme(
         "../../../../../README.md"
         );
 }
Пример #29
0
 /// <summary>
 ///   A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_strFomodName">The value with which to initialize the <see cref="FomodName" /> property.</param>
 /// <param name="p_lstCopyInstructions">The value with which to initialize the <see cref="CopyInstructions" /> property.</param>
 /// <param name="p_lstSourceFiles">The value with which to initialize the <see cref="SourceFiles" /> property.</param>
 /// <param name="p_strCustomHowToSteps">Custom howto steps that should be included in the PFP HowTo.</param>
 /// <param name="p_rmeReadme">The value with which to initialize the <see cref="Readme" /> property.</param>
 /// <param name="p_xmlInfo">The value with which to initialize the <see cref="Info" /> property.</param>
 /// <param name="p_booSetScreenshot">The value with which to initialize the <see cref="SetScreenshot" /> property.</param>
 /// <param name="p_shtScreenshot">The value with which to initialize the <see cref="Screenshot" /> property.</param>
 /// <param name="p_fscScript">The value with which to initialize the <see cref="Script" /> property.</param>
 /// <param name="p_strPackedPath">The value with which to initialize the <see cref="PackedPath" /> property.</param>
 public BuildPFPArgs(string p_strFomodName, IList <KeyValuePair <string, string> > p_lstCopyInstructions,
                     IList <SourceFile> p_lstSourceFiles, string p_strCustomHowToSteps, Readme p_rmeReadme,
                     XmlDocument p_xmlInfo, bool p_booSetScreenshot, Screenshot p_shtScreenshot,
                     FomodScript p_fscScript, string p_strPackedPath)
     : base(
         p_strFomodName, p_lstCopyInstructions, p_rmeReadme, p_xmlInfo, p_booSetScreenshot, p_shtScreenshot,
         p_fscScript, p_strPackedPath)
 {
     SourceFiles      = p_lstSourceFiles;
     CustomHowToSteps = p_strCustomHowToSteps;
 }
Пример #30
0
    /// <summary>
    ///   If no readme has been entered, this method looks for a readme file in the selected
    ///   files, and, if one is found, uses it to populate the readme editor.
    /// </summary>
    protected void SetReadmeDefault()
    {
      if (redReadmeEditor.Readme == null)
      {
        List<KeyValuePair<string, string>> lstReadmes = null;
        foreach (var strExtension in Readme.ValidExtensions)
        {
          lstReadmes = ffsFileStructure.FindFomodFiles("readme - " + tbxFomodFileName.Text + strExtension);
          if (lstReadmes.Count > 0)
          {
            break;
          }
        }
        if (lstReadmes.Count == 0)
        {
          foreach (var strExtension in Readme.ValidExtensions)
          {
            lstReadmes = ffsFileStructure.FindFomodFiles("*readme*" + strExtension);
            if (lstReadmes.Count > 0)
            {
              break;
            }
          }
        }
        if (lstReadmes.Count == 0)
        {
          foreach (var strExtension in Readme.ValidExtensions)
          {
            lstReadmes = ffsFileStructure.FindFomodFiles("*" + strExtension);
            if (lstReadmes.Count > 0)
            {
              break;
            }
          }
        }

        Readme rmeReadme = null;
        foreach (var kvpReadme in lstReadmes)
        {
          if (Readme.IsValidReadme(kvpReadme.Key))
          {
            string strReadme = null;
            if (kvpReadme.Value.StartsWith(Archive.ARCHIVE_PREFIX))
            {
              var kvpArchiveInfo = Archive.ParseArchivePath(kvpReadme.Value);
              var arcArchive = new Archive(kvpArchiveInfo.Key);
              strReadme = TextUtil.ByteToString(arcArchive.GetFileContents(kvpArchiveInfo.Value));
            }
            else if (File.Exists(kvpReadme.Value))
            {
              strReadme = File.ReadAllText(kvpReadme.Value);
            }
            rmeReadme = new Readme(kvpReadme.Key, strReadme);
            break;
          }
        }
        redReadmeEditor.Readme = rmeReadme ?? new Readme(ReadmeFormat.PlainText, null);
      }
    }
Пример #31
0
 private void btnReadme_Click(object sender, EventArgs e)
 {
     MessageBox.Show(Readme.TextReader(), "Readme");
 }
Пример #32
0
        private void InitializeForm(bool forceRefresh)
        {
            int digitalGoodId = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]);

            _DigitalGood = DigitalGoodDataSource.Load(digitalGoodId);
            if (_DigitalGood == null)
            {
                Response.Redirect(CancelButton.NavigateUrl);
            }
            RenameFileExtensions.Text = AbleContext.Current.Store.Settings.FileExt_DigitalGoods;
            if (!Page.IsPostBack || forceRefresh)
            {
                Name.Text     = _DigitalGood.Name;
                FileName.Text = _DigitalGood.FileName;
                MediaKey.Text = _DigitalGood.MediaKey;
                ListItem item = ActivationMode.Items.FindByValue(_DigitalGood.ActivationModeId.ToString());
                if (item != null)
                {
                    item.Selected = true;
                }
                if (_DigitalGood.MaxDownloads > 0)
                {
                    MaxDownloads.Text = _DigitalGood.MaxDownloads.ToString();
                }
                int days, hours, minutes;
                DigitalGood.ParseTimeout(_DigitalGood.ActivationTimeout, out days, out hours, out minutes);
                if (days > 0)
                {
                    ActivationTimeoutDays.Text = days.ToString();
                }
                if (hours > 0)
                {
                    ActivationTimeoutHours.Text = hours.ToString();
                }
                if (minutes > 0)
                {
                    ActivationTimeoutMinutes.Text = minutes.ToString();
                }
                DigitalGood.ParseTimeout(_DigitalGood.DownloadTimeout, out days, out hours, out minutes);
                if (days > 0)
                {
                    DownloadTimeoutDays.Text = days.ToString();
                }
                if (hours > 0)
                {
                    DownloadTimeoutHours.Text = hours.ToString();
                }
                if (minutes > 0)
                {
                    DownloadTimeoutMinutes.Text = minutes.ToString();
                }
                //bind license agreements
                LicenseAgreement.DataSource = LicenseAgreementDataSource.LoadAll();
                LicenseAgreement.DataBind();
                item = LicenseAgreement.Items.FindByValue(_DigitalGood.LicenseAgreementId.ToString());
                if (item != null)
                {
                    LicenseAgreement.SelectedIndex = LicenseAgreement.Items.IndexOf(item);
                }
                item = LicenseAgreementMode.Items.FindByValue(_DigitalGood.LicenseAgreementModeId.ToString());
                if (item != null)
                {
                    LicenseAgreementMode.SelectedIndex = LicenseAgreementMode.Items.IndexOf(item);
                }

                // BIND GROUPs
                Groups.DataBind();
                Groups.ClearSelection();

                foreach (DigitalGoodGroup dgg in _DigitalGood.DigitalGoodGroups)
                {
                    item = Groups.Items.FindByValue(dgg.Group.Id.ToString());
                    if (item != null)
                    {
                        item.Selected = true;
                    }
                }

                //bind readmes
                Readme.DataSource = ReadmeDataSource.LoadAll();
                Readme.DataBind();
                item = Readme.Items.FindByValue(_DigitalGood.ReadmeId.ToString());
                if (item != null)
                {
                    Readme.SelectedIndex = Readme.Items.IndexOf(item);
                }
                EnableSerialKeys.Checked = _DigitalGood.EnableSerialKeys;

                // INITIALIZE SERIAL KEY PROVIDERS
                KeySource.Items.Clear();
                KeySource.Items.Add(new ListItem("Manual Entry", "0"));

                // ADD PROVIDERS
                IList <ISerialKeyProvider> providers = SerialKeyProviderDataSource.GetSerialKeyProviders();
                foreach (ISerialKeyProvider provider in providers)
                {
                    string   classId = Misc.GetClassId(provider.GetType());
                    ListItem providerItem;
                    // (BUG # 8347) ABLECOMMERCE DEFAULT KEY PROVIDER SHOULD BE NAMED AS "Managed List of Keys"
                    if (provider.GetType() == typeof(DefaultSerialKeyProvider))
                    {
                        providerItem = new ListItem("Managed List of Keys", classId);
                    }
                    else
                    {
                        providerItem = new ListItem(provider.Name, classId);
                    }
                    KeySource.Items.Add(providerItem);
                }
                //SELECT CORRECT PROVIDER
                if (_DigitalGood.SerialKeyProviderId != null)
                {
                    ListItem providerItem = KeySource.Items.FindByValue(_DigitalGood.SerialKeyProviderId);
                    if (providerItem != null)
                    {
                        KeySource.SelectedIndex = KeySource.Items.IndexOf(providerItem);
                    }
                }

                IList <EmailTemplate> templates = EmailTemplateDataSource.LoadAll();
                foreach (EmailTemplate template in templates)
                {
                    ListItem activationItem = new ListItem(template.Name, template.Id.ToString());
                    ListItem fulfillItem    = new ListItem(template.Name, template.Id.ToString());

                    if (_DigitalGood.ActivationEmailId == template.Id)
                    {
                        activationItem.Selected = true;
                    }

                    if (_DigitalGood.FulfillmentEmailId == template.Id)
                    {
                        fulfillItem.Selected = true;
                    }

                    ActivationEmailTemplateList.Items.Add(activationItem);
                    FulfillmentEmailTemplateList.Items.Add(fulfillItem);
                }

                if (_DigitalGood.FulfillmentMode == CommerceBuilder.DigitalDelivery.FulfillmentMode.Manual)
                {
                    FulfillmentMode.SelectedIndex = 0;
                }
                else if (_DigitalGood.FulfillmentMode == CommerceBuilder.DigitalDelivery.FulfillmentMode.OnOrder)
                {
                    FulfillmentMode.SelectedIndex = 1;
                }
                else
                {
                    FulfillmentMode.SelectedIndex = 2;
                }

                ToggleConfigureProvider();
            }
        }
Пример #33
0
        /// <summary>
        ///   This builds the fomod based on the given data.
        /// </summary>
        /// <remarks>
        ///   This method is called by a <see cref="BackgroundWorkerProgressDialog" />.
        /// </remarks>
        /// <param name="p_objArgs">A <see cref="BuildFomodArgs" /> describing the fomod to build.</param>
        protected override void DoGenerateFomod(object p_objArgs)
        {
            var bfaArgs = p_objArgs as BuildFomodArgs;

            if (bfaArgs == null)
            {
                throw new ArgumentException("The given argument must be a BuildFomodArgs.", "p_objArgs");
            }

            var strSource = bfaArgs.SourcePath;

            /**
             * 1) Unpack source, if required
             * 2) Delete unwanted files
             * 3) Remove extraneous top-level folders
             * 4) Create readme
             * 5) Create info file
             * 6) Pack fomod
             *
             * Total steps  = 1 + 1 + 1 + 1 + 1 + 1
             *        = 6
             */
            ProgressDialog.OverallProgressMaximum = 6;

            // 1) Unpack source, if required
            if (File.Exists(bfaArgs.SourcePath))
            {
                strSource = CreateTemporaryDirectory();
                UnpackArchive(bfaArgs.SourcePath, strSource);
                if (ProgressDialog.Cancelled())
                {
                    return;
                }
                ProgressDialog.StepOverallProgress();
            }

            // 2) Delete unwanted files
            DeleteUnwantedFiles(strSource);
            if (ProgressDialog.Cancelled())
            {
                return;
            }
            ProgressDialog.StepOverallProgress();

            // 3) Remove extraneous top-level folders
            strSource = DescendToFomodFolder(strSource);
            if (ProgressDialog.Cancelled())
            {
                return;
            }
            ProgressDialog.StepOverallProgress();

            //warn if script is required but missing
            if (Program.GetFiles(strSource, "*.esp", SearchOption.AllDirectories).Length +
                Program.GetFiles(strSource, "*.esm", SearchOption.AllDirectories).Length >
                Program.GetFiles(strSource, "*.esp", SearchOption.TopDirectoryOnly).Length +
                Program.GetFiles(strSource, "*.esm", SearchOption.TopDirectoryOnly).Length)
            {
                var booHasScript = false;
                foreach (var strScriptName in FomodScript.ScriptNames)
                {
                    if (File.Exists(Path.Combine(strSource, "fomod\\" + strScriptName)))
                    {
                        booHasScript = true;
                        break;
                    }
                }
                if (!booHasScript &&
                    (MessageBox.Show(
                         "This archive contains plugins in subdirectories, and will need a script attached for fomm to install it correctly.",
                         "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel))
                {
                    return;
                }
            }

            // 4) Create readme
            var strReadmes = Directory.GetFiles(strSource, "readme - " + bfaArgs.FomodName + ".*",
                                                SearchOption.TopDirectoryOnly);

            if (strReadmes.Length == 0)
            {
                strReadmes = Directory.GetFiles(strSource, "*readme*.*", SearchOption.AllDirectories);
                foreach (var strExtension in Readme.ValidExtensions)
                {
                    if (strReadmes.Length > 0)
                    {
                        break;
                    }
                    strReadmes = Program.GetFiles(strSource, "*" + strExtension, SearchOption.AllDirectories);
                }
                Readme rmeReadme = null;
                foreach (var strReadme in strReadmes)
                {
                    if (Readme.IsValidReadme(strReadme))
                    {
                        rmeReadme = new Readme(strReadme, File.ReadAllText(strReadme));
                        break;
                    }
                }
                CreateReadmeFile(strSource, bfaArgs.FomodName, rmeReadme);
            }
            if (ProgressDialog.Cancelled())
            {
                return;
            }
            ProgressDialog.StepOverallProgress();

            // 5) Create info.xml
            if (!String.IsNullOrEmpty(bfaArgs.Url))
            {
                var strFomodFomodPath = Path.Combine(strSource, "fomod");
                if (!Directory.Exists(strFomodFomodPath))
                {
                    Directory.CreateDirectory(strFomodFomodPath);
                }
                if (!File.Exists(Path.Combine(strFomodFomodPath, "info.xml")))
                {
                    var xmlInfo = new XmlDocument();
                    xmlInfo.AppendChild(xmlInfo.CreateXmlDeclaration("1.0", "UTF-16", null));
                    var xndRoot    = xmlInfo.AppendChild(xmlInfo.CreateElement("fomod"));
                    var xndWebsite = xndRoot.AppendChild(xmlInfo.CreateElement("Website"));
                    xndWebsite.InnerText = bfaArgs.Url;
                    CreateInfoFile(strFomodFomodPath, xmlInfo);
                }
            }
            if (ProgressDialog.Cancelled())
            {
                return;
            }
            ProgressDialog.StepOverallProgress();

            // 6) Pack fomod
            PackFomod(strSource, bfaArgs.PackedPath);
            ProgressDialog.StepOverallProgress();
        }
Пример #34
0
        public static List <AbleCommerce.Code.ProductAssetWrapper> GetAssets(Page page, Product product, string optionList, string kitList, string returnUrl)
        {
            // BUILD LIST OF ASSETS
            List <string> assetTracker = new List <string>();
            string        encodedReturnUrl;

            if (!string.IsNullOrEmpty(returnUrl))
            {
                encodedReturnUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(returnUrl));
            }
            else
            {
                encodedReturnUrl = string.Empty;
            }
            List <AbleCommerce.Code.ProductAssetWrapper> assetList = new List <AbleCommerce.Code.ProductAssetWrapper>();

            string agreeUrl    = page.ResolveUrl("~/ViewLicenseAgreement.aspx") + "?id={0}&ReturnUrl=" + encodedReturnUrl;
            string agreePopup  = agreeUrl + "\" onclick=\"" + AbleCommerce.Code.PageHelper.GetPopUpScript(agreeUrl, "license", 640, 480, "resizable=1,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no") + ";return false";
            string readmeUrl   = page.ResolveUrl("~/ViewReadme.aspx") + "?ReadmeId={0}&ReturnUrl=" + encodedReturnUrl;
            string readmePopup = readmeUrl + "\" onclick=\"" + AbleCommerce.Code.PageHelper.GetPopUpScript(readmeUrl, "readme", 640, 480, "resizable=1,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no") + ";return false";

            List <ProductAndOptionList> products = new List <ProductAndOptionList>();

            products.Add(new ProductAndOptionList(product, optionList));

            // IF IT IS A KIT LOOK FOR CHILD PRODUCTS AS WELL
            if (!String.IsNullOrEmpty(kitList))
            {
                if (product.IsKit)
                {
                    bool  kitIsBundled  = !product.Kit.ItemizeDisplay;
                    int[] kitProductIds = AlwaysConvert.ToIntArray(kitList);
                    if (kitProductIds != null && kitProductIds.Length > 0)
                    {
                        foreach (int kitProductId in kitProductIds)
                        {
                            KitProduct kitProduct = KitProductDataSource.Load(kitProductId);
                            if ((kitProduct != null) &&
                                (kitProduct.KitComponent.InputType == KitInputType.IncludedHidden || kitIsBundled))
                            {
                                products.Add(new ProductAndOptionList(kitProduct.Product, kitProduct.OptionList));
                            }
                        }
                    }
                }
            }

            foreach (ProductAndOptionList pol in products)
            {
                foreach (ProductDigitalGood pdg in pol.Product.DigitalGoods)
                {
                    if ((string.IsNullOrEmpty(pdg.OptionList)) || (pol.OptionList == pdg.OptionList))
                    {
                        DigitalGood digitalGood = pdg.DigitalGood;
                        Readme      readme      = digitalGood.Readme;
                        if (readme != null && assetTracker.IndexOf("R" + readme.Id.ToString()) < 0)
                        {
                            assetList.Add(new AbleCommerce.Code.ProductAssetWrapper(string.Format(readmePopup, readme.Id), readme.DisplayName));
                            assetTracker.Add("R" + readme.Id.ToString());
                        }
                        LicenseAgreement agreement = digitalGood.LicenseAgreement;
                        if (agreement != null && assetTracker.IndexOf("L" + agreement.Id.ToString()) < 0)
                        {
                            assetList.Add(new AbleCommerce.Code.ProductAssetWrapper(string.Format(agreePopup, agreement.Id), agreement.DisplayName));
                            assetTracker.Add("L" + agreement.Id.ToString());
                        }
                    }
                }
            }
            return(assetList);
        }
Пример #35
0
    /// <summary>
    ///   This builds the fomod based on the given data.
    /// </summary>
    /// <remarks>
    ///   This method is called by a <see cref="BackgroundWorkerProgressDialog" />.
    /// </remarks>
    /// <param name="p_objArgs">A <see cref="BuildFomodArgs" /> describing the fomod to build.</param>
    protected override void DoGenerateFomod(object p_objArgs)
    {
      var bfaArgs = p_objArgs as BuildFomodArgs;
      if (bfaArgs == null)
      {
        throw new ArgumentException("The given argument must be a BuildFomodArgs.", "p_objArgs");
      }

      var strSource = bfaArgs.SourcePath;

      /**
       * 1) Unpack source, if required
       * 2) Delete unwanted files
       * 3) Remove extraneous top-level folders
       * 4) Create readme
       * 5) Create info file
       * 6) Pack fomod
       * 
       * Total steps  = 1 + 1 + 1 + 1 + 1 + 1
       *        = 6
       */
      ProgressDialog.OverallProgressMaximum = 6;

      // 1) Unpack source, if required
      if (File.Exists(bfaArgs.SourcePath))
      {
        strSource = CreateTemporaryDirectory();
        UnpackArchive(bfaArgs.SourcePath, strSource);
        if (ProgressDialog.Cancelled())
        {
          return;
        }
        ProgressDialog.StepOverallProgress();
      }

      // 2) Delete unwanted files
      DeleteUnwantedFiles(strSource);
      if (ProgressDialog.Cancelled())
      {
        return;
      }
      ProgressDialog.StepOverallProgress();

      // 3) Remove extraneous top-level folders
      strSource = DescendToFomodFolder(strSource);
      if (ProgressDialog.Cancelled())
      {
        return;
      }
      ProgressDialog.StepOverallProgress();

      //warn if script is required but missing
      if (Program.GetFiles(strSource, "*.esp", SearchOption.AllDirectories).Length +
          Program.GetFiles(strSource, "*.esm", SearchOption.AllDirectories).Length >
          Program.GetFiles(strSource, "*.esp", SearchOption.TopDirectoryOnly).Length +
          Program.GetFiles(strSource, "*.esm", SearchOption.TopDirectoryOnly).Length)
      {
        var booHasScript = false;
        foreach (var strScriptName in FomodScript.ScriptNames)
        {
          if (File.Exists(Path.Combine(strSource, "fomod\\" + strScriptName)))
          {
            booHasScript = true;
            break;
          }
        }
        if (!booHasScript &&
            (MessageBox.Show(
              "This archive contains plugins in subdirectories, and will need a script attached for fomm to install it correctly.",
              "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel))
        {
          return;
        }
      }

      // 4) Create readme
      var strReadmes = Directory.GetFiles(strSource, "readme - " + bfaArgs.FomodName + ".*",
                                          SearchOption.TopDirectoryOnly);
      if (strReadmes.Length == 0)
      {
        strReadmes = Directory.GetFiles(strSource, "*readme*.*", SearchOption.AllDirectories);
        foreach (var strExtension in Readme.ValidExtensions)
        {
          if (strReadmes.Length > 0)
          {
            break;
          }
          strReadmes = Program.GetFiles(strSource, "*" + strExtension, SearchOption.AllDirectories);
        }
        Readme rmeReadme = null;
        foreach (var strReadme in strReadmes)
        {
          if (Readme.IsValidReadme(strReadme))
          {
            rmeReadme = new Readme(strReadme, File.ReadAllText(strReadme));
            break;
          }
        }
        CreateReadmeFile(strSource, bfaArgs.FomodName, rmeReadme);
      }
      if (ProgressDialog.Cancelled())
      {
        return;
      }
      ProgressDialog.StepOverallProgress();

      // 5) Create info.xml
      if (!String.IsNullOrEmpty(bfaArgs.Url))
      {
        var strFomodFomodPath = Path.Combine(strSource, "fomod");
        if (!Directory.Exists(strFomodFomodPath))
        {
          Directory.CreateDirectory(strFomodFomodPath);
        }
        if (!File.Exists(Path.Combine(strFomodFomodPath, "info.xml")))
        {
          var xmlInfo = new XmlDocument();
          xmlInfo.AppendChild(xmlInfo.CreateXmlDeclaration("1.0", "UTF-16", null));
          var xndRoot = xmlInfo.AppendChild(xmlInfo.CreateElement("fomod"));
          var xndWebsite = xndRoot.AppendChild(xmlInfo.CreateElement("Website"));
          xndWebsite.InnerText = bfaArgs.Url;
          CreateInfoFile(strFomodFomodPath, xmlInfo);
        }
      }
      if (ProgressDialog.Cancelled())
      {
        return;
      }
      ProgressDialog.StepOverallProgress();

      // 6) Pack fomod
      PackFomod(strSource, bfaArgs.PackedPath);
      ProgressDialog.StepOverallProgress();
    }
Пример #36
0
        public static async Task <global::Lucene.Net.Documents.Document> AddReadMeAsync(this global::Lucene.Net.Documents.Document document, Readme readme)
        {
            if (readme?.Content != null)
            {
                document.AddStoredField(OctokitLuceneUtils.ReadmeFileNameField, readme.Name);
                document.AddTextField(OctokitLuceneUtils.ReadmeField, readme.Content, Field.Store.NO);
                document.AddStoredField(OctokitLuceneUtils.ReadmeHtmlField, (await readme.GetHtmlContent()) ?? readme.Content);
            }

            return(document);
        }
Пример #37
0
 /// <summary>
 ///   This creates a readme file in the specified folder using the given <see cref="Readme" />
 ///   metadata.
 /// </summary>
 /// <param name="p_strFomodFomodFolder">The folder in which to create the readme file.</param>
 /// <param name="p_rmeReadme">The metadata to use to create the file.</param>
 protected void CreateReadmeFile(string p_strFomodFolder, string p_strFomodName, Readme p_rmeReadme)
 {
   ProgressDialog.ItemProgress = 0;
   ProgressDialog.ItemProgressMaximum = 1;
   ProgressDialog.ItemProgressStep = 1;
   ProgressDialog.ItemMessage = String.Format("Creating Readme File...");
   if ((p_rmeReadme != null) && !String.IsNullOrEmpty(p_rmeReadme.Text))
   {
     var strReadmeFileName = String.Format("Readme - {0}{1}", p_strFomodName, p_rmeReadme.Extension);
     if (Settings.Default.UseDocsFolder)
     {
       strReadmeFileName = Path.Combine("docs", strReadmeFileName);
     }
     File.WriteAllText(Path.Combine(p_strFomodFolder, strReadmeFileName), p_rmeReadme.Text);
   }
   ProgressDialog.StepItemProgress();
 }
Пример #38
0
 /// <summary>
 /// A simple constructor that initializes the object with the required dependencies.
 /// </summary>
 /// <param name="p_strScriptTypeRegistry">The <see cref="IScriptTypeRegistry"/> contianing the list of available script types.</param>
 public Project(IScriptTypeRegistry p_strScriptTypeRegistry)
 {
     m_setFiles         = new ThreadSafeObservableList <VirtualFileSystemItem>();
     ModReadme          = new Readme(ReadmeFormat.PlainText, null);
     ScriptTypeRegistry = p_strScriptTypeRegistry;
 }