コード例 #1
0
        public void RegisterHostedService(TimeSpan callbackInterval, Action <HostedServiceCancellation> callback)
        {
            var cancellation = new HostedServiceCancellation();

            new System.Threading.Thread(() =>
            {
                while (!BackgroundServiceReset.WaitOne(callbackInterval))
                {
                    try
                    {
                        callback(cancellation);
                        if (cancellation.Cancel)
                        {
                            return;
                        }
                    }
                    catch (Exception e)
                    {
                        foreach (var page in GetActivePages())
                        {
                            CommunicationHub.SendError(page, e);
                        }
                    }
                }
            }).Start();
        }
コード例 #2
0
        public string OnComboBoxAjaxCall([FromBody] OnComboBoxAjaxCallParameters data)
        {
            var control = CommunicationHub.GetPage(data.connectionId).Manager.GetControl(data.controlId);

            if (control is Controls.Html.ComboBox_Ajax combo)
            {
                return(JsonConvert.SerializeObject(combo._OnAjaxRequestFromClient(data.searchString)));
            }
            return(null);
        }
コード例 #3
0
        public async Task <string> OnDataGridComboBoxAjaxCall([FromBody] OnDataGridComboBoxAjaxCallParameters data)
        {
            var control = CommunicationHub.GetPage(data.connectionId).Manager.GetControl(data.controlId);

            if (control is Controls.Html.IDataGrid dataGrid)
            {
                var col = dataGrid.GetColumns()[data.colId];
                if (dataGrid.MetaDatas.TryGetValue(data.row.ToString(), out var meta) && meta.Columns != null && meta.Columns.TryGetValue(data.colId, out var metaCol))
                {
                    if (metaCol.Editor is Controls.Html.DataGridColumn.ComboBoxAjaxEditor metaEditor)
                    {
                        return(JsonConvert.SerializeObject(await metaEditor.CallRequest(data.searchString)));
                    }
                }

                if (col?.Editor is Controls.Html.DataGridColumn.ComboBoxAjaxEditor editor)
                {
                    return(JsonConvert.SerializeObject(await editor.CallRequest(data.searchString)));
                }
            }
            return(null);
        }
コード例 #4
0
        public static (int id, string auth) RegisterFSWPage(FSWPage page, string FSWSessionId, string FSWSessionAuth, FSWComponentBase mainComponent, out string newFSWSessionId, out string newFSWSessionAuth)
        {
            Session session = null;

            // try to get an existing session

            if (!string.IsNullOrEmpty(FSWSessionId))
            {
                session = Session.GetSession(FSWSessionId, FSWSessionAuth);
            }

            // if new session OR the existing one doesn't exist anymore
            if (session == null)
            {
                session           = Session.GenerateNewSession();
                newFSWSessionId   = session.Id;
                newFSWSessionAuth = session.Auth;
            }
            else
            {
                newFSWSessionId   = null;
                newFSWSessionAuth = null;
            }

            int pageId;

            lock (TempIdLock)
                pageId = ++LatestTempID;

            page.Session       = session;
            page.PageAuth      = Guid.NewGuid().ToString();
            page.IsRegistered  = true;
            page.MainComponent = mainComponent;

            CommunicationHub.RegisterFSWPage(pageId, page);
            return(id : pageId, auth : page.PageAuth);
        }
コード例 #5
0
 public async Task <IActionResult> GenericFileUploadRequest(string actionToDo, string connectionId, string data, List <IFormFile> files)
 {
     return(await CommunicationHub.GetPage(connectionId).InvokeGenericFileUploadRequest(actionToDo, data, files));
 }
コード例 #6
0
 public async Task <IActionResult> GenericRequest(string actionToDo, string connectionId, string data)
 {
     return(await CommunicationHub.GetPage(connectionId).InvokeGenericRequest(actionToDo, data));
 }
コード例 #7
0
 protected StaticHostedService()
 {
     CommunicationHub.RegisterStaticHostedService(typeof(T), this);
 }