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); }
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); }
// 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); }
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); }