private string GetProductList()
        {
            var templateManager = new TemplateManager();
            string itemText = string.Empty;

            var cultureInfo = Thread.CurrentThread.CurrentCulture;
            var textInfo = cultureInfo.TextInfo;

            foreach (var package in Packages)
            {
                if (package.Repository.ToLower() == "argos-sdk")
                    continue;

                string module = package.Repository.Replace("argos-", "");
                module = textInfo.ToTitleCase(module);
                module = module.Replace("Saleslogix", "SalesLogix");

                string filePrefix = "-" + module.ToLower();
                if (filePrefix == "-saleslogix") filePrefix = "";

                var replacements = new List<StringReplacement>();
                replacements.Add(new StringReplacement { Pattern = "$PRODUCTNAME$", Value = module });
                replacements.Add(new StringReplacement { Pattern = "$PRODUCTNAMEFILE$", Value = filePrefix });

                itemText += templateManager.GetTemplate(IndexItemFileResource, replacements);
            }

            return itemText;
        }
        public void CreateIndex(string FilePath)
        {
            var templateManager = new TemplateManager();

            var replacements = new List<StringReplacement>();
            replacements.Add(new StringReplacement { Pattern = "<!--$PRODUCTLIST$-->", Value = GetProductList() });

            string indexText = templateManager.GetTemplate(IndexFileResource, replacements);

            using (var writer = new StreamWriter(Path.Combine(FilePath, "index.html")))
            {
                writer.Write(indexText);
            }
        }
        private string GetProductList()
        {
            var    templateManager = new TemplateManager();
            string itemText        = string.Empty;

            var cultureInfo = Thread.CurrentThread.CurrentCulture;
            var textInfo    = cultureInfo.TextInfo;

            foreach (var package in Packages)
            {
                if (package.Repository.ToLower() == "argos-sdk")
                {
                    continue;
                }

                string module = package.Repository.Replace("argos-", "");
                module = textInfo.ToTitleCase(module);
                module = module.Replace("Saleslogix", "SalesLogix");

                string filePrefix = "-" + module.ToLower();
                if (filePrefix == "-saleslogix")
                {
                    filePrefix = "";
                }

                var replacements = new List <StringReplacement>();
                replacements.Add(new StringReplacement {
                    Pattern = "$PRODUCTNAME$", Value = module
                });
                replacements.Add(new StringReplacement {
                    Pattern = "$PRODUCTNAMEFILE$", Value = filePrefix
                });

                itemText += templateManager.GetTemplate(IndexItemFileResource, replacements);
            }

            return(itemText);
        }
