本文整理汇总了C#中MxitTestApp.UserSession.setVariable方法的典型用法代码示例。如果您正苦于以下问题:C# UserSession.setVariable方法的具体用法?C# UserSession.setVariable怎么用?C# UserSession.setVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MxitTestApp.UserSession
的用法示例。
在下文中一共展示了UserSession.setVariable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: handleShortcutLinks
protected InputHandlerResult handleShortcutLinks(
UserSession us,
string input)
{
if (input == RESET)
{
us.user_profile.user_profile_custom.setColourTheme(UserColourTheme.NO_THEME);
us.setVariable(AScreenOutputAdapter.COLOUR_CHANGED, "COLOUR_CHANGED");
return new InputHandlerResult(
InputHandlerResult.DO_NOTHING_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
int colour_theme = -1;
if (!Int32.TryParse(input, out colour_theme))
{
return new InputHandlerResult(
InputHandlerResult.INVALID_MENU_ACTION,
"Invalid Input...");
}
//colour_theme -= 1;
if (!UserColourTheme.isColourThemeValid(colour_theme))
{
return new InputHandlerResult(
InputHandlerResult.INVALID_MENU_ACTION,
"Invalid Input...");
}
us.user_profile.user_profile_custom.setColourTheme(colour_theme);
us.setVariable(AScreenOutputAdapter.COLOUR_CHANGED, "COLOUR_CHANGED");
return new InputHandlerResult(
InputHandlerResult.DO_NOTHING_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
示例2: handleInput
public override InputHandlerResult handleInput(UserSession user_session, MessageReceived message_recieved)
{
string input = extractReply(message_recieved);
//Console.WriteLine("in input handler: " + input);
Console.WriteLine("User with ID: " + user_session.user_profile.id + " Entered: " + input);
//get reply
string curr_user_page = user_session.current_menu_loc;
InputHandlerResult output = handleDisplayMessageLinks(
user_session,
input,
"Your input was invalid. You message has been sent already but please click Back/Main to continue",
true);
if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
{
if(output.action == InputHandlerResult.BACK_WITHOUT_INIT_MENU_ACTION)
user_session.setVariable(Browse_Bible_Handler.BROWSE_CLEAR_SCREEN, true);
return output;
}
output = handleStdNavLinks(user_session, input,true);
if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
return output;
output = handleMyProfileLinks(user_session, input);
if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
return output;
//handle back or home here.
return new InputHandlerResult(
"Invalid entry...Please enter a valid input"); //invalid choice
}
示例3: handleFriendRequestLinks
/*this method either returns the new screen id or the main or prev command string*/
protected InputHandlerResult handleFriendRequestLinks(
UserSession user_session,
string input)
{
string curr_user_page = user_session.current_menu_loc;
String entry = input.ToUpper();
long friend_id = -1;
if (entry.StartsWith(APPROVE_REQUEST))
{
friend_id = long.Parse(entry.Split('_')[1]);
user_session.friend_manager.approveFriendRequest(friend_id);
String user_name = UserNameManager.getInstance().getUserName(friend_id);
user_session.setVariable(APPROVED_FRIEND_NAME, user_name);
return new InputHandlerResult(
InputHandlerResult.BACK_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID); //the menu id is retreived from the session in this case.
}
else if (entry.StartsWith(REJECT_REQUEST))
{
friend_id = long.Parse(entry.Split('_')[1]);
user_session.friend_manager.rejectFriendRequest(friend_id);
String user_name = UserNameManager.getInstance().getUserName(friend_id);
user_session.setVariable(REJECTED_FRIEND_NAME, user_name);
return new InputHandlerResult(
InputHandlerResult.BACK_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID); //the menu id is retreived from the session in this case.
}
else
{
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
示例4: handleInput
public override InputHandlerResult handleInput(UserSession user_session, MessageReceived message_recieved)
{
string input = extractReply(message_recieved);
// Console.WriteLine("in input handler: " + input
Console.WriteLine("User with ID: " + user_session.user_profile.id + " Entered: " + input);
//get reply
string curr_user_page = user_session.current_menu_loc;
InputHandlerResult output = handleStdNavLinks(user_session, input);
if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
return output;
output = handleStdPageLinks(user_session, input);
if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
return output;
MenuManager mm = MenuManager.getInstance();
//for now we assume this. must correct this later
OptionMenuPage omp = (OptionMenuPage)mm.menu_def.getMenuPage(curr_user_page);
List<MenuOptionItem> options = omp.options;
foreach (MenuOptionItem option in options)
{
if (option.link_val.Equals(input))
{
int final_input = Int32.Parse(input) - 1;
user_session.setVariable("ShortCode_Handler.testament_id", final_input.ToString());
return new InputHandlerResult(
InputHandlerResult.NEW_MENU_ACTION,
option.select_action,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
//handle back or home here.
return new InputHandlerResult(
"Invalid entry...Please enter a valid input"); //invalid choice
}
示例5: handleDisplayMessageLinks
protected InputHandlerResult handleDisplayMessageLinks(
UserSession user_session,
string input,
String error_message,
Boolean back_without_init)
{
bool message_page = user_session.getVariable(DISPLAY_MESSAGE) != null;
if (message_page == true)
{
user_session.removeVariable(DISPLAY_MESSAGE);
}
InputHandlerResult output = handleStdNavLinks(user_session, input, back_without_init);
if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
return output;
//if this was a messsage then the only options is the std Nav links. any other input is invalid so reshow message
if (message_page)
{
user_session.setVariable(DISPLAY_MESSAGE, "Message sent");//you must be sure to remove this from hash table in handler.
return new InputHandlerResult(
InputHandlerResult.DISPLAY_MESSAGE,
InputHandlerResult.DEFAULT_MENU_ID, //not used
error_message);
}
else
{
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID
);
}
}
示例6: handleExtraCommandInput
public override InputHandlerResult handleExtraCommandInput(UserSession us, String input)
{
if (getExtraCommandString() != null && getExtraCommandString() != "")
{
// Boolean confirmed_delete;
Boolean is_confirming = false;
try
{
Object o = us.removeVariable("ConfirmedHistoryDelete");
if (o != null)
{
is_confirming = (Boolean)o;
}
else
{
is_confirming = false;
}
/*is_confirming = true;*/
}
catch (Exception e)
{
is_confirming = false;
/*is_confirming = false;*/
}
if (!is_confirming && CLEAR_HISTORY.Equals(input.ToUpper()))
{
us.setVariable("ConfirmedHistoryDelete", true);
return new InputHandlerResult(
InputHandlerResult.CONF_PAGE_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
"Are you sure that you want to clear the history (Y/N)?");
}
if (is_confirming)
{
if (CONFIRMED_DELETE.Equals(input.ToUpper()) || CONFIRMED_DELETE_2.Equals(input.ToUpper()))
{
us.verse_history.clearHistory(us.user_profile);
return new InputHandlerResult("The history has been cleared");
}
else if (CANCELLED_DELETE.Equals(input.ToUpper()) || CANCELLED_DELETE_2.Equals(input.ToUpper()))
{
return new InputHandlerResult();
}
}
if (!is_confirming)
{
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
示例7: handleMessagePageLinks
protected InputHandlerResult handleMessagePageLinks(
UserSession user_session,
string input)
{
string curr_user_page = user_session.current_menu_loc;
//if(user_session.getVariable(CURRENT_THREAD_PAGE)==null)
// user_session.setVariable(CURRENT_THREAD_PAGE, 0);
int current_page_id = Int32.Parse(user_session.getVariable(CURRENT_MESSAGE_THREAD));
String entry = input.ToUpper();
if (PREV_PAGE.Equals(entry))
{
user_session.setVariable(CURRENT_MESSAGE_THREAD, (current_page_id - 1).ToString());
return new InputHandlerResult(
InputHandlerResult.PREV_PAGE_ACTION,
user_session.current_menu_loc,
current_page_id - 1); //the menu id is retreived from the session in this case.
}
else if (NEXT_PAGE.Equals(entry))
{
user_session.setVariable(CURRENT_MESSAGE_THREAD, (current_page_id + 1).ToString());
return new InputHandlerResult(
InputHandlerResult.NEXT_PAGE_ACTION,
user_session.current_menu_loc,
current_page_id + 1);
}
else if (FIRST_PAGE.Equals(entry))
{
user_session.setVariable(CURRENT_MESSAGE_THREAD, "0");
return new InputHandlerResult(
InputHandlerResult.CHANGE_PAGE_ACTION,
user_session.current_menu_loc,
0);
}
else if (entry.StartsWith(LAST_PAGE))
{
int page_id = Int32.Parse(entry.Split('_')[1]);
user_session.setVariable(CURRENT_MESSAGE_THREAD, page_id.ToString());
return new InputHandlerResult(
InputHandlerResult.CHANGE_PAGE_ACTION,
user_session.current_menu_loc,
page_id);
}
else
{
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
示例8: handleBrowseLinks
protected InputHandlerResult handleBrowseLinks(
UserSession us,
string input)
{
VerseSection vs = (VerseSection)us.getVariableObject("Browse.verse_section");
if (vs == null)
{
Console.WriteLine("Expected Browse.verse_section present, but not found");
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
Verse start_verse = vs.start_verse;
Verse end_verse = vs.end_verse;
if (DISPLAY_MORE.Equals(input.Trim().ToUpper()))
{
if (end_verse != null && end_verse.next_verse != null)
{
start_verse = end_verse.next_verse;
//end_verse = getDefaultEndVerse(start_verse);
vs = new VerseSection(start_verse, null);
us.setVariable("Browse.verse_section", vs);
return new InputHandlerResult(InputHandlerResult.NEW_MENU_ACTION,
us.current_menu_loc,
InputHandlerResult.DEFAULT_PAGE_ID);
}
else
{
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
else if (DISPLAY_NEXT_CHAPTER.Equals(input.Trim().ToUpper()))
{
if (start_verse != null &&
start_verse.chapter != null &&
start_verse.chapter.next_chapter != null)
{
start_verse = start_verse.chapter.next_chapter.getVerse(1);
//end_verse = getDefaultEndVerse(start_verse);
vs = new VerseSection(start_verse, null);
us.setVariable("Browse.verse_section", vs);
return new InputHandlerResult(InputHandlerResult.NEW_MENU_ACTION,
us.current_menu_loc,
InputHandlerResult.DEFAULT_PAGE_ID);
}
else
{
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
else if (DISPLAY_PREV_CHAPTER.Equals(input.Trim().ToUpper()))
{
if (start_verse != null &&
start_verse.chapter != null &&
start_verse.chapter.prev_chapter != null)
{
start_verse = start_verse.chapter.prev_chapter.getVerse(1);
//end_verse = getDefaultEndVerse(start_verse);
vs = new VerseSection(start_verse, null);
us.setVariable("Browse.verse_section", vs);
return new InputHandlerResult(InputHandlerResult.NEW_MENU_ACTION,
us.current_menu_loc,
InputHandlerResult.DEFAULT_PAGE_ID);
}
else
{
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
else
{
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
示例9: handleDirectVerseInput
protected InputHandlerResult handleDirectVerseInput(
UserSession us,
string input)
{
try
{
int verse_id = -1;
VerseSection vs = (VerseSection)us.getVariableObject("Browse.verse_section");
if (vs == null)
{
Console.WriteLine("Expected Browse.verse_section present, but not found");
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
if (Int32.TryParse(input, out verse_id))
{
Verse curr_start_verse = vs.start_verse;
Verse end_verse = vs.end_verse;
Verse start_verse = curr_start_verse.chapter.getVerse(verse_id);
if (start_verse != null)
{
//end_verse = getDefaultEndVerse(start_verse);
end_verse = start_verse;
vs = new VerseSection(start_verse, end_verse);//we set end verse to distinguish browsing from direct input
us.setVariable("Browse.verse_section", vs);
us.recordVerseSelection(start_verse, end_verse);
return new InputHandlerResult(InputHandlerResult.NEW_MENU_ACTION,
us.current_menu_loc,
InputHandlerResult.DEFAULT_PAGE_ID);
}
else
{
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
else
{
VerseSection vs1 = (VerseSection)us.getVariableObject("Browse.verse_section");
if (vs1 == null)
{
Console.WriteLine("Expected Browse.verse_section present, but not found");
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
String current_book = "";
String current_chapter = "";
input = input.Replace(".", ":");
if(vs1 != null && vs1.start_verse != null)
{
current_book = vs1.start_verse.book.name;
current_chapter = vs1.start_verse.chapter.chapter_id.ToString(); // TODO: check the taking of chapter from start verse and not end verse
}
VerseSection vsection = Verse_Handler.getVerseSection(us, input, current_book, current_chapter);
if (vsection != null)
{
us.setVariable("Browse.verse_section", vsection);
Verse start_verse = vsection.start_verse;
Verse end_verse = vsection.end_verse;
us.recordVerseSelection(start_verse, end_verse);
return new InputHandlerResult(
InputHandlerResult.NEW_MENU_ACTION,
us.current_menu_loc,
InputHandlerResult.DEFAULT_PAGE_ID);
}
else
{
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
}
catch (Exception e)
{
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
示例10: handleInput
public override InputHandlerResult handleInput(UserSession user_session, MessageReceived message_recieved)
{
string input = extractReply(message_recieved);
//Console.WriteLine("in input handler: " + input);
Console.WriteLine("User with ID: " + user_session.user_profile.id + " Entered: " + input);
//get reply
string curr_user_page = user_session.current_menu_loc;
InputHandlerResult output = handleStdNavLinks(user_session, input);
if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
return output;
MenuManager mm = MenuManager.getInstance();
//for now we assume this. must correct this later
VerseMenuPage vmp = (VerseMenuPage)mm.menu_def.getMenuPage(curr_user_page);
List<MenuOptionItem> options = vmp.options;
foreach (MenuOptionItem option in options)
{
if (option.link_val.Equals(input))
return new InputHandlerResult(
InputHandlerResult.NEW_MENU_ACTION,
option.select_action,
InputHandlerResult.DEFAULT_PAGE_ID);
}
//now handle input
input = input.Trim();
if (input.Equals(""))
{
return new InputHandlerResult(
"Invalid entry...Please enter a valid input (e.g. 'John 3:16' or '1 John 1:9' or read the help section for more information"); //invalid choice
}
input = input.Replace('.', ':');
Verse start_verse = null;
Verse end_verse = null;
if (input.Contains('-'))
{
String[] start_end = input.Split('-');
start_verse = getStartingVerse(user_session.user_profile.getDefaultTranslationId(), start_end[0]);
if (start_verse == null)
{
return new InputHandlerResult(
"Invalid entry...Please enter a valid input (e.g. 'John 3:16' or '1 John 1:9'"); //invalid choice
}
if (start_end.Count() >= 2)
{
end_verse = getEndingVerse(user_session.user_profile.getDefaultTranslationId(), start_verse, start_end[1]);
}
}
else
{
start_verse = getStartingVerse(user_session.user_profile.getDefaultTranslationId(), input);
}
user_session.deleteVariable("Browse.verse_section");
try
{
if (end_verse == null)
end_verse = start_verse;
VerseSection vs = new VerseSection(start_verse, end_verse);
user_session.setVariable("Browse.verse_section", vs);
//now this is one big hack
user_session.setVariable("Browse.directSelect", true);
}
catch (XInvalidVerseSection e)
{
return new InputHandlerResult(e.Message); //invalid choice
}
return new InputHandlerResult(
InputHandlerResult.NEW_MENU_ACTION,
vmp.input_item.target_page,
InputHandlerResult.DEFAULT_PAGE_ID);
}
示例11: init
public override void init(UserSession us)
{
//Console.WriteLine("Init Browse Interaction");
//first we need a way to know if the screen should be cleared.
us.setVariable(BROWSE_CLEAR_SCREEN, true);
//now this is one big hack
Boolean direct_select;
try
{
Object o = us.removeVariable("Browse.directSelect");
if(o==null)
direct_select = false;
else
direct_select = (Boolean)o;
}catch(Exception e)
{
direct_select = false;
}
int verse_history_index = getVerseHistoryIndex(us);
//Verse was selected from history of verses
if (verse_history_index > -1)
{
ReadOnlyCollection<VerseHistoryRecord> history_list = us.verse_history.getHistoryListForDisplay();
VerseHistoryRecord vhr = history_list[verse_history_index];
Verse start_verse = Verse_Handler.getStartingVerse(us.user_profile.getDefaultTranslationId(), vhr.start_verse);
Verse end_verse;
if (vhr.end_verse == null || vhr.start_verse.Equals(vhr.end_verse))
end_verse = start_verse;
else if ("NULL".Equals(vhr.end_verse))
end_verse = BrowseBibleScreenOutputAdapter.getDefaultEndVerse(start_verse);
else
end_verse = Verse_Handler.getStartingVerse(us.user_profile.getDefaultTranslationId(), vhr.end_verse);
VerseSection vs = new VerseSection(start_verse, end_verse);
us.setVariable("Browse.verse_section", vs);
}
else
{
String top_fav_verse = getTopFavouriteSelectedVerse(us);
if (top_fav_verse != null)
{
VerseSection vs = Verse_Handler.getVerseSection(us, top_fav_verse, null, null);
if (vs != null)
{
us.setVariable("Browse.verse_section", vs);
us.recordVerseSelection(vs.start_verse, vs.end_verse);
}
}
else
{
int fav_verse_index = getFavouriteVerseIndex(us);
//Verse was selected from history of verses
if (fav_verse_index > -1)
{
ReadOnlyCollection<FavouriteVerseRecord> favourite_list = us.favourite_verses.getFavouriteListForDisplay();
FavouriteVerseRecord fvr = favourite_list[fav_verse_index];
Verse start_verse = Verse_Handler.getStartingVerse(us.user_profile.getDefaultTranslationId(), fvr.start_verse);
Verse end_verse;
if (fvr.end_verse == null || fvr.start_verse.Equals(fvr.end_verse))
end_verse = start_verse;
else if ("NULL".Equals(fvr.end_verse))
end_verse = BrowseBibleScreenOutputAdapter.getDefaultEndVerse(start_verse);
else
end_verse = Verse_Handler.getStartingVerse(us.user_profile.getDefaultTranslationId(), fvr.end_verse);
VerseSection vs = new VerseSection(start_verse, end_verse);
us.setVariable("Browse.verse_section", vs);
us.recordVerseSelection(vs.start_verse, vs.end_verse);
}
else{
String bookmark_verse = getBookmarkVerse(us);
if (bookmark_verse != null)
{
VerseSection vs = Verse_Handler.getVerseSection(us, bookmark_verse, null, null);
if (vs != null)
{
us.setVariable("Browse.verse_section", vs);
us.recordVerseSelection(vs.start_verse, vs.end_verse);
}
}
else
{
String daily_verse = getDailyVerseSelected(us);
if (daily_verse != null)
{
VerseSection vs = Verse_Handler.getVerseSection(us, daily_verse, null, null);
if (vs != null)
{
us.setVariable("Browse.verse_section", vs);
us.recordVerseSelection(vs.start_verse, vs.end_verse);
}
}
else
{
String topic_verse = getTopicVerse(us);
if (topic_verse != null)
{
//.........这里部分代码省略.........
示例12: handleInput
public override InputHandlerResult handleInput(UserSession user_session, MessageReceived message_recieved)
{
string input = extractReply(message_recieved);
Console.WriteLine("User with ID: " + user_session.user_profile.id + " Entered: " + input);
//get reply
string curr_user_page = user_session.current_menu_loc;
MenuManager mm = MenuManager.getInstance();
MenuPage mp = mm.menu_def.getMenuPage(curr_user_page);
//for now we assume this. must correct this later
DynMenuPage dmp = (DynMenuPage)mm.menu_def.getMenuPage(curr_user_page);
//handle extra commands
InputHandlerResult output = dmp.dynamic_set.handleExtraCommandInput(user_session, input);
if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
return output;
output = handleStdNavLinks(user_session, input);
if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
return output;
output = handleStdPageLinks(user_session, input);
if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
return output;
List<MenuOptionItem> options = mp.getOptionList(user_session);
string output_var = dmp.output_var;
//this is a waste, if we do change input then its found so we can already return.
input = dmp.dynamic_set.parseInput(input, user_session);
foreach (MenuOptionItem option in options)
{
if (option.is_valid && (option.link_val.Equals(input) || option.menu_option_id.Equals(input)))
{
user_session.setVariable(output_var, input);
return new InputHandlerResult(
InputHandlerResult.NEW_MENU_ACTION,
option.select_action,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
/*else if (mp.GetType().Name == "MxitTestApp.OptionMenuPage")
{
OptionMenuPage omp = (OptionMenuPage)mm.menu_def.getMenuPage(curr_user_page);
List<MenuOptionItem> options = omp.options;
foreach (MenuOptionItem option in options)
{
if (option.link_val.Equals(input))
{
user_session.setVariable("SELECTED_BOOK_ID", input);
return new InputHandlerResult(
InputHandlerResult.NEW_MENU_ACTION,
option.select_action,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
}*/
//handle back or home here.
return new InputHandlerResult(
"Invalid entry...Please enter a valid input"); //invalid choice
}
示例13: displayMessage
public Boolean displayMessage(UserSession us, MessageToSend ms, InputHandlerResult ihr)
{
if (ihr.action == InputHandlerResult.DISPLAY_MESSAGE)
{
ms.Append(MessageBuilder.Elements.CreateClearScreen());
ms.Append(ihr.message + "\r\n");
appendBackMainLinks(us, ms);
appendMessageConfig(true, ms);
us.setVariable(AInputHandler.DISPLAY_MESSAGE , "Message sent");//you must be sure to remove this from hash table in handler.
return true;
}
return false;
}
示例14: handleFriendLinks
/*this method either returns the new screen id or the main or prev command string*/
protected InputHandlerResult handleFriendLinks(
UserSession user_session,
string input)
{
string curr_user_page = user_session.current_menu_loc;
String entry = input.ToUpper();
long friend_id = -1;
if (entry.StartsWith(BLOCK_FRIEND))
{
user_session.setVariable(ORIGINAL_ACTION, entry);
friend_id = long.Parse(entry.Split('_')[1]);
String user_name = UserNameManager.getInstance().getUserName(friend_id);
return new InputHandlerResult(
InputHandlerResult.CONF_PAGE_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
"Are you sure that you want block " + user_name +"?");
}
else if (entry.StartsWith(DELETE_FRIEND))
{
user_session.setVariable(ORIGINAL_ACTION, entry);
friend_id = long.Parse(entry.Split('_')[1]);
String user_name = UserNameManager.getInstance().getUserName(friend_id);
return new InputHandlerResult(
InputHandlerResult.CONF_PAGE_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
"Are you sure that you want remove " + user_name + " from your buddy list?");
}
if (entry.ToUpper().Equals(CONF_YES) || entry.ToUpper().Equals(CONF_Y))
{
String original_action = user_session.getVariable(ORIGINAL_ACTION);
if(original_action != null)
{
user_session.removeVariable(ORIGINAL_ACTION);
if (original_action.StartsWith(BLOCK_FRIEND))
{
friend_id = long.Parse(original_action.Split('_')[1]);
String user_name = UserNameManager.getInstance().getUserName(friend_id);
user_session.friend_manager.blockFriend(friend_id);
user_session.setVariable(BLOCKED_FRIEND_NAME, user_name);
}else if(original_action.StartsWith(DELETE_FRIEND))
{
friend_id = long.Parse(original_action.Split('_')[1]);
user_session.friend_manager.deleteFriendRequest(friend_id);
String user_name = UserNameManager.getInstance().getUserName(friend_id);
user_session.setVariable(DELETED_FRIEND_NAME, user_name);
}
return new InputHandlerResult(
InputHandlerResult.BACK_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID); //the menu id is retreived from the session in this case.
}
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
else if (entry.ToUpper().Equals(CONF_NO) || entry.ToUpper().Equals(CONF_N))
{
String original_action = user_session.getVariable(ORIGINAL_ACTION);
if(original_action != null)
{
user_session.removeVariable(ORIGINAL_ACTION);
}
return new InputHandlerResult(
InputHandlerResult.DO_NOTHING_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
else if (entry.StartsWith(FILTER_LIST))
{
String filter = entry.Split('_')[1];
user_session.setVariable(FRIEND_LIST_FILTER, filter);
return new InputHandlerResult(
InputHandlerResult.DO_NOTHING_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
else
{
String original_action = user_session.getVariable(ORIGINAL_ACTION);
if (original_action != null)
{
user_session.removeVariable(ORIGINAL_ACTION);
}
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
示例15: handleReferLink
protected InputHandlerResult handleReferLink(
UserSession us,
string input)
{
if (REFER_A_FRIEND.Equals(input.Trim().ToUpper()))
{
us.setVariable(REFER_A_FRIEND, REFER_A_FRIEND);
return new InputHandlerResult(
InputHandlerResult.DO_NOTHING_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
else
{
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}