コード例 #1
0
 protected void Page_LoadComplete(object sender, EventArgs e)
 {
     if (_DAO != null)
     {
         _DAO.Dispose();
     }
 }
コード例 #2
0
        public void execute(SPSite site, SPWeb web, string data)
        {
            EPMData epmdata = null;

            try
            {
                epmdata = new EPMData(site.ID);

                ProcessSecurity.ProcessSecurityGroups(site, epmdata.GetClientReportingConnection, data);
            }
            catch { }
            finally
            {
                if (epmdata != null)
                {
                    epmdata.Dispose();
                }
                if (web != null)
                {
                    web.Dispose();
                }
                if (site != null)
                {
                    site.Dispose();
                }
                data = null;
            }
        }
コード例 #3
0
        private bool AddField(SPListEventProperties properties)
        {
            bool   isSuccessful = true;
            string tableName    = string.Empty;
            string ssTableName  = string.Empty;
            var    rb           = new ReportBiz(properties.SiteId);

            try
            {
                var rd   = new ReportData(properties.SiteId);
                var cols = new ColumnDefCollection();
                tableName   = rd.GetTableName(properties.ListId);
                ssTableName = rd.GetTableNameSnapshot(properties.ListId);

                if (!rd.ColumnExists(tableName, properties.Field.InternalName))
                {
                    cols.AddColumn(properties.Field);
                    rd.AddColumns(tableName, cols);
                    rd.AddColumns(ssTableName, cols);
                    rd.InsertListColumns(properties.ListId, cols);
                }
                rd.Dispose();
            }
            catch (Exception ex)
            {
                var DAO = new EPMData(properties.SiteId);
                DAO.LogStatus(properties.ListId.ToString(), properties.FieldName,
                              "Database column add attempt: Unable to add column " + properties.FieldName + ". " + ex.Message,
                              ex.StackTrace, 2, 5, Guid.NewGuid().ToString()); //Logged in the RefreshAll event log.
                DAO.Dispose();
            }

            if (properties.Field is SPFieldLookup)
            {
                try
                {
                    //FOREIGN IMPLEMENTATION -- START
                    var DAO = new EPMData(properties.SiteId);
                    rb.UpdateForeignKeys(DAO);
                    DAO.Dispose();
                    // -- END
                }
                catch (Exception ex)
                {
                    isSuccessful = false;
                    SPSecurity.RunWithElevatedPrivileges(delegate
                    {
                        if (!EventLog.SourceExists("EPMLive Reporting - UpdateForeignKeys"))
                        {
                            EventLog.CreateEventSource("EPMLive Reporting - UpdateForeignKeys", "EPM Live");
                        }

                        LogEntry(ex, "EPMLive Reporting - UpdateForeignKeys");
                    });
                }
            }

            return(isSuccessful);
        }
コード例 #4
0
        public void execute(SPSite site, SPWeb web, string data)
        {
            EPMData       epmdata  = null;
            DataTable     dt       = null;
            StringBuilder sbErrors = null;

            try
            {
                sbErrors = new StringBuilder();
                epmdata  = new EPMData(site.ID);

                epmdata.SnapshotLists(base.JobUid, site.ID, data);

                dt = epmdata.GetSnapshotResults(base.JobUid);

                foreach (DataRow dr in dt.Rows)
                {
                    sbErrors.Append("Processing List (" + dr["ListName"] + ")");
                    if (dr["level"].ToString() == "2")
                    {
                        sbErrors.Append(" Failed: " + dr["ShortMessage"]);
                        bErrors = true;
                    }
                    else
                    {
                        sbErrors.Append(" Success");
                    }

                    sbErrors.Append("<br>");
                }
            }
            finally
            {
                sErrors  = sbErrors.ToString();
                sbErrors = null;
                if (dt != null)
                {
                    dt.Dispose();
                }
                if (epmdata != null)
                {
                    epmdata.Dispose();
                }
                if (web != null)
                {
                    web.Dispose();
                }
                if (site != null)
                {
                    site.Dispose();
                }
                data = null;
            }
        }
コード例 #5
0
        public void InitiateSync(SPSite site, out string processLog, out bool hasErrors, Guid tuid)
        {
            try
            {
                _ExecutionLogs.Add("AD Sync process started at: " + DateTime.Now.ToString());
                _tuid = tuid;
                _DAO  = new EPMData(site.ID);
                using (SPWeb web = site.OpenWeb())
                {
                    Initialize(web);
                }

                ProcessAllGroups();
                UpdateResourcePool();

                //Checking for any "Disabled" "Active Directory" users.
                if (_disableUsers.Count > 0)
                {
                    DisableUsers();
                }

                //If Resourcepool contained SID field initially, THEN audit Resourcepool and
                //delete or disable (depending on "Disabled" config setting) users.
                if (_hasSID)
                {
                    AuditResourcePool();
                }
                WriteOutLog();
                _DAO.Dispose();
            }
            catch (Exception ex)
            {
                _ExecutionLogs.Add("     ERROR -- Location: InitiateSync() -- Message: " + ex.Message);
                _hasErrors = true;
            }
            processLog = _processLog;
            hasErrors  = _hasErrors;
        }
