Example #1
0
        /// <summary>
        ///     Refreshes all.
        /// </summary>
        /// <returns></returns>
        public string RefreshAll()
        {
            try
            {
                using (var epmData = new EPMData(Web.Site.ID))
                {
                    epmData.DeleteWork(Guid.Empty, -1);

                    epmData.Command =
                        "select timerjobuid from timerjobs where siteguid=@siteguid and listguid is null and jobtype=5";
                    epmData.AddParam("@siteguid", Web.Site.ID);

                    object result = epmData.ExecuteScalar(epmData.GetEPMLiveConnection);

                    Guid timerJobId = Guid.Empty;

                    if (result != null)
                    {
                        timerJobId = (Guid)result;
                    }
                    else
                    {
                        timerJobId = Guid.NewGuid();

                        epmData.Command =
                            "INSERT INTO TIMERJOBS (siteguid, jobtype, jobname, scheduletype, webguid, timerjobuid) VALUES (@siteguid, 5, 'Reporting Refresh All', 2, @webguid, @timerjobuid)";
                        epmData.AddParam("@siteguid", Web.Site.ID);
                        epmData.AddParam("@webguid", Web.ID);
                        epmData.AddParam("@timerjobuid", timerJobId);

                        epmData.ExecuteNonQuery(epmData.GetEPMLiveConnection);
                    }

                    if (timerJobId != Guid.Empty)
                    {
                        CoreFunctions.enqueue(timerJobId, 0, Web.Site);
                    }
                }

                return("<RefreshAll><Data/></RefreshAll>");
            }
            catch (APIException)
            {
                throw;
            }
            catch (Exception exception)
            {
                throw new APIException((int)Errors.RefreshAll, exception.GetBaseException().Message);
            }
        }
        protected void CleanupLists(string sLists)
        {
            //Prod -- Start
            using (SPSite site = SPContext.Current.Site)
            {
                using (SPWeb web = SPContext.Current.Web)
                {
                    Guid listID = _DAO.GetListId(sLists, web.ID);

                    //DELETE WORK
                    _DAO.DeleteWork(listID, -1);
                    //END

                    _DAO.Command =
                        "select timerjobuid from timerjobs where siteguid=@siteguid and listguid = @listguid and jobtype=6";
                    _DAO.AddParam("@siteguid", site.ID.ToString());
                    _DAO.AddParam("@listguid", listID.ToString());
                    object oResult = _DAO.ExecuteScalar(_DAO.GetEPMLiveConnection);

                    Guid timerjobuid = Guid.Empty;

                    if (oResult != null)
                    {
                        timerjobuid = (Guid)oResult;
                    }
                    else
                    {
                        timerjobuid  = Guid.NewGuid();
                        _DAO.Command =
                            "INSERT INTO TIMERJOBS (timerjobuid, siteguid, jobtype, jobname, scheduletype, webguid, listguid, jobdata) VALUES (@timerjobuid, @siteguid, 6, 'List Data Cleanup', 0, @webguid, @listguid, @jobdata)";
                        _DAO.AddParam("@siteguid", site.ID.ToString());
                        _DAO.AddParam("@webguid", web.ID.ToString());
                        _DAO.AddParam("@listguid", listID.ToString());
                        _DAO.AddParam("@jobdata", sLists);
                        _DAO.AddParam("@timerjobuid", timerjobuid);
                        _DAO.ExecuteNonQuery(_DAO.GetEPMLiveConnection);
                    }

                    if (timerjobuid != Guid.Empty)
                    {
                        CoreFunctions.enqueue(timerjobuid, 0);
                    }
                }
            }
            //--End
        }
