// Установка выбранной записи
 public static void SetSelectedRecord(string componentName, string recordId)
 {
     if (AllSelectedRecords == null)
     {
         AllSelectedRecords = new Dictionary <string, string>();
     }
     if (SelectedRecords == null)
     {
         SelectedRecords = new Dictionary <string, string>();
     }
     if (!SelectedRecords.ContainsKey(componentName))
     {
         SelectedRecords.Add(componentName, recordId);
     }
     else
     {
         SelectedRecords[componentName] = recordId;
     }
     if (!AllSelectedRecords.ContainsKey(componentName))
     {
         AllSelectedRecords.Add(componentName, recordId);
     }
     else
     {
         AllSelectedRecords[componentName] = recordId;
     }
 }
 // Получение выбранной записи
 public static string GetSelectedRecord(string componentName)
 {
     if (SelectedRecords == null)
     {
         return(null);
     }
     else
     {
         return(SelectedRecords.GetValueOrDefault(componentName));
     }
 }
 // Возвращает значение, укзаывающие, присутствует ли компонента в списке выбранных записей
 public static bool IsInitComponent(string busCompName)
 {
     if (SelectedRecords != null && busCompName != null && SelectedRecords.ContainsKey(busCompName))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        // Возвращает текущие отображаемые записи для апплетов
        public static Dictionary <string, string> GetUIRecords(MainContext context, IViewInfo viewInfo)
        {
            Dictionary <string, string> UIRecords = new Dictionary <string, string>();

            SelectedRecords.ToList().ForEach(record =>
            {
                BusinessComponent busComp = context.BusinessComponents.FirstOrDefault(n => n.Name == record.Key);
                viewInfo.ViewApplets.Where(i => i.BusCompId == busComp.Id).ToList().ForEach(applet =>
                {
                    if (!UIRecords.ContainsKey(applet.Name))
                    {
                        UIRecords.Add(applet.Name, record.Value);
                    }
                });
            });
            return(UIRecords);
        }
Exemplo n.º 5
0
 public virtual Task SelectRecord(T selectedRecord)
 {
     if (RecordsSelectionMode == RecordsSelectionMode.Single)
     {
         OnSelectedRecord?.Invoke(selectedRecord);
     }
     else if (RecordsSelectionMode == RecordsSelectionMode.Multiple)
     {
         if (SelectedRecords.Contains(selectedRecord))
         {
             SelectedRecords.Remove(selectedRecord);
         }
         else if (MaximumRecordSelections <= 0 || (MaximumRecordSelections > 0 && SelectedRecords.Count < MaximumRecordSelections))
         {
             SelectedRecords.Add(selectedRecord);
         }
         MinimunRecordSelectionsReached = SelectedRecords.Count >= MinimunRecordSelections;
         OnMinimunRecordSelectionsReached?.Invoke(MinimunRecordSelectionsReached);
         MaximumRecordSelectionsReached = SelectedRecords.Count >= MaximumRecordSelections;
         OnMaximumRecordSelectionsReached?.Invoke(MaximumRecordSelectionsReached);
         OnSelectedRecords?.Invoke(SelectedRecords, MinimunRecordSelectionsReached, MaximumRecordSelectionsReached);
     }
     return(Task.CompletedTask);
 }