示例#1
0
        private string getProjectWss(string pwaUrl, Guid projectUid)
        {
            try
            {
                var wssInterop = new WssInterop
                {
                    Url         = $"{pwaUrl}/_vti_bin/psi/wssinterop.asmx",
                    Credentials = CredentialCache.DefaultCredentials
                };

                var projectWssInfoDataSet = new ProjectWSSInfoDataSet();

                SPSecurity.RunWithElevatedPrivileges(() => projectWssInfoDataSet = wssInterop.ReadWssData(projectUid));

                if (projectWssInfoDataSet.ProjWssInfo.Count > 0)
                {
                    return(projectWssInfoDataSet.ProjWssInfo[0].PROJECT_WORKSPACE_URL);
                }
            }
            catch (Exception exception)
            {
                myLog.WriteEntry(
                    $"Error in getProjectWss(): {exception.Message}{exception.StackTrace}{exception.InnerException}",
                    EventLogEntryType.Error,
                    315);
            }

            return(string.Empty);
        }
示例#2
0
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            if (!EventLog.SourceExists("EPM Live Feature Activation"))
            {
                EventLog.CreateEventSource("EPM Live Feature Activation", "EPM Live");
            }

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

                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    try
                    {
                        var events = new Events();
                        events.Url = SPContext.Current.Site.Url + "/_vti_bin/psi/events.asmx";
                        events.UseDefaultCredentials = true;

                        var dataSet = events.ReadEventHandlerAssociations();

                        Publish(myLog, events, dataSet);
                        Statusing(myLog, events, dataSet);
                        ResourceChanged(myLog, events, dataSet);
                        ResourceAdded(myLog, events, dataSet);
                        ResourceDeleted(myLog, events, dataSet);
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine(ex.ToString());
                        myLog.WriteEntry("Error Installing Enterprise Event Handler:\r\n " + ex.Message + ex.StackTrace + ex.InnerException, EventLogEntryType.Error, 650);
                    }
                });

                try
                {
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        var wss = new WssInterop();
                        wss.Url = SPContext.Current.Site.Url + "/_vti_bin/psi/wssinterop.asmx";
                        wss.UseDefaultCredentials = true;

                        var dsWss = wss.ReadWssSettings();
                        dsWss.WssAdmin[0].WADMIN_AUTO_ADD_USER_TO_SUBWEB = 0;
                        dsWss.WssAdmin[0].WADMIN_AUTO_CREATE_SUBWEBS     = 0;
                        wss.UpdateWssSettings(dsWss);

                        myLog.WriteEntry("Successfully Updated Project Workspace Provisioning Settings", EventLogEntryType.Information, 620);
                    });
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                    myLog.WriteEntry("Error Updating Project Workspace Provisioning Settings :\r\n " + ex.Message + ex.StackTrace + ex.InnerException, EventLogEntryType.Error, 651);
                }
            }
        }
        private void UpdatePublisherCheckPercentCompleteFive(int pubType, DateTime dtStart)
        {
            if (dtStart == null)
            {
                throw new ArgumentNullException(nameof(dtStart));
            }

            using (var pubSite = new SPSite(publishSiteUrl))
            {
                mySiteToPublish = pubSite.OpenWeb();

                pCf = new CustomFields
                {
                    Url = $"{mySite.Url}/_vti_bin/psi/customfields.asmx",
                    UseDefaultCredentials = true
                };
                cfDs = new CustomFieldDataSet();

                psiLookupTable = new LookupTable
                {
                    Url = $"{mySite.Url}/_vti_bin/psi/lookuptable.asmx",
                    UseDefaultCredentials = true
                };

                pResource = new Resource
                {
                    Url = $"{mySite.Url}/_vti_bin/psi/resource.asmx",
                    UseDefaultCredentials = true
                };

                pService = new Project
                {
                    Url = $"{mySite.Url}/_vti_bin/psi/project.asmx",
                    UseDefaultCredentials = true
                };

                Statusing = new Statusing
                {
                    Url = $"{mySite.Url}/_vti_bin/psi/statusing.asmx",
                    UseDefaultCredentials = true
                };

                pWssInterop = new WssInterop
                {
                    Url = $"{mySite.Url}/_vti_bin/psi/wssinterop.asmx",
                    UseDefaultCredentials = true
                };

                linkProjectWss();

                var          trackingGuid = Guid.NewGuid();
                const string Lcid         = "1033";
                StatusingDerived.SetImpersonationContext(true, contextInfo.UserName, contextInfo.UserGuid, trackingGuid, contextInfo.SiteGuid, Lcid);

                workspaceSynch = new ProjectWorkspaceSynch(mySiteGuid, publishSiteUrl, projectGuid, contextInfo.UserName);
                workspaceSynch.setUpGroups();
                workspaceSynch.processTaskCenter();
                workspaceSynch.processProjectCenter();
                workspaceSynch.processResources();

                using (var sqlCommand1 = new SqlCommand(
                           "UPDATE publishercheck set percentcomplete=5,laststatusdate=getdate() where projectguid=@projectguid",
                           cn))
                {
                    sqlCommand1.Parameters.AddWithValue("@projectguid", eventArgs.ProjectGuid);
                    sqlCommand1.ExecuteNonQuery();
                }

                loadFields();

                LoadCurrentTasks(pubType, dtStart);
            }
        }