Exemplo n.º 1
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;
            }
        }