Example #1
0
        public override void ActionPerforming(UIItem uiItem)
        {
            Focus();
            var screenItem = new ScreenItem(uiItem, ScrollBars);

            screenItem.MakeVisible(this);
        }
Example #2
0
        private void MoveToPreviousScreenItem()
        {
            bool bof = true;
            IEnumerator <KeyValuePair <string, ScreenItem> > cursor         = m_screenItem.GetEnumerator();
            IEnumerator <KeyValuePair <string, ScreenItem> > previousCursor = null;
            KeyValuePair <string, ScreenItem> previousItem = cursor.Current;

            while (cursor.MoveNext())
            {
                bof = false;

                if (cursor.Current.Key == m_currentItem.Value.Key)
                {
                    break;
                }

                ScreenItem scr = cursor.Current.Value;
                if (scr.ScreenType != null)
                {
                    previousCursor = cursor;
                    previousItem   = previousCursor.Current;
                }
            }

            if (!bof && previousCursor != null)
            {
                m_cursor      = previousCursor;
                m_currentItem = previousItem;
                ScreenItem scr = m_currentItem.Value.Value;
                int        col = (scr.ColumnStart + scr.ColumnLength);
                int        row = scr.Row;
                Console.SetCursorPosition(col, row);
            }
        }
Example #3
0
        public PurchaseViewModel(IPurchaseService purchaseService, INavigationService navigationService,
                                 IDialogsService dialogsService, ILocService locService)
        {
            _purchaseService   = purchaseService;
            _navigationService = navigationService;
            _dialogsService    = dialogsService;
            _locService        = locService;

            _screenItems = new ScreenItem[]
            {
                new ScreenItem(_locService["PurchaseView_Screen1_Line1_Text"],
                               _locService["PurchaseView_Screen1_Line2_Text"], 1),
                new ScreenItem(_locService["PurchaseView_Screen2_Line1_Text"],
                               _locService["PurchaseView_Screen2_Line2_Text"], 2),
                new ScreenItem(_locService["PurchaseView_Screen3_Line1_Text"],
                               _locService["PurchaseView_Screen3_Line2_Text"], 3),
                new ScreenItem(_locService["PurchaseView_Screen4_Line1_Text"],
                               _locService["PurchaseView_Screen4_Line2_Text"], 4),
                new ScreenItem(_locService["PurchaseView_Screen5_Line1_Text"],
                               _locService["PurchaseView_Screen5_Line2_Text"], 5),
                new ScreenItem(_locService["PurchaseView_Screen0_Line1_Text"],
                               _locService["PurchaseView_Screen0_Line2_Text"], 0, true)
                {
                    BuyPermanentCommand = new DelegateCommand(OnBuyPermanentCommand),
                    BuyMonthlyCommand   = new DelegateCommand(OnBuyMonthlyCommand)
                }
            };
        }
        private List <string> GetScreenItemProperties(ScreenItem screenItem, List <ScreenItem> parentScreenItems = null)
        {
            var properties = new List <string>();

            foreach (var formField in screenItem.FormFields)
            {
                properties.Add(GetProperty(formField, parentScreenItems));
            }

            foreach (var childScreenItem in screenItem.ChildScreenItems)
            {
                var childProperties  = new List <string>();
                var childScreenItems = new List <ScreenItem> {
                    childScreenItem
                };
                if (parentScreenItems != null)
                {
                    childScreenItems.AddRange(parentScreenItems);
                }

                childProperties.AddRange(GetScreenItemProperties(childScreenItem, childScreenItems));
                properties.Add($@"{childScreenItem.Entity.InternalName} = new {childScreenItem.Entity.InternalName}Response
{{
{childProperties.IndentLines(1, ",")}
}}");
            }

            return(properties);
        }
        public async Task <IActionResult> Edit(int id, [Bind("ScreenItemID,ScreenID,ScreenItemDescription,ScreenItemTakenDescription,ScreenItemAction")] ScreenItem screenItem)
        {
            if (id != screenItem.ScreenItemID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(screenItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ScreenItemExists(screenItem.ScreenItemID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(screenItem));
        }
Example #6
0
    private void SortLinkedList(LinkedList <ScreenItem> toSort)
    {
        ScreenItem[] tempItems = new ScreenItem[toSort.Count];
        toSort.CopyTo(tempItems, 0);
        ScreenItem temp;
        string     tempcur = current.Value.GetName();

        for (int i = 0; i < tempItems.Length; i++)
        {
            for (int j = i; j < tempItems.Length; j++)
            {
                if (tempItems [i].GetName().CompareTo(tempItems [j].GetName()) < 0)
                {
                    temp          = tempItems [i];
                    tempItems [i] = tempItems [j];
                    tempItems [j] = temp;
                }
            }
        }

        toSort.Clear();

        foreach (ScreenItem item in tempItems)
        {
            toSort.AddLast(item);
            if (string.Equals(item.GetName(), tempcur))
            {
                current = toSort.Last;
            }
        }
    }
Example #7
0
 public void AddItem(ScreenItem item)
 {
     DontDestroyOnLoad(item.gameObject);
     items.AddLast(item);
     SortLinkedList(items);
     SetItem(current);
 }
Example #8
0
        private void MoveToNextScreenItem(bool goToBegin = true)
        {
            bool eof = true;
            IEnumerator <KeyValuePair <string, ScreenItem> > nextCursor = m_cursor;
            KeyValuePair <string, ScreenItem> nextItem = nextCursor.Current;

            while (nextCursor.MoveNext())
            {
                eof      = false;
                nextItem = nextCursor.Current;
                ScreenItem scrItem = nextItem.Value;
                if (scrItem.ScreenType != null)
                {
                    break;
                }
            }

            if (eof)
            {
                SetCursorScreenItem();
                if (goToBegin)
                {
                    MoveToNextScreenItem(false);
                }
            }
            else
            {
                m_cursor      = nextCursor;
                m_currentItem = nextItem;
                ScreenItem scr = m_currentItem.Value.Value;
                int        col = (scr.ColumnStart + scr.ColumnLength);
                int        row = scr.Row;
                Console.SetCursorPosition(col, row);
            }
        }
        public static ScreenItemModel Factory(ShowItemType ItemType, IScreenItem source)
        {
            var item  = ScreenItem.Factory(ItemType, source);
            var model = ScreenItemModel.Factory(item);

            return(model);
        }
Example #10
0
 public override void ActionPerforming(UIItem uiItem)
 {
     if (uiItem.AutomationElement.Current.IsOffscreen)
     {
         var screenItem = new ScreenItem(uiItem, ScrollBars);
         screenItem.MakeVisible(this);
     }
 }
Example #11
0
        public void RefreshVideoSources()
        {
            AvailableVideoSources.Clear();

            // RegionSelector should only be shown on Region Capture.
            ServiceProvider.RegionProvider.SelectorVisible = SelectedVideoSourceKind == VideoSourceKind.Region;

            switch (SelectedVideoSourceKind)
            {
            case VideoSourceKind.Window:
                AvailableVideoSources.Add(WindowItem.TaskBar);

                foreach (var win in Window.EnumerateVisible())
                {
                    AvailableVideoSources.Add(new WindowItem(win));
                }
                break;

            case VideoSourceKind.DesktopDuplication:
                foreach (var screen in ScreenItem.Enumerate(true))
                {
                    AvailableVideoSources.Add(screen);
                }
                break;

            case VideoSourceKind.Screen:
                AvailableVideoSources.Add(FullScreenItem.Instance);

                foreach (var screen in ScreenItem.Enumerate(false))
                {
                    AvailableVideoSources.Add(screen);
                }
                break;

            case VideoSourceKind.Region:
                AvailableVideoSources.Add(ServiceProvider.RegionProvider.VideoSource);
                break;

            case VideoSourceKind.NoVideo:
                AvailableVideoSources.Add(WaveItem.Instance);

                foreach (var item in FFMpegAudioItem.Items)
                {
                    AvailableVideoSources.Add(item);
                }

                break;
            }

            // Set first source as default
            if (AvailableVideoSources.Count > 0)
            {
                SelectedVideoSource = AvailableVideoSources[0];
            }
        }
        public static IEnumerable <IScreenItem> ToScreenItemList(this IEnumerable <ScreenAtomicModel> ModelList)
        {
            var list = new List <IScreenItem>();

            foreach (var model in ModelList)
            {
                var item = ScreenItem.Factory(model);
                list.Add(item);
            }
            return(list);
        }
        public async Task <IActionResult> Create([Bind("ScreenItemID,ScreenID,ScreenItemDescription,ScreenItemTakenDescription,ScreenItemAction")] ScreenItem screenItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(screenItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(screenItem));
        }
    /// <summary>
    /// convert screenDefn model class to ScreenDefn class.
    /// </summary>
    /// <returns></returns>
    public ScreenDefn ToScreenDefn()
    {
      var defn = new ScreenDefn(
        this.ScreenName, this.NamespaceName, this.ScreenGuid, this.ScreenDim, this.ModelItems);

      var jj = from a in this.ModelItems
               select ScreenItem.Factory(a);
      defn.Items = jj.ToList();

      return defn;
    }
        private void Item_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            if (sender is ScreenItem)
            {
                ScreenItem item = sender as ScreenItem;


                if (item.Tag != null)
                {
                    KoreaLocation itemData = item.Tag as KoreaLocation;

                    if (String.IsNullOrEmpty(itemData.MapX) == false && String.IsNullOrEmpty(itemData.MapY) == false)
                    {
                        double lng  = Convert.ToDouble(itemData.MapX);;
                        double lat  = Convert.ToDouble(itemData.MapY);
                        string path = "ms-appx:///Assets/";
                        //"ms-appx:///Assets/customicon.png"
                        switch (itemData.Cat1)
                        {
                        case "A01":
                            path += "img1.png";
                            break;

                        case "A02":
                            path += "img2.png";
                            break;

                        case "A03":
                            path += "img3.png";
                            break;

                        case "A04":
                            path += "img4.png";
                            break;

                        case "A05":
                            path += "img5.png";
                            break;

                        case "B01":
                            path += "img6.png";
                            break;

                        case "B02":
                            path += "img7.png";
                            break;
                        }

                        umc_MapControl.SetLocation(lat, lng, itemData.Title, path);
                    }
                }
            }
        }
        public IActionResult Take(int inventoryItemID, int itemID, int chestID)
        {
            // TODO: Actions taken when taking
            User user = GetUser();

            Item          takenItem = _context.Item.Where(i => i.ItemID == itemID).FirstOrDefault();
            InventoryItem inv       = new InventoryItem();

            if (inventoryItemID == 0)
            {
                inv.ItemID   = itemID;
                inv.UserID   = user.UserID;
                inv.Quantity = 1;
                _context.InventoryItems.Add(inv);
                ScreenItem se = _context.ScreenItem.Where(s => s.ScreenID == user.Screen && s.ItemID == itemID).FirstOrDefault();
                _context.ScreenItem.Remove(se);
            }
            else
            {
                inv.InventoryItemID = inventoryItemID;
                inv.ItemID          = itemID;
                inv.UserID          = user.UserID;
                inv.Quantity        = 1;
                _context.InventoryItems.Update(inv);
            }
            user.Inventory.Add(takenItem);
            ItemType type = _context.ItemType.Where(t => t.ItemTypeID == takenItem.ItemTypeID).FirstOrDefault();

            if (type.ItemTypeName == "Weapon")
            {
                user.WeaponEquipped = true;
                user.WeaponID       = takenItem.ItemID;
            }
            SaveUser(user);
            FightLog f = new FightLog {
                UserID = user.UserID, Entry = $"You added the {takenItem.ItemName} to your inventory.", EntryType = "normal-event"
            };

            _context.FightLogs.Add(f);
            _context.User.Update(user);
            _context.SaveChanges();
            if (chestID == 0)
            {
                UpdateScreen(user);
                return(View("Console", BuildModel()));
            }
            else
            {
                BuildOpenViewDescription(chestID);

                return(View("Open", BuildModel()));
            }
        }
Example #17
0
        private void ReadData(ConsoleKeyInfo key)
        {
            int    colData   = -1;
            int    colLength = 0;
            int    rowData   = -1;
            string valueStr  = null;

            switch (key.Key)
            {
            case ConsoleKey.Backspace:
                if (m_currentItem != null)
                {
                    ScreenItem scr = m_currentItem.Value.Value;
                    if (scr.ColumnLength > 0)
                    {
                        scr.ColumnLength--;
                        scr.Value = scr.Value.Substring(0, scr.ColumnLength);
                        SetPropertyValue(scr.ObjRef, scr.PropertyName, scr.Value);
                        colData   = scr.ColumnStart;
                        colLength = scr.ColumnLength;
                        rowData   = scr.Row;
                        valueStr  = scr.Value;
                        //
                        Console.SetCursorPosition(colData + colLength, rowData);
                        Console.Write(" ");
                    }
                }
                break;

            default:
                if (m_currentItem != null && IsValidKeyChar(key.KeyChar))
                {
                    ScreenItem scr = m_currentItem.Value.Value;
                    if (scr.ColumnLength < scr.ColumnEnd)
                    {
                        scr.Value += key.KeyChar;
                        SetPropertyValue(scr.ObjRef, scr.PropertyName, scr.Value);
                        scr.ColumnLength = scr.Value.Length;
                        colData          = scr.ColumnStart;
                        colLength        = scr.ColumnLength;
                        rowData          = scr.Row;
                        valueStr         = scr.Value;
                    }
                }
                break;
            }

            if (colData >= 0 && rowData >= 0 && !string.IsNullOrEmpty(valueStr))
            {
                Console.SetCursorPosition(colData, rowData);
                Console.Write(valueStr);
            }
        }
Example #18
0
        public void SendScreenItem()
        {
            var screenItem = new ScreenItem("intro screen", null, "screen_user", DateTime.UtcNow, null, new Dictionary <string, object>
            {
                { "active", false }
            }, new Dictionary <string, object>()
            {
                { "All", true }
            });

            Assert.DoesNotThrowAsync(() => _passableSender.SendData(screenItem));
        }
Example #19
0
        private string GetCurrentScreenItemValue()
        {
            string val = null;

            if (m_currentItem != null)
            {
                ScreenItem scr = m_currentItem.Value.Value;
                val = scr.Value;
            }

            return(val);
        }
Example #20
0
        private bool PickScreen()
        {
            var screen = _videoSourcePicker.PickScreen();

            if (screen == null)
            {
                return(false);
            }

            _source = new ScreenItem(screen);
            RaisePropertyChanged(nameof(Source));
            return(true);
        }
        public override ScreenItem BusinessToData(ScreenItem screenItem, BUSScreenItem businessEntity, TContext context, bool NewRecord)
        {
            ScreenItem dataEntity = base.BusinessToData(screenItem, businessEntity, context, NewRecord);

            dataEntity.Screen           = businessEntity.Screen;
            dataEntity.ScreenId         = businessEntity.ScreenId;
            dataEntity.View             = businessEntity.View;
            dataEntity.ViewId           = businessEntity.ViewId;
            dataEntity.ParentCategory   = businessEntity.ParentCategory;
            dataEntity.ParentCategoryId = businessEntity.ParentCategoryId;
            dataEntity.ParentItem       = businessEntity.ParentItem;
            dataEntity.ParentItemId     = businessEntity.ParentItemId;
            dataEntity.Header           = businessEntity.Header;
            dataEntity.Type             = businessEntity.Type;
            dataEntity.DisplayInSiteMap = businessEntity.DisplayInSiteMap;
            return(dataEntity);
        }
Example #22
0
        private static string GetScreenItemValue(ScreenItem scr)
        {
            object value = null;

            if (scr.ObjRef == null)
            {
                value = Convert.ToString(scr.Value);
            }
            else
            {
                value = GetPropertyValue(scr.ObjRef, scr.PropertyName);
            }

            string valueStr = Convert.ToString(value);

            return(valueStr);
        }
Example #23
0
        public void ScreenSection(int column, int row, object objectReference, string propertyName,
                                  EnScreenType screenType, int length)
        {
            ScreenItem scrItem = new ScreenItem()
            {
                Column       = column,
                Row          = row,
                Value        = Convert.ToString(GetPropertyValue(objectReference, propertyName)),
                ObjRef       = objectReference,
                PropertyName = propertyName,
                ScreenType   = screenType,
                ColumnStart  = column,
                ColumnEnd    = (column + length)
            };

            AddScreenItem(column, row, scrItem);
        }
Example #24
0
        public void RefreshVideoSources()
        {
            AvailableVideoSources.Clear();

            switch (SelectedVideoSourceKind)
            {
            case VideoSourceKind.Window:
                // Desktop would be default
                AvailableVideoSources.Add(WindowItem.Desktop);
                AvailableVideoSources.Add(WindowItem.TaskBar);

                // Prevent RegionSelector from showing here
                RegionProvider.SelectorVisible = false;

                foreach (var win in Window.EnumerateVisible())
                {
                    AvailableVideoSources.Add(new WindowItem(win));
                }

                break;

            case VideoSourceKind.Screen:
                foreach (var screen in ScreenItem.Enumerate())
                {
                    AvailableVideoSources.Add(screen);
                }
                break;

            case VideoSourceKind.Region:
                AvailableVideoSources.Add(RegionProvider.VideoSource);
                break;
            }

            // Set first source as default
            if (AvailableVideoSources.Count > 0)
            {
                SelectedVideoSource = AvailableVideoSources[0];
            }

            // RegionSelector should only be shown on Region Capture.
            RegionProvider.SelectorVisible = SelectedVideoSourceKind == VideoSourceKind.Region;
        }
Example #25
0
        public void ScreenSection(int column, int row, string value)
        {
            int length = 0;

            if (!string.IsNullOrEmpty(value))
            {
                length = value.Length;
            }

            ScreenItem scrItem = new ScreenItem()
            {
                Column      = column,
                Row         = row,
                Value       = value,
                ScreenType  = null,
                ColumnStart = column,
                ColumnEnd   = (column + length)
            };

            AddScreenItem(column, row, scrItem);
        }
        public override BUSScreenItem DataToBusiness(ScreenItem dataEntity, TContext context)
        {
            BUSScreenItem businessEntity = base.DataToBusiness(dataEntity, context);
            Screen        screen         = context.Screens
                                           .AsNoTracking()
                                           .Select(s => new
            {
                id          = s.Id,
                name        = s.Name,
                screenItems = s.ScreenItems.Select(screenItem => new
                {
                    id   = screenItem.Id,
                    name = screenItem.Name,
                })
            })
                                           .Select(s => new Screen
            {
                Id          = s.id,
                Name        = s.name,
                ScreenItems = s.screenItems.Select(screenItem => new ScreenItem
                {
                    Id   = screenItem.id,
                    Name = screenItem.name
                }).ToList()
            })
                                           .FirstOrDefault(i => i.Id == dataEntity.ScreenId);

            businessEntity.Screen     = screen;
            businessEntity.ScreenId   = screen.Id;
            businessEntity.ScreenName = screen.Name;

            View view = context.Views.FirstOrDefault(i => i.Id == dataEntity.ViewId);

            if (view != null)
            {
                businessEntity.View     = view;
                businessEntity.ViewId   = view.Id;
                businessEntity.ViewName = view.Name;
            }

            ScreenItem parentCategory = screen.ScreenItems.FirstOrDefault(i => i.Id == dataEntity.ParentCategoryId);

            if (parentCategory != null)
            {
                businessEntity.ParentCategory     = parentCategory;
                businessEntity.ParentCategoryId   = parentCategory.Id;
                businessEntity.ParentCategoryName = parentCategory.Name;
            }

            ScreenItem parentItem = screen.ScreenItems.FirstOrDefault(i => i.Id == dataEntity.ParentItemId);

            if (parentItem != null)
            {
                businessEntity.ParentItem     = parentItem;
                businessEntity.ParentItemId   = parentItem.Id;
                businessEntity.ParentItemName = parentItem.Name;
            }

            businessEntity.DisplayInSiteMap = dataEntity.DisplayInSiteMap;
            businessEntity.Header           = dataEntity.Header;
            businessEntity.Type             = dataEntity.Type;
            return(businessEntity);
        }
Example #27
0
        public ActionResult Drilldown()
        {
            Applet currentApplet = viewInfo.CurrentPopupApplet ?? viewInfo.CurrentApplet;

            currentApplet = context.Applets
                            .AsNoTracking()
                            .Select(a => new
            {
                id      = a.Id,
                name    = a.Name,
                type    = a.Type,
                busComp = new
                {
                    id      = a.BusComp.Id,
                    name    = a.BusComp.Name,
                    routing = a.BusComp.Routing
                },
                drilldowns = a.Drilldowns.Select(d => new
                {
                    id               = d.Id,
                    name             = d.Name,
                    hyperLinkFieldId = d.HyperLinkFieldId,
                    sourceField      = new
                    {
                        id   = d.SourceField.Id,
                        name = d.SourceField.Name
                    },
                    destinationBusinessComponent = new
                    {
                        id      = d.DestinationBusinessComponent.Id,
                        name    = d.DestinationBusinessComponent.Name,
                        routing = d.DestinationBusinessComponent.Routing
                    },
                    destinationField = new
                    {
                        id   = d.DestinationField.Id,
                        name = d.DestinationField.Name
                    },
                    destinationScreenId     = d.DestinationScreenId,
                    destinationScreenItemId = d.DestinationScreenItemId,
                    destinationScreenItem   = new
                    {
                        id   = d.DestinationScreenItem.Id,
                        view = new
                        {
                            id          = d.DestinationScreenItem.View.Id,
                            busObjectId = d.DestinationScreenItem.View.BusObjectId
                        }
                    }
                })
            })
                            .Select(a => new Applet
            {
                Id      = a.id,
                Name    = a.name,
                Type    = a.type,
                BusComp = new BusinessComponent
                {
                    Id      = a.busComp.id,
                    Name    = a.busComp.name,
                    Routing = a.busComp.routing
                },
                Drilldowns = a.drilldowns.Select(d => new Drilldown
                {
                    Id               = d.id,
                    Name             = d.name,
                    HyperLinkFieldId = d.hyperLinkFieldId,
                    SourceField      = new Field
                    {
                        Id   = d.sourceField.id,
                        Name = d.sourceField.name
                    },
                    DestinationBusinessComponent = new BusinessComponent
                    {
                        Id      = d.destinationBusinessComponent.id,
                        Name    = d.destinationBusinessComponent.name,
                        Routing = d.destinationBusinessComponent.routing
                    },
                    DestinationField = new Field
                    {
                        Id   = d.destinationField.id,
                        Name = d.destinationField.name
                    },
                    DestinationScreenId   = d.destinationScreenId,
                    DestinationScreenItem = new ScreenItem
                    {
                        Id   = d.destinationScreenItem.id,
                        View = new View
                        {
                            Id          = d.destinationScreenItem.view.id,
                            BusObjectId = d.destinationScreenItem.view.busObjectId
                        }
                    }
                }).ToList()
            })
                            .FirstOrDefault(i => i.Id == currentApplet.Id);
            if (currentApplet != null)
            {
                string controlName;
                Field  field;
                switch (currentApplet.Type)
                {
                case "Tile":
                    controlName = viewInfo.CurrentColumn.Name;
                    field       = viewInfo.CurrentColumn.Field;
                    break;

                default:
                    controlName = viewInfo.CurrentPopupControl?.Name ?? viewInfo.CurrentControl?.Name;
                    field       = viewInfo.CurrentPopupControl?.Field ?? viewInfo.CurrentControl?.Field;
                    break;
                }
                if (field != null)
                {
                    TBUSFactory BUSFactory = new TBUSFactory();
                    Drilldown   drilldown  = currentApplet.Drilldowns.FirstOrDefault(i => i.HyperLinkFieldId == field.Id);
                    if (drilldown != null && drilldown.DestinationBusinessComponent?.Name != null && drilldown.DestinationField?.Name != null && drilldown.SourceField?.Name != null)
                    {
                        // Целевой экран
                        Screen destinationScreen = context.Screens.AsNoTracking().FirstOrDefault(i => i.Id == drilldown.DestinationScreenId);
                        if (destinationScreen != null)
                        {
                            applicationInfo.CurrentScreen = destinationScreen;

                            // Целевыое представление
                            View destinationView = context.Views.AsNoTracking().FirstOrDefault(i => i.Id == drilldown.DestinationScreenItem.View.Id);
                            if (destinationView != null)
                            {
                                applicationInfo.CurrentView = destinationView;

                                // Исходное поле
                                dynamic      sourceRecord   = BUSFactory.GetRecord(null, context, viewInfo, currentApplet.BusComp, "Id", viewInfo.CurrentRecord);
                                PropertyInfo sourceProperty = sourceRecord.GetType().GetProperty(drilldown.SourceField.Name);
                                if (sourceProperty != null)
                                {
                                    // Очистка старой информации о выбранных записях
                                    if (screenInfo.Screen.Name != destinationScreen.Name)
                                    {
                                        ComponentsRecordsInfo.Dispose();
                                    }

                                    // Установка текущей выбранной записи на целевой бизнес компоненте
                                    var sourcePropertyValue = sourceProperty.GetValue(sourceRecord);
                                    if (sourcePropertyValue != null)
                                    {
                                        dynamic destinationRecord = BUSFactory.GetRecord(null, context, viewInfo, drilldown.DestinationBusinessComponent, drilldown.DestinationField.Name, sourcePropertyValue.ToString());
                                        if (destinationRecord != null)
                                        {
                                            ComponentsRecordsInfo.SetSelectedRecord(drilldown.DestinationBusinessComponent.Name, destinationRecord.Id.ToString());
                                        }

                                        // Установка текущих выбранных записей на всех родительских бизнес компонентах целевой компоненты
                                        BusinessObject destinationBO = context.BusinessObjects
                                                                       .AsNoTracking()
                                                                       .Include(boc => boc.BusObjectComponents)
                                                                       .ThenInclude(l => l.Link)
                                                                       .ThenInclude(cf => cf.ChildField)
                                                                       .Include(boc => boc.BusObjectComponents)
                                                                       .ThenInclude(l => l.Link)
                                                                       .ThenInclude(pf => pf.ParentField)
                                                                       .FirstOrDefault(i => i.Id == destinationView.BusObjectId);
                                        BusinessObjectComponent destinationComponent = destinationBO.BusObjectComponents.FirstOrDefault(i => i.BusCompId == drilldown.DestinationBusinessComponent.Id);
                                        dynamic childRecord = destinationRecord;
                                        if (destinationComponent.Link != null)
                                        {
                                            BusinessComponent parentBusComp = context.BusinessComponents
                                                                              .AsNoTracking()
                                                                              .Select(bc => new
                                            {
                                                id    = bc.Id,
                                                name  = bc.Name,
                                                table = new
                                                {
                                                    id   = bc.Table.Id,
                                                    name = bc.Table.Name
                                                }
                                            })
                                                                              .Select(bc => new BusinessComponent
                                            {
                                                Id    = bc.id,
                                                Name  = bc.name,
                                                Table = new Table
                                                {
                                                    Id   = bc.table.id,
                                                    Name = bc.table.name
                                                }
                                            })
                                                                              .FirstOrDefault(i => i.Id == destinationComponent.Link.ParentBCId);
                                            BusinessComponent childBusComp = context.BusinessComponents
                                                                             .AsNoTracking()
                                                                             .Select(bc => new { id = bc.Id, name = bc.Name })
                                                                             .Select(bc => new BusinessComponent {
                                                Id = bc.id, Name = bc.name
                                            })
                                                                             .FirstOrDefault(i => i.Id == destinationComponent.Link.ChildBCId);
                                            string childFieldValue = childRecord.GetType().GetProperty(destinationComponent.Link.ChildField.Name).GetValue(childRecord).ToString();
                                            string parentFieldName = destinationComponent.Link.ParentField.Name;
                                            IEnumerable <dynamic> parentRecords = (IEnumerable <dynamic>)(context.GetType().GetProperty(parentBusComp.Table.Name).GetValue(context));
                                            string  searchSpecificationByParent = $"{parentFieldName} = \"{childFieldValue}\"";
                                            dynamic parentRecord = parentRecords.AsQueryable().Where(searchSpecificationByParent).FirstOrDefault();
                                            ComponentsRecordsInfo.SetSearchSpecification(childBusComp.Name, SearchSpecTypes.SearchSpecificationByParent, searchSpecificationByParent);
                                            ComponentsRecordsInfo.SetSelectedRecord(parentBusComp.Name, parentRecord.Id.ToString());
                                            destinationComponent = destinationBO.BusObjectComponents.FirstOrDefault(i => i.BusCompId == destinationComponent.Link.ParentBCId);
                                            childRecord          = parentRecord;
                                        }

                                        // Установка хлебных крошек
                                        ScreenItem crumb = screenInfo.Screen.ScreenItems.FirstOrDefault(n => n.View != null && n.View.Name == screenInfo.CurrentView.Name);
                                        ComponentsRecordsInfo.AppendCrumb(crumb);
                                        if (screenInfo.Screen.Name == destinationScreen.Name)
                                        {
                                            screenInfo.Initialize(screenInfo.Screen.Name, destinationView.Name, context);
                                            screenInfoUI.Initialize(screenInfo, context);
                                            viewInfo.View = destinationView;
                                        }
                                        viewInfo.ActionType = ActionType.Drilldown;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(Ok());
        }
        public override BUSDrilldown DataToBusiness(Drilldown dataEntity, TContext context)
        {
            // Applet
            BUSDrilldown businessEntity = base.DataToBusiness(dataEntity, context);
            Applet       applet         = context.Applets
                                          .AsNoTracking()
                                          .Select(a => new
            {
                id        = a.Id,
                name      = a.Name,
                busCompId = a.BusCompId,
                busComp   = new
                {
                    id     = a.BusComp.Id,
                    name   = a.BusComp.Name,
                    fields = a.BusComp.Fields.Select(f => new
                    {
                        id   = f.Id,
                        name = f.Name
                    })
                }
            })
                                          .Select(a => new Applet
            {
                Id        = a.id,
                Name      = a.name,
                BusCompId = a.busCompId,
                BusComp   = new BusinessComponent
                {
                    Id     = a.busComp.id,
                    Name   = a.busComp.name,
                    Fields = a.busComp.fields.Select(f => new Field
                    {
                        Id   = f.id,
                        Name = f.name
                    }).ToList()
                }
            })
                                          .FirstOrDefault(i => i.Id == dataEntity.AppletId);

            businessEntity.Applet   = applet;
            businessEntity.AppletId = applet.Id;

            if (applet.BusComp != null)
            {
                businessEntity.SourceBusinessComponent   = applet.BusComp;
                businessEntity.SourceBusinessComponentId = (Guid)applet.BusCompId;

                // Source and hyperlink fields
                if (applet.BusComp.Fields?.Count > 0)
                {
                    Field sourceField = applet.BusComp.Fields.FirstOrDefault(i => i.Id == dataEntity.SourceFieldId);
                    if (sourceField != null)
                    {
                        businessEntity.SourceField     = sourceField;
                        businessEntity.SourceFieldId   = sourceField.Id;
                        businessEntity.SourceFieldName = sourceField.Name;
                    }

                    Field hyperLinkField = applet.BusComp.Fields.FirstOrDefault(i => i.Id == dataEntity.HyperLinkFieldId);
                    if (hyperLinkField != null)
                    {
                        businessEntity.HyperLinkField     = hyperLinkField;
                        businessEntity.HyperLinkFieldId   = hyperLinkField.Id;
                        businessEntity.HyperLinkFieldName = hyperLinkField.Name;
                    }
                }

                // Destination business component and destination field
                BusinessComponent destinationBusinessComponent = context.BusinessComponents
                                                                 .AsNoTracking()
                                                                 .Select(bc => new
                {
                    id     = bc.Id,
                    name   = bc.Name,
                    fields = bc.Fields.Select(f => new
                    {
                        id   = f.Id,
                        name = f.Name
                    })
                })
                                                                 .Select(bc => new BusinessComponent
                {
                    Id     = bc.id,
                    Name   = bc.name,
                    Fields = bc.fields.Select(f => new Field
                    {
                        Id   = f.id,
                        Name = f.name
                    }).ToList()
                })
                                                                 .FirstOrDefault(i => i.Id == dataEntity.DestinationBusinessComponentId);
                if (destinationBusinessComponent != null)
                {
                    businessEntity.DestinationBusinessComponent     = destinationBusinessComponent;
                    businessEntity.DestinationBusinessComponentId   = destinationBusinessComponent.Id;
                    businessEntity.DestinationBusinessComponentName = destinationBusinessComponent.Name;
                    Field destinationField = destinationBusinessComponent.Fields.FirstOrDefault(i => i.Id == dataEntity.DestinationFieldId);
                    if (destinationField != null)
                    {
                        businessEntity.DestinationField     = destinationField;
                        businessEntity.DestinationFieldId   = destinationField.Id;
                        businessEntity.DestinationFieldName = destinationField.Name;
                    }
                }

                // Destination screen and destination view
                Screen destinationScreen = context.Screens
                                           .AsNoTracking()
                                           .Select(s => new
                {
                    id          = s.Id,
                    name        = s.Name,
                    screenItems = s.ScreenItems.Select(si => new
                    {
                        id   = si.Id,
                        name = si.Name
                    })
                })
                                           .Select(s => new Screen
                {
                    Id          = s.id,
                    Name        = s.name,
                    ScreenItems = s.screenItems.Select(si => new ScreenItem
                    {
                        Id   = si.id,
                        Name = si.name
                    }).ToList()
                })
                                           .FirstOrDefault(i => i.Id == dataEntity.DestinationScreenId);
                if (destinationScreen != null)
                {
                    businessEntity.DestinationScreen     = destinationScreen;
                    businessEntity.DestinationScreenId   = destinationScreen.Id;
                    businessEntity.DestinationScreenName = destinationScreen.Name;

                    ScreenItem destinationScreenItem = destinationScreen.ScreenItems.FirstOrDefault(i => i.Id == dataEntity.DestinationScreenItemId);
                    if (destinationScreenItem != null)
                    {
                        businessEntity.DestinationScreenItem     = destinationScreenItem;
                        businessEntity.DestinationScreenItemId   = destinationScreenItem.Id;
                        businessEntity.DestinationScreenItemName = destinationScreenItem.Name;
                    }
                }
            }

            return(businessEntity);
        }
Example #29
0
        public override bool Do(ref ScreenModel screenModel, out string message)
        {
            if (_preImportChecksResult == false)
            {
                message = _message;
                return(false);
            }

            try
            {
                message = string.Empty;

                int rowIndex = 0;
                int screenItemOrdenNumber = 0; // изменяется на 1 при каждой новой фразе (в соответсвие фразе приводится screenItem)

                while (_sh.GetRow(rowIndex) != null)
                {
                    var row = _sh.GetRow(rowIndex);

                    var cell_1 = row.GetCell(0);    var screenItem_cell_1 = new ScreenItem();
                    var cell_2 = row.GetCell(1);    var screenItem_cell_2 = new ScreenItem();
                    var cell_3 = row.GetCell(2);    var screenItem_cell_3 = new ScreenItem();

                    //bool checkStringCellType =     cell_1?.CellType == CellType.String
                    //                             && cell_2?.CellType == CellType.String
                    //                             && cell_3?.CellType == CellType.String ? true : false;

                    ////проверка на тип ячеек. Для корректного считывания (в данной имплементации) он должен быть строковым. Если так, checkStringCellType будет равен true
                    //if (checkStringCellType == false)
                    //{
                    //    message = "Тип ячеек в таблице должен быть строковым.";
                    //    return false;
                    //}

                    //проверка на заполненность первой ячейки
                    if (rowIndex == 0)
                    {
                        if (cell_1 == null)
                        {
                            message = "Некорректно заполнена таблица с данными.";
                            return(false);
                        }
                    }

                    rowIndex++;

                    if (cell_1 != null)
                    {
                        //считываем фразу из 1 колонки

                        IncrementOrderNumberFor(screenItem: ref screenItem_cell_1, currentOrderNumber: ref screenItemOrdenNumber);

                        var phrase = new Phrase()
                        {
                            Key = cell_1.StringCellValue
                        };
                        phrase.Value = GetValueByKey(phrase.Key);

                        screenItem_cell_1.Phrase = phrase;
                    }
                    else
                    {
                        screenItem_cell_1 = null;
                    }

                    if (cell_2 != null)
                    {
                        //считываем фразу из 2 колонки

                        IncrementOrderNumberFor(screenItem: ref screenItem_cell_2, currentOrderNumber: ref screenItemOrdenNumber);

                        var phrase = new Phrase()
                        {
                            Key = cell_2.StringCellValue
                        };
                        phrase.Value = GetValueByKey(phrase.Key);

                        screenItem_cell_2.Phrase = phrase;

                        if (cell_1 != null)
                        {
                            screenItem_cell_1.CompositionType = CompositionType.TableHeader;
                        }
                    }
                    else
                    {
                        screenItem_cell_2 = null;

                        if (cell_1 != null)
                        {
                            screenItem_cell_1.CompositionType = CompositionType.ElementOfOTHERTable;
                        }
                        //получилось, что ячейка соответствует "current for proportional solenoid valve1" из Примера данных
                    }

                    if (cell_3 != null)
                    {
                        //считываем фразу из 3 колонки

                        IncrementOrderNumberFor(screenItem: ref screenItem_cell_3, currentOrderNumber: ref screenItemOrdenNumber);

                        var phrase = new Phrase()
                        {
                            Key = cell_3.StringCellValue
                        };
                        phrase.Value = GetValueByKey(phrase.Key);

                        screenItem_cell_3.CompositionType = CompositionType.AccordingToOutputValue;
                        screenItem_cell_3.Phrase          = phrase;

                        if (cell_2 != null)
                        {
                            screenItem_cell_2.CompositionType = CompositionType.SubTableHeader;
                        }
                    }
                    else
                    {
                        screenItem_cell_3 = null;

                        if (cell_2 != null)
                        {
                            screenItem_cell_2.CompositionType = CompositionType.AccordingToOutputValue;
                        }
                    }

                    if (screenItem_cell_1 != null)
                    {
                        screenModel.ScreenItems.Add(screenItem_cell_1);
                    }
                    if (screenItem_cell_2 != null)
                    {
                        screenModel.ScreenItems.Add(screenItem_cell_2);
                    }
                    if (screenItem_cell_3 != null)
                    {
                        screenModel.ScreenItems.Add(screenItem_cell_3);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                message = string.Concat("Exception: ", ex.ToString());
                return(false);
            }
        }
Example #30
0
        private void AddScreenItem(int column, int row, ScreenItem scrItem)
        {
            string scrKey = string.Format("{0:00}-{1:00}", column, row);

            m_screenItem.Add(scrKey, scrItem);
        }