예제 #1
0
        public Publisher(PSLibrary.PSContextInfo psContextInfo, ProjectPostPublishEventArgs projectPostPublishEventArgs)
        {
            Guard.ArgumentIsNotNull(projectPostPublishEventArgs, nameof(projectPostPublishEventArgs));
            Guard.ArgumentIsNotNull(psContextInfo, nameof(psContextInfo));

            contextInfo         = psContextInfo;
            eventArgs           = projectPostPublishEventArgs;
            mySiteGuid          = contextInfo.SiteGuid;
            myLog.EntryWritten += myLog_EntryWritten;
        }
예제 #2
0
        public override void OnPublished(PSContextInfo contextInfo, ProjectPostPublishEventArgs e)
        {
            if (contextInfo == null)
            {
                throw new ArgumentNullException(nameof(contextInfo));
            }

            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            using (var myLog = new EventLog("EPM Live", ".", "EPM Live Publisher"))
            {
                myLog.MaximumKilobytes = 32768;

                using (var mySite = new SPSite(contextInfo.SiteGuid))
                {
                    var act  = new Act(mySite.RootWeb);
                    int iAct = act.CheckFeatureLicense(ActFeature.ProjectServer);
                    if (iAct == 0)
                    {
                        using (var publisher = new Publisher(contextInfo, e))
                        {
                            publisher.doPublish();
                        }
                    }
                    else
                    {
                        using (var connection = new SqlConnection(CoreFunctions.getConnectionString(mySite.WebApplication.Id)))
                        {
                            using (var command = new SqlCommand("update publishercheck set webguid=@webguid,logtext=@logtext, checkbit=0,status=@status,percentcomplete=0,laststatusdate=getdate() where projectguid=@projectguid", connection))
                            {
                                command.Parameters.AddWithValue("@projectguid", e.ProjectGuid);
                                command.Parameters.AddWithValue("@webguid", mySite.OpenWeb().ID);
                                command.Parameters.AddWithValue("@status", 3);
                                command.Parameters.AddWithValue("@logtext", $"Activation Error: {act.translateStatus(iAct)}");
                            }
                        }
                    }
                }
            }
        }
 public override void OnPublished(PSLibrary.PSContextInfo contextInfo, ProjectPostPublishEventArgs e)
 {
     base.OnPublished(contextInfo, e);
     try
     {
         SPSecurity.RunWithElevatedPrivileges(delegate
                                                  {
                                                      using (var Site = new SPSite(contextInfo.SiteGuid))
                                                      {
                                                          MyUtilities.EnableSQlServerCLR(Site.ID);
                                                          //MyUtilities.InstallStoredProcedure(Site.ID, false);
                                                          string ConnectionString = Utilities.GetProjectServerSQLDatabaseConnectionString(Site.ID, Utilities.DatabaseType.PublishedDatabase);
                                                          using (var sqlConnection = new SqlConnection(ConnectionString.Replace("15", "180")))
                                                          {
                                                              sqlConnection.Open();
                                                              var cmd = new SqlCommand();
                                                              cmd.Connection = sqlConnection;
                                                              cmd.CommandType = CommandType.StoredProcedure;
                                                              cmd.Parameters.Add(new SqlParameter("ProjectUID", e.ProjectGuid.ToString()));
                                                              cmd.Parameters.Add(new SqlParameter("ModifiedBy", contextInfo.UserName));
                                                              cmd.CommandText = "ITXTaskAuditTrail";
                                                              DateTime starttime = DateTime.Now;
                                                              cmd.ExecuteNonQuery();
                                                              MyUtilities.ErrorLog("Time taken for execution : " + starttime.Subtract(DateTime.Now).Seconds, EventLogEntryType.SuccessAudit);
                                                          }
                                                      }
                                                  });
     }
     catch (Exception ex)
     {
         if (string.IsNullOrEmpty(ex.StackTrace))
             MyUtilities.ErrorLog("Error on Published Event due to : " + ex.Message, EventLogEntryType.Error);
         else
             MyUtilities.ErrorLog("Error on Published Event due to : " + ex.Message + Environment.NewLine + "Stack Trace :" + ex.StackTrace, EventLogEntryType.Error);
     }
 }