示例#1
0
 private static Dictionary <string, object> GetCreateFavWorkspaceQueryParams(AnalyticsData data)
 {
     return(data.IsItem ?
            new Dictionary <string, object>
     {
         { "@siteid", data.SiteId },
         { "@webid", data.WebId },
         { "@listid", data.ListId },
         { "@itemid", data.ItemId },
         { "@userid", data.UserId },
         { "@icon", data.Icon },
         { "@title", data.Title },
         { "@fstring", data.FString }
     }
         :
            new Dictionary <string, object>
     {
         { "@siteid", data.SiteId },
         { "@webid", data.WebId },
         { "@listid", data.ListId },
         { "@userid", data.UserId },
         { "@icon", data.Icon },
         { "@title", data.Title },
         { "@fstring", data.FString }
     });
 }
        public static string GetQuery(AnalyticsData data)
        {
            var query = string.Empty;

            switch (data.Type)
            {
            case AnalyticsType.Favorite:
                query = GetFavoriteQueries(data);
                break;

            case AnalyticsType.Frequent:
                query = GetFrequentQueries(data);
                break;

            case AnalyticsType.Recent:
                query = GetRecentQueries(data);
                break;

            case AnalyticsType.FavoriteWorkspace:
                query = GetFavoriteWorkspaceQueries(data);
                break;
            }

            return(query);
        }
        public static string Create(string xml)
        {
            var result = string.Empty;
            var dt     = new System.Data.DataTable();
            var data   = new AnalyticsData(xml, AnalyticsType.Frequent, AnalyticsAction.Create);

            try
            {
                var exec = new QueryExecutor(SPContext.Current.Web);
                dt = exec.ExecuteEpmLiveQuery(
                    FRFQueryFactory.GetQuery(data),
                    FRFQueryParamFactory.GetParam(data));
                if (dt != null && dt.Rows.Count > 0)
                {
                    result = string.Join(",", dt.Rows[0].ItemArray);
                }


                ClearCache(data);
            }
            catch (Exception e)
            {
                result = "error: " + e.Message;
            }
            return(result);
        }
示例#4
0
        public static Dictionary <string, object> GetParam(AnalyticsData data)
        {
            var queryParams = new Dictionary <string, object>();

            switch (data.Type)
            {
            case AnalyticsType.Favorite:
                queryParams = GetFavoriteQueryParams(data);
                break;

            case AnalyticsType.Frequent:
                queryParams = GetFrequentQueryParams(data);
                break;

            case AnalyticsType.Recent:
                queryParams = GetRecentItemQueryParams(data);
                break;

            case AnalyticsType.FavoriteWorkspace:
                queryParams = GetFavWorkspaceQueryParams(data);
                break;
            }

            return(queryParams);
        }
示例#5
0
 private static Dictionary <string, object> GetDeleteFrequentQueryParams(AnalyticsData data)
 {
     return(data.IsItem ?
            new Dictionary <string, object>
     {
         { "@siteid", data.SiteId },
         { "@webid", data.WebId },
         { "@listid", data.ListId },
         { "@itemid", data.ItemId },
         { "@fstring", data.FString },
         { "@userid", data.UserId },
         { "@icon", data.Icon },
         { "@title", data.Title },
     }
     :
            new Dictionary <string, object>
     {
         { "@siteid", data.SiteId },
         { "@webid", data.WebId },
         { "@listid", data.ListId },
         { "@itemid", DBNull.Value },
         { "@fstring", data.FString },
         { "@userid", data.UserId },
         { "@icon", data.Icon },
         { "@title", data.Title },
     }
            );
 }
示例#6
0
        // insert data
        public static string AddFavWorkspace(string xml)
        {
            var result = string.Empty;
            var dt     = new System.Data.DataTable();
            var data   = new AnalyticsData(xml, AnalyticsType.FavoriteWorkspace, AnalyticsAction.Create);

            try
            {
                var qExec = new QueryExecutor(SPContext.Current.Web);
                dt = qExec.ExecuteEpmLiveQuery(
                    FRFQueryFactory.GetQuery(data),
                    FRFQueryParamFactory.GetParam(data));
                ClearCache(data);
                if (dt.Rows != null && dt.Rows.Count > 0)
                {
                    result = string.Join(",", dt.Rows[0].ItemArray);
                }
                else
                {
                    throw new APIException(21000, "[FavoritesWorkspaceService-AddFavWorkspace] No new fav was added.");
                }
            }
            catch (Exception e)
            {
                throw new APIException(21000, "[FavoritesWorkspaceService-AddFavWorkspace] " + e.Message);
            }

            return(result);
        }
