Beispiel #1
0
        private string GetFiles()
        {
            var tempPath = ConfigDirectoryPath;

            if (Directory.Exists(tempPath))
            {
                Directory.Delete(tempPath, true);
            }

            Directory.CreateDirectory(tempPath);

            var service = new CompanyServiceClient();
            var stream  = service.GetCompanyFiles(Company.Id, "assets");
            var zipFile = Path.Combine(tempPath, "out.zip");

            using (Stream file = File.OpenWrite(zipFile))
            {
                CopyStream(stream, file);
            }

            using (var unzip = new Unzip(zipFile))
            {
                unzip.ExtractToDirectory(tempPath);
            }

            File.Delete(zipFile);


            CreateConfigFile(Path.Combine(tempPath, "settings.json"), s => s.IsClientSetting);
            CreateConfigFile(Path.Combine(tempPath, "allSettings.json"), s => true);

            return(tempPath);
        }
        private void DeployTheme(string companyId, string companyName, string targetWeDirectory)
        {
            try
            {
                var themeFolder = Path.Combine(targetWeDirectory, @"themes\" + companyName);
                Log("Checking if default theme exist : " + themeFolder);
                if (!Directory.Exists(themeFolder))
                {
                    Log("Copying default theme");
                    var defaultThemeFolder = Path.Combine(targetWeDirectory, @"themes\TaxiHail");
                    DirectoryCopy(defaultThemeFolder, themeFolder, true);
                }

                Log("Getting web theme from cutsomer portal");
                var service = new CompanyServiceClient();

                using (var zip = new ZipArchive(service.GetCompanyFiles(companyId, "webtheme")))
                {
                    foreach (var entry in zip.Entries)
                    {
                        Log("Theme file : " + entry.Name);
                        if (entry.FullName.EndsWith(".less", StringComparison.OrdinalIgnoreCase))
                        {
                            entry.ExtractToFile(Path.Combine(themeFolder + "\\less", entry.Name), true);
                        }

                        if (entry.FullName.EndsWith(".json", StringComparison.OrdinalIgnoreCase))
                        {
                            entry.ExtractToFile(Path.Combine(themeFolder + "\\localization", entry.Name), true);
                        }

                        if (entry.FullName.EndsWith(".handlebars", StringComparison.OrdinalIgnoreCase))
                        {
                            entry.ExtractToFile(Path.Combine(themeFolder + "\\templates", entry.Name), true);
                        }

                        if (entry.FullName.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
                        {
                            entry.ExtractToFile(Path.Combine(themeFolder + "\\img", entry.Name), true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log("Warning, cannot copy theme : " + ex.Message);
            }
        }