private void WriteWebConfig(WebSite webSite, string nikosOneServiceUrl, string nikosOneFileServiceUrl)
        {
            var path = Path.Combine(webSite.PhysicalPath, "web.config");
            var doc  = XDocument.Load(path);

            foreach (var e in doc.Root.Element("nikos").Elements("data"))
            {
                var e2 = e.Element("SERVICEBASE");
                if (e2 != null)
                {
                    e2.Value = nikosOneServiceUrl;
                }

                e2 = e.Element("FILESERVICEBASE");
                if (e2 != null)
                {
                    e2.Value = nikosOneFileServiceUrl;
                }

                UpdateStoreConnectionString(e);
            }
            doc.Save(path);
        }
        public static bool Deserialize(Root root)
        {
            var dir  = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            var path = Path.Combine(dir, "Granikos\\NikosOne\\installerstate.xml");

            if (!File.Exists(path))
            {
                return(false);
            }

            try
            {
                var doc = XDocument.Load(path);
                var e0  = doc.Root;

                if (e0 == null)
                {
                    return(false);
                }

                e0.ReadAttribute("currentStep", a => root.CurrentStep         = root.Steps[(int)a]);
                e0.ReadAttribute("useIisExpress", a => root.UseIisExpress     = (bool)a);
                e0.ReadAttribute("rebootArguments", a => root.RebootArguments = (string)a);

                var e1 = e0.Element("connectionString");
                if (e1 != null)
                {
                    var cs = root.ConnectionString;
                    e1.ReadAttribute("server", a => cs.Server     = (string)a);
                    e1.ReadAttribute("database", a => cs.Database = (string)a);
                    e1.ReadAttribute("userName", a => cs.UserName = (string)a);
                    e1.ReadAttribute("password", a => cs.Password = (string)a);
                    e1.ReadAttribute("isIntegratedAuthentication", a => cs.IsIntegratedAuthentication = (bool)a);
                }

                e1 = e0.Element("tasks");
                if (e1 != null)
                {
                    foreach (var e2 in e1.Elements("task"))
                    {
                        InstallerTask task = null;
                        e2.ReadAttribute("index", a => task = root.Tasks[(int)a]);
                        if (task == null)
                        {
                            continue;
                        }
                        e2.ReadAttribute("isEnabled", a => task.IsEnabled   = (bool)a);
                        e2.ReadAttribute("isSkipped", a => task.IsCancelled = (bool)a);
                        e2.ReadAttribute("isSelected", a => task.IsSelected = (bool)a);
                        e2.ReadAttribute("text", a => task.Text             = (string)a);
                        e2.ReadAttribute("progress", a => task.Progress     = (double)a);
                        e2.ReadAttribute("isError", a => task.IsError       = (bool)a);
                        e2.ReadAttribute("isSuccess", a => task.IsSuccess   = (bool)a);
                        e2.ReadAttribute("isRunning", a => task.IsRunning   = (bool)a);
                    }
                }

                e1 = e0.Element("webSites");
                if (e1 == null)
                {
                    return(true);
                }

                foreach (var e2 in e1.Elements("webSite"))
                {
                    var webSite = new WebSite();
                    e2.ReadAttribute("name", a => webSite.Name = (string)a);
                    if (root.InstalledWebSites.ContainsKey(webSite.ProductId))
                    {
                        continue;
                    }

                    e2.ReadAttribute("physicalPath", a => webSite.PhysicalPath = (string)a);
                    e2.ReadAttribute("productId", a => webSite.ProductId       = (string)a);
                    e2.ReadAttribute("siteName", a => webSite.SiteName         = (string)a);
                    e2.ReadAttribute("url", a => webSite.Url = (string)a);

                    root.InstalledWebSites.Add(webSite.ProductId, webSite);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Log.Error(ex);

                return(false);
            }
            finally
            {
                try
                {
                    File.Delete(path);
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }
            }
        }