public ListMembers ( IMemberData data, string authToken ) : IDataResponse | ||
data | IMemberData | |
authToken | string | |
return | IDataResponse |
private void SearchMembers(IDumpUserContentModel model, IMainPresenter presenter) { if (!string.IsNullOrEmpty(model.UserAccessToken)) { MemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.ListMembersUrl = ApplicationResource.ActionListMembers; service.UserAgentVersion = ApplicationResource.UserAgent; IDataResponse response = service.ListMembers(new MemberData() { SearchLimit = ApplicationResource.SearchDefaultLimit }, model.UserAccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonData = JsonConvert.DeserializeObject<dynamic>(data); // clear existing data first model.MemberList.Clear(); int total = 0; int resultCount = jsonData["members"].Count; for (int i = 0; i < resultCount; i++) { dynamic profile = jsonData["members"][i]["profile"]; dynamic idObj = profile["team_member_id"]; dynamic emailObj = profile["email"]; dynamic status = profile["status"]; if (status != null && (status[".tag"].ToString().Equals("active") || status[".tag"].ToString().Equals("suspended") || status[".tag"].ToString().Equals("invited"))) { string teamId = idObj.Value as string; string email = emailObj.Value as string; // update model TeamListViewItemModel lvItem = new TeamListViewItemModel() { Email = email, TeamId = teamId }; model.MemberList.Add(lvItem); } if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo("Scanning Account(s): " + (++total)); }, null); } } //if the memberID count is above limit - default 1000 we need to grab the cursor and call continue bool hasMore = jsonData["has_more"]; string cursor = jsonData["cursor"]; while (hasMore) { service.ListMembersContinuationUrl = ApplicationResource.ActionListMembersContinuation; IDataResponse responseCont = service.ListMembersContinuation(new MemberData() { Cursor = cursor }, model.UserAccessToken); string dataCont = responseCont.Data.ToString(); dynamic jsonDataCont = JsonConvert.DeserializeObject<dynamic>(dataCont); int resultContCount = jsonDataCont["members"].Count; for (int i = 0; i < resultContCount; i++) { dynamic profile = jsonDataCont["members"][i]["profile"]; dynamic idObj = profile["team_member_id"]; dynamic emailObj = profile["email"]; dynamic status = profile["status"]; if (status != null && (status[".tag"].ToString().Equals("active") || status[".tag"].ToString().Equals("suspended") || status[".tag"].ToString().Equals("invited"))) { string teamId = idObj.Value as string; string email = emailObj.Value as string; // update model TeamListViewItemModel lvItem = new TeamListViewItemModel() { Email = email, TeamId = teamId }; model.MemberList.Add(lvItem); } if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo("Scanning Account(s): " + (++total)); }, null); } } hasMore = jsonDataCont["has_more"]; cursor = jsonDataCont["cursor"]; } } } } }
private void GetDevices(IDevicesModel model, IMainPresenter presenter) { if (!string.IsNullOrEmpty(model.UserAccessToken)) { IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.GetDevicesUrl = ApplicationResource.ActionListTeamDevices; service.UserAgentVersion = ApplicationResource.UserAgent; List<string[]> members = new List<string[]>(); //BEGIN GET MEMBERS MemberServices serviceMembers = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); serviceMembers.ListMembersUrl = ApplicationResource.ActionListMembers; IDataResponse responseMembers = serviceMembers.ListMembers(new MemberData() { SearchLimit = ApplicationResource.SearchDefaultLimit }, ApplicationResource.DefaultAccessToken); if (responseMembers.StatusCode == HttpStatusCode.OK) { if (responseMembers.Data != null) { string data = responseMembers.Data.ToString(); dynamic jsonData = JsonConvert.DeserializeObject<dynamic>(data); int resultCount = jsonData["members"].Count; for (int i = 0; i < resultCount; i++) { dynamic idObj = jsonData["members"][i]["profile"]["team_member_id"]; dynamic emailObj = jsonData["members"][i]["profile"]["email"]; string teamId = idObj.Value as string; string email = emailObj.Value as string; string[] str = new string[2]; str[0] = teamId; str[1] = email; members.Add(str); } //if the memberID count is above limit - grab the cursor and call continue bool hasMore = jsonData["has_more"]; string cursor = jsonData["cursor"]; while (hasMore) { serviceMembers.ListMembersContinuationUrl = ApplicationResource.ActionListMembersContinuation; IDataResponse responseMembersCont = serviceMembers.ListMembersContinuation(new MemberData() { Cursor = cursor }, ApplicationResource.DefaultAccessToken); string dataCont = responseMembersCont.Data.ToString(); dynamic jsonDataCont = JsonConvert.DeserializeObject<dynamic>(dataCont); int resultContCount = jsonDataCont["members"].Count; for (int i = 0; i < resultContCount; i++) { dynamic idObj = jsonDataCont["members"][i]["profile"]["team_member_id"]; dynamic emailObj = jsonDataCont["members"][i]["profile"]["email"]; string teamId = idObj.Value as string; string email = emailObj.Value as string; string[] str = new string[2]; str[0] = teamId; str[1] = email; members.Add(str); } hasMore = jsonDataCont["has_more"]; cursor = jsonDataCont["cursor"]; } } } //END GET MEMBERS bool FilterCriteriaContains = false; bool FilterCriteriaNotContains = false; bool FilterCriteriaBeginsWith = false; bool FilterCriteriaEndsWith = false; if (model.FilterCriteria == "CONTAINS") { FilterCriteriaContains = true; } if (model.FilterCriteria == "NOT CONTAINS") { FilterCriteriaNotContains = true; } if (model.FilterCriteria == "BEGINS WITH") { FilterCriteriaBeginsWith = true; } if (model.FilterCriteria == "ENDS WITH") { FilterCriteriaEndsWith = true; } IDataResponse response = service.FindDevices(new MemberData() { //no cursor needed on first hit }, model.UserAccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonDevicesData = JsonConvert.DeserializeObject<dynamic>(data); // clear existing data first model.DeviceList.Clear(); int resultCount = jsonDevicesData["devices"].Count; if (resultCount > 0) { for (int i = 0; i < resultCount; i++) { DateTime created = new DateTime(); string teamId = string.Empty; string deviceName = string.Empty; string ipAddress = string.Empty; string sessionId = string.Empty; string clientType = string.Empty; string email = string.Empty; dynamic idObj = jsonDevicesData["devices"][i]["team_member_id"]; int resultWebCount = jsonDevicesData["devices"][i]["web_sessions"].Count; int resultDesktopCount = jsonDevicesData["devices"][i]["desktop_clients"].Count; int resultMobileCount = jsonDevicesData["devices"][i]["mobile_clients"].Count; if (resultWebCount > 0) { for (int i2 = 0; i2 < resultWebCount; i2++) { dynamic deviceNameObj = jsonDevicesData["devices"][i]["web_sessions"][i2]["user_agent"]; dynamic ipAddressObj = jsonDevicesData["devices"][i]["web_sessions"][i2]["ip_address"]; dynamic sessionIdObj = jsonDevicesData["devices"][i]["web_sessions"][i2]["session_id"]; clientType = "Web"; dynamic createdObj = jsonDevicesData["devices"][i]["web_sessions"][i2]["created"]; if (idObj != null) { teamId = idObj.Value as string; } if (deviceNameObj != null) { deviceName = deviceNameObj.Value as string; } if (ipAddressObj != null) { ipAddress = ipAddressObj.Value as string; } if (sessionIdObj != null) { sessionId = sessionIdObj.Value as string; } if (createdObj != null) { created = jsonDevicesData["devices"][i]["web_sessions"][i2]["created"]; } foreach (string[] lvitem in members) { if (teamId == lvitem[0]) { email = lvitem[1]; } } // update model DeviceListViewItemModel lvItem = new DeviceListViewItemModel() { Created = created, TeamId = teamId, DeviceName = deviceName, IpAddress = ipAddress, SessionId = sessionId, ClientType = clientType, Email = email }; if (string.IsNullOrEmpty(model.Filter)) { model.DeviceList.Add(lvItem); } if (FilterCriteriaContains && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.Contains(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.Contains(model.Filter)) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaNotContains && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.Contains(model.Filter)) { //do nothing, don't add to list } if (model.FilterType == "DeviceName" && deviceName.Contains(model.Filter)) { //do nothing, don't add to list } if ((model.FilterType == "IpAddress" && (!ipAddress.Contains(model.Filter))) || (model.FilterType == "DeviceName" && (!deviceName.Contains(model.Filter)))) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaBeginsWith && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.StartsWith(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.StartsWith(model.Filter)) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaEndsWith && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.EndsWith(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.EndsWith(model.Filter)) { model.DeviceList.Add(lvItem); } } } if (resultDesktopCount > 0) { for (int i3 = 0; i3 < resultDesktopCount; i3++) { dynamic deviceNameObj = jsonDevicesData["devices"][i]["desktop_clients"][i3]["host_name"]; dynamic ipAddressObj = jsonDevicesData["devices"][i]["desktop_clients"][i3]["ip_address"]; dynamic sessionIdObj = jsonDevicesData["devices"][i]["desktop_clients"][i3]["session_id"]; clientType = "Desktop"; dynamic createdObj = jsonDevicesData["devices"][i]["desktop_clients"][i3]["created"]; if (idObj != null) { teamId = idObj.Value as string; } if (deviceNameObj != null) { deviceName = deviceNameObj.Value as string; } if (ipAddressObj != null) { ipAddress = ipAddressObj.Value as string; } if (sessionIdObj != null) { sessionId = sessionIdObj.Value as string; } if (createdObj != null) { created = jsonDevicesData["devices"][i]["desktop_clients"][i3]["created"]; } foreach (string[] lvitem in members) { if (teamId == lvitem[0]) { email = lvitem[1]; } } // update model DeviceListViewItemModel lvItem = new DeviceListViewItemModel() { Created = created, TeamId = teamId, DeviceName = deviceName, IpAddress = ipAddress, SessionId = sessionId, ClientType = clientType, Email = email }; if (string.IsNullOrEmpty(model.Filter)) { model.DeviceList.Add(lvItem); } if (FilterCriteriaContains && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.Contains(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.Contains(model.Filter)) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaNotContains && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.Contains(model.Filter)) { //do nothing, don't add to list } if (model.FilterType == "DeviceName" && deviceName.Contains(model.Filter)) { //do nothing, don't add to list } if ((model.FilterType == "IpAddress" && (!ipAddress.Contains(model.Filter))) || (model.FilterType == "DeviceName" && (!deviceName.Contains(model.Filter)))) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaBeginsWith && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.StartsWith(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.StartsWith(model.Filter)) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaEndsWith && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.EndsWith(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.EndsWith(model.Filter)) { model.DeviceList.Add(lvItem); } } } } if (resultMobileCount > 0) { for (int i4 = 0; i4 < resultMobileCount; i4++) { dynamic deviceNameObj = jsonDevicesData["devices"][i]["mobile_clients"][i4]["device_name"]; dynamic ipAddressObj = jsonDevicesData["devices"][i]["mobile_clients"][i4]["ip_address"]; dynamic sessionIdObj = jsonDevicesData["devices"][i]["mobile_clients"][i4]["session_id"]; clientType = "Mobile"; dynamic createdObj = jsonDevicesData["devices"][i]["mobile_clients"][i4]["created"]; if (idObj != null) { teamId = idObj.Value as string; } if (deviceNameObj != null) { deviceName = deviceNameObj.Value as string; } if (ipAddressObj != null) { ipAddress = ipAddressObj.Value as string; } if (sessionIdObj != null) { sessionId = sessionIdObj.Value as string; } if (createdObj != null) { created = jsonDevicesData["devices"][i]["mobile_clients"][i4]["created"]; } foreach (string[] lvitem in members) { if (teamId == lvitem[0]) { email = lvitem[1]; } } // update model DeviceListViewItemModel lvItem = new DeviceListViewItemModel() { Created = created, TeamId = teamId, DeviceName = deviceName, IpAddress = ipAddress, SessionId = sessionId, ClientType = clientType, Email = email }; if (string.IsNullOrEmpty(model.Filter)) { model.DeviceList.Add(lvItem); } if (FilterCriteriaContains && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.Contains(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.Contains(model.Filter)) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaNotContains && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.Contains(model.Filter)) { //do nothing, don't add to list } if (model.FilterType == "DeviceName" && deviceName.Contains(model.Filter)) { //do nothing, don't add to list } if ((model.FilterType == "IpAddress" && (!ipAddress.Contains(model.Filter))) || (model.FilterType == "DeviceName" && (!deviceName.Contains(model.Filter)))) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaBeginsWith && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.StartsWith(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.StartsWith(model.Filter)) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaEndsWith && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.EndsWith(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.EndsWith(model.Filter)) { model.DeviceList.Add(lvItem); } } } } } } //if the device count has more, we need to pull next batch from cursor value bool hasMore = jsonDevicesData["has_more"]; string cursor = jsonDevicesData["cursor"]; while (hasMore) { service.GetDevicesUrl = ApplicationResource.ActionListTeamDevices; IDataResponse responseCont = service.FindDevices(new MemberData() { Cursor = cursor }, model.UserAccessToken); string dataCont = responseCont.Data.ToString(); dynamic jsonDevicesDataCont = JsonConvert.DeserializeObject<dynamic>(dataCont); int resultCountCont = jsonDevicesDataCont["devices"].Count; if (resultCountCont > 0) { for (int i = 0; i < resultCountCont; i++) { DateTime created = new DateTime(); string teamId = string.Empty; string deviceName = string.Empty; string ipAddress = string.Empty; string sessionId = string.Empty; string clientType = string.Empty; string email = string.Empty; dynamic idObj = jsonDevicesDataCont["devices"][i]["team_member_id"]; int resultWebCount = jsonDevicesDataCont["devices"][i]["web_sessions"].Count; int resultDesktopCount = jsonDevicesDataCont["devices"][i]["desktop_clients"].Count; int resultMobileCount = jsonDevicesDataCont["devices"][i]["mobile_clients"].Count; if (resultWebCount > 0) { for (int i2 = 0; i2 < resultWebCount; i2++) { dynamic deviceNameObj = jsonDevicesDataCont["devices"][i]["web_sessions"][i2]["user_agent"]; dynamic ipAddressObj = jsonDevicesDataCont["devices"][i]["web_sessions"][i2]["ip_address"]; dynamic sessionIdObj = jsonDevicesDataCont["devices"][i]["web_sessions"][i2]["session_id"]; clientType = "Web"; dynamic createdObj = jsonDevicesDataCont["devices"][i]["web_sessions"][i2]["created"]; if (idObj != null) { teamId = idObj.Value as string; } if (deviceNameObj != null) { deviceName = deviceNameObj.Value as string; } if (ipAddressObj != null) { ipAddress = ipAddressObj.Value as string; } if (sessionIdObj != null) { sessionId = sessionIdObj.Value as string; } if (createdObj != null) { created = jsonDevicesDataCont["devices"][i]["web_sessions"][i2]["created"]; } foreach (string[] lvitem in members) { if (teamId == lvitem[0]) { email = lvitem[1]; } } // update model DeviceListViewItemModel lvItem = new DeviceListViewItemModel() { Created = created, TeamId = teamId, DeviceName = deviceName, IpAddress = ipAddress, SessionId = sessionId, ClientType = clientType, Email = email }; if (string.IsNullOrEmpty(model.Filter)) { model.DeviceList.Add(lvItem); } if (FilterCriteriaContains && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.Contains(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.Contains(model.Filter)) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaNotContains && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.Contains(model.Filter)) { //do nothing, don't add to list } if (model.FilterType == "DeviceName" && deviceName.Contains(model.Filter)) { //do nothing, don't add to list } if ((model.FilterType == "IpAddress" && (!ipAddress.Contains(model.Filter))) || (model.FilterType == "DeviceName" && (!deviceName.Contains(model.Filter)))) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaBeginsWith && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.StartsWith(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.StartsWith(model.Filter)) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaEndsWith && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.EndsWith(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.EndsWith(model.Filter)) { model.DeviceList.Add(lvItem); } } } } if (resultDesktopCount > 0) { for (int i3 = 0; i3 < resultDesktopCount; i3++) { dynamic deviceNameObj = jsonDevicesDataCont["devices"][i]["desktop_clients"][i3]["host_name"]; dynamic ipAddressObj = jsonDevicesDataCont["devices"][i]["desktop_clients"][i3]["ip_address"]; dynamic sessionIdObj = jsonDevicesDataCont["devices"][i]["desktop_clients"][i3]["session_id"]; clientType = "Desktop"; dynamic createdObj = jsonDevicesDataCont["devices"][i]["desktop_clients"][i3]["created"]; if (idObj != null) { teamId = idObj.Value as string; } if (deviceNameObj != null) { deviceName = deviceNameObj.Value as string; } if (ipAddressObj != null) { ipAddress = ipAddressObj.Value as string; } if (sessionIdObj != null) { sessionId = sessionIdObj.Value as string; } if (createdObj != null) { created = jsonDevicesDataCont["devices"][i]["desktop_clients"][i3]["created"]; } foreach (string[] lvitem in members) { if (teamId == lvitem[0]) { email = lvitem[1]; } } // update model DeviceListViewItemModel lvItem = new DeviceListViewItemModel() { Created = created, TeamId = teamId, DeviceName = deviceName, IpAddress = ipAddress, SessionId = sessionId, ClientType = clientType, Email = email }; if (string.IsNullOrEmpty(model.Filter)) { model.DeviceList.Add(lvItem); } if (FilterCriteriaContains && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.Contains(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.Contains(model.Filter)) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaNotContains && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.Contains(model.Filter)) { //do nothing, don't add to list } if (model.FilterType == "DeviceName" && deviceName.Contains(model.Filter)) { //do nothing, don't add to list } if ((model.FilterType == "IpAddress" && (!ipAddress.Contains(model.Filter))) || (model.FilterType == "DeviceName" && (!deviceName.Contains(model.Filter)))) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaBeginsWith && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.StartsWith(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.StartsWith(model.Filter)) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaEndsWith && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.EndsWith(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.EndsWith(model.Filter)) { model.DeviceList.Add(lvItem); } } } } if (resultMobileCount > 0) { for (int i4 = 0; i4 < resultMobileCount; i4++) { dynamic deviceNameObj = jsonDevicesDataCont["devices"][i]["mobile_clients"][i4]["device_name"]; dynamic ipAddressObj = jsonDevicesDataCont["devices"][i]["mobile_clients"][i4]["ip_address"]; dynamic sessionIdObj = jsonDevicesDataCont["devices"][i]["mobile_clients"][i4]["session_id"]; clientType = "Mobile"; dynamic createdObj = jsonDevicesDataCont["devices"][i]["mobile_clients"][i4]["created"]; if (idObj != null) { teamId = idObj.Value as string; } if (deviceNameObj != null) { deviceName = deviceNameObj.Value as string; } if (ipAddressObj != null) { ipAddress = ipAddressObj.Value as string; } if (sessionIdObj != null) { sessionId = sessionIdObj.Value as string; } if (createdObj != null) { created = jsonDevicesDataCont["devices"][i]["mobile_clients"][i4]["created"]; } foreach (string[] lvitem in members) { if (teamId == lvitem[0]) { email = lvitem[1]; } } // update model DeviceListViewItemModel lvItem = new DeviceListViewItemModel() { Created = created, TeamId = teamId, DeviceName = deviceName, IpAddress = ipAddress, SessionId = sessionId, ClientType = clientType, Email = email }; if (string.IsNullOrEmpty(model.Filter)) { model.DeviceList.Add(lvItem); } if (FilterCriteriaContains && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.Contains(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.Contains(model.Filter)) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaNotContains && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.Contains(model.Filter)) { //do nothing, don't add to list } if (model.FilterType == "DeviceName" && deviceName.Contains(model.Filter)) { //do nothing, don't add to list } if ((model.FilterType == "IpAddress" && (!ipAddress.Contains(model.Filter))) || (model.FilterType == "DeviceName" && (!deviceName.Contains(model.Filter)))) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaBeginsWith && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.StartsWith(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.StartsWith(model.Filter)) { model.DeviceList.Add(lvItem); } } if (FilterCriteriaEndsWith && !string.IsNullOrEmpty(model.Filter)) { if (model.FilterType == "IpAddress" && ipAddress.EndsWith(model.Filter)) { model.DeviceList.Add(lvItem); } if (model.FilterType == "DeviceName" && deviceName.EndsWith(model.Filter)) { model.DeviceList.Add(lvItem); } } } } } } hasMore = jsonDevicesDataCont["has_more"]; cursor = jsonDevicesDataCont["cursor"]; } } } } } }
private void SearchMembers(ITextSearchModel model) { if (!string.IsNullOrEmpty(model.QueryString) && !string.IsNullOrEmpty(model.AccessToken)) { MemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.ListMembersUrl = ApplicationResource.ActionListMembers; service.UserAgentVersion = ApplicationResource.UserAgent; IDataResponse response = service.ListMembers(new MemberData() { SearchLimit = model.SearchResultsLimit }, model.AccessToken); IMainPresenter presenter = SimpleResolver.Instance.Get<IMainPresenter>(); if (response.StatusCode == System.Net.HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonData = JsonConvert.DeserializeObject<dynamic>(data); // clear existing data first model.MemberList.Clear(); int resultCount = jsonData["members"].Count; for (int i = 0; i < resultCount; i++) { dynamic idObj = jsonData["members"][i]["profile"]["team_member_id"]; dynamic emailObj = jsonData["members"][i]["profile"]["email"]; string memberId = idObj.Value as string; string email = emailObj.Value as string; // update model MemberListViewItemModel lvItem = new MemberListViewItemModel() { Email = email, MemberId = memberId }; // perform file search if (!SearchFiles(service, memberId, model, email, presenter)) { model.MemberList.Add(lvItem); } SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Searching Content(s) From : {0}", email)); }, null); } } } else { // TODO: Report error } } }