示例#7
0
        public static string RemoveFav(string xml)
        {
            var result = string.Empty;
            var dt     = new System.Data.DataTable();
            var data   = new AnalyticsData(xml, AnalyticsType.Favorite, AnalyticsAction.Delete);

            try
            {
                var qExec = new QueryExecutor(SPContext.Current.Web);
                dt = qExec.ExecuteEpmLiveQuery(
                    FRFQueryFactory.GetQuery(data),
                    FRFQueryParamFactory.GetParam(data));
                ClearCache(data);
                if (dt.Rows.Count > 0)
                {
                    result = string.Join(",", CleanItemArray(dt.Rows[0].ItemArray));
                }
                else
                {
                    throw new APIException(21000, "[FavoritesService-RemoveFav] ");
                }
            }
            catch (Exception e)
            {
                throw new APIException(21000, "[FavoritesService-RemoveFav] " + e.Message);
            }

            return(result);
        }
        private static bool IsValidList(AnalyticsData data)
        {
            bool isValid      = false;
            var  inValidLists = new List <string>
            {
                "Holiday Schedules",
                "My Timesheet",
                "Holidays",
                "My Work",
                "Roles",
                "Departments",
                "Non Work",
                "Project Schedules",
                "Site Assets",
                "IzendaReports",
                "Planner Templates",
                "Report Library",
                "Site Pages",
                "User Profile Pictures",
                "Excel Reports",
                "Style Library",
                "Work Hour"
            };

            try
            {
                try
                {
                    using (var spSite = new SPSite(data.SiteId))
                    {
                        using (var spWeb = spSite.OpenWeb(data.WebId))
                        {
                            SPList testList = null;
                            try
                            {
                                testList = spWeb.Lists[data.ListId];
                            }
                            catch
                            {
                            }

                            if (testList != null && !testList.Hidden && !inValidLists.Contains(testList.Title))
                            {
                                isValid = true;
                            }
                        }
                    }
                }
                catch
                {
                }
            }
            catch { }

            return(isValid);
        }
        private static string GetRecentQueries(AnalyticsData data)
        {
            var query = string.Empty;

            switch (data.Action)
            {
            case AnalyticsAction.Create:
                query = GetCreateRecentItemQuery(data);
                break;
            }
            return(query);
        }
示例#10
0
 private static Dictionary <string, object> GetCreateFrequentQueryParams(AnalyticsData data)
 {
     return(new Dictionary <string, object>
     {
         { "@siteid", data.SiteId },
         { "@webid", data.WebId },
         { "@listid", data.ListId },
         { "@userid", data.UserId },
         { "@icon", data.Icon },
         { "@title", data.Title },
     });
 }
示例#11
0
        private static Dictionary <string, object> GetRecentItemQueryParams(AnalyticsData data)
        {
            var queryParams = new Dictionary <string, object>();

            switch (data.Action)
            {
            case AnalyticsAction.Create:
                queryParams = GetCreateRecentItemQueryParams(data);
                break;
            }

            return(queryParams);
        }
示例#12
0
        private static Dictionary <string, object> GetFavWorkspaceQueryParams(AnalyticsData data)
        {
            var queryParams = new Dictionary <string, object>();

            switch (data.Action)
            {
            case AnalyticsAction.Create:
                queryParams = GetCreateFavWorkspaceQueryParams(data);
                break;

            case AnalyticsAction.Delete:
                queryParams = GetRemoveFavWorkspaceQueryParams(data);
                break;
            }

            return(queryParams);
        }
