public static async Task <Bitmap> GetPropertyPhoto(int propertyId) { Bitmap bitmap = null; try { string select = "Id"; string filter = string.Format("sl_propertyIDId eq {0}", propertyId); string orderBy = "Modified desc"; List <ListItem> listItems = await ListClient.GetListItems("Property%20Photos", select, string.Empty, 1, filter, orderBy); if (listItems != null && listItems.Any()) { int photoId = Helper.GetInt(listItems[0].mData["Id"]); if (photoId > 0) { string fileServerRelativeUrl = await ListClient.GetFileServerRelativeUrl("Property%20Photos", photoId); if (!string.IsNullOrEmpty(fileServerRelativeUrl)) { bitmap = await ListClient.GetFile(fileServerRelativeUrl); } } } } catch (Exception) { bitmap = null; } return(bitmap); }
public static async Task <List <int> > GetPhotoIdCollection(string listName, int incidentId, int inspectionId, int roomId) { List <int> idCollection = new List <int>(); try { string select = "Id"; string filter = string.Format("sl_incidentIDId eq {0} and sl_inspectionIDId eq {1} and sl_roomIDId eq {2}", incidentId, inspectionId, roomId); string orderBy = "Modified desc"; List <ListItem> listItems = await ListClient.GetListItems(listName, select, string.Empty, 1000, filter, orderBy); if (listItems != null && listItems.Any()) { for (int i = 0; i < listItems.Count; i++) { int photoId = Helper.GetInt(listItems[i].mData["Id"]); if (photoId > 0) { idCollection.Add(photoId); } } } } catch (Exception) { idCollection = new List <int>(); } return(idCollection); }
public static async Task <int> GetAvailableIncidentId() { List <IncidentModel> incidents = new List <IncidentModel>(); string select = "ID"; string orderBy = "ID desc"; List <ListItem> listItems = await ListClient.GetListItems("Incidents", select, "", 0, "", orderBy); if (listItems.Count > 0) { return(Helper.GetInt(listItems [0].mData ["ID"])); } return(-1); }
public static async Task <List <IncidentModel> > GetIncidents() { List <IncidentModel> incidents = new List <IncidentModel>(); string select = "ID,Title,sl_inspectorIncidentComments,sl_dispatcherComments,sl_repairComments,sl_status,sl_type,sl_date,sl_repairCompleted,sl_propertyIDId,sl_inspectionIDId,sl_roomIDId,sl_taskId,sl_inspectionID/ID,sl_inspectionID/sl_datetime,sl_inspectionID/sl_finalized,sl_inspectionID/sl_inspector,sl_inspectionID/sl_emailaddress,sl_propertyID/ID,sl_propertyID/Title,sl_propertyID/sl_emailaddress,sl_propertyID/sl_owner,sl_propertyID/sl_address1,sl_propertyID/sl_address2,sl_propertyID/sl_city,sl_propertyID/sl_state,sl_propertyID/sl_postalCode,sl_roomID/ID,sl_roomID/Title"; string expand = "sl_inspectionID,sl_propertyID,sl_roomID"; string filter = string.Format("sl_propertyIDId eq {0} and sl_inspectionIDId gt 0 and sl_roomIDId gt 0", App.PropertyId); string orderBy = "sl_date desc"; List <ListItem> listItems = await ListClient.GetListItems("Incidents", select, expand, 0, filter, orderBy); foreach (ListItem item in listItems) { incidents.Add(new IncidentModel(item.mData)); } return(incidents); }
public static async Task <int> GetPropertyIdByIncidentId() { int propertyId = 0; try { string select = "sl_propertyIDId"; string filter = string.Format("ID eq {0} and sl_propertyIDId gt 0 and sl_inspectionIDId gt 0 and sl_roomIDId gt 0", App.IncidentId); string orderBy = "sl_date desc"; List <ListItem> listItems = await ListClient.GetListItems("Incidents", select, string.Empty, 1, filter, orderBy); if (listItems != null && listItems.Any()) { propertyId = Helper.GetInt(listItems[0].mData["sl_propertyIDId"]); } } catch (Exception) { propertyId = 0; } return(propertyId); }