Esempio n. 1
0
 private void Installer_Load(object sender, EventArgs e)
 {
     if (MyConfiguration.DeploymentLevel != MyUtilities.DeploymentLevel.None)
     {
         this.Text   = MyConfiguration.Application_Title;
         this.Cursor = Cursors.WaitCursor;
         MyUtilities.UpdateStatus("Getting Site Url ....", LblStatus);
         PrbStatus.StartWaiting();
         Refresh();
         PnlInstaller.Visible      = false;
         PnlConfiguration2.Visible = false;
         PnlConfiguration.Visible  = true;
         this.Height = PnlConfiguration.Height + 25;
         if (MyConfiguration.IsDemoOn)
         {
             TxtUrl.Text = MyConfiguration.DefaultSiteUrl;
         }
         Application.DoEvents();
         this.Cursor = Cursors.Default;
     }
     else
     {
         PnlConfiguration.Visible  = false;
         PnlConfiguration2.Visible = false;
         PnlInstaller.Visible      = true;
         this.Height = PnlInstaller.Height + 25;
         MyUtilities.UpdateStatus("Initializing ...", LblStatus);
         Application.DoEvents();
         MyConfiguration.StartInstallation(null, null, LblStatus);
     }
 }
Esempio n. 2
0
 private void BtnInstall_Click(object sender, EventArgs e)
 {
     PnlConfiguration.Visible  = false;
     PnlConfiguration2.Visible = false;
     PnlInstaller.Visible      = true;
     this.Height = PnlInstaller.Height + 25;
     Application.DoEvents();
     MyUtilities.UpdateStatus("Connecting to SharePoint Site ....", LblStatus);
     try
     {
         SiteUrl = string.Empty;
         using (SPSite Site = new SPSite(TxtUrl.Text.Trim()))
         {
             try
             {
                 FolderPath = Application.StartupPath + "\\";
                 Application.DoEvents();
                 WindowsImpersonationContext wic = WindowsIdentity.Impersonate(IntPtr.Zero);
                 MyUtilities.UpdateStatus("Installing Solutions ...", LblStatus);
                 MyConfiguration.StartInstallation(Site, Site.AllWebs[new Guid(CmbWeb.SelectedValue.ToString())], LblStatus);
             }
             catch (Exception ex)
             {
                 MyUtilities.ShowDialog("An unknown error occured. Further details contact your vendor." + Environment.NewLine + "Error : " + Environment.NewLine + ex.Message, Telerik.WinControls.RadMessageIcon.Error);
             }
             finally
             {
                 this.Close();
                 Application.Exit();
             }
         }
         SiteUrl = TxtUrl.Text.Trim();
         this.Close();
     }
     catch (Exception ex)
     {
         MyUtilities.ShowDialog(ex.Message, Telerik.WinControls.RadMessageIcon.Error);
         PnlInstaller.Visible     = false;
         PnlConfiguration.Visible = true;
         this.Height = PnlConfiguration.Height + 25;
         TxtUrl.Focus();
         Application.DoEvents();
         return;
     }
 }