Example #3
0
        private void CleanupListAfterFieldUpdate(EPMData DAO, string sList)
        {
            using (SPSite site = new SPSite(DAO.SiteId))
            {
                using (SPWeb web = site.RootWeb)
                {
                    Guid listID = DAO.GetListId(sList, web.ID);

                    //DELETE WORK
                    DAO.DeleteWork(listID, -1);
                    //END

                    DAO.Command =
                        "select timerjobuid from timerjobs where siteguid=@siteguid and listguid = @listguid and jobtype=6";
                    DAO.AddParam("@siteguid", site.ID.ToString());
                    DAO.AddParam("@listguid", listID.ToString());
                    object oResult = DAO.ExecuteScalar(DAO.GetEPMLiveConnection);

                    Guid timerjobuid = Guid.Empty;

                    if (oResult != null)
                    {
                        timerjobuid = (Guid)oResult;
                    }
                    else
                    {
                        timerjobuid = Guid.NewGuid();
                        DAO.Command =
                            "INSERT INTO TIMERJOBS (timerjobuid, siteguid, jobtype, jobname, scheduletype, webguid, listguid, jobdata) VALUES (@timerjobuid, @siteguid, 6, 'List Data Cleanup', 0, @webguid, @listguid, @jobdata)";
                        DAO.AddParam("@siteguid", site.ID.ToString());
                        DAO.AddParam("@webguid", web.ID.ToString());
                        DAO.AddParam("@listguid", listID.ToString());
                        DAO.AddParam("@jobdata", sList);
                        DAO.AddParam("@timerjobuid", timerjobuid);
                        DAO.ExecuteNonQuery(DAO.GetEPMLiveConnection);
                    }

                    if (timerjobuid != Guid.Empty)
                    {
                        EPMLiveCore.CoreFunctions.enqueue(timerjobuid, 0, site);
                    }
                }
            }
            //--End
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _DAO = new EPMData(SPContext.Current.Site.ID);
            string action       = Request["Action"];
            Guid   timerjobguid = Guid.NewGuid();

            //DataTable dtResults;

            if (action != null && action == "SnapshotAll")
            {
                try
                {
                    //Local Testing -- Start
                    //_DAO.SnapshotLists(timerjobguid, _DAO.GetListNames());
                    //dtResults = _DAO.GetSnapshotResults(timerjobguid);
                    // -- END

                    //PROD -- Start
                    string sListIDs = _DAO.GetAllListIDs();
                    using (SPSite site = SPContext.Current.Site)
                    {
                        using (SPWeb web = SPContext.Current.Web)
                        {
                            _DAO.Command =
                                "INSERT INTO TIMERJOBS (timerjobuid, siteguid, jobtype, jobname, scheduletype, webguid, jobdata) VALUES (@timerjobuid,@siteguid, 7, 'Reporting Snapshot All', 0, @webguid, @jobdata)";
                            _DAO.AddParam("@timerjobuid", timerjobguid);
                            _DAO.AddParam("@siteguid", site.ID.ToString());
                            _DAO.AddParam("@webguid", web.ID.ToString());
                            _DAO.AddParam("@jobdata", sListIDs);
                            _DAO.ExecuteNonQuery(_DAO.GetEPMLiveConnection);
                        }
                        CoreFunctions.enqueue(timerjobguid, 0);
                    }
                    //END
                }
                catch (Exception ex)
                {
                    _DAO.LogStatus(string.Empty, string.Empty, "Process: SnapshotAll - " + ex.Message, ex.StackTrace, 2,
                                   9, string.Empty);
                    Response.Write("Error: " + ex.Message);
                    return;
                }
                SPUtility.Redirect("epmlive/ListMappings.aspx", SPRedirectFlags.RelativeToLayoutsPage,
                                   HttpContext.Current);
            }
            else if (action != null && action == "CleanupAll")
            {
                //Local Testing -- Start
                //string sListNames = _DAO.GetListNames();
                //DataTable dtWebResults = null;
                //timerjobguid = new Guid();
                //DataTable dtListResults = new RefreshLists().InitializeResultsDT(sListNames);

                //if (sListNames != string.Empty)
                //{
                //    RefreshLists oListRefresh = null;
                //    foreach (SPWeb web in SPContext.Current.Site.AllWebs)
                //    {
                //        oListRefresh = new RefreshLists(web, sListNames);
                //        oListRefresh.StartRefresh(timerjobguid, out dtWebResults);
                //        dtWebResults.TableName = web.ServerRelativeUrl;
                //        oListRefresh.AppendStatus(web.Name, web.ServerRelativeUrl, dtListResults, dtWebResults);
                //    }
                //    oListRefresh.SaveResults(dtListResults, timerjobguid);
                //}
                // -- End

                //PROD -- Start
                using (SPSite site = SPContext.Current.Site)
                {
                    using (SPWeb web = SPContext.Current.Web)
                    {
                        //DELETE WORK
                        _DAO.DeleteWork(Guid.Empty, -1);
                        //END

                        _DAO.Command =
                            "select timerjobuid from timerjobs where siteguid=@siteguid and listguid is null and jobtype=6";
                        _DAO.AddParam("@siteguid", site.ID.ToString());
                        object oResult     = _DAO.ExecuteScalar(_DAO.GetEPMLiveConnection);
                        Guid   timerjobuid = Guid.Empty;

                        if (oResult != null)
                        {
                            timerjobuid = (Guid)oResult;
                        }
                        else
                        {
                            timerjobuid  = Guid.NewGuid();
                            _DAO.Command =
                                "INSERT INTO TIMERJOBS (siteguid, jobtype, jobname, scheduletype, webguid, timerjobuid) VALUES (@siteguid, 6, 'List Data Cleanup', 2, @webguid, @timerjobuid)";
                            _DAO.AddParam("@siteguid", site.ID.ToString());
                            _DAO.AddParam("@webguid", web.ID.ToString());
                            _DAO.AddParam("@timerjobuid", timerjobuid);
                            _DAO.ExecuteNonQuery(_DAO.GetEPMLiveConnection);
                        }

                        if (timerjobuid != Guid.Empty)
                        {
                            CoreFunctions.enqueue(timerjobuid, 0);
                        }
                    }
                }
                // -- END
                SPUtility.Redirect("epmlive/ListMappings.aspx", SPRedirectFlags.RelativeToLayoutsPage,
                                   HttpContext.Current);
            }
        }