Esempio n. 1
0
        public static async void OnDelete(SRiRequestGroupModel model)
        {
            try
            {
                var pMap = AppContext.AppContext.InspectionCell.PropertyMappingFromIndex(model.ShortIndex);
                foreach (var iMap in pMap.ActiveExpanded)
                {
                    if (iMap.Type == MappingType.Record)
                    {
                        var record = AppData.PropertyModel.EntityFromMapping(iMap) as SRiRecordMeta;
                        if (record != null && record.Record.Details.Equals(model.GroupDetails))
                        {
                            AppData.PropertyModel.Delete(record);
                            AppData.PropertyModel.SelectedProperty = null;
                            break;
                        }
                    }
                }
                await SplitView.HubMaster.ReloadPropertyData();

                SplitView.HubMaster.MakeDeleteVisible(false);
                SplitView.InspectionCount?.Update();
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("{0}", ex.ToString()));
            }
        }
 public static void DeSelectItem()
 {
     try
     {
         CurrentUnifiedItem = null;
         SplitView.HubMaster.MakeDeleteVisible(false);
     }
     catch (Exception ex)
     {
         LogTracking.LogTrace(ex.ToString());
     }
 }
        /// ------------------------------------------------------------------------------------------------

        /// ------------------------------------------------------------------------------------------------
        #region Private functions

        /// Name		Inspection_Tapped
        ///
        /// <summary>
        /// Catches the item selected in the listview.
        /// </summary>
        ///
        /// <param name="sender">			The Inspection_RowSeleted instance.</param>
        /// <param name="e">				The event arguments of the row being selected.</param>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        private async void Inspection_Tapped(object sender, ItemTappedEventArgs e)
        {
            try
            {
                var item = e.Item as SRiRequestGroupModel;
                CurrentUnifiedItem = (SRiRequestGroupModel)e.Item;
                if (item != null)
                {
                    var pMap = PropertyMappingFromIndex(item.ShortIndex); //get the property mapping from shortindex
                    _refreshCellIndex = item.ShortIndex.Section;
                    int index = 0;
                    foreach (var indexMap in pMap.ActiveExpanded)
                    {
                        if (indexMap.Property == item.ShortIndex.PropertyIndex && indexMap.RequestGroup == item.ShortIndex.RequestGroupIndex &&
                            indexMap.Record == item.ShortIndex.RecordIndex)
                        {
                            var iMap = pMap.ActiveExpanded[index];
                            //check the indexmapping type
                            if (iMap.Type == MappingType.Record)
                            {
                                var record = AppData.PropertyModel.EntityFromMapping(iMap) as SRiRecordMeta;
                                if (record != null && (AppData.PropertyModel.SelectedRecord == null || !AppData.PropertyModel.SelectedRecord.Record.Record.KeyVal.Equals(record.Record?.KeyVal)))
                                {
                                    if (AppData.PropertyModel.SelectedRecord != null && AppData.PropertyModel.SelectedRecord.Edited)
                                    {
                                        if (await SplitView.DisplayAlert("Unsaved changes", "Not all changes have been saved, what would like to do?", "Save", "Discard"))
                                        {
                                            Exception error;
                                            AppData.PropertyModel.SaveRecord(out error);
                                            if (error != null)
                                            {
                                                await SplitView.DisplayAlert("Save failed", error.Message, "OK", null);
                                            }

                                            AppData.PropertyModel.SelectedRecord = new SelectedRecord(record, iMap, false);
                                            await SplitView.Instace().PushRightContent(new RecordSummaryView());
                                        }
                                        else
                                        {
                                            AppData.PropertyModel.SelectedRecord = new SelectedRecord(record, iMap, false);
                                            await SplitView.Instace().PushRightContent(new RecordSummaryView());
                                        }
                                    }
                                    else
                                    {
                                        AppData.PropertyModel.SelectedRecord = new SelectedRecord(record, iMap, GetSyncStatus(record.Record.Status) == "new_upload.png" ? true : false);
                                        await SplitView.Instace().PushRightContent(new RecordSummaryView());
                                    }
                                }
                            }
                            break;
                        }
                        index++;
                    }
                }
                if (Device.OS == TargetPlatform.Android)
                {
                    SplitView.HubMaster.MakeDeleteVisible(CurrentUnifiedItem.UploadStatusImage == "new_upload.png");
                }
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
            }
        }