Пример #1
0
 protected void UpdateGuestButtonClick(
     object sender,
     EventArgs e)
 {
     if (!string.IsNullOrEmpty(_guestId.Value) && !string.IsNullOrEmpty(_allowControl.Value))
     {
         var guestId = Guid.Empty;
         if (Guid.TryParse(_guestId.Value, out guestId))
         {
             var allowControl = true;
             if (bool.TryParse(_allowControl.Value, out allowControl))
             {
                 var script = string.Empty;
                 var guest  = sharingClient.UpdateGuest(guestId, allowControl);
                 if (guest == null)
                 {
                     script = "alert('guest not found or failed to update guest');";
                 }
                 else
                 {
                     script = string.Format("alert('updated guest: {0}, control: {1}, active: {2}, websocket: {3}');", guest.Id, guest.Control, guest.Active, guest.Websocket);
                 }
                 ClientScript.RegisterClientScriptBlock(GetType(), Guid.NewGuid().ToString(), script, true);
             }
         }
     }
 }
Пример #2
0
        protected void UpdateGuestButtonClick(
            object sender,
            EventArgs e)
        {
            var gatewayUrl = GetIFrameGatewayUrl((sender as HtmlInputButton).Attributes["data-fid"]);

            if (!string.IsNullOrEmpty(gatewayUrl))
            {
                var connectionId = GetIFrameConnectionId((sender as HtmlInputButton).Attributes["data-fid"]);
                if (connectionId != Guid.Empty)
                {
                    if (!string.IsNullOrEmpty(_guestId.Value) && !string.IsNullOrEmpty(_allowControl.Value))
                    {
                        var guestId = Guid.Empty;
                        if (Guid.TryParse(_guestId.Value, out guestId))
                        {
                            var allowControl = true;
                            if (bool.TryParse(_allowControl.Value, out allowControl))
                            {
                                var script        = string.Empty;
                                var sharingClient = new SharingClient(string.Format("{0}/api/Sharing/", gatewayUrl));
                                var guest         = sharingClient.UpdateGuest(guestId, allowControl);
                                if (guest == null)
                                {
                                    script = "alert('guest not found or failed to update guest');";
                                }
                                else
                                {
                                    script = string.Format("alert('updated guest: {0}, control: {1}, active: {2}, websocket: {3}');", guest.Id, guest.Control, guest.Active, guest.Websocket);
                                }
                                ClientScript.RegisterClientScriptBlock(GetType(), Guid.NewGuid().ToString(), script, true);
                            }
                        }
                    }
                }
            }
        }