示例#13
0
 private static void ClearCache(AnalyticsData data)
 {
     try
     {
         SPWeb web = null;
         try
         {
             using (var spSite = new SPSite(data.SiteId))
             {
                 using (SPWeb spWeb = spSite.OpenWeb(data.WebId))
                 {
                     web = spWeb;
                     new WorkspaceLinkProvider(data.SiteId, data.WebId, spWeb.Users.GetByID(data.UserId).LoginName).ClearCache();
                 }
             }
         }
         catch
         {
             CacheStore.Current.RemoveCategory(new CacheStoreCategory(web).Navigation);
         }
     }
     catch { }
 }
示例#14
0
        public static string IsFav(string xml)
        {
            var result = "false";
            var data   = new AnalyticsData(xml, AnalyticsType.Favorite, AnalyticsAction.Read);

            try
            {
                var qExec = new QueryExecutor(SPContext.Current.Web);
                var table = qExec.ExecuteEpmLiveQuery(
                    FRFQueryFactory.GetQuery(data),
                    FRFQueryParamFactory.GetParam(data));
                if (table != null)
                {
                    result = table.Rows[0][0].ToString();
                }
            }
            catch (Exception e)
            {
                throw new APIException(21000, "[FavoritesService-IsFav] " + e.Message);
            }

            return(result);
        }
示例#15
0
        private static Dictionary <string, object> GetFrequentQueryParams(AnalyticsData data)
        {
            var queryParams = new Dictionary <string, object>();

            switch (data.Action)
            {
            case AnalyticsAction.Create:
                queryParams = GetCreateFrequentQueryParams(data);
                break;

            case AnalyticsAction.Read:
                queryParams = GetReadFrequentQueryParams(data);
                break;

            case AnalyticsAction.Update:
                break;

            case AnalyticsAction.Delete:
                queryParams = GetDeleteFrequentQueryParams(data);
                break;
            }

            return(queryParams);
        }
        private static string GetFavoriteWorkspaceQueries(AnalyticsData data)
        {
            var query = string.Empty;

            switch (data.Action)
            {
            case AnalyticsAction.Create:
                query = GetCreateFavWorkSpaceQuery(data);
                break;

            case AnalyticsAction.Read:
                query = GetReadFavWorkSpaceQuery(data);
                break;

            case AnalyticsAction.Update:

                break;

            case AnalyticsAction.Delete:
                query = GetRemoveFavWorkSpaceQuery(data);
                break;
            }
            return(query);
        }
        private static string GetFrequentQueries(AnalyticsData data)
        {
            var query = string.Empty;

            switch (data.Action)
            {
            case AnalyticsAction.Create:
                query = GetCreateFrequentQuery(data);
                break;

            case AnalyticsAction.Read:
                query = GetReadFrequentQuery(data);
                break;

            case AnalyticsAction.Update:
                query = GetUpdateFrequentQuery(data);
                break;

            case AnalyticsAction.Delete:
                query = GetRemoveFrequentQuery(data);
                break;
            }
            return(query);
        }
 private static string GetRemoveFavoriteQuery(AnalyticsData data)
 {
     return(data.IsItem ? queryRemoveFav_Item : queryRemoveFav_NonItem);
 }
 private static string GetUpdateFrequentQuery(AnalyticsData data)
 {
     return(data.IsItem ? queryCheckFrequentStatus_Item : queryCheckFrequentStatus_NonItem);
 }
 private static string GetCreateRecentItemQuery(AnalyticsData data)
 {
     return(queryCreateRecentItem);
 }
 private static string GetRemoveFrequentQuery(AnalyticsData data)
 {
     return(data.IsItem ? queryRemoveFrequent_Item : queryRemoveFrequent_NonItem);
 }
 private static string GetCreateFrequentQuery(AnalyticsData data)
 {
     return(queryCreateFrequent);
 }
 private static string GetReadFavWorkSpaceQuery(AnalyticsData data)
 {
     return(data.IsItem ? queryReadFavWSStatus_Item : queryReadFavWSStatus_NonItem);
 }
 private static string GetCreateFavWorkSpaceQuery(AnalyticsData data)
 {
     return(data.IsItem ? queryCreateFavWS_Item : queryCreateFavWS_NonItem);
 }
 private static string GetReadFavoriteQuery(AnalyticsData data)
 {
     return(data.IsItem ? queryCheckFavStatus_Item : queryCheckFavStatus_NonItem);
 }