private void ChangeWebsiteSettingsIfNeeded(string path, ImportArgs args)
    {
      XmlDocumentEx websiteSettings = new XmlDocumentEx();
      websiteSettings.Load(path);
      args.siteName = this.CreateNewSiteName(InstanceManager.Instances, args.siteName);
      websiteSettings.SetElementAttributeValue("/appcmd/SITE", "SITE.NAME", args.siteName);
      websiteSettings.SetElementAttributeValue("/appcmd/SITE/site", "name", args.siteName);

      websiteSettings.SetElementAttributeValue("/appcmd/SITE", "bindings", "http/*:80:" + args.siteName);

      // need to change site ID
      args.siteID = this.CreateNewID(args.siteID);
      websiteSettings.SetElementAttributeValue("/appcmd/SITE", "SITE.ID", args.siteID.ToString());
      websiteSettings.SetElementAttributeValue("/appcmd/SITE/site", "id", args.siteID.ToString());

      // change apppool name
      websiteSettings.SetElementAttributeValue("/appcmd/SITE/site/application", "applicationPool", args.appPoolName);
      websiteSettings.SetElementAttributeValue("/appcmd/SITE/site/applicationDefaults", "applicationPool", args.appPoolName);

      // change root folder
      websiteSettings.SetElementAttributeValue("/appcmd/SITE/site/application/virtualDirectory", "physicalPath", args.rootPath + "\\Website");

      // TODO: need to change bindings in right way(maybe with the UI dialog)
      // websiteSettings.SetElementAttributeValue("/appcmd/SITE/site/bindings/binding[@bindingInformation='*:80:" + args.oldSiteName + "']", "bindingInformation", "*:80:" + args.siteName);
      XmlElement bindingsElement = websiteSettings.SelectSingleElement("/appcmd/SITE/site/bindings");
      if (bindingsElement != null)
      {
        bindingsElement.InnerXml = string.Empty;

        // it's a f*****g HACK, I can't work with xml nodes
        foreach (var key in args.bindings.Keys)
        {
          bindingsElement.InnerXml += "<binding protocol=\"http\" bindingInformation=\"*:{1}:{0}\" />".FormatWith(key, args.bindings[key].ToString());
        }

        // foreach (XmlElement bindingElement in bindingsElement.ChildNodes)
        // {

        // //if (bindingElement.Attributes["bindingInformation"].Value.Split(':').Last() != null && bindingElement.Attributes["bindingInformation"].Value.Split(':').Last() != "")
        // //    args.siteBindingsHostnames.Add(bindingElement.Attributes["bindingInformation"].Value.Split(':').Last());
        // //if(bindingElement.Attributes["bindingInformation"].Value.Split(':').Last() != null && bindingElement.Attributes["bindingInformation"].Value.Split(':').Last() != "")
        // //bindingElement.Attributes["bindingInformation"].Value = bindingElement.Attributes["bindingInformation"].Value.Replace(bindingElement.Attributes["bindingInformation"].Value.Split(':').Last(), args.siteName);
        // }
      }

      websiteSettings.Save(websiteSettings.FilePath + ".fixed.xml");
    }
    private void ChangeAppPoolSettingsIfNeeded(string path, ImportArgs args)
    {
      // should be executed before ChangeWebsiteSettingsIfNeeded
      // need to change AppName
      XmlDocumentEx appPoolSettings = new XmlDocumentEx();
      appPoolSettings.Load(path);
      args.appPoolName = this.CreateNewAppPoolName(args.appPoolName);
      appPoolSettings.SetElementAttributeValue("/appcmd/APPPOOL", "APPPOOL.NAME", args.appPoolName);
      appPoolSettings.SetElementAttributeValue("appcmd/APPPOOL/add", "name", args.appPoolName);

      appPoolSettings.Save(appPoolSettings.FilePath + ".fixed.xml");
    }