Exemple #1
0
        private static List <XElement> RunProvider(XElement config, IInfoProvider provider)
        {
            List <XElement> result  = new List <XElement>();
            DateTime        endTime = DateTime.Now.AddMinutes(double.Parse(ConfigurationManager.AppSettings["TskMgrMinutesTotal"]));

            while (DateTime.Now < endTime)
            {
                Tools.WriteLine($"{nameof(TskMgrDataTask)}: Collecting info (until {endTime.ToString("dd-MM-yyyy  HH:mm:ss")})...");
                var info = provider.ProvideInfo(config);
                if (info != null)
                {
                    result.Add(new XElement(provider.GetType().Name,
                                            new XAttribute("Date", DateTime.Now.ToString("dd-MM-yyyy  HH:mm:ss")),
                                            info));
                }

                if (DateTime.Now < endTime)
                {
                    Tools.WriteLine($"{nameof(TskMgrDataTask)}: Info collected. Going to sleep for {int.Parse(ConfigurationManager.AppSettings["TskMgrMinutesInterval"])} minutes");
                    System.Threading.Thread.Sleep(1000 * 60 * int.Parse(ConfigurationManager.AppSettings["TskMgrMinutesInterval"]));
                }
            }

            return(result);
        }
Exemple #2
0
        public string GetValue(string username, string password)
        {
            Type          asstype = this.PluginAssembly.GetType("MainClass");
            IInfoProvider i       = (IInfoProvider)Activator.CreateInstance(asstype);

            return(i.GetValue());
        }
Exemple #3
0
        protected IEnumerable <PanelViewContainer> GetListeners(IInfoProvider provider)
        {
            List <PanelViewContainer> views;

            if (!providerToViewMap.TryGetValue(provider, out views))
            {
                return(Enumerable.Empty <PanelViewContainer>());
            }
            return(views.Where(c => !c.Pinned));
        }
Exemple #4
0
 public string GetValue()
 {
     if (valid)
     {
         Type          asstype = PluginAssembly.GetType("MainClass");
         IInfoProvider i       = (IInfoProvider)Activator.CreateInstance(asstype);
         return(laststring = i.GetValue(username, password));
     }
     return("Плагин неправильный");
 }
 private Task <T> InvokeAsync <T>(IInfoProvider provider, Func <T> func)
 {
     if (provider is IDispatcherObject dispatcherObject)
     {
         return(dispatcherObject.Dispatcher.InvokeAsync(func));
     }
     else
     {
         return(Task.Run(func));
     }
 }
Exemple #6
0
 private void Invoke(IInfoProvider provider, Action action)
 {
     if (provider is IDispatcherObject dispatcherObject)
     {
         dispatcherObject.Dispatcher.Invoke(action);
     }
     else
     {
         action();
     }
 }
Exemple #7
0
 private T Invoke <T>(IInfoProvider provider, Func <T> func)
 {
     if (provider is IDispatcherObject dispatcherObject)
     {
         return(dispatcherObject.Dispatcher.Invoke(func));
     }
     else
     {
         return(func());
     }
 }
Exemple #8
0
    public override string ToString()
    {
        IInfoProvider infovalue = m_value as IInfoProvider;

        if (infovalue != null)
        {
            return(infovalue.Info);
        }
        else
        {
            return("Not defined: " + m_value.GetType().ToString());
        }
    }
 public static IEnumerable <object> GetInfos(this IInfoProvider provider)
 {
     foreach (var entry in provider.InfoMetadata)
     {
         if (provider.TryGetInfo(entry.Name, out var value))
         {
             yield return(value);
         }
         else
         {
             yield return(null);
         }
     }
 }
        public static UiDataProviderNode Create <T>(InfoProviderGroup <T> providers) where T : class
        {
            UiContextMenu menu = UiContextMenuFactory.Create();

            for (int index = 0; index < providers.Count; index++)
            {
                IInfoProvider <T> provider = providers[index];
                UiMenuItem        menuItem = UiMenuItemFactory.Create(provider.Title, new UiDataProviderNodeRefreshCommand(() => providers.Refresh(provider)));
                menuItem.ToolTip = provider.Description;
                menu.AddChild(menuItem);
            }

            UiDataProviderNode node = new UiDataProviderNode(providers.Title, providers.Description, menu);

            providers.InfoLost     += node.OnInfoLost;
            providers.InfoProvided += node.OnInfoProvided;

            return(node);
        }
