本文整理汇总了C#中MxitTestApp.UserSession.getVariable方法的典型用法代码示例。如果您正苦于以下问题:C# UserSession.getVariable方法的具体用法?C# UserSession.getVariable怎么用?C# UserSession.getVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MxitTestApp.UserSession
的用法示例。
在下文中一共展示了UserSession.getVariable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getOptionList
public override List<MenuOptionItem> getOptionList(UserSession us)
{
String current_category_id = us.getVariable(CATEGORY_ID_VAR_NAME);
if(current_category_id == null)
{
return null;
}
int cat_id = Int32.Parse(current_category_id);
List<Topic> topic_list = BibleTopicManager.getInstance().getCategory(cat_id).topics;
if (topic_list != null)
{
List<MenuOptionItem> final_list = new List<MenuOptionItem>();
for (int i = 0; i < topic_list.Count; i++)
{
final_list.Add(
new MenuOptionItem(
(topic_list[i].verse_ref).ToString(),
(i+1).ToString(),
target_page,
topic_list[i].topic + " - " + topic_list[i].verse_ref));
}
return final_list;
}
return null;
}
示例2: 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
);
}
}
示例3: parseInput
//too many returns in this method
public override string parseInput(String input, UserSession us)
{
for (int i = 0; i < list.Count; i++)
{
if(input==list[i].display_text)
return list[i].link_val;
}
int starting_index = 0;//us.current_menu_page * MenuDefinition.PAGE_ITEM_COUNT;
string test_id = (String)us.getVariable(SearchTestamentHandler.SEARCH_TESTAMENT_VAR_NAME);
if (test_id == "1")
starting_index += 39;
try{
int book_id = starting_index + Int32.Parse(input) - 1 ;
if (book_id < book_list.Count)
{
return book_list.ElementAt(book_id).name;
}
else
{
return input;
}
}catch(Exception e)
{
input = BibleHelper.getFullBookName(input);
return input;
}
//return input;
}
示例4: addThreadLinks
public void addThreadLinks(
UserSession us,
MessageToSend ms)
{
int current_page = Int32.Parse(us.getVariable(MessageInboxHandler.CURRENT_MESSAGE_THREAD));
int count = (current_page * THREAD_COUNT_PER_PAGE) + 1;
VerseMessageThread vmt;
int starting_index = current_page * THREAD_COUNT_PER_PAGE;
List<VerseMessageThread> threads = us.verse_messaging_manager.getParticipatingThreads();
if (threads.Count() == 0)
{
ms.Append("Your inbox is empty");
return;
}
for (int i = starting_index;
i < threads.Count && i < starting_index + THREAD_COUNT_PER_PAGE;
i++)
{
vmt = threads.ElementAt(i);
if (vmt == null)
continue;
appendMessageThread(us, ms, vmt);
}
appendPaginateLinks(us, ms, threads.Count, THREAD_COUNT_PER_PAGE);
}
示例5: getOptionList
public override List<MenuOptionItem> getOptionList(UserSession us)
{
LinkedList<FriendRelation> friend_list = us.friend_manager.getFriends();
if (friend_list != null)
{
String friend_filter = "ALL";
if (us.getVariable(FriendHandler.FRIEND_LIST_FILTER) != null)
{
friend_filter = (String)us.getVariable(FriendHandler.FRIEND_LIST_FILTER);
}
List<MenuOptionItem> final_list = new List<MenuOptionItem>();
int i=0;
long friend_id = -1;
String user_name = "";
foreach(var friend in friend_list)
{
if (friend != null)
{
if(friend.id_a == us.user_profile.id)
{
friend_id = friend.id_b;
}
else
{
friend_id = friend.id_a;
}
user_name = UserNameManager.getInstance().getUserName(friend_id);
if (friend_filter == "ALL" || user_name.ToUpper().StartsWith(friend_filter.ToUpper()))
{
MenuOptionItem m_o = new FriendRelationMenuOptionItem(
"*",
friend.friendship_id.ToString(),
target_page,
friend_id.ToString(),
friend);
i++;
final_list.Add(m_o);
}
}
}
return final_list;
}
return null;
}
示例6: addQuickFilterLinksToMessageFromList
public void addQuickFilterLinksToMessageFromList(
UserSession us,
MessageToSend ms)
{
List<char> starting_chars = us.friend_manager.getStartingCharacters();
//.. starting_chars
starting_chars.Sort();
String filter = "";
if (us.hasVariable(ChooseFriendHandler.FRIEND_LIST_FILTER))
{
filter = us.getVariable(ChooseFriendHandler.FRIEND_LIST_FILTER);
}
if (starting_chars.Count() > 1)
{
int i = 0;
foreach (var a_char in starting_chars)
{
if (i == 0)
{
i++;
ms.Append("\r\nFilter - ");
if (filter.Equals("") || filter.Equals("ALL"))
{
ms.Append("[ALL]");
}
else
{
ms.Append(createMessageLink(MENU_LINK_NAME, "[ALL]", FriendHandler.FILTER_LIST + "ALL"));
}
ms.Append(" ");
}
if (filter.Equals(a_char.ToString().ToUpper()))
{
ms.Append("[" + a_char.ToString().ToUpper() + "]");
}
else
{
ms.Append(createMessageLink(MENU_LINK_NAME, "[" + a_char.ToString().ToUpper() + "]", FriendHandler.FILTER_LIST + a_char));
}
ms.Append(" ");
}
ms.Append("\r\n\r\n");
}
}
示例7: getOptionList
public override List<MenuOptionItem> getOptionList(UserSession us)
{
if (book_list != null)
{
List<MenuOptionItem> final_list = new List<MenuOptionItem>();
for (int i = 0; i < book_list.Count; i++)
{
if (book_list[i].testament.testament_id
== Int32.Parse(us.getVariable(SearchTestamentHandler.SEARCH_TESTAMENT_VAR_NAME)))
{
final_list.Add(
new MenuOptionItem(
(book_list[i].name).ToString(),
(book_list[i].name).ToString(),
target_page,
book_list[i].name));
}
}
return final_list;
}
return null;
}
示例8: getOptionList
public override List<MenuOptionItem> getOptionList(UserSession us)
{
if (book_list != null)
{
List<MenuOptionItem> final_list = new List<MenuOptionItem>();
for (int i = 0; i < book_list.Count; i++)
{
if (book_list[i].testament.testament_id
== Int32.Parse(us.getVariable("Testament_Handler.testament_id")))
{
final_list.Add(
new MenuOptionItem(
(book_list[i].name).ToString(),
(book_list[i].name).ToString(),
target_page,
book_list[i].name + " (" + book_list[i].abbr + ")"));
}
}
return final_list;
}
return null;
}
示例9: parseMessage
/*replace variables with session variables*/
protected string parseMessage(UserSession us, string message)
{
int b_index = message.IndexOf('[');
if (b_index != -1)
{
int e_index = message.IndexOf(']');
string variable_name = message.Substring(b_index+1, e_index - b_index - 1);
//we have to call the function on the variable to get the desired message
if (variable_name.Contains(':'))
{
String[] method_and_var = variable_name.Split(':');
if (method_and_var.Count() != 2)
throw new Exception("INVALID MESSAGE VARIABLE NAME [" + variable_name + "] DEFINED");
String methodName = method_and_var[0];
MethodInfo magicMethod = typeof(AScreenOutputAdapter).GetMethod(methodName);
String current_trans = us.getVariable(method_and_var[1]);
object stringVal = magicMethod.Invoke(this, new object[] { us, current_trans });
message = parseMessage(us, message.Replace('[' + variable_name + ']', (String)stringVal));
}
else
{
message = parseMessage(us, message.Replace('[' + variable_name + ']', us.getVariable(variable_name)));
}
}
else
{
return message;
}
return message;
}
示例10: 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;
InputHandlerResult output = handleDisplayMessageLinks(
user_session,
input,
"Your input was invalid. You message has been sent already but please click Back/Main to continue");
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;*/
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);
}
if (input.Count() > MAX_MESSAGE_LENGTH)
{
return new InputHandlerResult(
"Your message is too long, please keep it less than " + MAX_MESSAGE_LENGTH + " characters.\r\n"); //invalid choice
}
else if (input.Trim().Equals(""))
{
return new InputHandlerResult(
"You entered a blank message. please try again.\r\n"); //blank input
}
else if (input.Trim().ToUpper().Equals(MessageThreadHandler.REPLY))
{
return new InputHandlerResult(
InputHandlerResult.DO_NOTHING_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_MENU_ID); //blank input
}
else
{
try
{
long thread_id = long.Parse(user_session.getVariable(MessageInboxHandler.CURRENTLY_VIEWING_TRHEAD));
VerseMessageThread vmt = VerseThreadManager.getInstance().getVerseMessageThread(thread_id);
if (vmt != null)
{
//check the current state of the friendship before along the user to send the message.
if (user_session.friend_manager.getFriendStatus(vmt.user_created_id) == FriendRelation.FRIEND_BLOCKED_BY_YOU)
{
return new InputHandlerResult(
InputHandlerResult.DISPLAY_MESSAGE,
InputHandlerResult.DEFAULT_MENU_ID,
"You blocked the original sender of this message. As a result you cant send them a message until you re-add you as a friend. You have to use their buddy code and send a friend request to them again. Because you blocked them they can't add you.");
}
else if (user_session.friend_manager.getFriendStatus(vmt.user_created_id) == FriendRelation.FRIEND_BLOCKED_YOU)
{
return new InputHandlerResult(
InputHandlerResult.DISPLAY_MESSAGE,
InputHandlerResult.DEFAULT_MENU_ID,
"The original sender of this message blocked you as a buddy. This means that you cant send them any messages. The only way to be unblocked is for them to resend a friend request to you.");
}
user_session.verse_messaging_manager.addMessageToThread(vmt, input);
}
//if vmt is null there is something wrong. need to handle this because we might delete the thread while someone is viewing it.
return new InputHandlerResult(
InputHandlerResult.BACK_WITHOUT_INIT_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
catch (Exception e)
{
Console.WriteLine(e.StackTrace);
return new InputHandlerResult(
"Something went wrong when trying to send your message, please try again later. "); //invalid choice
}
}
}
示例11: 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);
}
}
示例12: getOptionList
public override List<MenuOptionItem> getOptionList(UserSession us)
{
List<VerseTag> tagged_verses = VerseTagManager.getInstance().getListOfVerseTagsForEmotion(Int32.Parse(us.getVariable(SELECTED_EMOTION_VAR_NAME)));
//LinkedList<VerseHistoryRecord>
List<MenuOptionItem> final_list = new List<MenuOptionItem>();
if (tagged_verses != null)
{
if(tagged_verses.Count > 0)
tagged_verses.Sort();
int index = 0;
foreach (VerseTag verse_tag in tagged_verses)
{
index++;
if (verse_tag != null)
{
try
{
String start_verse = verse_tag.start_verse;
String end_verse = verse_tag.end_verse;
/*if (verse_tag.datetime != null && verse_tag.datetime != DateTime.MinValue && !"".Equals(verse_tag.datetime))
{
date_tagged = verse_tag.datetime.ToString("dd/MM/yy");
}
else
{
date_tagged = "";
}*/
int like_count = verse_tag.getLikeCount();
String like_string;
if (like_count == 0)
{
like_string = "";
}
else if (like_count == 1)
{
like_string = "1 person likes this";
}
else
{
like_string = like_count + " people likes this";
}
String rel_date = DateUtils.RelativeDate(verse_tag.datetime);
Verse s_v = Verse_Handler.getStartingVerse(us.user_profile.getDefaultTranslationId(), start_verse);
Verse e_v;
if (s_v != null)
{
if (end_verse == null || "".Equals(end_verse) || end_verse.Equals(start_verse))
e_v = null;
else if ("NULL".Equals(end_verse))
e_v = BrowseBibleScreenOutputAdapter.getDefaultEndVerse(s_v);
else
e_v = Verse_Handler.getStartingVerse(us.user_profile.getDefaultTranslationId(), end_verse);
//VerseRecord vr = new VerseRecord(start_verse, end_verse);
String verse_summ = BibleContainer.getSummaryOfVerse(s_v, 7);
String user_name = UserNameManager.getInstance().getUserName(verse_tag.user_id);
TaggedVerseMenuOptionItem m_o;
String verse_ref = BibleHelper.getVerseSectionReferenceWithoutTranslation(s_v, e_v);
if (start_verse == null || end_verse == null)
{
m_o = new TaggedVerseMenuOptionItem(
(index).ToString(),
(index).ToString()/*(book_list[i].name).ToString()*/,
target_page,
"N/A",
verse_tag);
m_o.is_valid = false;
final_list.Add(m_o);
}
else
{
m_o = new TaggedVerseMenuOptionItem(
(index).ToString(),
verse_ref/*(i + 1).ToString()/*(book_list[i].name).ToString()*/,
target_page,
verse_ref + " (" + rel_date + ") - " + verse_summ + "... \r\nTagged by: " + user_name + " \r\n" + like_string,
verse_tag);
m_o.is_valid = true;
final_list.Add(m_o);
}
}
else
{
TaggedVerseMenuOptionItem m_o = new TaggedVerseMenuOptionItem(
(index).ToString(),
(index).ToString()/*(book_list[i].name).ToString()*/,
target_page,
"Currently not available in your chosen translation (this could be due to a S/W bug).",
verse_tag);
m_o.is_valid = false;
final_list.Add(m_o);
}
}
catch (Exception e)
//.........这里部分代码省略.........
示例13: searchBible
public void searchBible(UserSession us, String input)
{
String search_testament = us.getVariable(SearchTestamentHandler.SEARCH_TESTAMENT_VAR_NAME);
int test_search = -1;
if (search_testament != null)
{
test_search = Int32.Parse(search_testament);
}
String search_book = us.getVariable(BOOK_SEARCH_VAR_NAME);
int book_search = -1;
if (search_book != null)
{
book_search = BibleContainer.getBookId(us.user_profile.getDefaultTranslationId(),search_book).id;
}
IList<SearchQueryResult> results = BibleSearch.getInstance().searchBible(input, Int32.Parse(us.user_profile.getDefaultTranslationId()), book_search, test_search);
List<SearchVerseRecord> search_result_list = new List<SearchVerseRecord>();
String book = "";
int chapter = -1;
int verse = -1;
int rank = -1;
int testament= -1;
String verse_ref = "";
String book_id = "";
foreach (SearchQueryResult result in results)
{
foreach (Match match in result.Matches)
{
book_id = match.AttributesValues["book"].GetValue().ToString();
book = BibleHelper.getNameFromID(book_id);
chapter = (int)match.AttributesValues["chapter"].GetValue();
verse = (int) match.AttributesValues["verse"].GetValue();
rank = match.Weight;
testament = BibleHelper.getTestamentIDFromBookID(book_id);
Verse start_verse = BibleContainer.getInstance().getVerse(
Int32.Parse(us.user_profile.getDefaultTranslationId()),
testament,
book,
chapter,
verse);
verse_ref = BibleHelper.getVerseSectionReferenceWithoutTranslation(start_verse, start_verse);
search_result_list.Add(new SearchVerseRecord(verse_ref, verse_ref, rank));
}
}
us.search_results = search_result_list;
}
示例14: handleMyProfileLinks
/*this method either returns the new screen id or the main or prev command string*/
protected InputHandlerResult handleMyProfileLinks(
UserSession user_session,
string input)
{
string curr_user_page = user_session.current_menu_loc;
String entry = input.ToUpper();
if (CHOOSE_FRIEND_ID.Equals(entry))
{
return new InputHandlerResult(
InputHandlerResult.NEW_MENU_ACTION,
MenuIDConstants.ENTER_RECIP_ID_NOTIF_MESSAGE); //the menu id is retreived from the session in this case.
}
else if (ENTER_MESSAGE_SUBJECT.Equals(entry))
{
return new InputHandlerResult(
InputHandlerResult.NEW_MENU_ACTION,
MenuIDConstants.SEND_VERSE_ENTER_SUBJECT); //the menu id is retreived from the session in this case.
}
else if (ENTER_MESSAGE.Equals(entry))
{
return new InputHandlerResult(
InputHandlerResult.NEW_MENU_ACTION,
MenuIDConstants.SEND_VERSE_ENTER_MESSAGE); //the menu id is retreived from the session in this case.
}
else if (SEND_MESSAGE.Equals(entry))
{
String message_text = "";
//String recip_id_s = "";
long recip_id = -1;
String start_verse = "";
String end_verse = "";
String subject = "";
if (user_session.hasVariable(VerseMessageSendOutputAdapter.MESSAGE_TEXT))
message_text = user_session.getVariable(VerseMessageSendOutputAdapter.MESSAGE_TEXT);
if (user_session.hasVariable(VerseMessageSendOutputAdapter.MESSAGE_SUBJECT))
subject = user_session.getVariable(VerseMessageSendOutputAdapter.MESSAGE_SUBJECT);
if (user_session.hasVariable(NotifMessageSendOutputAdapter.RECIPIENT_ID))
recip_id= long.Parse(user_session.getVariable(NotifMessageSendOutputAdapter.RECIPIENT_ID));
else
return new InputHandlerResult("There is a problem in sending the message. Please let us know about this problem by using the feedback option");
start_verse = VerseMessageThread.NOTIFICATION_THREAD;
end_verse = VerseMessageThread.NOTIFICATION_THREAD;
user_session.verse_messaging_manager.createThreadAndAddPrivateMessage(
message_text,
recip_id,
start_verse,
end_verse,
subject);
return new InputHandlerResult(
InputHandlerResult.DISPLAY_MESSAGE,
InputHandlerResult.DEFAULT_MENU_ID, //not used
"Your Message has been sent...");
}
else
{
return new InputHandlerResult(
InputHandlerResult.UNDEFINED_MENU_ACTION,
InputHandlerResult.DEFAULT_MENU_ID,
InputHandlerResult.DEFAULT_PAGE_ID);
}
}
示例15: getSearchObject
public String getSearchObject(UserSession us, string dummy)
{
String search_book = us.getVariable(SearchHandler.BOOK_SEARCH_VAR_NAME);
if (search_book != null)
{
return search_book;
}
String search_testament = us.getVariable(SearchTestamentHandler.SEARCH_TESTAMENT_VAR_NAME);
if (search_testament != null)
{
return "the " + getTestamentName(us, search_testament);
}
return SEARCH_BIBLE_DISPLAY;
}