Exemplo n.º 4
0
        public void Create(string ProductName)
        {
            string version       = GetTemplateVersion();
            string baseNamespace = "FX.Mobile.DeveloperTools.Templates" + "." + version + ".";

            var template      = new TemplateManager();
            var templateFiles = template.GetTemplateList();

            int total = 0;
            int count = 1;

            foreach (var templateFile in templateFiles)
            {
                if (templateFile.StartsWith(baseNamespace))
                {
                    total++;
                }
            }

            if (ProductCreateInitializing != null)
            {
                ProductCreateInitializing(this, new ProductCreateEventArgs {
                    Count = 0, CurrentFile = string.Empty, Total = total
                });
            }

            var replacements = new List <StringReplacement>();

            replacements.Add(new StringReplacement {
                Pattern = "[MODULE:Custom]", Value = ProductName
            });
            replacements.Add(new StringReplacement {
                Pattern = "[MODULE-LC:Custom]", Value = ProductName.ToLower()
            });

            foreach (var templateFile in templateFiles)
            {
                if (templateFile.StartsWith(baseNamespace))
                {
                    var fileContents = template.GetTemplate(templateFile, replacements);
                    var fileName     = templateFile.Replace(baseNamespace, "");

                    var filePath = Path.Combine(MobilePath, @"products\");
                    if (!Directory.Exists(filePath))
                    {
                        Directory.CreateDirectory(filePath);
                    }

                    filePath = Path.Combine(filePath, "argos-" + ProductName.ToLower());
                    if (!Directory.Exists(filePath))
                    {
                        Directory.CreateDirectory(filePath);
                    }

                    //check if sub directory
                    var parts = fileName.Split('.');
                    if (parts.Length > 2)
                    {
                        for (int i = 0; i < parts.Length - 2; i++)
                        {
                            filePath = Path.Combine(filePath, parts[i]);
                            if (!Directory.Exists(filePath))
                            {
                                Directory.CreateDirectory(filePath);
                            }

                            fileName = fileName.Replace(parts[i] + ".", "");
                        }
                    }

                    if (fileName == "build-custom.cmd")
                    {
                        fileName = fileName.Replace("custom", ProductName.ToLower());
                        filePath = MobilePath;
                    }
                    if (fileName == "index-dev-custom.html")
                    {
                        fileName = fileName.Replace("custom", ProductName.ToLower());
                        filePath = Path.Combine(MobilePath, @"products\argos-saleslogix\");
                        if (!Directory.Exists(filePath))
                        {
                            Directory.CreateDirectory(filePath);
                        }
                    }

                    if (ProductCreateProgress != null)
                    {
                        ProductCreateProgress(this, new ProductCreateEventArgs {
                            Count = count, CurrentFile = fileName, Total = total
                        });
                    }

                    count++;

                    using (var writer = new StreamWriter(Path.Combine(filePath, fileName)))
                    {
                        writer.Write(fileContents);
                    }
                }
            }

            Program.Path = MobilePath;
            CreateIndexFile();

            if (ProductCreateComplete != null)
            {
                ProductCreateComplete(this, new ProductCreateEventArgs {
                    Count = count, CurrentFile = string.Empty, Total = total
                });
            }
        }
        public void Create(string ProductName)
        {
            string version = GetTemplateVersion();
            string baseNamespace = "FX.Mobile.DeveloperTools.Templates" + "." + version + ".";

            var template = new TemplateManager();
            var templateFiles = template.GetTemplateList();

            int total = 0;
            int count = 1;
            foreach (var templateFile in templateFiles)
            {
                if (templateFile.StartsWith(baseNamespace))
                    total++;
            }

            if (ProductCreateInitializing != null)
                ProductCreateInitializing(this, new ProductCreateEventArgs { Count = 0, CurrentFile = string.Empty, Total = total });

            var replacements = new List<StringReplacement>();
            replacements.Add(new StringReplacement { Pattern = "[MODULE:Custom]", Value = ProductName });
            replacements.Add(new StringReplacement { Pattern = "[MODULE-LC:Custom]", Value = ProductName.ToLower() });

            foreach (var templateFile in templateFiles)
            {
                if (templateFile.StartsWith(baseNamespace))
                {
                    var fileContents = template.GetTemplate(templateFile, replacements);
                    var fileName = templateFile.Replace(baseNamespace, "");

                    var filePath = Path.Combine(MobilePath, @"products\");
                    if (!Directory.Exists(filePath))
                        Directory.CreateDirectory(filePath);

                    filePath = Path.Combine(filePath, "argos-" + ProductName.ToLower());
                    if (!Directory.Exists(filePath))
                        Directory.CreateDirectory(filePath);

                    //check if sub directory
                    var parts = fileName.Split('.');
                    if (parts.Length > 2)
                    {
                        for (int i = 0; i < parts.Length - 2; i++)
                        {
                            filePath = Path.Combine(filePath, parts[i]);
                            if (!Directory.Exists(filePath))
                                Directory.CreateDirectory(filePath);

                            fileName = fileName.Replace(parts[i] + ".", "");
                        }
                    }

                    if (fileName == "build-custom.cmd")
                    {
                        fileName = fileName.Replace("custom", ProductName.ToLower());
                        filePath = MobilePath;
                    }
                    if (fileName == "index-dev-custom.html")
                    {
                        fileName = fileName.Replace("custom", ProductName.ToLower());
                        filePath = Path.Combine(MobilePath, @"products\argos-saleslogix\");
                        if (!Directory.Exists(filePath))
                            Directory.CreateDirectory(filePath);
                    }

                    if (ProductCreateProgress != null)
                        ProductCreateProgress(this, new ProductCreateEventArgs { Count = count, CurrentFile = fileName, Total = total });

                    count++;

                    using (var writer = new StreamWriter(Path.Combine(filePath, fileName)))
                    {
                        writer.Write(fileContents);
                    }
                }
            }

            Program.Path = MobilePath;
            CreateIndexFile();

            if (ProductCreateComplete != null)
                ProductCreateComplete(this, new ProductCreateEventArgs { Count = count, CurrentFile = string.Empty, Total = total });
        }