Esempio n. 1
0
        private void DoRegenerateSync(XmlNode config)
        {
            var syncResult = GetSyncResult();

            if (syncResult.AreTemplatesSynchronized)
            {
                return;
            }

            if (!syncResult.AreTemplatesSynchronized)
            {
                foreach (var template in syncResult)
                {
                    if (!template.IsSynchronized)
                    {
                        Log.Warn("Synthesis template desynchronization: " + template, this);
                    }
                }
            }

            var projectPathNode = config.SelectSingleNode("setting[@name='StartupRegenerateProjectPath']");

            if (projectPathNode == null || projectPathNode.Attributes["value"] == null)
            {
                throw new InvalidOperationException("The StartupRegenerateProjectPath setting must be specified when Synthesis Sync StartupCheckMode is set to Regenerate");
            }

            var projectPathValue = projectPathNode.Attributes["value"].InnerText;

            if (projectPathValue == "auto")
            {
                projectPathValue = ResolveAutoProjectPath();

                if (projectPathValue == null)
                {
                    throw new InvalidOperationException("Unable to automatically find a valid project file to build. I looked at sibling and parent folders to the concrete file output path for *proj.");
                }
            }

            if (!File.Exists(projectPathValue))
            {
                throw new InvalidOperationException("The auto-rebuild project file \"" + projectPathValue + "\" did not exist.");
            }

            ProviderResolver.CreateGenerator().GenerateToDisk();

            var outputLogPath = Path.GetDirectoryName(projectPathValue) + Path.DirectorySeparatorChar + "synthesis-autobuild.log";

            if (!BuildUtility.BuildProject(projectPathValue, "Release", outputLogPath))
            {
                Log.Error("Synthesis automatic project build on " + projectPathValue + " failed! Review the build log at " + outputLogPath + " to find out what happened.", this);
            }

            Log.Info("Synthesis detected templates were not synchronized and attempted to automatically rebuild " + projectPathValue + " to correct the problem.", this);
        }
Esempio n. 2
0
        private static void DoOnDemandRegenerate(HttpContext context)
        {
            var timer = new Stopwatch();

            timer.Start();
            ProviderResolver.Current.TemplateInputProvider.Refresh();
            ProviderResolver.CreateGenerator().GenerateToDisk();
            timer.Stop();

            string result = string.Format("<p>Generation complete in {0} ms. You will want to rebuild to pick up the changes.</p>", timer.ElapsedMilliseconds);

            context.Response.Write(WrapReport("Regenerating Model", result));

            context.Response.End();
        }