internal override string Execute(string[] parameters) { int userID; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } if (parameters.Length < 2) { return(ErrorWrapper.SendError("Command parameters missing.")); } BLClient client = null; int pcID; try { client = new BLClient(); pcID = client.AddPC(userID, parameters[1]); } catch (Exception ex) { return(ErrorWrapper.SendError(ex.Message)); } finally { client.Dispose(); } return(pcID.ToString()); }
internal override string Execute(NameValueCollection commandParameters) { int channelID; string error = ValidateIntParameter(commandParameters, "channelId", out channelID); if (error != string.Empty) { return(error); } Channel channel = null; BLClient client = null; try { client = new BLClient(); channel = client.GetChannelDetailsSimple(channelID); } catch (Exception exception) { return(ErrorWrapper.SendError(exception.Message)); } finally { if (client != null) { client.Dispose(); } } return(Flatten(channel)); }
/// <summary> /// Gets the appropriate command processor with the specified type /// </summary> /// <param name="commandType">Type of the processor to instantiate</param> /// <param name="context">HttpContext object that requested this instantiation</param> /// <returns>a CommandProcessor that will perform the requested command action, null if instantiation failed.</returns> protected T GetCommandProcessor <T>(string commandType, HttpContext context) where T : CommandProcessor { Type type = null; T commandProcessor = null; try { type = Type.GetType(commandType); } catch (Exception ex) { context.Response.Write(ErrorWrapper.SendError(ex.Message)); return(null); } try { commandProcessor = (T)(Activator.CreateInstance(type, new object[] { context.Session })); } catch (Exception ex) { context.Response.Write(ErrorWrapper.SendError(ex.Message)); return(null); } return(commandProcessor); }
internal override string Execute(System.Collections.Specialized.NameValueCollection commandParameters) { int userID; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } BLClient client = null; List <ChannelSimple> channels = null; try { client = new BLClient(); channels = client.GetChannelsAll(userID); } catch (Exception exception) { return(ErrorWrapper.SendError(exception.Message)); } finally { if (client != null) { client.Dispose(); } } return(Flatten(channels)); }
internal override string Execute(string[] parameters) { int oldFolderID; int newFolderID; int userID; List <int> channelIDList; string error = Helper.GetIDsMove(_session, parameters, out userID, out oldFolderID, out newFolderID, out channelIDList); if (error != "1") { return(error); } BLClient client = null; try { client = new BLClient(); client.MovePCChannels(userID, oldFolderID, newFolderID, channelIDList); } catch (Exception ex) { return(ErrorWrapper.SendError(ex.Message)); } finally { client.Dispose(); } return("1"); }
internal override string Execute(NameValueCollection commandParameters) { int userID; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } List <List <CreateContentGenericFolder> > folderList; BLClient client = null; try { client = new BLClient(); folderList = client.GetFolders(userID); } catch (Exception exception) { return(ErrorWrapper.SendError(exception.Message)); } finally { if (client != null) { client.Dispose(); } } return(Flatten(folderList)); }
internal override string Execute(string[] parameters) { int folderID; int userID; List <int> contentIDList; string error = Helper.GetIDs(_session, parameters, out userID, out folderID, out contentIDList); if (error != "1") { return(error); } BLClient client = null; try { client = new BLClient(); client.AddSlideContent(userID, folderID, contentIDList); } catch (Exception ex) { return(ErrorWrapper.SendError(ex.Message)); } finally { client.Dispose(); } return("1"); }
public virtual void ProcessRequest(HttpContext context) { context.Response.Clear(); ChannelCommandConfigurationSection commandSection = (ChannelCommandConfigurationSection)System.Configuration.ConfigurationManager.GetSection("channelCommandSet"); // is this a GET request if (context.Request.QueryString["command"] != null) { string commandName = context.Request.QueryString["command"]; if (commandSection.ChannelCommands[commandName] == null) { context.Response.Write(ErrorWrapper.SendError("Invalid command.")); return; } string commandType = commandSection.ChannelCommands[commandName].Type; GetCommandProcessor getCommandProcessor = GetCommandProcessor <GetCommandProcessor>(commandType, context); if (getCommandProcessor != null) { context.Response.Write(getCommandProcessor.Execute(context.Request.QueryString)); } } // is this a POST request else if (context.Request.Form["command"] != null) { string[] postVars = context.Request.Form["command"].Split(new string[] { ",," }, StringSplitOptions.None); if (postVars.Length < 2) { context.Response.Write(ErrorWrapper.SendError("Not enough parameters.")); return; } if (commandSection.ChannelCommands[postVars[0]] == null) { context.Response.Write(ErrorWrapper.SendError("Invalid command.")); return; } string commandType = commandSection.ChannelCommands[postVars[0]].Type; PostCommandProcessor postCommandProcessor = GetCommandProcessor <PostCommandProcessor>(commandType, context); if (postCommandProcessor != null) { context.Response.Write(postCommandProcessor.Execute(postVars)); } } else { context.Response.Write(ErrorWrapper.SendError("Command parameter not specified.")); } }
/// <summary> /// Validates if a Query String parameter exists in the Query String /// </summary> /// <param name="commandParameters">the Query String to check</param> /// <param name="parameter">the parameter to validate</param> /// <returns>An empty string if the parameter exists, an error message otherwise</returns> protected string ValidateParameterExists(NameValueCollection commandParameters, string parameter) { if (commandParameters[parameter] == null) { return(ErrorWrapper.SendError("Parameter " + parameter + " not supplied")); } return(String.Empty); }
internal override string Execute(string[] parameters) { int slideFolderID; int slideID; int userID; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } if (parameters.Length < 3) { return(ErrorWrapper.SendError("Command parameters missing.")); } if (!int.TryParse(parameters[1], out slideFolderID)) { return(ErrorWrapper.SendError("Cannot parse Slide Folder ID")); } if (!int.TryParse(parameters[2], out slideID)) { return(ErrorWrapper.SendError("Cannot parse Slide ID")); } BLClient client = null; bool bCanRemove = false; try { client = new BLClient(); bCanRemove = client.RemoveSlideContent(userID, slideFolderID, slideID); } catch (Exception ex) { return(ErrorWrapper.SendError(ex.Message)); } finally { client.Dispose(); } if (!bCanRemove) { return("-1"); } return("1"); }
internal override string Execute(string[] parameters) { int userID; int pcID; int channelID; int channelWeighting; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } if (parameters.Length < 4) { return(ErrorWrapper.SendError("Command parameters missing.")); } if (!int.TryParse(parameters[1], out pcID)) { return(ErrorWrapper.SendError("Cannot parse PC ID.")); } if (!int.TryParse(parameters[2], out channelID)) { return(ErrorWrapper.SendError("Cannot parse Channel ID.")); } if (!int.TryParse(parameters[3], out channelWeighting)) { return(ErrorWrapper.SendError("Cannot parse Channel Weighting.")); } BLClient client = null; try { client = new BLClient(); client.EditChannelWeighting(userID, pcID, channelID, channelWeighting); } catch (Exception ex) { return(ErrorWrapper.SendError(ex.Message)); } finally { client.Dispose(); } return("1"); }
internal override string Execute(string[] parameters) { int userID; int assetContentFolderID; int assetContentID; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } if (parameters.Length < 3) { return(ErrorWrapper.SendError("Command parameters missing.")); } if (!int.TryParse(parameters[1], out assetContentFolderID)) { return(ErrorWrapper.SendError("Cannot parse raw content folder ID.")); } if (!int.TryParse(parameters[2], out assetContentID)) { return(ErrorWrapper.SendError("Cannot parse raw content ID.")); } BLClient client = null; int fileLength = -1; try { client = new BLClient(); fileLength = client.RemoveAssetContent(userID, assetContentFolderID, assetContentID); } catch (Exception ex) { return(ErrorWrapper.SendError(ex.Message)); } finally { client.Dispose(); } if (fileLength != -1) { ((User)_session["User"]).UsedBytes -= fileLength; } return("1"); }
/// <summary> /// Checks whether a given string is "0" or "1", else returns an error message /// </summary> /// <param name="intSwitchParam">the parameter to check</param> /// <returns>An empty string if the intSwitchParam is "0" or "1", an error message otherwise</returns> protected string ValidateIntSwitchParameter(string intSwitchParam) { switch (intSwitchParam) { case "1": goto case "0"; case "0": return(String.Empty); default: return(ErrorWrapper.SendError("Cannot parse int switch")); } }
private string GetSortChannelsByFromConfig(string sortByValue, out string sortByEnumString) { QueryStringParameterValueConfiguration queryStringParameterValueConfiguration = (QueryStringParameterValueConfiguration)System.Configuration.ConfigurationManager.GetSection("queryStringParameterGroup/enumQueryStringParameterSet"); if (queryStringParameterValueConfiguration.QueryStringParameters[sortByValue] == null) { sortByEnumString = String.Empty; return(ErrorWrapper.SendError("Enum parameter " + sortByValue + " does not exist.")); } sortByEnumString = queryStringParameterValueConfiguration.QueryStringParameters[sortByValue].Value; return(String.Empty); }
private string TryParseSortChannelsBy(Type type, string sortBy, out SortChannelsBy sortChannelBy) { try { sortChannelBy = (SortChannelsBy)Enum.Parse(type, sortBy); } catch { sortChannelBy = SortChannelsBy.Alphabetical; return(ErrorWrapper.SendError(sortBy + " cannot be parsed.")); } return(String.Empty); }
internal override string Execute(string[] parameters) { // is there a command name, username, password, firstname, lastname? if (parameters.Length < 5) { return(ErrorWrapper.SendError("Command parameters missing.")); } if (!emailPattern.IsMatch(parameters[1])) { return("-3"); } BLClient client = null; User user = null; foreach (string parameter in parameters) { if (parameter.Trim() == String.Empty) { return("-1"); } } // call WCF BLL layer try { client = new BLClient(); user = client.Signup(parameters[1], parameters[2], parameters[3], parameters[4]); } catch (Exception exception) { _logger.WriteMessage(exception.ToString()); return(ErrorWrapper.SendError(exception.Message)); } finally { client.Dispose(); } if (user == null) { return("-2"); } _session.Add("User", user); return("1"); }
private string GetIDs(string[] parameters, out int pcID, out List <int> contentIDList) { contentIDList = null; pcID = -1; if (parameters.Length < 3) { return(ErrorWrapper.SendError("Command parameters missing.")); } if (!int.TryParse(parameters[1], out pcID)) { return(ErrorWrapper.SendError("Can't parse PC ID")); } return(Helper.GetContentIDs(parameters[2], out contentIDList)); }
/// <summary> /// Checks whether a given int exists in a Query string and then extracts it /// </summary> /// <param name="commandParameters">the Query String to check</param> /// <param name="parameter">the parameter to validate and extract</param> /// <param name="numerical">the reference of the int to extract the parameter to</param> /// <returns>An empty string if the parameter exists, an error message otherwise</returns> protected string ValidateIntParameter(NameValueCollection commandParameters, string parameter, out int numerical) { string error = ValidateParameterExists(commandParameters, parameter); if (error != String.Empty) { numerical = -1; return(error); } if (!int.TryParse(commandParameters[parameter], out numerical)) { return(ErrorWrapper.SendError("invalid parameter:" + parameter)); } return(String.Empty); }
internal override string Execute(string[] parameters) { // is there a command name, username, password and a "remember me" setting? if (parameters.Length < 3) { return(ErrorWrapper.SendError("Command parameters missing.")); } BLClient client = null; User user = null; // call WCF BLL layer try { client = new BLClient(); user = client.Login(parameters[1], parameters[2]); } catch (Exception exception) { return(ErrorWrapper.SendError(exception.Message)); } finally { client.Dispose(); } if (user != null) { _session.Add("User", user); // in case user was poking around the Download page while logged off, we need to clear // log-off PC Creation operation parameters _session.Remove("PcProfileToken"); if (string.IsNullOrEmpty(user.FirstName)) { return("-"); } return(user.FirstName); } return("0"); }
internal override string Execute(string[] parameters) { int userID; List <int> contentIDList = null; int folderId; int templateId; string field1; string field2; string error; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } if (!int.TryParse(parameters[1], out folderId)) { return(ErrorWrapper.SendError("Invalid FolderId")); } if (!int.TryParse(parameters[2], out templateId)) { return(ErrorWrapper.SendError("Invalid Template ID")); } field1 = parameters[3]; field2 = parameters[4]; error = Helper.GetContentIDs(parameters[5], out contentIDList); if (error != "1") { return(error); } if (templateId == 0) { var client = new BLClient(); client.AddSlideContent(userID, folderId, contentIDList); } else { var slideManagementService = ServiceLocator.Current.GetInstance <ISlideManagementService>(); slideManagementService.CreateFromTemplate(userID, folderId, contentIDList, templateId, field1, field2); } return("1"); }
internal override string Execute(string[] parameters) { int userID; int channelID; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } if (parameters.Length < 3) { return(ErrorWrapper.SendError("Command parameters missing.")); } if (!int.TryParse(parameters[1], out channelID)) { return(ErrorWrapper.SendError("Cannot parse channel ID.")); } string thumbnailSlideRelativePath = System.Configuration.ConfigurationSettings.AppSettings["thumbnailSlideRelativePath"]; int thumbnailSlideRelativePathLength = thumbnailSlideRelativePath.Length; string imagePath = parameters[2].Substring(thumbnailSlideRelativePathLength, parameters[2].Length - thumbnailSlideRelativePathLength); BLClient client = null; try { client = new BLClient(); client.EditChannelThumbnail(userID, channelID, imagePath); } catch (Exception ex) { return(ErrorWrapper.SendError(ex.Message)); } finally { client.Dispose(); } return("1"); }
internal override string Execute(string[] parameters) { int userID; int streamID; int categoryID; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } if (!int.TryParse(parameters[1], out streamID)) { return(ErrorWrapper.SendError("Parsing Stream ID")); } if (!int.TryParse(parameters[2], out categoryID)) { return(ErrorWrapper.SendError("Parsing Category ID")); } BLClient client = null; try { client = new BLClient(); client.SetCategory(userID, streamID, categoryID); } catch (Exception exception) { return(ErrorWrapper.SendError(exception.Message)); } finally { if (client != null) { client.Dispose(); } } return("1"); }
internal override string Execute(NameValueCollection commandParameters) { int userID = -1; string pcProfileToken = null; Helper.TryGetUserID(_session, out userID); if (userID == -1 && _session["PcProfileToken"] == null) { pcProfileToken = System.Guid.NewGuid().ToString(); _session.Add("PcProfileToken", pcProfileToken); } else { pcProfileToken = (string)_session["PcProfileToken"]; } List <PC> endUserMachineList; BLClient client = null; try { client = new BLClient(); endUserMachineList = client.GetPcList(userID, pcProfileToken); } catch (Exception exception) { return(ErrorWrapper.SendError(exception.Message)); } finally { if (client != null) { client.Dispose(); } } return(Flatten(endUserMachineList)); }
internal override string Execute(NameValueCollection commandParameters) { string keyword; int userID; if (!Helper.TryGetUserID(_session, out userID)) { userID = -1; } string error = ValidateStringParameter(commandParameters, "keyword", out keyword); if (error != String.Empty) { return(error); } List <ChannelListChannel> channelList; BLClient client = null; // call WCF BLL Method try { client = new BLClient(); channelList = client.Search(userID, keyword); } catch (Exception exception) { return(ErrorWrapper.SendError(exception.Message)); } finally { if (client != null) { client.Dispose(); } } return(Flatten(channelList)); }
internal override string Execute(System.Collections.Specialized.NameValueCollection commandParameters) { int userID; int folderID; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } string error = ValidateIntParameter(commandParameters, "folderID", out folderID); if (error != String.Empty) { return(error); } PageAssetContentData contentList; BLClient client = null; // call WCF BLL Method try { client = new BLClient(); contentList = client.GetRawContent(userID, folderID); } catch (Exception exception) { return(ErrorWrapper.SendError(exception.Message)); } finally { if (client != null) { client.Dispose(); } } return(Flatten(contentList)); }
internal override string Execute(System.Collections.Specialized.NameValueCollection commandParameters) { int channelsSlideID; int userID; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } string error = ValidateIntParameter(commandParameters, "slideID", out channelsSlideID); if (error != String.Empty) { return(error); } ChannelSlideProperties channelSlideProperties = null; BLClient client = null; // call WCF BLL Method try { client = new BLClient(); channelSlideProperties = client.GetChannelSlideProperties(userID, channelsSlideID); } catch (Exception exception) { return(ErrorWrapper.SendError(exception.Message)); } finally { if (client != null) { client.Dispose(); } } return(Flatten(channelSlideProperties)); }
internal override string Execute(NameValueCollection commandParameters) { int folderID; int userID; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } string error = ValidateIntParameter(commandParameters, "folderID", out folderID); if (error != String.Empty) { return(error); } PageSlideData pageSlideData; BLClient client = null; // call WCF BLL Method try { client = new BLClient(); pageSlideData = client.GetUserStreams(userID, folderID); } catch (Exception exception) { return(ErrorWrapper.SendError(exception.Message)); } finally { if (client != null) { client.Dispose(); } } return(Flatten(pageSlideData)); }
internal override string Execute(string[] parameters) { int pcID; int userID = -1; List <int> contentIDList; string error = null; if (_session["User"] != null) { error = Helper.GetIDs(_session, parameters, out userID, out pcID, out contentIDList); } else { error = GetIDs(parameters, out pcID, out contentIDList); } if (error != "1") { return(error); } BLClient client = null; try { client = new BLClient(); client.RemovePCStream(userID, pcID, contentIDList); } catch (Exception ex) { return(ErrorWrapper.SendError(ex.Message)); } finally { client.Dispose(); } return("1"); }
internal override string Execute(string[] parameters) { int userID; int channelID; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } if (parameters.Length < 3) { return(ErrorWrapper.SendError("Command parameters missing.")); } if (!int.TryParse(parameters[1], out channelID)) { return(ErrorWrapper.SendError("Cannot parse channel ID.")); } BLClient client = null; bool bUnlocked = false; try { client = new BLClient(); bUnlocked = client.UnlockStream(userID, channelID, parameters[2]); } catch (Exception ex) { return(ErrorWrapper.SendError(ex.Message)); } finally { client.Dispose(); } return(bUnlocked ? "1" : "0"); }
internal override string Execute(string[] parameters) { int userID; int folderID; if (!Helper.TryGetUserID(_session, out userID)) { return(String.Empty); } if (parameters.Length < 3) { return(ErrorWrapper.SendError("Command parameters missing.")); } if (!int.TryParse(parameters[1], out folderID)) { return(ErrorWrapper.SendError("Cannot parse folder ID.")); } BLClient client = null; try { client = new BLClient(); client.EditAssetContentFolder(userID, folderID, parameters[2]); } catch (Exception ex) { return(ErrorWrapper.SendError(ex.Message)); } finally { client.Dispose(); } return("1"); }