コード例 #6
0
        private bool DeleteList(SPListEventProperties properties)
        {
            bool isSuccessful = true;
            var  reportBiz    = new ReportBiz(properties.SiteId);
            Guid listId       = properties.ListId;
            var  DAO          = new EPMData(properties.SiteId);

            DAO.Command = "SELECT TableName FROM RPTList WHERE RPTListID=@RPTListID";
            DAO.AddParam("@RPTListID", listId);
            string sTableName = string.Empty;

            try
            {
                sTableName = DAO.ExecuteScalar(DAO.GetClientReportingConnection).ToString();
                DataTable refTables = reportBiz.GetReferencingTables(DAO, sTableName);
                if (refTables.Rows.Count == 0)
                {
                    reportBiz.GetListBiz(listId).Delete();
                }
                else
                {
                    isSuccessful = false;
                    DAO.LogStatus(listId.ToString(), sTableName,
                                  "Database table delete attempt: Unable to delete " + sTableName + ".",
                                  sTableName + " is referenced by other tables.", 2, 5, Guid.NewGuid().ToString());
                    //Logged in the RefreshAll event log.
                }
            }
            catch (Exception ex)
            {
                DAO.LogStatus(listId.ToString(), sTableName,
                              "Database table delete attempt: Unable to delete " + sTableName + ". " + ex.Message, ex.StackTrace,
                              2, 5, Guid.NewGuid().ToString()); //Logged in the RefreshAll event log.
            }
            reportBiz = null;
            DAO.Dispose();
            return(isSuccessful);
        }
