Exemple #1
0
        internal static int Run(System.Web.UI.Page caller)
        {
            var runOnceMarkerPath = caller.MapPath("/" + RunOnceGuid);

            if (!IO.File.Exists(runOnceMarkerPath))
            {
                return(0);
            }
            var runningMarkerPath = caller.MapPath("/779B94A7-7204-45b4-830F-10CC5B5BC0F2");

            lock (_locker)
            {
                if (IO.File.Exists(runningMarkerPath))
                {
                    return(2);
                }
                IO.File.Create(runningMarkerPath).Close();
            }

            var ctdPath       = caller.MapPath("/Root/System/Schema/ContentTypes");
            var sourcePath    = caller.MapPath("/Root");
            var targetPath    = "/Root";
            var asmPath       = caller.MapPath("/bin");
            var logPath       = caller.MapPath("/install.log");
            var scriptsPath   = caller.MapPath("/Scripts");
            var installerUser = HttpContext.Current.Application["SNInstallUser"] as string;

            try
            {
                CreateLog(logPath);
                LoadAssemblies(asmPath);
            }
            catch (Exception e)
            {
                Logger.WriteException(e);

                LogWriteLine();
                LogWriteLine("========================================");
                LogWriteLine("Import ends with error:");
                PrintException(e);

                ImportError = e.Message;
                return(2);
            }

            TotalCount = Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories).Length;

            var runOnce        = new RunOnce();
            var importDelegate = new ImportDelegate(runOnce.Import);

            importDelegate.BeginInvoke(ctdPath, sourcePath, targetPath, asmPath, runOnceMarkerPath, runningMarkerPath, scriptsPath, logPath, installerUser, null, null);
            return(1);
        }
Exemple #2
0
        internal static int Run(System.Web.UI.Page caller)
        {
            var runOnceMarkerPath = caller.MapPath("/" + RunOnceGuid);
            if (!IO.File.Exists(runOnceMarkerPath))
            {
                return 0;
            }
            var runningMarkerPath = caller.MapPath("/779B94A7-7204-45b4-830F-10CC5B5BC0F2");
            lock (_locker)
            {
                if (IO.File.Exists(runningMarkerPath))
                    return 2;
                IO.File.Create(runningMarkerPath).Close();
            }

            var ctdPath = caller.MapPath("/Root/System/Schema/ContentTypes");
            var sourcePath = caller.MapPath("/Root");
            var targetPath = "/Root";
            var asmPath = caller.MapPath("/bin");
            var logPath = caller.MapPath("/install.log");
            var scriptsPath = caller.MapPath("/Scripts");
            var installerUser = HttpContext.Current.Application["SNInstallUser"] as string;

            try
            {
                CreateLog(logPath);
                LoadAssemblies(asmPath);
            }
            catch (Exception e)
            {
                Logger.WriteException(e);

                LogWriteLine();
                LogWriteLine("========================================");
                LogWriteLine("Import ends with error:");
                PrintException(e);

                ImportError = e.Message;
                return 2;
            }

            TotalCount = Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories).Length;

            var runOnce = new RunOnce();
            var importDelegate = new ImportDelegate(runOnce.Import);
            importDelegate.BeginInvoke(ctdPath, sourcePath, targetPath, asmPath, runOnceMarkerPath, runningMarkerPath, scriptsPath, logPath, installerUser, null, null);
            return 1;
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!PortalContext.IsWebSiteRoot)
            {
                //installing Sense/Net to a virtual folder is
                //not allowed currently. If the software is not
                //in the root of a website than present an info page.

                if (InstallPanel != null)
                {
                    InstallPanel.Visible = false;
                }
                if (AppNameErrorPanel != null)
                {
                    AppNameErrorPanel.Visible = true;
                }

                return;
            }

            if (!this.IsPostBack)
            {
                _runOnceState = RunOnce.Run(this);

                if (_runOnceState == 0)
                {
                    var ctx = PortalContext.Current;
                    if (PortalContext.Current.Site != null)
                    {
                        Response.Redirect("/", true);
                    }
                    else
                    {
                        RegisterHost();
                        Response.Redirect(HttpContext.Current.Request.Url.ToString());
                    }
                }
            }
        }
Exemple #4
0
        protected void Timer_OnTick(object sender, EventArgs e)
        {
            _runOnceState = RunOnce.Run(this);

            if (_runOnceState != 0)
            {
                string imgUrl       = imgMain.ImageUrl;
                int    currentIndex = -1;
                int    maxPictures  = GetMaxPictures();

                string currentChar = imgUrl.Substring(imgUrl.Length - 5, 1);
                if (int.TryParse(currentChar, out currentIndex))
                {
                    currentIndex++;
                }

                if (currentIndex < 0 || currentIndex > maxPictures)
                {
                    currentIndex = 0;
                }

                imgMain.ImageUrl = string.Format("Install/pic{0}.png", currentIndex);

                if (string.IsNullOrEmpty(RunOnce.ImportError) && RunOnce.TotalCount > 0)
                {
                    //max value is 99% not 100%, because we need to run index
                    //population after importing all the contents...
                    var percentFull  = Math.Min(Math.Max((RunOnce.ImportedCount * 1.0 / RunOnce.TotalCount) * 100, 1.15), 99);
                    var perCentRound = Math.Min(Math.Max(Convert.ToInt32(Math.Round(percentFull)), 1), 99);

                    labelProgressPercent.Text = percentFull.ToString("0.00") + "%";
                    panelBar.Width            = new Unit(string.Format("{0}%", perCentRound));
                }
                else
                {
                    ErrorPanel.Visible     = true;
                    plcProgressBar.Visible = false;

                    labelError.Text   = RunOnce.ImportError ?? "unknown error";
                    timerMain.Enabled = false;
                }

                updSensenetFooter.Update();
            }
            else
            {
                plcProgressBar.Visible = false;

                imgMain.ImageUrl    = "Install/picLast.png";
                imgMessage.ImageUrl = "Install/installer-portlet-caption-text-2.png";
                finish.Visible      = true;
                timerMain.Enabled   = false;

                // wait 1 sec and then redirect to cleanup.aspx -> this way 'Congratulations' picture is shown before being deleted
                var redirectScript = "setTimeout('window.location = \"/Cleanup.aspx\";', 1000)";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "RedirectToCleanup", redirectScript, true);

                updSensenetFooter.Update();

                //HACK: Reset the pinned object: User.Visitor
                SenseNet.ContentRepository.DistributedApplication.Cache.Reset();
                SenseNet.ContentRepository.User.Reset();
            }
        }