public async Task <Item> GetItemAsync(string id)
        {
            Item item = null;

            if (id != null)
            {
                //LkData lkdata = LinkarClt.GetVersion(credentialsOptions);

                //var json = await client.GetStringAsync($"api/Linkar/GetItem?token=" + App.Token + "&code=" + id);
                //return await Task.Run(() => JsonConvert.DeserializeObject<Item>(json));

                string lkstring = LinkarClt.Read_Text(credentialsOptions, "LK.ITEMS", id, "", new ReadOptions(true), DataFormat.TYPE.MV, "", 0);

                char     delimiter         = ASCII_Chars.FS_chr;
                char     delimiterThisList = DBMV_Mark.AM;
                string   records           = "";
                string   recordCalculateds = "";
                string[] parts             = lkstring.Split(delimiter);
                if (parts.Length >= 1)
                {
                    string[] ThisList    = parts[0].Split(delimiterThisList);
                    int      numElements = ThisList.Length;
                    for (int i = 1; i < numElements; i++)
                    {
                        if (ThisList[i].Equals("RECORD"))
                        {
                            records = parts[i];
                        }
                        if (ThisList[i].Equals("CALCULATED"))
                        {
                            recordCalculateds = parts[i];
                        }
                        //if (ThisList[i].Equals("ERRORS"))
                        //{
                        //    if (parts[i] != null && parts[i].Length > 0)
                        //        this.LstErrors = new List<string>(parts[i].Split(DBMV_Mark.AM));
                        //    else
                        //        this.LstErrors = new List<string>();
                        //}
                    }
                }

                //Fill the class with response data
                if (records != null && records != "")
                {
                    item = LkItem.GetRecord(id, records, recordCalculateds);
                }
            }

            return(item);
        }
