public void ProcessItems(T _rootItem, Boolean TrimTemplateItems) { XPathRoot = items.Select(x => x.path).GetCommonPathRoot(); Level = XPathRoot.GetXPathLevel(); var firstItem = items.FirstOrDefault(); if (_rootItem != null) { rootItem = _rootItem; XPathRoot = rootItem.path; } if (rootItem == null) { rootItem = firstItem.parent as T; } if (firstItem != null) { Template = new RecordTemplate(); Template.SubXPath = rootItem.path.GetLastNodeNameFromXPath(); type = JunctionPointType.BranchToLeafs; foreach (graphWrapNode <LeafNodeDictionaryEntry> child in firstItem.GetChildren()) { RecordTemplateItem r_item = new RecordTemplateItem(); if (child.IsBranchToLeaf()) { } else { type = JunctionPointType.DeepJunctionPoint; break; } if (child.item != null) { r_item.Category = child.item.Category; } if (TrimTemplateItems) { r_item.SubXPath = child.name; } else { r_item.SubXPath = child.path.GetRelativeXPath(XPathRoot); } Template.items.Add(r_item); } } JunctionSize = items.Count; }
public Request(ResourceMethod method, RecordTemplate input, Dictionary <string, List <string> > headers, Dictionary <string, object> queryParams, string baseUrlTemplate, Dictionary <string, object> pathKeys) { this.method = method; this.input = input; this.headers = headers.ToDictionary(_ => _.Key, _ => (IReadOnlyList <string>)_.Value); this.queryParams = queryParams; this.baseUrlTemplate = baseUrlTemplate; this.pathKeys = pathKeys; }
public ListRecordsPage(int ID) { InitializeComponent(); this.ID = ID; _ParentStack.Children.Add(RecordTemplate.RecordTemplate01(0, "Title", ass, false)); _ParentStack.Children.Add(RecordTemplate.RecordTemplate01(0, "Title 2", "Content", false)); }
/// <summary> /// Creates the record. /// </summary> /// <param name="record">The record.</param> /// <param name="undo">if set to <c>true</c> [undo].</param> /// <returns>Record</returns> public DAL.Record CreateRecord(UPCRMRecord record, bool undo) { string infoAreaId = record.InfoAreaId; List <FieldIdType> fieldIds; List <string> linkFieldNames; bool checkDataModel = true; TableInfo tableInfo = this.DatabaseInstance.GetTableInfoByInfoArea(infoAreaId); if (tableInfo == null) { return(null); } int statNoField = 0, lnrField = 0; bool saveOfflineStationNumber = false; if (!undo && record.OfflineRecordNumber > 0 && record.OfflineStationNumber > 0) { statNoField = tableInfo.GetStatNoFieldId(); if (statNoField >= 0) { lnrField = tableInfo.GetLNrFieldId(); if (lnrField >= 0 && tableInfo.GetFieldInfo(statNoField) != null && tableInfo.GetFieldInfo(lnrField) != null) { saveOfflineStationNumber = true; } } } List <UPCRMFieldValue> fieldValues = record.FieldValues; int fieldCount = fieldValues?.Count ?? 0; int linkCount = record.Links?.Count ?? 0; if (undo) { linkCount = 0; } List <string> recordFieldValues = new List <string>(); if (fieldCount == 0) { fieldIds = null; } else { fieldIds = new List <FieldIdType>(); for (int i = 0; i < fieldCount; i++) { UPCRMFieldValue fieldValue = fieldValues[i]; FieldInfo fieldInfo = tableInfo.GetFieldInfo(fieldValue.FieldId); if (!checkDataModel || fieldInfo != null) { int currentFieldId = fieldValue.FieldId; fieldIds.Add((FieldIdType)currentFieldId); recordFieldValues.Add(undo ? fieldValue.OldValue : fieldValue.Value); if (saveOfflineStationNumber && (currentFieldId == statNoField || currentFieldId == lnrField)) { saveOfflineStationNumber = false; } } } if (saveOfflineStationNumber) { fieldIds.Add((FieldIdType)statNoField); recordFieldValues.Add(record.OfflineStationNumber.ToString()); fieldIds.Add((FieldIdType)lnrField); recordFieldValues.Add(record.OfflineRecordNumber.ToString()); } } if (record.Links != null && (record.Links.Count == 0 || undo)) { linkFieldNames = null; linkCount = 0; } else { linkFieldNames = new List <string>(); for (int i = 0; i < linkCount; i++) { UPCRMLink link = record.Links[i]; LinkInfo linkInfo = tableInfo.GetLink(link.LinkFieldName()) ?? tableInfo.GetLink(link.InfoAreaId, link.LinkId); if (linkInfo != null && linkInfo.HasColumn) { if (linkInfo.IsGeneric) { string targetInfoAreaId = this.RootPhysicalInfoAreaIdForInfoAreaId(link.InfoAreaId); recordFieldValues.Add(targetInfoAreaId); linkFieldNames.Add(linkInfo.InfoAreaColumnName); } recordFieldValues.Add(link.RecordId); linkFieldNames.Add(linkInfo.ColumnName); } } } var recordTemplate = new RecordTemplate( this.DatabaseInstance, false, infoAreaId, fieldIds?.Count ?? 0, fieldIds?.ToArray(), linkFieldNames.Count, linkFieldNames, false, false); Record rec = new Record(infoAreaId, record.RecordId); rec.SetTemplate(recordTemplate); for (var i = 0; i < recordFieldValues.Count; i++) { rec.SetValue(i, recordFieldValues[i]); } return(rec); }
public static async Task GetMedicalRecords(RecordType UserRecordType, StackLayout ParentStack) { Dictionary <String, String> ResultingData = new Dictionary <String, String>(); Dictionary <int, String[]> Data = new Dictionary <int, string[]> { { 0, new String[] { "user_id", Utilities.ID.ToString() } }, }; String URL = ""; switch (UserRecordType) { case RecordType.Personal: URL = "user/medical-records/search"; break; case RecordType.Drug: URL = "user/prescribtions/search"; break; case RecordType.Lab: URL = "user/lab-results/search"; break; case RecordType.Medical: URL = "user/medical-records/search"; break; } try { int NoOfChangesMade = 0; String ResultJson = await GeneralModel.PostAsync(Utilities.PostDataEncoder(Data), URL); var DecodedJson = JObject.Parse(ResultJson); if ((int)DecodedJson["records"] > 0) { foreach (var Child in DecodedJson["results"]) { ///StoredContent returns as e.g "{Personal/Medical/Drug/Lab}{Title [length=17]:Title goes here}{Content [lenght=42]:Content goes here}" String StoredContent = Child["description"].ToString(); String CurrentRecordType = StoredContent.Substring((StoredContent.IndexOf('{') + 1), ((StoredContent.IndexOf('}') - 1))); ///if record isnt personal when user clicks "Personal Record" skip if (UserRecordType == RecordType.Personal) { if (CurrentRecordType != Enum.GetName(typeof(RecordType), UserRecordType)) { continue; } } else if (UserRecordType == RecordType.Medical) { if (CurrentRecordType != Enum.GetName(typeof(RecordType), UserRecordType)) { continue; } } ///strip out the record type StoredContent = StoredContent.Replace("{" + CurrentRecordType + "}", ""); ///{Title [length=17]:Title goes here} ///Title = "Title [length=17]:Title goes here" String Title = StoredContent.Substring(StoredContent.IndexOf('{') + 1, ((StoredContent.IndexOf('}') - 1))); ///get the length of the title e.g "Title goes here" == 17 i.e [length=17] int TitleLength = Convert.ToInt32(Title.Substring(Title.IndexOf('[') + 1, ((Title.IndexOf(']')) - (Title.IndexOf('[') + 1))).Replace("length=", "")); ///Title = Title goes here Title = StoredContent.Substring((StoredContent.IndexOf(':') + 1), TitleLength); ///strip out title StoredContent = StoredContent.Replace("{Title [length=" + TitleLength + "]:" + Title + "}", ""); String Content = StoredContent.Substring(StoredContent.IndexOf('{') + 1, ((StoredContent.IndexOf('}') - 1))); int ContentLength = Convert.ToInt32(Content.Substring(Content.IndexOf('[') + 1, ((Content.IndexOf(']')) - (Content.IndexOf('[') + 1))).Replace("length=", "")); Content = StoredContent.Substring((StoredContent.IndexOf(':') + 1), ContentLength); NoOfChangesMade++; Device.BeginInvokeOnMainThread(() => { ParentStack.Children.Add(RecordTemplate.RecordTemplate01((int)Child["medic"]["id"], Title, Content, false)); }); } if (NoOfChangesMade == 0) { Device.BeginInvokeOnMainThread(() => { ParentStack.Children.Add(new Label { Text = "No Records in this section currently.", Style = App.Current.Resources["_EmptyLabelTemplate"] as Style }); }); } } else { Device.BeginInvokeOnMainThread(() => { ParentStack.Children.Add(new Label { Text = "No Records in this section currently.", Style = App.Current.Resources["_EmptyLabelTemplate"] as Style }); }); } } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Alert", ex.StackTrace, "Ok"); } }