コード例 #7
0
        public void execute(SPSite site, SPWeb web, string data)
        {
            sbErrors = new StringBuilder();
            EPMData   epmdata     = null;
            Hashtable hshMessages = null;
            SPWeb     rootWeb     = null;

            try
            {
                hshMessages = new Hashtable();

                #region Process security

                try
                {
                    totalCount = site.AllWebs.Count;
                    epmdata    = new EPMData(site.ID);
                    epmdata.LogStatus("", "", "Reporting Refresh  Collect Job", "Reporting refresh process started.", 2, 3, Convert.ToString(JobUid));
                    try
                    {
                        epmdata.LogStatus("", "", "Reporting Refresh  Collect Job", string.Format("Started processing security groups for site: {0}", site.Url), 2, 3, Convert.ToString(JobUid));
                        ProcessSecurity.ProcessSecurityGroups(site, epmdata.GetClientReportingConnection, "");
                        sbErrors.Append("Completed processing security groups for site: " + site.Url + ".</br>");
                        epmdata.LogStatus("", "", "Reporting Refresh  Collect Job", string.Format("Completed processing security groups for site: {0}", site.Url), 2, 3, Convert.ToString(JobUid));
                    }
                    catch (Exception ex)
                    {
                        var message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

                        bErrors = true;
                        sbErrors.Append("<font color=\"red\">Error processing security on site: " + site.Url + ". Error: " + message + "</font><br>");
                        epmdata.LogStatus("", "", "Reporting Refresh  Collect Job", string.Format("Error processing security on site: {0}. Error: {1}", site.Url, message), 2, 3, Convert.ToString(JobUid));
                    }

                    if (string.IsNullOrEmpty(data))
                    {
                        //try
                        //{
                        //    data = epmdata.GetListNames();
                        //}
                        //catch (Exception exData)
                        //{
                        //    bErrors = true;
                        //    sErrors += "<font color=\"red\">Error while retrieving list names: " + exData.Message + "</font><br>";
                        //}

                        try
                        {
                            epmdata.LogStatus("", "", "Reporting Refresh Collect Job", string.Format("Started updating reporting settings for site: {0}.", site.Url), 2, 3, Convert.ToString(JobUid));
                            setRPTSettings(epmdata, site);
                            epmdata.LogStatus("", "", "Reporting Refresh Collect Job", string.Format("Completed updating reporting settings for site: {0}.", site.Url), 2, 3, Convert.ToString(JobUid));
                        }
                        catch (Exception ex)
                        {
                            var message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

                            bErrors = true;
                            sbErrors.Append("<font color=\"red\">Error Updating RPTSettings: " + message + "</font><br>");
                            epmdata.LogStatus("", "", "Reporting Refresh Collect Job", string.Format("Updating reporting settings failed for site: {0}. ,Error {1}", site.Url, message), 2, 3, Convert.ToString(JobUid));
                        }
                    }
                }
                catch (Exception ex)
                {
                    bErrors = true;
                    sbErrors.Append("<font color=\"red\">Error Updating base: " + ex.Message + "</font><br>");
                    epmdata.LogStatus("", "", "Reporting Refresh Collect Job", string.Format("Updating reporting settings failed for site: {0}. ,Error {1}", site.Url, ex.Message), 2, 3, Convert.ToString(JobUid));
                }

                #endregion

                #region History

                //try
                //{
                //    data = epmdata.UpdateListNames(data);
                //}
                //catch (Exception ex)
                //{
                //    bErrors = true;
                //    sErrors += "<font color=\"red\">Error Updating List Names: " + ex.Message + "</font><br>";
                //}

                // TODO: We need to make sure this doesn't break anything!!!!
                //foreach (SPWeb w in site.AllWebs)
                //{
                //    // IGNORE SPDispose 130 error, web is being disposed
                //    try
                //    {
                //        List<string> allLists = new List<string>(data.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
                //        List<SPList> allSpLists = new List<SPList>();
                //        foreach (string l in allLists)
                //        {
                //            SPList list = w.Lists.TryGetList(l);
                //            if (list == null ||
                //                list.Title == "Work Hours" ||
                //                list.Title == "Resources")
                //            {
                //                continue;
                //            }

                //            if (list != null)
                //            {
                //                allSpLists.Add(list);
                //            }
                //        }
                //        ProcessSecurity.ProcessSecurityOnRefreshAll(w, allSpLists, epmdata.GetClientReportingConnection);
                //        if (w != null)
                //        {
                //            w.Dispose();
                //        }
                //    }
                //    catch
                //    {
                //        if (w != null)
                //        {
                //            w.Dispose();
                //        }
                //    }
                //}

                #endregion

                #region Process TimeSheet Data

                try
                {
                    string err = "";
                    bool   consolidationdone     = false;
                    bool   reportingRefreshBatch = false;

                    epmdata.LogStatus("", "", "Reporting Refresh Collect Job Process TimeSheet Data", string.Format("Starting Process TimeSheet Data for site: {0}.", site.Url), 2, 3, Convert.ToString(JobUid));
                    bool.TryParse(EPMLiveCore.CoreFunctions.getConfigSetting(web, "epmliveconsolidation"), out consolidationdone);
                    bool.TryParse(EPMLiveCore.CoreFunctions.getConfigSetting(web, "epmlivereportingrefreshbatch"), out reportingRefreshBatch);
                    bool bErrorRefreshTimesheet = false;
                    if (reportingRefreshBatch)
                    {
                        int pageSize = 0;
                        int.TryParse(EPMLiveCore.CoreFunctions.getConfigSetting(web, "epmliverepotingrefreshbatchpagesize"), out pageSize);
                        bErrorRefreshTimesheet = epmdata.RefreshTimesheetBatch(out err, base.JobUid, pageSize);
                    }
                    else
                    {
                        bErrorRefreshTimesheet = epmdata.RefreshTimesheets(out err, base.JobUid, consolidationdone);
                    }
                    if (bErrorRefreshTimesheet)
                    {
                        bErrors = true;
                        sbErrors.Append("<font color=\"red\">Error Processing Timesheets: " + err + "</font><br>");
                        epmdata.LogStatus("", "", "Reporting Refresh Collect Job Process TimeSheet Data", string.Format("Process TimeSheet Data failed for site: {0}. Error {1}", site.Url, err), 2, 3, Convert.ToString(JobUid));
                    }

                    else
                    {
                        sbErrors.Append("Processed Timesheets<br>");
                        epmdata.LogStatus("", "", "Reporting Refresh Collect Job Process TimeSheet Data", string.Format("Completed timeSheet data processing for site: {0}", site.Url), 2, 3, Convert.ToString(JobUid));
                    }
                }
                catch (Exception ex)
                {
                    var message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

                    bErrors = true;
                    sbErrors.Append("<font color=\"red\">Error Processing Timesheets: " + message + "</font><br>");
                    epmdata.LogStatus("", "", "Reporting Refresh Collect Job Process TimeSheet Data", string.Format("Process TimeSheet Data failed for site: {0}. Error {1}", site.Url, message), 2, 3, Convert.ToString(JobUid));
                }

                #endregion

                #region Process PFE Data

                try
                {
                    if (site.Features[new Guid("158c5682-d839-4248-b780-82b4710ee152")] != null)
                    {
                        epmdata.LogStatus("", "", "Reporting Refresh Collect Job Process PFE Data", string.Format("Processing PFE Data for site: {0}", site.Url), 2, 3, Convert.ToString(JobUid));
                        rootWeb = site.RootWeb;

                        string basePath   = CoreFunctions.getConfigSetting(rootWeb, "epkbasepath");
                        string ppmId      = CoreFunctions.getConfigSetting(rootWeb, "ppmpid");
                        string ppmCompany = CoreFunctions.getConfigSetting(rootWeb, "ppmcompany");
                        string ppmDbConn  = CoreFunctions.getConfigSetting(rootWeb, "ppmdbconn");

                        Assembly assemblyInstance =
                            Assembly.Load(
                                "PortfolioEngineCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5");
                        Type   thisClass   = assemblyInstance.GetType("PortfolioEngineCore.WEIntegration.WEIntegration");
                        object classObject = Activator.CreateInstance(thisClass,
                                                                      new object[] { basePath, site.WebApplication.ApplicationPool.Username, ppmId, ppmCompany, ppmDbConn, false });

                        MethodInfo m       = thisClass.GetMethod("ExecuteReportExtract");
                        var        message =
                            (string)
                            m.Invoke(classObject,
                                     new object[]
                        {
                            "<ExecuteReportExtract><Params /><Data><ReportExtract Connection=\"" +
                            getReportingConnection(web) + "\" Execute=\"1\" /></Data></ExecuteReportExtract>"
                        });

                        sbErrors.Append("Processed PfE Reporting: " + message + "<br>");
                        epmdata.LogStatus("", "", "Reporting Refresh Collect Job Process PFE Data", string.Format("Completed Processing PFE Data for site: {0}", site.Url), 2, 3, Convert.ToString(JobUid));
                    }
                }
                catch (Exception ex)
                {
                    var message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

                    bErrors = true;
                    sbErrors.Append("<font color=\"red\">Error Processing PfE Reporting: " + message + "</font><br>");
                    epmdata.LogStatus("", "", "Reporting Refresh Collect Job Process PFE Data", string.Format("Error Processing PfE Reporting for site: {0} Error {1}", site.Url, message), 2, 3, Convert.ToString(JobUid));
                }

                #endregion Process PFE Data



                #region Clean Data

                try
                {
                    string errMsg = string.Empty;
                    epmdata.LogStatus("", "", "Reporting Refresh Collect Job DataScrubber CleanTables", string.Format("Started DataScrubber.CleanTables for site: {0}", site.Url), 2, 3, Convert.ToString(JobUid));
                    bool bErrorCleanTables = DataScrubber.CleanTables(site, epmdata, base.JobUid, ref errMsg);
                    if (bErrorCleanTables)
                    {
                        bErrors = true;
                        sbErrors.Append("<font color=\"red\">Error while cleaning tables: " + errMsg + "</font><br>");
                        epmdata.LogStatus("", "", "Reporting Refresh Collect Job DataScrubber CleanTables", string.Format("Error while cleaning tables for site: {0} error {1}", site.Url, errMsg), 2, 3, Convert.ToString(JobUid));
                    }
                    else
                    {
                        epmdata.LogStatus("", "", "Reporting Refresh Collect Job DataScrubber CleanTables", string.Format("Completed DataScrubber.CleanTables for site: {0}", site.Url), 2, 3, Convert.ToString(JobUid));
                    }
                }
                catch (Exception ex)
                {
                    var message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

                    bErrors = true;
                    sbErrors.Append("<font color=\"red\">Error while cleaning tables: " + message + "</font><br>");
                    epmdata.LogStatus("", "", "Reporting Refresh Collect Job DataScrubber CleanTables", string.Format("Error while cleaning tables for site: {0} error {1}", site.Url, message), 2, 3, Convert.ToString(JobUid));
                }

                #endregion

                #region Update Status Field

                try
                {
                    if (string.IsNullOrEmpty(data))
                    {
                        DataSet ds = null;
                        try
                        {
                            ds = new DataSet();
                            using (var cmd1 = new SqlCommand("SELECT TABLENAME FROM RPTList", epmdata.GetClientReportingConnection))
                            {
                                epmdata.LogStatus("", "", "Reporting Refresh Collect Job Update Status Field", string.Format("Started Update Status Field for site: {0} ,SQL  (SELECT TABLENAME FROM RPTList) ", site.Url), 2, 3, Convert.ToString(JobUid));
                                using (SqlDataAdapter da = new SqlDataAdapter(cmd1))
                                {
                                    da.Fill(ds);

                                    foreach (DataRow dr in ds.Tables[0].Rows)
                                    {
                                        using (var cmd2 = new SqlCommand("spUpdateStatusFields", epmdata.GetClientReportingConnection))
                                        {
                                            cmd2.CommandType = CommandType.StoredProcedure;
                                            cmd2.Parameters.AddWithValue("@listtable", dr[0].ToString());
                                            cmd2.ExecuteNonQuery();
                                            epmdata.LogStatus("", "", "Reporting Refresh Collect Job Update Status Field", string.Format("Executing  store procedure spUpdateStatusFields '{0}'", dr[0].ToString()), 2, 3, Convert.ToString(JobUid));
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            var message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

                            bErrors = true;
                            sbErrors.Append("<font color=\"red\">Error updating status fields: " + message + "</font><br>");
                            epmdata.LogStatus("", "", "Reporting Refresh Collect Job Update Status Field", string.Format("Error updating status fields: for site {0},error {1} ", site.Url, message), 2, 3, Convert.ToString(JobUid));
                        }
                        finally
                        {
                            if (ds != null)
                            {
                                ds.Dispose();
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            foreach (string sList in data.Split(','))
                            {
                                if (sList != "")
                                {
                                    DataSet ds   = null;
                                    SPList  list = null;
                                    try
                                    {
                                        list = web.Lists[sList];

                                        ds = new DataSet();
                                        using (var cmd1 = new SqlCommand("SELECT TABLENAME FROM RPTList where listid=@listid", epmdata.GetClientReportingConnection))
                                        {
                                            epmdata.LogStatus("", "", "Reporting Refresh Collect Job Update Status Field", string.Format("SELECT TABLENAME FROM RPTList where listid={0} ", list.ID), 2, 3, Convert.ToString(JobUid));
                                            cmd1.Parameters.AddWithValue("@listid", list.ID);
                                            using (SqlDataAdapter da = new SqlDataAdapter(cmd1))
                                            {
                                                da.Fill(ds);

                                                using (var cmd2 = new SqlCommand("spUpdateStatusFields", epmdata.GetClientReportingConnection))
                                                {
                                                    cmd2.CommandType = CommandType.StoredProcedure;
                                                    cmd2.Parameters.AddWithValue("@listtable", ds.Tables[0].Rows[0][0].ToString());
                                                    cmd2.ExecuteNonQuery();
                                                    epmdata.LogStatus("", "", "Reporting Refresh Collect Job Update Status Field", string.Format("Executed spUpdateStatusFields '{0}' ", Convert.ToString(ds.Tables[0].Rows[0][0])), 2, 3, Convert.ToString(JobUid));
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        var message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

                                        bErrors = true;
                                        sbErrors.Append("<font color=\"red\">Error updating status fields (" + sList + "): " + message + "</font><br>");
                                        epmdata.LogStatus("", "", "Reporting Refresh Collect Job Update Status Field", string.Format("Error updating status fields ({0}) Error {1}", sList, message), 2, 3, Convert.ToString(JobUid));
                                    }
                                    finally
                                    {
                                        if (ds != null)
                                        {
                                            ds.Dispose();
                                        }
                                        list = null;
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            var message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

                            bErrors = true;
                            sbErrors.Append("<font color=\"red\">Error updating status fields: " + message + "</font><br>");
                            epmdata.LogStatus("", "", "Reporting Refresh Collect Job Update Status Field", string.Format("Error updating status fields Error {0}", message), 2, 3, Convert.ToString(JobUid));
                        }
                    }

                    foreach (string list in data.Split(','))
                    {
                        if (list != "")
                        {
                            try
                            {
                                using (var cmd2 = new SqlCommand("spUpdateStatusFields", epmdata.GetClientReportingConnection))
                                {
                                    cmd2.CommandType = CommandType.StoredProcedure;
                                    cmd2.Parameters.AddWithValue("@listtable", list);
                                    cmd2.ExecuteNonQuery();
                                    epmdata.LogStatus("", "", "Reporting Refresh Collect Job Update Status Field", string.Format("Executed spUpdateStatusFields '{0}'", list), 2, 3, Convert.ToString(JobUid));
                                }
                            }
                            catch (Exception ex)
                            {
                                var message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

                                bErrors = true;
                                sbErrors.Append("<font color=\"red\">Error running schedule field update for (" + list + "): " + message + "</font><br>");
                                epmdata.LogStatus("", "", "Reporting Refresh Collect Job Update Status Field", string.Format("Error running schedule field update for ({0}) error {1}.", list, message), 2, 3, Convert.ToString(JobUid));
                            }

                            if (!hshMessages.Contains(list))
                            {
                                hshMessages.Add(list, "");
                            }
                        }
                    }

                    sbErrors.Append("<br>Updated Status Fields<br>");
                    epmdata.LogStatus("", "", "Reporting Refresh Collect Job Update Status Field", string.Format("Complete  running Updated Status Fields"), 2, 3, Convert.ToString(JobUid));
                }
                catch (Exception ex)
                {
                    var message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                    bErrors = true;
                    sbErrors.Append("<font color=\"red\">Error running schedule field update: " + message + "</font><br>");
                    epmdata.LogStatus("", "", "Reporting Refresh Collect Job Update Status Field", string.Format("Error running schedule field update: {0}", message), 2, 3, Convert.ToString(JobUid));
                }

                #endregion

                #region Clear Cache

                try
                {
                    epmdata.LogStatus("", "", "Reporting Refresh Collect Job Clear Cache", string.Format("Started Cleaning cache for site : {0}", site.Url), 2, 3, Convert.ToString(JobUid));
                    CacheStore.Current.RemoveSafely(web.Url, new CacheStoreCategory(web).Navigation);
                    epmdata.LogStatus("", "", "Reporting Refresh Collect Job Clear Cache", string.Format("Completed Cleaning cache for site : {0}", site.Url), 2, 3, Convert.ToString(JobUid));
                }
                catch (Exception ex)
                {
                    var message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

                    bErrors = true;
                    sbErrors.Append("<font color=\"red\">Clear Cache Error: " + message + "</font><br>");
                    epmdata.LogStatus("", "", "Reporting Refresh Collect Job Clear Cache", string.Format("Cleaning Cache Failed for site : {0} error {1}", site.Url, message), 2, 3, Convert.ToString(JobUid));
                }

                #endregion
            }
            catch (Exception ex)
            {
                var message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

                bErrors = true;
                sbErrors.Append("<font color=\"red\">General Execute Error: " + message + "</font><br>");
                epmdata.LogStatus("", "", "Reporting Refresh Collect Job", string.Format("General Execute Error for site : {0} error {1}", site.Url, message), 2, 3, Convert.ToString(JobUid));
            }
            finally
            {
                sErrors  = sbErrors.ToString();
                sbErrors = null;
                //Already calling from TimerClass
                //finishJob();
                hshMessages = null;
                if (epmdata != null)
                {
                    epmdata.Dispose();
                }
                if (web != null)
                {
                    web.Dispose();
                }
                if (rootWeb != null)
                {
                    rootWeb.Dispose();
                }
                if (site != null)
                {
                    site.Dispose();
                }
                data = null;
            }
        }
コード例 #8
0
        public bool AddTimerJob(SPWeb web, int iTime, int iScheduleType, string days, bool runNow)
        {
            SqlConnection con    = null;
            bool          passed = true;

            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    Guid timerjobuid = Guid.Empty;
                    if (_DAO == null)
                    {
                        _DAO = new EPMData(web.Site.ID);
                    }

                    _DAO.Command = "select timerjobuid from timerjobs where siteguid=@siteguid and jobtype=8";
                    _DAO.AddParam("@siteguid", web.Site.ID.ToString());
                    object oResult = _DAO.ExecuteScalar(_DAO.GetEPMLiveConnection);

                    if (oResult != null)
                    {
                        timerjobuid  = (Guid)oResult;
                        _DAO.Command = "UPDATE TIMERJOBS SET runtime = @runtime, scheduleType = @scheduletype, days = @days WHERE jobtype=8";
                        _DAO.AddParam("@runtime", iTime);
                        _DAO.AddParam("@scheduletype", iScheduleType);
                        _DAO.AddParam("@days", days);
                        _DAO.ExecuteNonQuery(_DAO.GetEPMLiveConnection);
                    }
                    else
                    {
                        timerjobuid  = Guid.NewGuid();
                        _DAO.Command = "INSERT INTO TIMERJOBS (timerjobuid,jobname,siteguid,webguid,listguid,jobtype,enabled,runtime,scheduletype,days,jobdata,lastqueuecheck,parentjobuid) VALUES (@timerjobuid,@jobname,@siteguid,@webguid,NULL,@jobtype,@enabled,@runtime,@scheduletype,@days,@jobdata,@lastqueuecheck,@parentjobuid)";
                        _DAO.AddParam("@timerjobuid", timerjobuid);
                        _DAO.AddParam("@jobname", "EPMLiveADSync");
                        _DAO.AddParam("@siteguid", web.Site.ID.ToString());
                        _DAO.AddParam("@webguid", web.Site.RootWeb.ID.ToString());
                        _DAO.AddParam("@jobtype", 8);
                        _DAO.AddParam("@enabled", true);
                        _DAO.AddParam("@runtime", iTime);
                        _DAO.AddParam("@scheduletype", iScheduleType);
                        _DAO.AddParam("@days", days);
                        _DAO.AddParam("@jobdata", web.Site.RootWeb.Url);
                        _DAO.AddParam("@lastqueuecheck", DBNull.Value);
                        _DAO.AddParam("@parentjobuid", DBNull.Value);
                        _DAO.ExecuteNonQuery(_DAO.GetEPMLiveConnection);
                    }

                    if (runNow && timerjobuid != Guid.Empty)
                    {
                        EPMLiveCore.CoreFunctions.enqueue(timerjobuid, 0);
                    }
                });
            }
            catch (Exception ex)
            {
                passed = false;
                _ExecutionLogs.Add("     ERROR -- Location: AddTimerJob() -- Message: " + ex.Message);
                _hasErrors = true;
            }
            finally
            {
                _DAO.Dispose();
            }
            return(passed);
        }
コード例 #9
0
        public void execute(SPSite site, SPWeb web, string data)
        {
            sbErrors = new StringBuilder();
            Hashtable hshMessages   = null;
            EPMData   epmdata       = null;
            DataTable dtListResults = null;

            WebAppId = web.Site.WebApplication.Id;
            try
            {
                float webCount = 0;
                base.totalCount = site.AllWebs.Count;

                hshMessages = new Hashtable();
                bool refreshAll = (string.IsNullOrEmpty(data) ? true : false);
                epmdata = new EPMData(true, site.ID, web.ID);

                if (data == null || data == "")
                {
                    data = epmdata.GetListNames();
                    try
                    {
                        setRPTSettings(epmdata, site);
                    }
                    catch (Exception ex)
                    {
                        bErrors = true;
                        sbErrors.Append("<font color=\"red\">Error Updating RPTSettings: " + ex.Message + "</font><br>");
                    }
                }

                //try
                //{
                //    data = epmdata.UpdateListNames(data);
                //}
                //catch (Exception ex)
                //{
                //    bErrors = true;
                //    sErrors += "<font color=\"red\">Error Updating List Names: " + ex.Message + "</font><br>";
                //}

                try
                {
                    epmdata.DeleteAllItemsDB(data, refreshAll);
                }
                catch (Exception ex)
                {
                    bErrors = true;
                    sbErrors.Append("<font color=\"red\">Error Cleaning Up Tables: " + ex.Message + "</font><br>");
                }

                foreach (string list in data.Split(','))
                {
                    if (!hshMessages.Contains(list))
                    {
                        hshMessages.Add(list, "");
                    }
                }

                dtListResults = new RefreshLists().InitializeResultsDT(data, refreshAll);

                foreach (SPWeb w in site.AllWebs)
                {
                    // indicates whether the site is the top-level Web site of the site collection and skip the workspace sites.
                    if (!w.IsRootWeb)
                    {
                        continue;
                    }

                    // IGNORE spdispose 130, w is being disposed
                    var dt = new DataTable();
                    try
                    {
                        sbErrors.Append("Processing Web: " + w.Title + " (" + w.ServerRelativeUrl + ")<br>");

                        //Call Reporting Code
                        var rf = new RefreshLists(w, data);

                        rf.StartRefresh(base.JobUid, out dt, refreshAll);
                        rf.AppendStatus(w.Title, w.ServerRelativeUrl, dtListResults, dt);

                        //Process Logs
                        foreach (DictionaryEntry de in hshMessages)
                        {
                            sbErrors.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Processing List (" + de.Key + ")");

                            bool      lFailed    = false;
                            string    msg        = "";
                            DataRow[] drMessages = dt.Select("ListName='" + de.Key + "'");
                            if (drMessages.Length > 0)
                            {
                                foreach (DataRow drMessage in drMessages)
                                {
                                    if (drMessage["ResultText"].ToString() != "")
                                    {
                                        msg +=
                                            "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\">" +
                                            drMessage["ResultText"] + "</font>";
                                        bErrors = true;
                                        lFailed = true;
                                    }
                                }
                            }

                            if (lFailed)
                            {
                                sbErrors.Append(" Failed: " + msg + ".<br>");
                            }
                            else
                            {
                                sbErrors.Append(" Success.<br>");
                            }
                        }
                        updateProgress(webCount++);
                    }
                    catch { }
                    finally
                    {
                        if (dt != null)
                        {
                            dt.Dispose();
                        }
                        if (w != null)
                        {
                            w.Dispose();
                        }
                    }
                }
            }
            finally
            {
                sErrors  = sbErrors.ToString();
                sbErrors = null;
                var refreshLists = new RefreshLists(web, "");
                refreshLists.SaveResults(dtListResults, base.JobUid);
                //Already Called in TimerClass.cs
                //finishJob();

                hshMessages = null;
                if (dtListResults != null)
                {
                    dtListResults.Dispose();
                }
                if (epmdata != null)
                {
                    epmdata.Dispose();
                }
                if (web != null)
                {
                    web.Dispose();
                }
                if (site != null)
                {
                    site.Dispose();
                }
                data = null;
            }
        }
コード例 #10
0
        public static DataSet GetReportingData(SPWeb web, string list, bool bRollup, string query, string orderby, int page, int pagesize)
        {
            var reportBiz = new ReportBiz(web.Site.ID);

            if (reportBiz.SiteExists())
            {
                var     oList = web.Lists[list];
                EPMData data  = null;

                try
                {
                    data = new EPMData(web.Site.ID);
                    var clientReportingConnection = data.GetClientReportingConnection;
                    var borderBy = false;
                    using (var sqlCommand = new SqlCommand(
                               "select * from information_schema.parameters where specific_name='spGetReportListData' and parameter_name='@orderby'",
                               clientReportingConnection))
                    {
                        using (var reader = sqlCommand.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                borderBy = true;
                            }
                        }
                    }

                    var dataSet = new DataSet();
                    using (var sqlCommand = new SqlCommand("spGetReportListData", clientReportingConnection))
                    {
                        sqlCommand.CommandType = CommandType.StoredProcedure;
                        sqlCommand.Parameters.AddWithValue("@siteid", web.Site.ID);
                        sqlCommand.Parameters.AddWithValue("@webid", web.ID);
                        sqlCommand.Parameters.AddWithValue("@weburl", web.ServerRelativeUrl);
                        sqlCommand.Parameters.AddWithValue("@userid", web.CurrentUser.ID);
                        sqlCommand.Parameters.AddWithValue("@rollup", bRollup);
                        sqlCommand.Parameters.AddWithValue("@list", list);
                        sqlCommand.Parameters.AddWithValue("@query", query);
                        sqlCommand.Parameters.AddWithValue("@pagesize", pagesize);
                        sqlCommand.Parameters.AddWithValue("@page", page);
                        sqlCommand.Parameters.AddWithValue("@listid", oList.ID);

                        if (borderBy)
                        {
                            sqlCommand.Parameters.AddWithValue("@orderby", orderby);
                        }

                        using (var dataAdapter = new SqlDataAdapter(sqlCommand))
                        {
                            dataAdapter.Fill(dataSet);
                        }
                    }

                    return(dataSet);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                    throw;
                }
                finally
                {
                    if (data != null)
                    {
                        data.Dispose();
                    }
                }
            }
            else
            {
                throw new Exception("Reporting Not Setup.");
            }
        }
コード例 #11
0
        private bool UpdateField(SPListEventProperties properties)
        {
            bool   isSuccessful    = true;
            string tableName       = string.Empty;
            string ssTableName     = string.Empty;
            var    rb              = new ReportBiz(properties.SiteId);
            bool   isUpdateRequire = false;

            try
            {
                var rd   = new ReportData(properties.SiteId);
                var cols = new ColumnDefCollection();
                // Actual table name
                tableName = rd.GetTableName(properties.ListId);
                // Snapshot table name
                ssTableName = rd.GetTableNameSnapshot(properties.ListId);
                // Create column definition collection to process with
                cols.AddColumn(properties.Field);

                var DAO = new EPMData(properties.SiteId);
                // Update only when field type is changed from single to multi value and vice-verse
                if (IsUpdateRequire(DAO, properties, tableName, cols[0].SqlColumnName))
                {
                    isUpdateRequire = true;

                    // Get Foreign Key
                    DataTable foreignKeyTable = rb.GetSpecificForeignKey(DAO, properties.ListId.ToString(), tableName, cols[0].SqlColumnName);

                    // Delete Foreign Key
                    if (foreignKeyTable.Rows.Count > 0)
                    {
                        rb.AddORRemoveForeignKey(DAO, foreignKeyTable.Rows[0], false);
                    }

                    // Delete & Add Field
                    rd.UpdateColumns(tableName, cols);
                    rd.UpdateColumns(ssTableName, cols);
                    rd.UpdateListColumns(properties.ListId, cols);

                    // Add Foreign Key only if lookup type is NOT allowed multi select
                    if (foreignKeyTable.Rows.Count > 0 && !properties.Field.TypeAsString.Equals("LookupMulti", StringComparison.InvariantCultureIgnoreCase))
                    {
                        rb.AddORRemoveForeignKey(DAO, foreignKeyTable.Rows[0], true);
                    }
                }
                DAO.Dispose();
                rd.Dispose();
            }
            catch (Exception ex)
            {
                var DAO = new EPMData(properties.SiteId);
                DAO.LogStatus(properties.ListId.ToString(), properties.FieldName,
                              "Database column update attempt: Unable to update column " + properties.FieldName + ". " + ex.Message,
                              ex.StackTrace, 2, 5, Guid.NewGuid().ToString()); //Logged in the RefreshAll event log.
                DAO.Dispose();
            }

            if (properties.Field is SPFieldLookup && isUpdateRequire)
            {
                #region Update all foreign keys
                try
                {
                    //FOREIGN IMPLEMENTATION -- START
                    var DAO = new EPMData(properties.SiteId);
                    rb.UpdateForeignKeys(DAO);
                    DAO.Dispose();
                    // -- END
                }
                catch (Exception ex)
                {
                    isSuccessful = false;
                    SPSecurity.RunWithElevatedPrivileges(delegate
                    {
                        if (!EventLog.SourceExists("EPMLive Reporting - UpdateForeignKeys"))
                        {
                            EventLog.CreateEventSource("EPMLive Reporting - UpdateForeignKeys", "EPM Live");
                        }

                        LogEntry(ex, "EPMLive Reporting - UpdateForeignKeys");
                    });
                }
                #endregion

                #region Cleanup list after field data type update to retain value
                try
                {
                    // List clean up -- START
                    var _DAO = new EPMData(properties.SiteId);
                    CleanupListAfterFieldUpdate(_DAO, properties.ListTitle);
                    // -- END
                }
                catch (Exception ex)
                {
                    isSuccessful = false;
                    SPSecurity.RunWithElevatedPrivileges(delegate
                    {
                        if (!EventLog.SourceExists("EPMLive Reporting - CleanupListAfterFieldUpdate"))
                        {
                            EventLog.CreateEventSource("EPMLive Reporting - CleanupListAfterFieldUpdate", "EPM Live");
                        }

                        LogEntry(ex, "EPMLive Reporting - CleanupListAfterFieldUpdate");
                    });
                }
                #endregion
            }
            return(isSuccessful);
        }