public RadComboBoxData FillRadComboData4AssignPartner(RadComboBoxContext context, string strClientCode) { RadComboBoxData comboData = new RadComboBoxData(); DataTable dtPartnerData = GetPartner4AssignPartnerCombo(context["PartnerCode"].ToString(), context.Text.ToString(), strClientCode).Tables[0]; if (dtPartnerData != null) { List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(context.NumberOfItems); try { int itemsPerRequest = 10; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > dtPartnerData.Rows.Count) { endOffset = dtPartnerData.Rows.Count; } if (endOffset == dtPartnerData.Rows.Count) { comboData.EndOfItems = true; } else { comboData.EndOfItems = false; } result = new List <RadComboBoxItemData>(); for (int i = itemOffset; i < endOffset; i++) { RadComboBoxItemData itemData = new RadComboBoxItemData(); String itemText = dtPartnerData.Rows[i]["PartnerCode"].ToString().Trim() + " " + dtPartnerData.Rows[i]["PartnerName"].ToString(); itemData.Text = itemText; itemData.Value = dtPartnerData.Rows[i]["PartnerCode"].ToString().Trim(); itemData.Attributes["PartnerCode"] = dtPartnerData.Rows[i]["PartnerCode"].ToString().Trim(); itemData.Attributes["PartnerName"] = dtPartnerData.Rows[i]["PartnerName"].ToString().Trim(); itemData.Attributes["PartnerTypeCode"] = dtPartnerData.Rows[i]["PartnerTypeCode"].ToString().Trim(); result.Add(itemData); } if (dtPartnerData.Rows.Count > 0) { comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dtPartnerData.Rows.Count.ToString()); } else { comboData.Message = "No matches"; } } catch (Exception e) { comboData.Message = e.Message; } comboData.Items = result.ToArray(); } return(comboData); }
public RadComboBoxItemData[] GetPointsWithStateFilter(RadComboBoxContext context, bool includeDeleted) { IDictionary <string, object> contextDictionary = (IDictionary <string, object>)context; string filter = context.Text; int _identityID = -1; //int _townID = ((int)contextDictionary["TownID"]); if (contextDictionary.Keys.FirstOrDefault(k => k == "IdentityID") != null) { _identityID = ((int)contextDictionary["IdentityID"]); } // The search text entered by the user ("e.Text") can be split into two regions delimited by a backslash. // Any text to the left of the first backslash (or when there is no backslash) should be used to filter the organisation name. // Any text to the right of a backslash should be used to filter the point description. char filterChar = '\\'; // Backslash character "\" string[] filterString = filter.Split(';')[0].Split(filterChar.ToString().ToCharArray()); DataSet ds = null; Orchestrator.Facade.Point facPoint = new Orchestrator.Facade.Point(); int noOfRowsToReturnPerRequest = 20; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + noOfRowsToReturnPerRequest; if (string.IsNullOrEmpty(filter)) { // Do not filter the point type for the time being - just display 'Any'. ds = facPoint.GetAllWithAddress(ePointType.Any, "", "", noOfRowsToReturnPerRequest, includeDeleted); } else if (filterString.Length == 1) { // Do not filter the point type for the time being - just display 'Any'. // when only one strng is entered, surely the intention is to search on the point description not the organisationname ds = facPoint.GetAllWithAddress(ePointType.Any, "", filterString[0], noOfRowsToReturnPerRequest, includeDeleted); } else if (filterString.Length > 1) { // Do not filter the point type for the time being - just display 'Any'. ds = facPoint.GetAllWithAddress(ePointType.Any, filterString[1], filterString[0], noOfRowsToReturnPerRequest, includeDeleted); } DataTable dt = ds.Tables[0]; Telerik.Web.UI.RadComboBoxItemData rcItem = null; List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); foreach (DataRow row in dt.Rows) { rcItem = new RadComboBoxItemData(); PointComboItem comboItem = new PointComboItem(row); rcItem.Text = comboItem.SingleLineText; rcItem.Value = row["IdentityId"].ToString() + "," + row["PointId"]; result.Add(rcItem); } return(result.ToArray()); }
public RadComboBoxData GetCompanyNames(RadComboBoxContext context) { List<ComboBoxItemData> data = GetData(context.Text); RadComboBoxData comboData = new RadComboBoxData(); int itemOffset = context.NumberOfItems; int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Count); comboData.EndOfItems = endOffset == data.Count; List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(endOffset - itemOffset); for (int i = itemOffset; i < endOffset; i++) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = data[i].CompanyName; itemData.Value = data[i].CompanyId.ToString(); itemData.Attributes["Branch"] = data[i].BranchName; itemData.Attributes["Site"] = data[i].SiteName; result.Add(itemData); } comboData.Message = GetStatusMessage(endOffset, data.Count); comboData.Items = result.ToArray(); return comboData; }
public RadComboBoxItemData[] GetAllTrailers(RadComboBoxContext context) { List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); string[] clientArgs = context["FilterString"].ToString().Split(':'); int depotID = 0; depotID = int.Parse(clientArgs[0]); Facade.IResource facResource = new Facade.Resource(); DataSet ds = facResource.GetAllResourcesFiltered(context.Text, eResourceType.Trailer, depotID, false, true); int itemsPerRequest = 20; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > ds.Tables[0].Rows.Count) { endOffset = ds.Tables[0].Rows.Count; } DataTable dt = ds.Tables[0]; Telerik.Web.UI.RadComboBoxItemData rcItem = null; for (int i = itemOffset; i < endOffset; i++) { rcItem = new Telerik.Web.UI.RadComboBoxItemData(); rcItem.Text = dt.Rows[i]["Description"].ToString(); rcItem.Value = dt.Rows[i]["ResourceId"].ToString(); result.Add(rcItem); } return(result.ToArray()); }
public RadComboBoxItemData[] GetUserOrOrganization(RadComboBoxContext context) { IDictionary <string, object> contextDictionary = (IDictionary <string, object>)context; Organizations organizations = new Organizations(UserSession.LoginUser); organizations.LoadByLikeOrganizationName(UserSession.LoginUser.OrganizationID, context["FilterString"].ToString(), true); UsersView users = new UsersView(UserSession.LoginUser); users.LoadByLikeName(UserSession.LoginUser.OrganizationID, context["FilterString"].ToString()); List <RadComboBoxItemData> list = new List <RadComboBoxItemData>(); foreach (Organization organization in organizations) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = organization.Name; itemData.Value = 'o' + organization.OrganizationID.ToString(); list.Add(itemData); } foreach (UsersViewItem user in users) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = String.Format("{0}, {1} [{2}]", user.LastName, user.FirstName, user.Organization); itemData.Value = 'u' + user.UserID.ToString(); list.Add(itemData); } return(list.ToArray()); }
public RadComboBoxItemData[] GetAllDrivers(RadComboBoxContext context) { List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); Facade.IResource facResource = new Facade.Resource(); DataSet ds = facResource.GetAllResourcesFiltered(context.Text, eResourceType.Driver, false); var itemsPerRequest = context.ContainsKey("ItemsPerRequest") ? (int)context["ItemsPerRequest"] : 20; DataTable dt = ds.Tables[0]; var itemCount = dt.Rows.Count; int itemOffset = context.NumberOfItems; int endOffset = itemsPerRequest == 0 ? itemCount : itemOffset + itemsPerRequest; if (endOffset > itemCount) { endOffset = itemCount; } for (int i = itemOffset; i < endOffset; i++) { var rcItem = new Telerik.Web.UI.RadComboBoxItemData(); rcItem.Text = dt.Rows[i]["Description"].ToString(); rcItem.Value = dt.Rows[i]["ResourceId"].ToString(); result.Add(rcItem); } return(result.ToArray()); }
public RadComboBoxItemData[] GetDriversForPlanner(RadComboBoxContext context) { List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); string[] clientArgs = context["FilterString"].ToString().Split(':'); int plannerIdentityID = 0; plannerIdentityID = int.Parse(clientArgs[0]); using (var uow = DIContainer.CreateUnitOfWork()) { var repo = DIContainer.CreateRepository <Repositories.IDriverRepository>(uow); var drivers = from d in repo.GetAll() where d.PlannerIdentityID == plannerIdentityID orderby d.Individual.LastName select new Telerik.Web.UI.RadComboBoxItemData() { Text = d.Individual.FirstNames + " " + d.Individual.LastName, Value = d.ResourceID.ToString() }; result.AddRange(drivers); } return(result.ToArray()); }
public RadComboBoxItemData[] GetUsers(RadComboBoxContext context) { IDictionary <string, object> contextDictionary = (IDictionary <string, object>)context; List <RadComboBoxItemData> list = new List <RadComboBoxItemData>(); try { Users users = new Users(UserSession.LoginUser); //string search = context["FilterString"].ToString(); //users.LoadByName(search, UserSession.LoginUser.OrganizationID, true); users.LoadByOrganizationID(UserSession.LoginUser.OrganizationID, true); foreach (User user in users) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = user.FirstLastName; itemData.Value = user.UserID.ToString(); list.Add(itemData); } } catch (Exception) { } if (list.Count < 1) { RadComboBoxItemData noData = new RadComboBoxItemData(); noData.Text = "[No users to display.]"; noData.Value = "-1"; list.Add(noData); } return(list.ToArray()); }
public RadComboBoxItemData[] GetClosestTownNoCountry(RadComboBoxContext context) { List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); try { Orchestrator.Facade.IReferenceData facRefData = new Orchestrator.Facade.ReferenceData(); DataSet ds = facRefData.GetTownForTownName(context.Text); int itemsPerRequest = 20; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > ds.Tables[0].Rows.Count) { endOffset = ds.Tables[0].Rows.Count; } DataTable dt = ds.Tables[0]; RadComboBoxItemData rcItem = null; for (int i = itemOffset; i < endOffset; i++) { rcItem = new RadComboBoxItemData(); rcItem.Text = dt.Rows[i]["Description"].ToString(); rcItem.Value = dt.Rows[i]["TownId"].ToString(); result.Add(rcItem); } } catch (Exception ex) { throw ex; } return(result.ToArray()); }
public RadComboBoxData GetCompanyNames(RadComboBoxContext context) { List <ComboBoxItemData> data = GetData(context.Text); RadComboBoxData comboData = new RadComboBoxData(); int itemOffset = context.NumberOfItems; int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Count); comboData.EndOfItems = endOffset == data.Count; List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(endOffset - itemOffset); for (int i = itemOffset; i < endOffset; i++) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = data[i].CompanyName; itemData.Value = data[i].CompanyId.ToString(); itemData.Attributes["Branch"] = data[i].BranchName; itemData.Attributes["Site"] = data[i].SiteName; result.Add(itemData); } comboData.Message = GetStatusMessage(endOffset, data.Count); comboData.Items = result.ToArray(); return(comboData); }
public RadComboBoxItemData[] GetOrganisations(RadComboBoxContext context) { List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); Orchestrator.Facade.IReferenceData facRefData = new Orchestrator.Facade.ReferenceData(); DataSet ds = facRefData.GetAllOrganisationsFiltered(context.Text, false); int itemsPerRequest = 20; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > ds.Tables[0].Rows.Count) { endOffset = ds.Tables[0].Rows.Count; } DataTable dt = ds.Tables[0]; Telerik.Web.UI.RadComboBoxItemData rcItem = null; for (int i = itemOffset; i < endOffset; i++) { rcItem = new Telerik.Web.UI.RadComboBoxItemData(); rcItem.Text = dt.Rows[i]["OrganisationName"].ToString(); rcItem.Value = dt.Rows[i]["IdentityId"].ToString(); result.Add(rcItem); } return(result.ToArray()); }
public RadComboBoxItemData[] GetVehicles(RadComboBoxContext context) { List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); // If the context contains a "TopItemText" key then add to a the top of the result list an item containing this text (for example "- all -" or "- select -") // But only if the list is currently empty. If they have clicked the ShowMoreResultsBox arrow, we don't want to add another "- all -" bool hasTopItemText = false; var topItemText = context.ContainsKey("TopItemText") ? context["TopItemText"].ToString() : string.Empty; hasTopItemText = !string.IsNullOrWhiteSpace(topItemText); if (hasTopItemText && context.NumberOfItems == 0) { result.Add(new Telerik.Web.UI.RadComboBoxItemData { Text = topItemText }); } string[] clientArgs = context["FilterString"].ToString().Split(':'); int depotID = int.Parse(clientArgs[0]); var query = (context.ContainsKey("Text") && context.Text != topItemText) ? context.Text : string.Empty; Facade.IResource facResource = new Facade.Resource(); DataSet ds = facResource.GetAllResourcesFiltered(query, eResourceType.Vehicle, depotID, false, true); int itemsPerRequest = 20; int itemOffset = context.NumberOfItems; // If the list contains a Top Item (e.g. -All-) and the list is already populated (the ShowMoreResultsBox has been clicked), do not include the Top Item or the offset will skip a vehicle. if (hasTopItemText && context.NumberOfItems > 0) { itemOffset--; } int endOffset = itemOffset + itemsPerRequest; if (endOffset > ds.Tables[0].Rows.Count) { endOffset = ds.Tables[0].Rows.Count; } DataTable dt = ds.Tables[0]; Telerik.Web.UI.RadComboBoxItemData rcItem = null; for (int i = itemOffset; i < endOffset; i++) { rcItem = new Telerik.Web.UI.RadComboBoxItemData(); rcItem.Text = dt.Rows[i]["Description"].ToString(); rcItem.Value = dt.Rows[i]["ResourceId"].ToString(); result.Add(rcItem); } return(result.ToArray()); }
public RadComboBoxItemData[] GetProductsByModel(RadComboBoxContext context) { List <RadComboBoxItemData> suggestions = new List <RadComboBoxItemData>(context.NumberOfItems); if (context != null && !string.IsNullOrEmpty(context.Text)) { var products = new ProductRepository().GetByModel(context.Text); RadComboBoxData data = new RadComboBoxData(); try { int itemsPerRequest = 10; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > products.Count) { endOffset = products.Count; } if (endOffset == products.Count) { data.EndOfItems = true; } else { data.EndOfItems = false; } suggestions = new List <RadComboBoxItemData>(endOffset - itemOffset); for (int i = itemOffset; i < endOffset; i++) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = products[i].PartNumber; itemData.Value = products[i].ID.ToString(); suggestions.Add(itemData); } if (products.Count > 0) { data.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), products.Count.ToString()); } else { data.Message = "No matches"; } } catch (Exception e) { data.Message = e.Message; } data.Items = suggestions.ToArray(); return(data.Items); } return(suggestions.ToArray()); }
public RadComboBoxData LoadStoreDDL(RadComboBoxContext context) { //The RadComboBoxData object contains all required information for load on demand: // - the items // - are there more items in case of paging // - status message to be displayed (which is optional) RadComboBoxData result = new RadComboBoxData(); LookupDAO lkp = new LookupDAO(); List <KeyValuePair <string, string> > stores = lkp.GetStore(); //Get all items from the Customers table. This query will not be executed untill the ToArray method is called. var allStores = from store in stores orderby store.Key, store.Value select new RadComboBoxItemData { Text = store.Key + " - " + store.Value, Value = store.Key }; //In case the user typed something - filter the result set string text = context.Text; if (!String.IsNullOrEmpty(text)) { allStores = allStores.Where(item => item.Text.StartsWith(text)); } //Perform the paging // - first skip the amount of items already populated // - take the next 10 items int numberOfItems = context.NumberOfItems; var storelist = allStores.Skip(numberOfItems).Take(10); //This will execute the database query and return the data as an array of RadComboBoxItemData objects result.Items = storelist.ToArray(); int endOffset = numberOfItems + storelist.Count(); int totalCount = allStores.Count(); //Check if all items are populated (this is the last page) if (endOffset == totalCount) { result.EndOfItems = true; } //Initialize the status message result.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset, totalCount); return(result); }
public RadComboBoxData GetProductsByProductID(RadComboBoxContext context) { //if (context != null && !string.IsNullOrEmpty(context.Text)) //{ // DataSet ds = Utilities.ExecuteStoredProc(ConfigurationManager.AppSettings["DBNAME"], "selectProductsByNameForAutoComplete", "product", context.Text); // List<RadComboBoxItemData> suggestions = new List<RadComboBoxItemData>(context.NumberOfItems); // RadComboBoxData data = new RadComboBoxData(); // try // { // int itemsPerRequest = 10; // int itemOffset = context.NumberOfItems; // int endOffset = itemOffset + itemsPerRequest; // if (endOffset > ds.Tables[0].Rows.Count) // { // endOffset = ds.Tables[0].Rows.Count; // } // if (endOffset == ds.Tables[0].Rows.Count) // { // data.EndOfItems = true; // } // else // { // data.EndOfItems = false; // } // suggestions = new List<RadComboBoxItemData>(endOffset - itemOffset); // for (int i = itemOffset; i < endOffset; i++) // { // RadComboBoxItemData itemData = new RadComboBoxItemData(); // itemData.Text = ds.Tables[0].Rows[i]["product"].ToString(); // itemData.Value = ds.Tables[0].Rows[i]["productid"].ToString(); // suggestions.Add(itemData); // } // if (ds.Tables[0].Rows.Count > 0) // { // data.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), ds.Tables[0].Rows.Count.ToString()); // } // else // { // data.Message = "No matches"; // } // } // catch (Exception e) // { // data.Message = e.Message; // } // data.Items = suggestions.ToArray(); // return data; //} return(null); }
public static RadComboBoxItemData[] GetUsers(RadComboBoxContext context) { IDictionary <string, object> contextDictionary = (IDictionary <string, object>)context; List <RadComboBoxItemData> list = new List <RadComboBoxItemData>(); try { Users users = new Users(UserSession.LoginUser); string[] s = context["FilterString"].ToString().Split(','); string filter = s[0]; string search = s[1]; switch (filter) { case "OtherChatUsers": users.LoadByName(search, UserSession.LoginUser.OrganizationID, true, false, true, UserSession.LoginUser.UserID); break; case "AllChatUsers": users.LoadByName(search, UserSession.LoginUser.OrganizationID, true, false, true); break; case "OtherUsers": users.LoadByName(search, UserSession.LoginUser.OrganizationID, true, false, false, UserSession.LoginUser.UserID); break; case "AdminUsers": users.LoadByName(search, UserSession.LoginUser.OrganizationID, true, true, false); break; default: users.LoadByName(search, UserSession.LoginUser.OrganizationID, true, false, false); break; } foreach (User user in users) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = user.FirstLastName; itemData.Value = user.UserID.ToString(); list.Add(itemData); } } catch (Exception ex) { RadComboBoxItemData noData = new RadComboBoxItemData(); noData.Text = ex.Message; noData.Value = "-1"; list.Add(noData); return(list.ToArray()); } if (list.Count < 1) { RadComboBoxItemData noData = new RadComboBoxItemData(); noData.Text = "[No users to display.]"; noData.Value = "-1"; list.Add(noData); } return(list.ToArray()); }
public RadComboBoxItemData[] GetClients(RadComboBoxContext context) { List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); // If the context contains a "TopItemText" key then add to a the top of the result list an item containing this text (for example "- all -" or "- select -") var topItemText = context.ContainsKey("TopItemText") ? context["TopItemText"].ToString() : string.Empty; if (!string.IsNullOrWhiteSpace(topItemText)) { result.Add(new Telerik.Web.UI.RadComboBoxItemData { Text = topItemText }); } bool includeSuspended = false; if (context.ContainsKey("DisplaySuspended")) { includeSuspended = context["DisplaySuspended"] == null ? false : context["DisplaySuspended"].ToString() == "False" ? false : true; } var query = (context.ContainsKey("Text") && context.Text != topItemText) ? context.Text : string.Empty; Orchestrator.Facade.IReferenceData facRefData = new Orchestrator.Facade.ReferenceData(); DataSet ds = facRefData.GetAllClientsFiltered(query, includeSuspended); int itemsPerRequest = 20; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > ds.Tables[0].Rows.Count) { endOffset = ds.Tables[0].Rows.Count; } DataTable dt = ds.Tables[0]; Telerik.Web.UI.RadComboBoxItemData rcItem = null; for (int i = itemOffset; i < endOffset; i++) { rcItem = new Telerik.Web.UI.RadComboBoxItemData(); rcItem.Text = dt.Rows[i]["OrganisationName"].ToString(); rcItem.Value = dt.Rows[i]["IdentityId"].ToString(); result.Add(rcItem); } return(result.ToArray()); }
public static RadComboBoxData GetEmployeeList(RadComboBoxContext context) { RadComboBoxData comboData = new RadComboBoxData(); try { string keyword = context.Text; int pageFrom = context.NumberOfItems; int pageSize = 10; int?departmentId = null; if (context.ContainsKey("DepartmentId") && context["DepartmentId"] != null) { departmentId = Convert.ToInt32(context["DepartmentId"]); } var employees = EmployeeManager.GetEmployees(pageFrom, pageSize, departmentId, context.Text, null, true); if (employees != null) { List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); foreach (var item in employees) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = item.EmployeeName; itemData.Value = Convert.ToString(item.EmployeeId); result.Add(itemData); } int totalCount = employees[0].TotalCount; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + totalCount; comboData.EndOfItems = totalCount < pageSize; //comboData.Message = GetStatusMessagecustom(endOffset); comboData.Items = result.ToArray(); } return(comboData); } catch (Exception ex) { return(comboData); } }
public RadComboBoxItemData[] GetCountries(RadComboBoxContext context) { Orchestrator.Facade.IReferenceData facRef = new Orchestrator.Facade.ReferenceData(); DataSet ds = facRef.GetAllCountries(); DataTable dt = ds.Tables[0]; Telerik.Web.UI.RadComboBoxItemData rcItem = null; List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); foreach (DataRow dr in dt.Rows) { rcItem = new RadComboBoxItemData(); rcItem.Text = dr["CountryDescription"].ToString(); rcItem.Value = dr["CountryId"].ToString(); result.Add(rcItem); } return(result.ToArray()); }
public static RadComboBoxItemData[] GetReports(RadComboBoxContext context) { IDictionary <string, object> contextDictionary = (IDictionary <string, object>)context; List <RadComboBoxItemData> list = new List <RadComboBoxItemData>(); Reports reports = new Reports(UserSession.LoginUser); reports.LoadAll(UserSession.LoginUser.OrganizationID); foreach (Report report in reports) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = report.Name; itemData.Value = report.ReportID.ToString(); list.Add(itemData); } return(list.ToArray()); }
public RadComboBoxData GetCoworker(RadComboBoxContext context) { if (context.Text.Length > 1) { RadComboBoxData comboData = new RadComboBoxData(); List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); string searchterm = context.Text.ToLower(); foreach (v_ad_user_creation pos in repo.Query.Where(p => p.Fullname.ToLower().Substring(0, searchterm.Length).Equals(searchterm) && p.User_fk != null)) { RadComboBoxItemData item = new RadComboBoxItemData(); item.Text = pos.Fullname + " -- " + pos.Orgunit + " -- " + pos.Position; item.Value = pos.samaccount; result.Add(item); } comboData.Items = result.ToArray(); return(comboData); } return(null); }
public RadComboBoxData GetEmployee(RadComboBoxContext context) { if (context.Text.Length > 1) { RadComboBoxData comboData = new RadComboBoxData(); List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); string searchterm = context.Text.ToLower(); //p.User_fk == null && foreach (v_ad_user_creation pos in repo.Query.Where(p => p.User_fk == null && p.Fullname.ToLower().Substring(0, searchterm.Length).Equals(searchterm))) { RadComboBoxItemData item = new RadComboBoxItemData(); item.Text = pos.Fullname + " -- " + pos.Orgunit + " -- " + pos.Position + " -- MedNR: " + pos.Opus_id; item.Value = pos.Opus_id.ToString(); result.Add(item); } comboData.Items = result.ToArray(); return(comboData); } return(null); }
public static RadComboBoxItemData[] GetOrganization(RadComboBoxContext context) { IDictionary <string, object> contextDictionary = (IDictionary <string, object>)context; Organizations organizations = new Organizations(UserSession.LoginUser); organizations.LoadByLikeOrganizationName(UserSession.LoginUser.OrganizationID, context["FilterString"].ToString(), !UserSession.CurrentUser.IsSystemAdmin, 250); List <RadComboBoxItemData> list = new List <RadComboBoxItemData>(); foreach (Organization organization in organizations) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = organization.Name; itemData.Value = organization.OrganizationID.ToString(); list.Add(itemData); } return(list.ToArray()); }
public RadComboBoxItemData[] GetTicketTags(RadComboBoxContext context) { IDictionary <string, object> contextDictionary = (IDictionary <string, object>)context; Tags tags = new Tags(UserSession.LoginUser); string search = context["FilterString"].ToString(); tags.LoadBySearchTerm(search); List <RadComboBoxItemData> list = new List <RadComboBoxItemData>(); foreach (Tag tag in tags) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = tag.Value; itemData.Value = tag.TagID.ToString(); list.Add(itemData); } return(list.ToArray()); }
public RadComboBoxData GetComboItems([FromBody] RadComboBoxContext context) { string text = ""; int numberOfItems = 0; foreach (var item in context) { JToken token = JObject.Parse(item.Value.ToString()); text = (string)token.SelectToken("Text"); numberOfItems = (int)token.SelectToken("NumberOfItems"); } List <Product> products = GetProducts(text); RadComboBoxData comboData = new RadComboBoxData(); int itemOffset = numberOfItems; int endOffset = Math.Min(itemOffset + ItemsPerRequest, products.Count); comboData.EndOfItems = endOffset == products.Count; List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); for (int i = itemOffset; i < endOffset; i++) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = products[i].Name; itemData.Value = products[i].Id.ToString(); result.Add(itemData); } comboData.Message = GetStatusMessage(endOffset, products.Count); comboData.Items = result.ToArray(); return(comboData); }
public RadComboBoxItemData[] GetMultiTrunk(RadComboBoxContext context) { string multiTrunkDescription = context["FilterString"].ToString(); List <Entities.MultiTrunk> multiTrunks = null; Orchestrator.Facade.MultiTrunk facMultiTrunk = new Orchestrator.Facade.MultiTrunk(); int noOfRowsToReturn = 20; multiTrunks = facMultiTrunk.GetForDescriptionFiltered(multiTrunkDescription, true, noOfRowsToReturn); Telerik.Web.UI.RadComboBoxItemData rcItem = null; List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); foreach (Entities.MultiTrunk mt in multiTrunks) { rcItem = new Telerik.Web.UI.RadComboBoxItemData(); rcItem.Text = mt.HtmlTableFormattedTrunkPointDescriptionsWithTravelTimesAndMultiTrunkDescription; rcItem.Value = mt.MultiTrunkId.ToString(); result.Add(rcItem); } return(result.ToArray()); }
public RadComboBoxData FillRadComboData(RadComboBoxContext context, string strClientCode) { RadComboBoxData comboData = new RadComboBoxData(); DataTable dtMaterialData = GetSalesOrderDetail4Combo(context.Text.ToString(), context["SODocCode"].ToString().Trim(), strClientCode).Tables[0]; if (dtMaterialData != null) { List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(context.NumberOfItems); try { int itemsPerRequest = 10; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > dtMaterialData.Rows.Count) { endOffset = dtMaterialData.Rows.Count; } if (endOffset == dtMaterialData.Rows.Count) { comboData.EndOfItems = true; } else { comboData.EndOfItems = false; } result = new List <RadComboBoxItemData>(); for (int i = itemOffset; i < endOffset; i++) { RadComboBoxItemData itemData = new RadComboBoxItemData(); String itemText = dtMaterialData.Rows[i]["MaterialCode"].ToString() + " " + dtMaterialData.Rows[i]["MatDesc"].ToString(); itemData.Text = itemText; itemData.Value = dtMaterialData.Rows[i]["SOItemNo"].ToString().Trim(); itemData.Attributes["MatDesc"] = dtMaterialData.Rows[i]["MatDesc"].ToString(); itemData.Attributes["MaterialTypeCode"] = dtMaterialData.Rows[i]["MaterialTypeCode"].ToString().Trim(); itemData.Attributes["MatGroup1Code"] = dtMaterialData.Rows[i]["MatGroup1Code"].ToString().Trim(); itemData.Attributes["MatGroup2Code"] = dtMaterialData.Rows[i]["MatGroup2Code"].ToString().Trim(); itemData.Attributes["UOMCode"] = dtMaterialData.Rows[i]["UOMCode"].ToString(); itemData.Attributes["ValClassType"] = dtMaterialData.Rows[i]["ValClassType"].ToString(); itemData.Attributes["NetWeight"] = dtMaterialData.Rows[i]["NetWeight"].ToString(); itemData.Attributes["GrossWeight"] = dtMaterialData.Rows[i]["GrossWeight"].ToString(); itemData.Attributes["NetPriceperQty"] = dtMaterialData.Rows[i]["PriceUnit"].ToString(); result.Add(itemData); } if (dtMaterialData.Rows.Count > 0) { comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dtMaterialData.Rows.Count.ToString()); } else { comboData.Message = "No matches"; } } catch (Exception e) { comboData.Message = e.Message; } comboData.Items = result.ToArray(); } return(comboData); }
public static RadComboBoxData GetFieldNames(RadComboBoxContext context) { var fields = new List<string>(); if (HttpContext.Current.Session["Fields"] != null) { fields = (List<string>) HttpContext.Current.Session["Fields"]; } var data = (from f in fields where f.ToLower().Contains(context.Text.ToLower()) select f).ToList(); var comboData = new RadComboBoxData(); var itemOffset = context.NumberOfItems; var endOffset = Math.Min(itemOffset + 10, data.Count); comboData.EndOfItems = endOffset == data.Count; var result = new List<RadComboBoxItemData>(endOffset - itemOffset); for (var i = itemOffset; i < endOffset; i++) { var itemData = new RadComboBoxItemData {Text = data.ElementAt(i), Value = data.ElementAt(i)}; result.Add(itemData); } comboData.Message = GetStatusMessage(endOffset, data.Count); comboData.Items = result.ToArray(); return comboData; }
public RadComboBoxData GetLeadsMobileDept(RadComboBoxContext context) { string searchtext = string.Empty; searchtext = Convert.ToString(context.Text); RadComboBoxData comboData = new RadComboBoxData(); if (HttpContext.Current.Session["GlobalValueKey"] != null) { DataTable data = new DataTable(); using (SqlConnection connection = new SqlConnection(Convert.ToString(HttpContext.Current.Session["GlobalValueKey"]))) { using (SqlCommand CMD = new SqlCommand()) { //Last Name,First Name,Status string strqry = string.Empty; strqry = strqry + " SELECT "; strqry = strqry + " (L.LName + ', ' + L.FName + CASE WHEN LEN(L.MInitial) > 0 Then ' ' + L.MInitial Else '' End) As FullName , "; strqry = strqry + " ISNULL(L.StatusCode,'') AS Status,L.PhoneMobile as MobilePhone "; strqry = strqry + " FROM Lead AS L LEFT JOIN LeadStatus AS LS ON L.StatusCode = LS.StatusCode LEFT JOIN Employees AS E "; strqry = strqry + " ON L.EmpID = E.EmpID "; strqry = strqry + " where (L.PhoneMobile is not null and L.PhoneMobile<>'') and ( L.LName + ', ' + L.FName like '" + searchtext + "%' or L.StatusCode like '" + searchtext + "%' or L.PhoneMobile like '" + searchtext + "%') "; strqry = strqry + " ORDER BY L.LName + ', ' + L.FName "; CMD.Connection = connection; CMD.CommandType = System.Data.CommandType.Text; CMD.CommandText = strqry; CMD.Prepare(); SqlDataAdapter DataAdapter = new SqlDataAdapter(CMD); DataAdapter.Fill(data); } } List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(context.NumberOfItems); try { int itemsPerRequest = 10; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > data.Rows.Count) { endOffset = data.Rows.Count; } if (endOffset == data.Rows.Count) { comboData.EndOfItems = true; } else { comboData.EndOfItems = false; } result = new List <RadComboBoxItemData>(endOffset - itemOffset); for (int i = itemOffset; i < endOffset; i++) { RadComboBoxItemData itemData = new RadComboBoxItemData(); // itemData.Text = Convert.ToString(data.Rows[i]["FullName"]); string itemtext = string.Empty; itemtext = itemtext + "<ul>"; itemtext = itemtext + "<li class='SMScol1'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["FullName"]) + "</li>"; itemtext = itemtext + "<li class='SMScol2'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["MobilePhone"]) + "</li>"; itemtext = itemtext + "<li class='SMScol3'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["Status"]) + "</li> "; itemtext = itemtext + "</ul>"; itemData.Text = itemtext; itemData.Value = Convert.ToString(data.Rows[i]["MobilePhone"]); result.Add(itemData); } if (data.Rows.Count > 0) { comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString()); } else { comboData.Message = "No matches"; } } catch (Exception e) { comboData.Message = e.Message; } comboData.Items = result.ToArray(); } return(comboData); }
public RadComboBoxItemData[] GetKBTicketByDescription(RadComboBoxContext context) { Options options = new Options(); options.TextFlags = TextFlags.dtsoTfRecognizeDates; using (SearchJob job = new SearchJob()) { string searchTerm = context["FilterString"].ToString().Trim(); job.Request = searchTerm; job.FieldWeights = "TicketNumber: 5000, Name: 1000"; job.BooleanConditions = "(OrganizationID::" + TSAuthentication.OrganizationID.ToString() + ") AND (IsKnowledgeBase::True)"; job.MaxFilesToRetrieve = 25; job.AutoStopLimit = 100000; job.TimeoutSeconds = 10; job.SearchFlags = SearchFlags.dtsSearchSelectMostRecent | SearchFlags.dtsSearchStemming | SearchFlags.dtsSearchDelayDocInfo; int num = 0; if (!int.TryParse(searchTerm, out num)) { job.Fuzziness = 1; job.Request = job.Request + "*"; job.SearchFlags = job.SearchFlags | SearchFlags.dtsSearchFuzzy; } if (searchTerm.ToLower().IndexOf(" and ") < 0 && searchTerm.ToLower().IndexOf(" or ") < 0) { job.SearchFlags = job.SearchFlags | SearchFlags.dtsSearchTypeAllWords; } job.IndexesToSearch.Add(DataUtils.GetTicketIndexPath(TSAuthentication.GetLoginUser())); job.Execute(); SearchResults results = job.Results; IDictionary <string, object> contextDictionary = (IDictionary <string, object>)context; List <RadComboBoxItemData> list = new List <RadComboBoxItemData>(); try { for (int i = 0; i < results.Count; i++) { results.GetNthDoc(i); RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = results.CurrentItem.DisplayName; itemData.Value = results.CurrentItem.Filename + "," + results.CurrentItem.UserFields["TicketNumber"].ToString(); list.Add(itemData); } } catch (Exception) { } if (list.Count < 1) { RadComboBoxItemData noData = new RadComboBoxItemData(); noData.Text = "[No tickets to display.]"; noData.Value = "-1"; list.Add(noData); } return(list.ToArray()); } }
public RadComboBoxData GetGroupSearch(RadComboBoxContext context) { List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems); RadComboBoxData comboData = new RadComboBoxData(); if (!string.IsNullOrWhiteSpace(context.Text)) { try { const int TAKE = 15; aqufitEntities entities = new aqufitEntities(); int itemOffset = context.NumberOfItems; IQueryable<Group> friends = entities.UserSettings.OfType<Group>().OrderBy(w => w.UserName); friends = friends.Where(w => w.UserName.ToLower().Contains(context.Text) || w.UserFirstName.ToLower().Contains(context.Text)); int length = friends.Count(); friends = friends.Skip(itemOffset).Take(TAKE); Group[] groups = friends.ToArray(); foreach (Group g in groups) { RadComboBoxItemData item = new RadComboBoxItemData(); item.Text = g.UserFirstName; item.Value = " { 'Address': '', 'GroupKey':" + g.Id + ", 'Lat':" + g.DefaultMapLat + ", 'Lng':" + g.DefaultMapLng + " , 'Name':'" + g.UserFirstName + "', 'UserName':'******'", "") + "', 'UserKey':" + g.UserKey + ", 'ImageId':0, 'Description':'' }"; // item.ImageUrl = ResolveUrl("~/DesktopModules/ATI_Base/services/images/profile.aspx") + "?u=" + g.UserKey + "&p=" + g.PortalKey; result.Add(item); } int endOffset = Math.Min(itemOffset + TAKE + 1, length); if (endOffset > length) { endOffset = length; } if (endOffset == length) { comboData.EndOfItems = true; } else { comboData.EndOfItems = false; } if (length > 0) { comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), length); } else { comboData.Message = "No matches"; } comboData.Items = result.ToArray(); } catch (Exception ex) { comboData.Message = ex.Message; } } else { comboData.Message = "Type to search"; } return comboData; }
public RadComboBoxData GetSwitchLeads(RadComboBoxContext context) { string searchtext = string.Empty; searchtext = Convert.ToString(context.Text); RadComboBoxData comboData = new RadComboBoxData(); if (HttpContext.Current.Session["Switchcampusconstring"] != null) { DataTable data = new DataTable(); using (SqlConnection connection = new SqlConnection(Convert.ToString(HttpContext.Current.Session["Switchcampusconstring"]))) { using (SqlCommand CMD = new SqlCommand()) { string strqry = string.Empty; strqry = strqry + " SELECT L.LeadsID as LeadsID, "; strqry = strqry + " Lead = L.LName + ', ' + L.FName + CASE WHEN LEN(L.MInitial) > 0 Then ' ' + L.MInitial Else '' End , "; strqry = strqry + " ISNULL(L.StatusCode,'') AS LeadStatus, AdRep = E.LName + ', ' + E.FName, L.City, L.State, L.Zip, L.SSN "; strqry = strqry + " FROM Lead AS L LEFT JOIN LeadStatus AS LS ON L.StatusCode = LS.StatusCode "; strqry = strqry + " LEFT JOIN Employees AS E ON L.EmpID = E.EmpID "; strqry = strqry + " where L.LName + ', ' + L.FName like '" + searchtext + "%' or L.StatusCode like '" + searchtext + "%' "; strqry = strqry + " or E.LName + ', ' + E.FName like '" + searchtext + "%' or L.City like '" + searchtext + "%' or "; strqry = strqry + " L.State like '" + searchtext + "%' or L.Zip like '" + searchtext + "%' or L.SSN like '" + searchtext + "%' "; strqry = strqry + " ORDER BY L.LName + ', ' + L.FName + ' ' + ISNULL(L.MInitial,'') "; CMD.Connection = connection; CMD.CommandType = System.Data.CommandType.Text; CMD.CommandText = strqry; CMD.Prepare(); SqlDataAdapter DataAdapter = new SqlDataAdapter(CMD); DataAdapter.Fill(data); } } List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(context.NumberOfItems); try { int itemsPerRequest = 10; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > data.Rows.Count) { endOffset = data.Rows.Count; } if (endOffset == data.Rows.Count) { comboData.EndOfItems = true; } else { comboData.EndOfItems = false; } result = new List <RadComboBoxItemData>(endOffset - itemOffset); for (int i = itemOffset; i < endOffset; i++) { RadComboBoxItemData itemData = new RadComboBoxItemData(); string itemtext = string.Empty; itemtext = itemtext + "<ul style='z-index:100'>"; itemtext = itemtext + "<li class='Lcol1'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["Lead"]); itemtext = itemtext + "</li>"; itemtext = itemtext + "<li class='Lcol2'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["LeadsID"]); itemtext = itemtext + "<li class='Lcol3'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["LeadStatus"]); itemtext = itemtext + "<li class='Lcol4'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["AdRep"]); itemtext = itemtext + "<li class='Lcol5'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["City"]); itemtext = itemtext + "<li class='Lcol6'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["State"]); itemtext = itemtext + "<li class='Lcol7'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["Zip"]); itemtext = itemtext + "</ul>"; itemData.Text = itemtext; itemData.Value = Convert.ToString(data.Rows[i]["LeadsID"]); result.Add(itemData); } if (data.Rows.Count > 0) { comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString()); } else { comboData.Message = "No matches"; } } catch (Exception e) { comboData.Message = e.Message; } comboData.Items = result.ToArray(); } return(comboData); }
public RadComboBoxData GetExerciseListOnDemand(RadComboBoxContext context) { List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems); RadComboBoxData comboData = new RadComboBoxData(); try { int itemsPerRequest = 15; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; aqufitEntities entities = new aqufitEntities(); IQueryable<Exercise> erercisesQuery = string.IsNullOrEmpty(context.Text) ? entities.Exercises.OrderBy(e => e.Name) : entities.Exercises.Where(e => e.Name.ToLower().StartsWith(context.Text)).OrderBy(e => e.Name); int length = erercisesQuery.Count(); Exercise[] exercises = erercisesQuery.Skip(itemOffset).Take(itemsPerRequest).ToArray(); foreach (Exercise exer in exercises) { RadComboBoxItemData item = new RadComboBoxItemData(); item.Text = exer.Name; item.Value = "" + exer.Id; result.Add(item); } if (endOffset > length) { endOffset = length; } if (endOffset == length) { comboData.EndOfItems = true; } else { comboData.EndOfItems = false; } if (length > 0) { comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), length); } else { comboData.Message = "No matches"; } comboData.Items = result.ToArray(); } catch (Exception ex) { comboData.Message = ex.Message; } return comboData; }
public RadComboBoxData GetStandardWorkoutsOnDemand(RadComboBoxContext context) { List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems); RadComboBoxData comboData = new RadComboBoxData(); try { int itemsPerRequest = 10; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; long ProfileUserSettingsId = Convert.ToInt64(context["UserSettingsId"]); aqufitEntities entities = new aqufitEntities(); UserSettings UserSettings = entities.UserSettings.FirstOrDefault(u => u.Id == ProfileUserSettingsId); IQueryable<WOD> wods = entities.WODs.Where(w => w.Standard > 0); wods.Select(w => w.WODType).ToArray(); // hydrate WODTypes string lowerTxt = context.Text.ToLower(); if (!string.IsNullOrWhiteSpace(context.Text)) { wods = wods.Where(w => w.Name.ToLower().Contains(lowerTxt) || w.WODSchedules.Where(ws => ws.HideTillDate.HasValue && DateTime.Now.CompareTo(ws.HideTillDate.Value) < 0).Any(ws => ws.HiddenName.ToLower().Contains(lowerTxt))).OrderBy(w => w.Name); } else { wods = wods.OrderByDescending(w => w.CreationDate); } int length = wods.Count(); wods = wods.Skip(itemOffset).Take(itemsPerRequest); WOD[] wodList = wods.ToArray(); for (int i = 0; i < wodList.Length; i++) { WOD w = wodList[i]; if (w.WODSchedules != null && w.WODSchedules.Count > 0) { WODSchedule ws = w.WODSchedules.OrderByDescending(s => s.HideTillDate).First(); if (ws.HideTillDate.HasValue && DateTime.Now.CompareTo(ws.HideTillDate.Value) < 0) { if (string.IsNullOrWhiteSpace(context.Text)) { result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(ws.HiddenName), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" }); if (w.Standard > 0 || w.WODSchedules.Count > 1) { // CA - here is what is going on here. If the workout is suppost to be hidden until a date (common for crossfit gyms) then we just put a date name like up // top. But if it is a standard WOD (or a wod that they have done before (w.WODSchedules.Count > 1) then we still need to add the WOD result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(w.Name), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" }); } } else if (ws.HiddenName.ToLower().StartsWith(lowerTxt)) { result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(ws.HiddenName), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" }); } } else { result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(w.Name), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" }); } } else { result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(w.Name), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" }); } } if (endOffset > length) { endOffset = length; } if (endOffset == length) { comboData.EndOfItems = true; } else { comboData.EndOfItems = false; } if (length > 0) { comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), length); } else { comboData.Message = "No matches"; } comboData.Items = result.ToArray(); } catch (Exception ex) { comboData.Message = ex.Message; } return comboData; }
public RadComboBoxData GetRoutesOnDemand(RadComboBoxContext context) { List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems); RadComboBoxData comboData = new RadComboBoxData(); try { int itemsPerRequest = 10; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; long ProfileUserSettingsId = Convert.ToInt64(context["UserSettingsId"]); aqufitEntities entities = new aqufitEntities(); UserSettings UserSettings = entities.UserSettings.FirstOrDefault(u => u.Id == ProfileUserSettingsId); IQueryable<MapRoute> mapRoutesQuery = string.IsNullOrEmpty(context.Text) ? entities.User2MapRouteFav.Include("MapRoutes").Where(r => r.UserSettingsKey == ProfileUserSettingsId).Select(r => r.MapRoute).OrderBy(w => w.Name) : entities.User2MapRouteFav.Include("MapRoutes").Where(r => r.UserSettingsKey == ProfileUserSettingsId).Select(r => r.MapRoute).Where(r => r.Name.ToLower().StartsWith(context.Text)).OrderBy(r => r.Name); int length = mapRoutesQuery.Count(); MapRoute[] mapRoutes = mapRoutesQuery.Skip(itemOffset).Take(itemsPerRequest).ToArray(); string mapIcon = ResolveUrl("~/DesktopModules/ATI_Base/resources/images/iMap.png"); if (itemOffset == 0) { RadComboBoxItemData item = new RadComboBoxItemData(); item.Text = "<img src=\"" + mapIcon + "\" /> Add New Map"; item.Value = "{'Id':0, 'Dist':'0'}"; result.Add(item); } Affine.Utils.UnitsUtil.MeasureUnit unit = UserSettings.DistanceUnits != null ? Affine.Utils.UnitsUtil.ToUnit(Convert.ToInt32(UserSettings.DistanceUnits)) : Affine.Utils.UnitsUtil.MeasureUnit.UNIT_MILES; string unitName = Affine.Utils.UnitsUtil.unitToStringName(unit); foreach (MapRoute mr in mapRoutes) { double dist = Affine.Utils.UnitsUtil.systemDefaultToUnits(mr.RouteDistance, unit); dist = Math.Round(dist, 2); RadComboBoxItemData item = new RadComboBoxItemData(); item.Text = "<img src=\"" + Affine.Utils.ImageUtil.GetGoogleMapsStaticImage(mr, 200, 150) + "\" />" + Affine.Utils.Web.WebUtils.FromWebSafeString(mr.Name) + " (" + dist + " " + unitName + ")"; item.Value = "{ 'Id':" + mr.Id + ", 'Dist':" + mr.RouteDistance + "}"; result.Add(item); } if (endOffset > length) { endOffset = length; } if (endOffset == length) { comboData.EndOfItems = true; } else { comboData.EndOfItems = false; } if (length > 0) { comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), length); } else { comboData.Message = "No matches"; } comboData.Items = result.ToArray(); } catch (Exception ex) { comboData.Message = ex.Message; } return comboData; }
public RadComboBoxData GetSwitchStudents(RadComboBoxContext context) { string searchtext = string.Empty; searchtext = Convert.ToString(context.Text); RadComboBoxData comboData = new RadComboBoxData(); if (HttpContext.Current.Session["Switchcampusconstring"] != null) { DataTable data = new DataTable(); using (SqlConnection connection = new SqlConnection(Convert.ToString(HttpContext.Current.Session["Switchcampusconstring"]))) { using (SqlCommand CMD = new SqlCommand()) { string strqry = string.Empty; strqry = strqry + " select S.StudentID,S.LastName+', '+ S.FirstName as FullName,convert(varchar(50), S.StudentNo) as StudentNo, "; strqry = strqry + " (Select StudentStatus from StudentStatus where StudentStatusID=S.StudentStatusID) as StudentStatus "; strqry = strqry + " ,S.StudentStatusID,S.EMail,S.SSN from Students AS S "; strqry = strqry + " where S.LastName+', '+ S.FirstName like '" + searchtext + "%' or S.StudentNo like '" + searchtext + "%' "; strqry = strqry + " or (Select StudentStatus from StudentStatus where StudentStatusID=S.StudentStatusID) like '" + searchtext + "%' "; strqry = strqry + " or S.EMail like '" + searchtext + "%' or S.SSN like '" + searchtext + "%' ORDER BY S.LastName+', '+ S.FirstName "; CMD.Connection = connection; CMD.CommandType = System.Data.CommandType.Text; CMD.CommandText = strqry; CMD.Prepare(); SqlDataAdapter DataAdapter = new SqlDataAdapter(CMD); DataAdapter.Fill(data); } } List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(context.NumberOfItems); try { int itemsPerRequest = 10; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > data.Rows.Count) { endOffset = data.Rows.Count; } if (endOffset == data.Rows.Count) { comboData.EndOfItems = true; } else { comboData.EndOfItems = false; } result = new List <RadComboBoxItemData>(endOffset - itemOffset); //================================================================= /*List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems); * foreach(row in rows) * { * RadComboBoxItemData itemData = new RadComboBoxItemData(); * itemData.Attributes.Add("HostName", row["HostName"].ToString()); * itemData.Value = row["ID"].ToString(); * result.Add(itemData); * } * return result;*/ //=================================================================== for (int i = itemOffset; i < endOffset; i++) { RadComboBoxItemData itemData = new RadComboBoxItemData(); // itemData.Text = Convert.ToString(data.Rows[i]["FullName"]); string itemtext = string.Empty; itemtext = itemtext + "<ul style='z-index:100'>"; itemtext = itemtext + "<li class='col1'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["FullName"]) + "</li>"; itemtext = itemtext + "<li class='col2'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["StudentNo"]) + "</li>"; itemtext = itemtext + "<li class='col3'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["StudentStatus"]) + "</li> "; itemtext = itemtext + "<li class='col4'>"; itemtext = itemtext + Convert.ToString(data.Rows[i]["EMail"]) + "</li> "; itemtext = itemtext + "</ul>"; itemData.Text = itemtext; itemData.Value = Convert.ToString(data.Rows[i]["StudentNo"]); result.Add(itemData); } if (data.Rows.Count > 0) { comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString()); } else { comboData.Message = "No matches"; } } catch (Exception e) { comboData.Message = e.Message; } comboData.Items = result.ToArray(); } return(comboData); }
public RadComboBoxData GetWorkoutsOnDemand(RadComboBoxContext context) { List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems); RadComboBoxData comboData = new RadComboBoxData(); try { int itemsPerRequest = 10; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; long ProfileUserSettingsId = Convert.ToInt64(context["UserSettingsId"]); aqufitEntities entities = new aqufitEntities(); UserSettings UserSettings = entities.UserSettings.FirstOrDefault(u => u.Id == ProfileUserSettingsId); if (itemOffset == 0) { RadComboBoxItemData item = new RadComboBoxItemData(); item.Text = "Create a New Workout"; item.Value = "{'Id':0, 'Type':'0'}"; result.Add(item); } IQueryable<WOD> wods = entities.User2WODFav.Where(w => w.UserSetting.Id == UserSettings.Id).Select(w => w.WOD); wods = wods.Union<WOD>(entities.WODs.Where(w => w.Standard > 0)); wods.Select(w => w.WODType).ToArray(); // hydrate WODTypes long[] groupIds = null; groupIds = entities.UserFriends.Where(f => (f.SrcUserSettingKey == UserSettings.Id || f.DestUserSettingKey == UserSettings.Id) && f.Relationship >= (int)Affine.Utils.ConstsUtil.Relationships.GROUP_OWNER).Select(f => f.SrcUserSettingKey == UserSettings.Id ? f.DestUserSettingKey : f.SrcUserSettingKey).ToArray(); // OK this is a bit of a trick... this query hydrates only the "WODSchedule" in the above WOD query.. so we will get the wods we are looking for.. IEnumerable<WODSchedule>[] workoutSchedule = entities.UserSettings.OfType<Group>().Where(LinqUtils.BuildContainsExpression<UserSettings, long>(us => us.Id, groupIds)).Select(g => g.WODSchedules.Where(ws => ws.HideTillDate.HasValue && DateTime.Now.CompareTo(ws.HideTillDate.Value) < 0)).ToArray(); string lowerTxt = context.Text.ToLower(); if (!string.IsNullOrWhiteSpace(context.Text)) { wods = wods.Where(w => w.Name.ToLower().Contains(lowerTxt) || w.WODSchedules.Where(ws => ws.HideTillDate.HasValue && DateTime.Now.CompareTo(ws.HideTillDate.Value) < 0).Any(ws => ws.HiddenName.ToLower().Contains(lowerTxt))).OrderBy(w => w.Name); } else { wods = wods.OrderByDescending(w => w.CreationDate); } int length = wods.Count(); wods = wods.Skip(itemOffset).Take(itemsPerRequest); WOD[] wodList = wods.ToArray(); for (int i = 0; i < wodList.Length; i++) { WOD w = wodList[i]; if (w.WODSchedules != null && w.WODSchedules.Count > 0) { WODSchedule ws = w.WODSchedules.OrderByDescending(s => s.HideTillDate).First(); if (ws.HideTillDate.HasValue && DateTime.Now.CompareTo(ws.HideTillDate.Value) < 0) { if (string.IsNullOrWhiteSpace(context.Text)) { result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(ws.HiddenName), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" }); if (w.Standard > 0 || w.WODSchedules.Count > 1) { // CA - here is what is going on here. If the workout is suppost to be hidden until a date (common for crossfit gyms) then we just put a date name like up // top. But if it is a standard WOD (or a wod that they have done before (w.WODSchedules.Count > 1) then we still need to add the WOD result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(w.Name), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" }); } } else if (ws.HiddenName.ToLower().StartsWith(lowerTxt)) { result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(ws.HiddenName), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" }); } } else { result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(w.Name), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" }); } } else { result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(w.Name), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" }); } } if (endOffset > length) { endOffset = length; } if (endOffset == length) { comboData.EndOfItems = true; } else { comboData.EndOfItems = false; } if (length > 0) { comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), length); } else { comboData.Message = "No matches"; } comboData.Items = result.ToArray(); } catch (Exception ex) { comboData.Message = ex.Message; } return comboData; }
public RadComboBoxData GetFlexFWDSearch(RadComboBoxContext context) { List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems); RadComboBoxData comboData = new RadComboBoxData(); if (!string.IsNullOrWhiteSpace(context.Text)) { try { int itemsPerRequest = 10; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; long ProfileUserSettingsId = Convert.ToInt64(context["UserSettingsId"]); aqufitEntities entities = new aqufitEntities(); //UserSettings profileSettings = entities.UserSettings.OfType<User>().FirstOrDefault(u => u.UserKey == PortalSettings.Current.UserId && u.PortalKey == PortalSettings.Current.PortalId); IQueryable<UserSettings> friends = entities.UserSettings.Where(u => u.PortalKey == PortalSettings.Current.PortalId).OrderBy(w => w.UserName); friends = friends.Where(w => w.UserName.ToLower().StartsWith(context.Text) || w.UserFirstName.ToLower().StartsWith(context.Text) || w.UserLastName.ToLower().StartsWith(context.Text)); int length = friends.Count(); var users = friends.Skip(itemOffset).Take(itemsPerRequest).Select(u => new {Id = u.Id, Type = (u is User ? "User" : "Group"), UserKey = u.UserKey, PortalKey = u.PortalKey, UserFirstName = u.UserFirstName, UserLastName = u.UserLastName, UserName = u.UserName }).ToArray(); foreach (var u in users) { RadComboBoxItemData item = new RadComboBoxItemData(); if (u.Type == "User") { item.Text = "<img style=\"float: left;\" src=\"" + StreamService.ResolveUrl("~/DesktopModules/ATI_Base/services/images/profile.aspx") + "?u=" + u.UserKey + "&p=" + u.PortalKey + "\" /><span class=\"atiTmItem\">" + u.UserName + "<br /> (" + u.UserFirstName + " " + u.UserLastName + ")</span>"; item.Value = "{ Type:'USER', Val:'" + u.UserName + "'}"; } else { item.Text = "<img style=\"float: left;\" src=\"" + StreamService.ResolveUrl("~/DesktopModules/ATI_Base/services/images/profile.aspx") + "?us=" + u.Id + "\" /><span class=\"atiTmItem\">" + u.UserFirstName + "</span>"; item.Value = "{ Type:'GROUP', Val:'" + u.UserName + "'}"; } result.Add(item); } if (endOffset > length) { endOffset = length; } if (endOffset == length) { comboData.EndOfItems = true; } else { comboData.EndOfItems = false; } if (length > 0) { comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), length); } else { comboData.Message = "No matches"; } comboData.Items = result.ToArray(); } catch (Exception ex) { comboData.Message = ex.Message; } } else { comboData.Message = "Type to search"; } return comboData; }