Esempio n. 3
0
 private void BtnInstall_Click_1(object sender, EventArgs e)
 {
     try
     {
         if (MyConfiguration.DeploymentLevel != MyUtilities.DeploymentLevel.None)
         {
             this.Cursor = Cursors.WaitCursor;
             if (TxtUrl.Text.Trim() == "")
             {
                 this.Cursor = Cursors.Default;
                 MyUtilities.ShowDialog("Enter Site Url and then Press OK.", RadMessageIcon.Error);
                 TxtUrl.Focus();
                 return;
             }
             using (SPSite Site = new SPSite(TxtUrl.Text.Trim()))
             {
                 if (MyConfiguration.DeploymentLevel == MyUtilities.DeploymentLevel.Workspace)
                 {
                     CmbWeb.Items.Clear();
                     RadComboBoxItem item1 = new RadComboBoxItem();
                     item1.Text = "Root Web";
                     CmbWeb.Items.Add(item1);
                     foreach (SPWeb Web in Site.AllWebs)
                     {
                         if (!Web.IsRootWeb)
                         {
                             RadComboBoxItem item = new RadComboBoxItem();
                             item.Text  = Web.Title;
                             item.Value = Web.ID.ToString();
                             CmbWeb.Items.Add(item);
                         }
                     }
                     if (CmbWeb.Items.Count > 0)
                     {
                         CmbWeb.SelectedIndex = 0;
                     }
                     PnlConfiguration.Visible  = false;
                     PnlInstaller.Visible      = false;
                     PnlConfiguration2.Visible = true;
                     this.Height = PnlConfiguration2.Height + 25;
                     Application.DoEvents();
                     this.Cursor = Cursors.Default;
                 }
                 else
                 {
                     PnlConfiguration.Visible  = false;
                     PnlConfiguration2.Visible = false;
                     PnlInstaller.Visible      = true;
                     this.Height = PnlInstaller.Height + 25;
                     Application.DoEvents();
                     MyUtilities.UpdateStatus("Connecting to SharePoint Site ....", LblStatus);
                     MyConfiguration.StartInstallation(Site, Site.OpenWeb(), LblStatus);
                 }
             }
         }
         else
         {
             PnlConfiguration.Visible  = false;
             PnlConfiguration2.Visible = false;
             PnlInstaller.Visible      = true;
             this.Height = PnlInstaller.Height + 25;
             Application.DoEvents();
             MyUtilities.UpdateStatus("Initializing ...", LblStatus);
             MyConfiguration.StartInstallation(null, null, LblStatus);
         }
     }
     catch (Exception ex)
     {
         this.Cursor = Cursors.Default;
         MyUtilities.ShowDialog(ex.Message, RadMessageIcon.Error);
     }
 }
        public static void StartInstallation(SPSite Site, SPWeb Web, Label LblStatus)
        {
            if (Web != null)
            {
                Web.AllowUnsafeUpdates = true;
            }

            MyUtilities.UpdateStatus(" Copying required files  ", LblStatus);
            Deployment.CopyFilesAndFolders(Application.StartupPath + "\\layouts", MyUtilities.LayoutsFolderPath, true);
            //Deployment.CopyFilesAndFolders(Application.StartupPath + "\\Features", MyUtilities.FeaturesFolderPath, true);

            //Deployment.CreateGenericList(Site.RootWeb, "Project Governance Report", "For Project Governance Report.", true);

            //Deployment.InsertWebPart(Site.RootWeb, "Project Governance Report", true, "MSPageViewer.dwp", "Link",
            //                               "/_layouts/ITXCloseTasksUpdate/LockProjectTasks.ascx", "", 0, true);

            /*try
             * {
             *  var navigationnode = new SPNavigationNode("Project Governance Report", "/" + Site.RootWeb.ServerRelativeUrl + "/_layouts/ITXProjectGovernanceReport/ITXPGReport.aspx", true);
             *  Site.RootWeb.Navigation.QuickLaunch.AddAsLast(navigationnode);
             *  Site.RootWeb.Update();
             * }
             * catch (Exception)
             * {
             * }
             *
             * MyUtilities.UpdateStatus(" Installing required feature ", LblStatus);
             * // Creating an Batch file to install the Feature
             * string WebPartInstallerPath = Application.StartupPath + "\\Install2.bat";
             * if (File.Exists(WebPartInstallerPath))
             * File.Delete(WebPartInstallerPath);
             * try
             * {
             * var Writer = new StreamWriter(WebPartInstallerPath);
             * Writer.WriteLine("@ echo off");
             * Writer.WriteLine(@"stsadm -o installfeature -filename ITXProjectGovernanceReport\feature.xml");
             * Writer.Flush();
             * Writer.Close();
             * Writer.Dispose();
             * }
             * catch (Exception)
             * {
             * }
             * Deployment.ExecuteProcess(WebPartInstallerPath, ProcessWindowStyle.Hidden, true);
             *
             * try
             * {
             * MyUtilities.UpdateStatus(" Creatng configuration list and adding project records ", LblStatus);
             * // define project server web service
             * var Project_Svc = new Project
             * {
             *     Url = Site.Url + "/_vti_bin/psi/project.asmx",
             *     UseDefaultCredentials = true,
             *     AllowAutoRedirect = true
             * };
             * SPList configurationList = ITXPGReportUtilities.MyUtilities.GetConfigurationList(Site);
             * if (configurationList != null)
             * {
             *     ProjectDataSet ProjectList = Project_Svc.ReadProjectList();
             *     foreach (ProjectDataSet.ProjectRow PRow in ProjectList.Project.Rows)
             *     {
             *         ITXPGReportUtilities.MyUtilities.CheckandAddEntry(configurationList, PRow.PROJ_UID, Project_Svc);
             *     }
             * }
             * }
             * catch (Exception ex)
             * {
             * ITXPGReportUtilities.MyUtilities.ErrorLog("Error at populating the project records in the list due to " + ex.Message, EventLogEntryType.Error);
             * }
             *
             */

            // executing database schema for Group Configurations

            try
            {
                string QRY     = @"
                CREATE TABLE [groups] (
                [groups_id] INT NOT NULL,
                [<_u_i_d>k___backing_field] VARCHAR(255) NULL,
                [<name>k___backing_field] VARCHAR(255) NULL,
                [voa_version] SMALLINT NOT NULL,
                CONSTRAINT [pk_groups] PRIMARY KEY ([groups_id])
            );
            CREATE TABLE [groups_projects] (
                [groups_id] INT NOT NULL,
                [seq] INT NOT NULL,
                [projects_id] INT NULL,
                CONSTRAINT [pk_groups_projects] PRIMARY KEY ([groups_id], [seq])
            );
            CREATE TABLE [projects] (
                [projects_id] INT NOT NULL,
                [<name>k___backing_field] VARCHAR(255) NULL,
                [<uid>k___backing_field] VARCHAR(255) NULL,
                [voa_version] SMALLINT NOT NULL,
                CONSTRAINT [pk_projects] PRIMARY KEY ([projects_id])
            );
            CREATE TABLE [users] (
                [users_id] INT NOT NULL,
                [<_rsrc_u_i_d>k___backing_field] VARCHAR(255) NULL,
                [voa_version] SMALLINT NOT NULL,
                CONSTRAINT [pk_users] PRIMARY KEY ([users_id])
            );
            CREATE TABLE [users_groups] (
                [users_id] INT NOT NULL,
                [seq] INT NOT NULL,
                [groups_id] INT NULL,
                CONSTRAINT [pk_users_groups] PRIMARY KEY ([users_id], [seq])
            );
            CREATE TABLE [voa_keygen] (
                [table_name] VARCHAR(64) NOT NULL,
                [last_used_id] INT NOT NULL,
                CONSTRAINT [pk_voa_keygen] PRIMARY KEY ([table_name])
            );
            ALTER TABLE [groups_projects] ADD CONSTRAINT [ref_groups_projects_groups] FOREIGN KEY ([groups_id]) REFERENCES [groups]([groups_id]);
            ALTER TABLE [groups_projects] ADD CONSTRAINT [ref_groups_projects_projects] FOREIGN KEY ([projects_id]) REFERENCES [projects]([projects_id]);
            ALTER TABLE [users_groups] ADD CONSTRAINT [ref_users_groups_users] FOREIGN KEY ([users_id]) REFERENCES [users]([users_id]);
            ALTER TABLE [users_groups] ADD CONSTRAINT [ref_users_groups_groups] FOREIGN KEY ([groups_id]) REFERENCES [groups]([groups_id]);";
                string connstr = Utilities.GetProjectServerSQLDatabaseConnectionString(Site.ID,
                                                                                       Utilities.DatabaseType.
                                                                                       PublishedDatabase);
                var builder = new SqlConnectionStringBuilder(connstr);
                builder.InitialCatalog = MyUtilities.GovernanceReportGroupConfigDBname;
                using (var connection = new SqlConnection(builder.ConnectionString))
                {
                    connection.Open();
                    var command = new SqlCommand(QRY, connection);
                    command.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            try
            {
                MyUtilities.UpdateStatus(" Updating web.config file ", LblStatus);
                //To Get Port from Siteurl
                Uri uri  = new Uri(Site.Url);
                int Port = uri.Port;
                if (Port != 80)
                {
                    string Wss80Path = Deployment.GetWssVirtualDirectoryPath("80");
                    if (Wss80Path != string.Empty)
                    {
                        // Moving files from Current Application Path to Virtual directory
                        Deployment.CopyFilesAndFolders(Application.StartupPath + @"\bin", Wss80Path + @"\bin", true);
                        Wss80Path += @"\web.config";
                        Utilities.SetAttributeValueInWebConfig(Wss80Path, "configuration/system.web/trust", "level", "Full");
                    }
                }
                var ExtendedUrlList = new List <string>();
                foreach (int zoneindex in Enum.GetValues(typeof(SPUrlZone)))
                {
                    string ExtendedUrl = Deployment.GetVirtualDirectoryPath((SPUrlZone)zoneindex, Site);
                    bool   Found       = false;
                    foreach (string s in ExtendedUrlList)
                    {
                        if (s.ToLower().Trim() == ExtendedUrl.ToLower().Trim())
                        {
                            Found = true;
                            break;
                        }
                    }
                    if (!Found)
                    {
                        ExtendedUrlList.Add(ExtendedUrl);
                    }
                }
                foreach (string Urls in ExtendedUrlList)
                {
                    try
                    {
                        // Moving files from Current Application Path to Virtual directory
                        Deployment.CopyFilesAndFolders(Application.StartupPath + @"\bin", Urls + @"\bin", true);
                        Utilities.SetAttributeValueInWebConfig(Urls + @"\web.config", "configuration/system.web/trust", "level", "Full");
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }
            catch (Exception)
            {
            }

            // Restart IIS
            MyUtilities.UpdateStatus("Restart IIS started ...", LblStatus);
            if (MyUtilities.ShowDialog("This will Reset the IIS. Are you sure? \r\n Recommended Yes", Telerik.WinControls.RadMessageIcon.Question) == DialogResult.Yes)
            {
                Application.DoEvents();
                Deployment.RestartIIS(Application.StartupPath);
            }
            Application.Exit();
        }