Exemple #11
0
        public void SetInfoProvider(IInfoProvider provider)
        {
            if (this.currentInfoProvider == provider)
            {
                return;
            }
            this.currentInfoProvider = provider;
            if (!providerToViewMap.ContainsKey(provider))
            {
                var views = PanelViewFactory.CreateAll(provider.InfoWidgets)
                            .Select(v => PanelViewContainer.Wrap(v))
                            .ToList();
                views.ForEach(v => v.Unpinned    += OnContainerUnpinned);
                views.ForEach(v => v.InfoProvider = provider);
                views.ForEach(v => (v.Widget as IPanelView)?.Refresh());
                providerToViewMap.Add(provider, views);
            }

            var childrenToRemove = content.Children.Where(v => !(v as PanelViewContainer).Pinned);

            foreach (var child in childrenToRemove)
            {
                content.Remove(child);
            }

            List <PanelViewContainer> newViews;

            if (!providerToViewMap.TryGetValue(provider, out newViews))
            {
                return;
            }
            foreach (var viewContainer in newViews)
            {
                bool alreadyOnPanel = viewContainer.Pinned;
                if (!alreadyOnPanel)
                {
                    content.Add(viewContainer);
                    content.SetChildPacking(viewContainer, false, false, 0, PackType.Start);
                    viewContainer.Visible = viewContainer.VisibleOnPanel;
                }
            }
            UpdatePanelVisibility();
        }
Exemple #12
0
        public void OnInfoProviderDisposed(IInfoProvider provider)
        {
            List <PanelViewContainer> views;

            if (providerToViewMap.TryGetValue(provider, out views))
            {
                foreach (var view in views)
                {
                    view.InfoProvider = null;
                }
                foreach (var view in views.Where(c => !c.Pinned))
                {
                    content.Remove(view);
                    view.Widget?.Destroy();
                    view.Dispose();
                }
                providerToViewMap.Remove(provider);
            }
        }
Exemple #13
0
        public T Refresh(IInfoProvider <T> provider)
        {
            lock (_lock)
            {
                ClearValue();
                T result = provider.Provide();

                if (Count == 0)
                {
                    Add(provider);
                }
                else if (this[0] != provider)
                {
                    Remove(provider);
                    Insert(0, provider);
                }

                return(SetValue(result));
            }
        }
Exemple #14
0
 public TemplateServiceImpl(DataContext dc, IInfoProvider ip)
     : base(dc, ip)
 {
 }
Exemple #15
0
 public TemplateService(IInfoProvider infoProvider)
     : base(infoProvider)
 {
     Impl = new TemplateServiceImpl(this.DataContext, this.InfoProvider);
 }
 public static IServiceCollection AddInfo(this IServiceCollection services, IInfoProvider infoProvider)
 {
     _infoProvider = infoProvider ?? throw new ArgumentNullException(nameof(infoProvider));
     return(services);
 }
Exemple #17
0
 public PartAnalyzer(IObjectFactory objectFactory, IInfoProvider infoProvider)
     : base(objectFactory)
 {
     _infoProvider = infoProvider;
 }
Exemple #18
0
 public static void RegisterExternalInfoProvider(IInfoProvider provider)
 {
     infoProviderList.Add(provider);
 }
Exemple #19
0
 public FormHostServiceFacade(IInfoProvider ip)
 {
     this.DataContext  = new DataContext();
     this.InfoProvider = ip;
 }
Exemple #20
0
 public FormHostService(DataContext dc, IInfoProvider ip)
 {
     this.DataContext  = dc;
     this.InfoProvider = ip;
 }
Exemple #21
0
 public TurboFactory(IObjectFactory objectFactory, IInfoProvider infoProvider)
 {
     _objectFactory = objectFactory;
     _infoProvider  = infoProvider;
 }
Exemple #22
0
 public FillServiceImpl(DataContext dc, IInfoProvider ip)
     : base(dc, ip)
 {
 }
Exemple #23
0
 public InfoHandler(IInfoProvider provider)
 {
     this.provider = provider;
 }
Exemple #24
0
 public FillService(IInfoProvider infoProvider)
     : base(infoProvider)
 {
     Impl = new FillServiceImpl(this.DataContext, this.InfoProvider);
 }
 public InfoHandler(IInfoProvider provider)
 {
     this.provider = provider;
 }
Exemple #26
0
 public static void RegisterExternalInfoProvider(IInfoProvider provider)
 {
     infoProviderList.Add(provider);
 }