コード例 #2
0
        public async Task <Item> GetItemAsync(string id)
        {
            Item result = null;

            if (id != null)
            {
                //var json = await client.GetStringAsync($"api/Linkar/GetItem?token=" + App.Token + "&code=" + id);
                //return await Task.Run(() => JsonConvert.DeserializeObject<Item>(json));

                try
                {
                    string lkstring = App.linkarClt.Read("LK.ITEMS", id, "", new ReadOptions(true), "", 0); //NEWFRAMEWORK: Replace Read_Text for Read, remove DATAFORMATCRU_TYPE.MV

                    char     delimiter         = ASCII_Chars.FS_chr;
                    char     delimiterThisList = DBMV_Mark.AM;
                    string   records           = "";
                    string   recordCalculateds = "";
                    string[] parts             = lkstring.Split(delimiter);
                    if (parts.Length >= 1)
                    {
                        string[] ThisList    = parts[0].Split(delimiterThisList);
                        int      numElements = ThisList.Length;
                        for (int i = 1; i < numElements; i++)
                        {
                            if (ThisList[i].Equals("RECORD"))
                            {
                                records = parts[i];
                            }
                            if (ThisList[i].Equals("CALCULATED"))
                            {
                                recordCalculateds = parts[i];
                            }
                        }
                    }

                    //Fill the class with response data
                    if (records != null && records != "")
                    {
                        result = LkItem.GetRecord(id, records, recordCalculateds);
                    }
                }
                catch (Exception ex)
                {
                    string error = App.GetException(ex);
                    await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("ERROR", error, "OK");
                }
            }

            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the LkDataCRUD class.
        /// </summary>
        /// <param name="crudOperationResult">The string result of the CRUD operation execution.</param>
        public LkDataCRUD(string crudOperationResult) : base(crudOperationResult)
        {
            this.TotalItems = StringFunctions.ExtractTotalRecords(crudOperationResult);

            string[] lstIdDicts         = StringFunctions.ExtractRecordsIdDicts(crudOperationResult);
            string[] lstDictionaries    = StringFunctions.ExtractRecordsDicts(crudOperationResult);
            string[] lstCalculatedDicts = StringFunctions.ExtractRecordsCalculatedDicts(crudOperationResult);
            this.LkRecords = new LkItems(lstIdDicts, lstDictionaries, lstCalculatedDicts);

            string[] lstRecords           = StringFunctions.ExtractRecords(crudOperationResult);
            string[] lstRecordIds         = StringFunctions.ExtractRecordIds(crudOperationResult);
            string[] lstOriginalRecords   = StringFunctions.ExtractOriginalRecords(crudOperationResult);
            string[] lstRecordsCalculated = StringFunctions.ExtractRecordsCalculated(crudOperationResult);
            for (int i = 0; i < lstRecordIds.Length; i++)
            {
                string record         = (lstRecords.Length == lstRecordIds.Length ? lstRecords[i] : "");
                string originalRecord = (lstOriginalRecords.Length == lstRecordIds.Length ? lstOriginalRecords[i] : "");
                string calculateds    = (lstRecordsCalculated.Length == lstRecordIds.Length ? lstRecordsCalculated[i] : "");
                LkItem lkRecord       = new LkItem(lstRecordIds[i], record, calculateds, originalRecord);
                this.LkRecords.Add(lkRecord);
            }
        }
        public async Task <IEnumerable <Item> > GetItemsAsync()
        {
            //var json = await client.GetStringAsync($"api/Linkar/GetItems?token=" + App.Token);
            //items = await Task.Run(() => JsonConvert.DeserializeObject<IEnumerable<Item>>(json));

            //LkData lkdata = LinkarClt.GetVersion(credentialsOptions);
            List <Item> items    = null;
            string      lkstring = LinkarClt.Select_Text(credentialsOptions, "LK.ITEMS", "", "BY CODE", "", "", new SelectOptions(false, false, 10, 1, true), DataFormat.TYPE.MV, "", 0);

            if (!string.IsNullOrEmpty(lkstring))
            {
                char     delimiter         = ASCII_Chars.FS_chr;
                char     delimiterThisList = DBMV_Mark.AM;
                String   recordIds         = "";
                String   records           = "";
                String   recordCalculateds = "";
                String[] parts             = lkstring.Split(delimiter);
                if (parts.Length >= 1)
                {
                    String[] ThisList    = parts[0].Split(delimiterThisList);
                    int      numElements = ThisList.Length;
                    for (int i = 1; i < numElements; i++)
                    {
                        if (ThisList[i].Equals("RECORD_ID"))
                        {
                            recordIds = parts[i];
                        }
                        if (ThisList[i].Equals("RECORD"))
                        {
                            records = parts[i];
                        }
                        if (ThisList[i].Equals("CALCULATED"))
                        {
                            recordCalculateds = parts[i];
                        }
                        //if (ThisList[i].Equals("ERRORS"))
                        //{
                        //    if (parts[i] != null && parts[i].Length > 0)
                        //        this.LstErrors = new List<string>(parts[i].Split(DBMV_Mark.AM));
                        //    else
                        //        this.LstErrors = new List<string>();
                        //}
                    }
                }

                //Fill all the records with response data
                String[] lstids   = recordIds.Split(ASCII_Chars.RS_chr);
                String[] lstregs  = records.Split(ASCII_Chars.RS_chr);
                String[] lstcalcs = recordCalculateds.Split(ASCII_Chars.RS_chr);

                items = new List <Item>();

                for (int i = 0; i < lstids.Length; i++)
                {
                    Item record = new Item(); //_LinkarClt);
                                              //record.RecordOriginalContent = lstregs[i];
                    if (recordCalculateds != null && recordCalculateds != "")
                    {
                        //record.RecordOriginalContentItypes = lstcalcs[i];
                        record = LkItem.GetRecord(lstids[i], lstregs[i], lstcalcs[i]);
                    }
                    else
                    {
                        record = LkItem.GetRecord(lstids[i], lstregs[i], "");
                    }

                    //if (this.LstErrors != null && this.LstErrors.Count > 0)
                    //{
                    //    for (int j = 0; j < this.LstErrors.Count; j++)
                    //    {
                    //        if (!string.IsNullOrEmpty(this.LstErrors[i]))
                    //        {
                    //            string[] errorParts = this.LstErrors[i].Split(DBMV_Mark.VM);
                    //            if (errorParts.Length > 2 && errorParts[2] == record.Code)
                    //                record.LstErrors.Add(this.LstErrors[i]);
                    //        }
                    //    }
                    //}

                    //record.Status = LinkarMainClass.StatusTypes.READED;
                    items.Add(record);
                }
            }

            return(items);
        }
コード例 #5
0
        public async Task <IEnumerable <Item> > GetItemsAsync(bool forceRefresh = false)
        {
            if (forceRefresh)
            {
                //var json = await client.GetStringAsync($"api/Linkar/GetItems?token=" + App.Token);
                //items = await Task.Run(() => JsonConvert.DeserializeObject<IEnumerable<Item>>(json));
                items = null;
                try
                {
                    string lkstring = App.linkarClt.Select("LK.ITEMS", "", "BY ID", "", "", new SelectOptions(false, false, 10, 1, true), "", 0); //NEWFRAMEWORK: Replace Select_Text for Select, remove DATAFORMATCRU_TYPE.MV

                    if (!string.IsNullOrEmpty(lkstring))
                    {
                        char     delimiter         = ASCII_Chars.FS_chr;
                        char     delimiterThisList = DBMV_Mark.AM;
                        String   recordIds         = "";
                        String   records           = "";
                        String   recordCalculateds = "";
                        String[] parts             = lkstring.Split(delimiter);
                        if (parts.Length >= 1)
                        {
                            String[] ThisList    = parts[0].Split(delimiterThisList);
                            int      numElements = ThisList.Length;
                            for (int i = 1; i < numElements; i++)
                            {
                                if (ThisList[i].Equals("RECORD_ID"))
                                {
                                    recordIds = parts[i];
                                }
                                if (ThisList[i].Equals("RECORD"))
                                {
                                    records = parts[i];
                                }
                                if (ThisList[i].Equals("CALCULATED"))
                                {
                                    recordCalculateds = parts[i];
                                }
                            }
                        }

                        //Fill all the records with response data
                        String[] lstids   = recordIds.Split(ASCII_Chars.RS_chr);
                        String[] lstregs  = records.Split(ASCII_Chars.RS_chr);
                        String[] lstcalcs = recordCalculateds.Split(ASCII_Chars.RS_chr);

                        items = new List <Item>();

                        for (int i = 0; i < lstids.Length; i++)
                        {
                            Item record = new Item();
                            if (recordCalculateds != null && recordCalculateds != "")
                            {
                                record = LkItem.GetRecord(lstids[i], lstregs[i], lstcalcs[i]);
                            }
                            else
                            {
                                record = LkItem.GetRecord(lstids[i], lstregs[i], "");
                            }

                            items.Add(record);
                        }
                    }
                }
                catch (Exception ex)
                {
                    string error = App.GetException(ex);
                    await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("ERROR", error, "OK");
                }
            }

            return(items);
        }