public async static Task <bool> Ping(ConnectionItem connectionItem) { JObject requestObject = new JObject( new JProperty("jsonrpc", "2.0"), new JProperty("id", 234), new JProperty("method", "JSONRPC.ping")); string requestData = requestObject.ToString(); // httpClient.Timeout = new TimeSpan(0, 0, 2); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/jsonrpc?request="); request.Content = new StringContent(requestData, Encoding.UTF8, "application/json"); HttpResponseMessage response = await connectionItem.HttpClient.SendAsync(request); string responseString = await response.Content.ReadAsStringAsync(); if (responseString.Length == 0) { return(false); } //dynamic responseObject = JObject.Parse(responseString); JObject responseObject = JObject.Parse(responseString); bool isSuccessful = responseObject["result"].ToString() == "pong"; return(isSuccessful); }
private async void SaveConnectionAppBarButton_Click(object sender, RoutedEventArgs e) { int port; if (!int.TryParse(PortTextBox.Text, out port)) { MessageDialog msg = new MessageDialog("Please enter a valid port number.", "Invalid Port"); await msg.ShowAsync(); return; } if (NameTextBox.Text.Equals(string.Empty) || IPTextBox.Text.Equals(string.Empty)) { MessageDialog msg = new MessageDialog("Please enter valid name and server address", "Invalid Details"); await msg.ShowAsync(); return; } var newConnection = new ConnectionItem { ConnectionName = NameTextBox.Text, IpAddress = IPTextBox.Text, Port = port, Username = UsernameTextBox.Text, Password = PasswordTextBox.Text }; await App.ConnectionsVM.AddConnectionItem(newConnection).ConfigureAwait(true); Frame.GoBack(); }
private async void WakeUpServerMFI_Click(object sender, RoutedEventArgs e) { ConnectionItem selectedConnection = (ConnectionItem)(sender as MenuFlyoutItem).DataContext; if (selectedConnection.SubnetMask == null || selectedConnection.MACAddress == null) { MessageDialog message = new MessageDialog(loader.GetString("WOLMacNotFoundMessage"), loader.GetString("WOLMacNotFoundHeader")); await message.ShowAsync(); return; } SetPageState(PageStates.Busy, loader.GetString("WakingUp")); uint result = await WOLHelper.WakeUp(selectedConnection); await Task.Delay(3500); SetPageState(PageStates.Ready); if (result != 102) { string messageText; switch (result) { case 10: messageText = loader.GetString("IPErrorMessage"); break; default: messageText = loader.GetString("WOLErrorMessage") + result; break; } MessageDialog message = new MessageDialog(messageText, loader.GetString("WakeUpFailed")); await message.ShowAsync(); } }
public void AddConnection() { Spatial env = GetNode <Spatial>("/root/main/env"); for (var i = 0; i < env.GetChildCount(); i++) { if (env.GetChild(i).GetScript() == null) { continue; } else if (env.GetChild(i) is Arm) { GD.Print("adding connection"); ConnectionItem new_item = new ConnectionItem { connectName = env.GetChild(i).Name, baseNode = (Spatial)env.GetChild(i) }; AddConnectionItem(new_item); } else { } } }
private async Task ConnectToServer(ConnectionItem connectionItem) { SetPageState(PageStates.Connecting); bool isSuccessful = false; try { isSuccessful = await JSONRPC.Ping(connectionItem); } catch { isSuccessful = false; } if (isSuccessful) { ConnectionManager.CurrentConnection = connectionItem; SettingsHelper.SetValue("RecentServerIP", connectionItem.IpAddress); Frame.Navigate(typeof(CoverPage)); } else { MessageDialog message = new MessageDialog(loader.GetString("ConnectionUnsuccessful_Content"), loader.GetString("ConnectionUnsuccessful_Title")); await message.ShowAsync(); SetPageState(PageStates.Ready); } }
private IMenuItem[] GenerateNodeMenuItems(ITreeNode treeNode) { ObjectExplorerItem objectExplorerItem = treeNode.Data as ObjectExplorerItem; switch (objectExplorerItem.ItemType) { case ObjectExplorerItemType.Connections: { return(new IMenuItem[] { MenuFactory.CreateMenuItem("Add connection", () => CommandBus.Send(new ConnectionAddCommand())) }); } case ObjectExplorerItemType.Connection: { ConnectionItem connectionItem = objectExplorerItem as ConnectionItem; return(new IMenuItem[] { MenuFactory.CreateMenuItem("Connect", () => CommandBus.Send(new ConnectCommand(connectionItem))), MenuFactory.CreateMenuItem("Edit", () => CommandBus.Send(new ConnectionEditCommand(connectionItem))) }); } default: return(new IMenuItem[] { }); } }
/// <summary> /// Removes a Protocol, Connection or Folder /// </summary> public static bool RemoveItem(ConnectionItem removeItem) { Logger.Log(LogEntryType.Info, String.Format("Delete ItemID {0} of type {1} by user {2}", removeItem.ConnectionID, removeItem.ConnectionType, StorageCore.Core.GetUserId())); try { switch (removeItem.ConnectionType) { case ConnectionTypeItems.protocol: RemoveProtocol(removeItem); break; case ConnectionTypeItems.connection: RemoveConnection(removeItem); break; case ConnectionTypeItems.folder: RemoveFolder(removeItem); break; } } catch (Exception ea) { Logger.Log( LogEntryType.Exception, String.Format( "Error on deleting an Item (ItemID {0} of type {1} by user {2})", removeItem.ConnectionID, removeItem.ConnectionType, StorageCore.Core.GetUserId()), ea); return(false); } return(true); }
public override void LoadNextLevel(TreeViewObjectExplorer tv, TreeNodeObject parentNode) { ClassPointer root = parentNode.OwnerIdentity as ClassPointer; IList <Guid> gl = root.GetDatabaseConnectionsUsed(); IList <Guid> gl2 = root.Project.GetObjectGuidList(); List <Guid> lst = new List <Guid>(); lst.AddRange(gl); foreach (Guid g in gl2) { if (!lst.Contains(g)) { lst.Add(g); } } if (lst.Count > 0) { foreach (Guid g in lst) { ConnectionItem ci = ConnectionItem.LoadConnection(g, false, false); if (ci != null) { parentNode.Nodes.Add(new TreeNodeDatabaseConnection(ci)); } } } }
/// <summary> /// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// <para> /// Page specific logic should be placed in event handlers for the /// <see cref="NavigationHelper.LoadState"/> /// and <see cref="NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. /// </para> /// </summary> /// <param name="e">Provides data for navigation methods and event /// handlers that cannot cancel the navigation request.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { GlobalVariables.CurrentTracker.SendView("EditConnectionPage"); currentConnection = e.Parameter as ConnectionItem; this.DataContext = currentConnection; this.navigationHelper.OnNavigatedTo(e); }
public void StartConnect(IDocument document, ConnectionItem connectionItem) { var connection = PrepareConnection(document, connectionItem); ConnectingStarted.Invoke(null, new DocumentConnectionEvent(document, Connections[document])); connection.StartOpen(); }
private List <ConnectionItem> GetSubFolders(long mainFolderId, List <Folder> folderList, byte rootLevel) { var conItem = new ConnectionItem("tempname"); var conList = new List <ConnectionItem>(); //Foreach Folder foreach (var aFolder in folderList) { //Search the folder itself if (aFolder.Id == mainFolderId) { conItem.ConnectionName = aFolder.Name; conItem.ConnectionID = aFolder.Id; conItem.RootLevel = rootLevel; } //Search the Folder-Childs if (aFolder.ParentId == mainFolderId) { var listSubConnections = GetSubFolders(aFolder.Id, folderList, (byte)(rootLevel + 1)); conItem.SubConnections = new ObservableCollection <ConnectionItem>(listSubConnections); conList.InsertRange(conList.Count, listSubConnections); } } conList.Insert(0, conItem); return(conList); }
/// <summary> /// Detect and show path when dragging /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void OnDragDelta_DetectPath(object sender, DragDeltaEventArgs e) { AdornerDataThumb <ModelItem, Connector> thumb = sender as AdornerDataThumb <ModelItem, Connector>; Point currentPoint = thumb.Data.Position + new Vector(e.HorizontalChange, e.VerticalChange); Connector target = HitTest(thumb, currentPoint); ModelItem item = thumb.AdornedParent; Canvas canvas = item.ContainerCanvas; #if DEBUG_ON // test value System.Console.WriteLine("{0} Dragging - connItem {1} ", System.DateTime.Now.Millisecond, drawingConn); #endif if (drawingConn == null) { // create new connection drawingConn = new ConnectionItem(); // get current connection type Window w = Window.GetWindow(canvas); ConnectionType connType = (ConnectionType)(w.FindName("CurrentConnectionType") as ComboBox).SelectedIndex; drawingConn.ContentObject.Type = connType.ToString(); drawingConn.ContentObject.Source = thumb.Data; // bind source here Diagram diagram = Project.Current.Children.FindByCanvas(canvas); diagram.Children.Add(drawingConn.ContentObject); } if ((drawingConn.ContentObject.Sink = target) != null) { drawingConn.UpdatePath(); } else { drawingConn.UpdatePath(drawingConn.ContentObject.SinkPosition = currentPoint); } drawingConn.Draw(); e.Handled = true; }
public void AddConnection(ConnectionItem connectionItem) { var config = this.GetConfiguration(); config.Connections.Add(connectionItem); saveConfiguration(config); }
private void setDefaultConnection() { if (_defConnectionType != null && !string.IsNullOrEmpty(_defConnectionString)) { if (connect != null) { Guid id; if (!string.IsNullOrEmpty(connect.Filename)) { id = new Guid(connect.Filename); } else { id = connect.ConnectionObject.ConnectionGuid; } Connection _def = new Connection(); _def.ConnectionGuid = id; _def.DatabaseType = _defConnectionType; _def.ConnectionString = _defConnectionString; ConnectionItem.AddDefaultConnection(_def); if (connect.ConnectionObject.DatabaseType == null) { connect.ConnectionObject.DatabaseType = _defConnectionType; } if (string.IsNullOrEmpty(connect.ConnectionObject.ConnectionString)) { connect.ConnectionObject.ConnectionString = _defConnectionString; } } } }
/// <summary> /// Downloads image content from a remote location, ignoring the cache. /// </summary> /// <param name="imageUri">Image location</param> /// <returns>Stream content of the HTTP response. null if not connected, imageUri is invalid, or HTTP response is not OK</returns> private static async Task <Stream> GetImageStreamAsync(Uri imageUri) { Stream imageStream = null; // Download the image with HTTP Basic auth HttpClient client = new HttpClient(); // Ignore the HttpClient cache client.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue() { NoCache = true }; ConnectionItem con = ConnectionManager.CurrentConnection; if (con != null && con.HasCredentials()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue( "Basic", System.Convert.ToBase64String(Encoding.UTF8.GetBytes( String.Format("{0}:{1}", con.Username, con.Password) )) ); } client.BaseAddress = new Uri(imageUri.Scheme + "://" + imageUri.Authority); HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, imageUri.AbsolutePath); HttpResponseMessage res = await client.SendAsync(req); if (res.IsSuccessStatusCode) { imageStream = await res.Content.ReadAsStreamAsync(); } return(imageStream); }
public TopicsViewModel(ConnectionItem connectionItem) { ConnectionItem = connectionItem; IEnumerable <SettingTopicItem> items = (connectionItem.Topics ?? Enumerable.Empty <string>()) .Select(x => new SettingTopicItem(x)).Concat(new SettingTopicItem[] { new NewSettingTopicItem(), }); Topics = new ObservableCollection <SettingTopicItem>(items); }
public TreeNodeDatabaseConnection(ConnectionItem ci) : base(false) { _connect = ci; Text = ci.ToString(); ImageIndex = TreeViewObjectExplorer.IMG_CONNECT; SelectedImageIndex = TreeViewObjectExplorer.IMG_CONNECT; }
/// <summary> /// Deletes a folder, its subfolders and their connections, settings and options /// </summary> /// <param name="removeItem"></param> private static void RemoveFolder(ConnectionItem removeItem) { if (removeItem.ConnectionType != ConnectionTypeItems.folder) { return; } RemoveFolder(removeItem.ConnectionID); }
/// <summary> /// Deletes a Connection, its protocols and their options /// </summary> /// <param name="removeItem"></param> public static void RemoveConnection(ConnectionItem removeItem) { if (removeItem.ConnectionType != ConnectionTypeItems.connection) { return; } RemoveConnection(removeItem.ConnectionID); }
private void comBoxConnectionSelector_SelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedConnection = (ComboBox)sender; ConnectionItem selected = (ConnectionItem)selectedConnection.SelectedItem; ConfigModel.ConnectionType = selected.Name; txtBlockConnType.Text = $"Connection: {ConfigModel.ConnectionType}"; }
/// <summary> /// Deletes a Protocol and its options /// </summary> /// <param name="removeItem"></param> private static void RemoveProtocol(ConnectionItem removeItem) { if (removeItem.ConnectionType != ConnectionTypeItems.protocol) { return; } RemoveProtocol(removeItem.ConnectionID); }
private async void SaveConnectionAppBarButton_Click(object sender, RoutedEventArgs e) { int port; if (!int.TryParse(PortTextBox.Text, out port)) { MessageDialog msg = new MessageDialog("Please enter a valid port number.", "Invalid Port"); await msg.ShowAsync(); return; } String ipAddress = IPTextBox.Text; if (NameTextBox.Text.Equals(string.Empty) || ipAddress.Equals(string.Empty)) { MessageDialog msg = new MessageDialog("Please enter valid name and server address", "Invalid Details"); await msg.ShowAsync(); return; } // ********************************************************************************************* // // Michele Mischitelli (11/07/2015) : // We should check for ip addresses starting with http:// in case people use dynamic DNS to always // be able to connect to their kodi at home. Https:// is not supported for now. const String httpsPrefix = "https://"; if (ipAddress.ToLower().StartsWith(httpsPrefix)) { var md = new MessageDialog("Https protocol is not currently supported.", "Invalid protocol"); await md.ShowAsync(); return; } const String httpPrefix = "http://"; if (ipAddress.ToLower().StartsWith(httpPrefix)) { ipAddress = ipAddress.Substring(httpPrefix.Length); } // ********************************************************************************************* // var newConnection = new ConnectionItem { ConnectionName = NameTextBox.Text, IpAddress = ipAddress, Port = port, Username = UsernameTextBox.Text, Password = PasswordTextBox.Text }; App.ConnectionsVM.AddConnectionItem(newConnection); Frame.GoBack(); }
private void ContextMenuDeleteConnection_Click(object sender, RoutedEventArgs e) { var t = sender as MenuItem; if (t != null) { ConnectionItem connectionItem = t.DataContext as ConnectionItem; App.MainVM.RemoveConnectionItem(connectionItem); } }
public void UpdateConnection(ConnectionItem connectionItem) { var config = this.GetConfiguration(); var existing = config.Connections.FirstOrDefault(c => c.ConnectionData.Name == connectionItem.ConnectionData.Name); var index = config.Connections.IndexOf(existing); config.Connections.RemoveAt(index); config.Connections.Insert(index, connectionItem); saveConfiguration(config); }
public void stworz_konw(int[] _number, int my_number) { znaleziony = false; checkUpdate = false; //messageForm.ConnectionsListView.Items.Add(new ConnectionItem { UserName = "******", UserNumber = "test" }); if (trafficController.GetState() == State.LoggedIn || trafficController.GetState() == State.OpenedGate) { //MyItem selectedItem = (MyItem)ListViewAddressBook.SelectedItems[0]; //currentNumber = trafficController.FindNumber(selectedItem.UserName); trafficController.SetState(State.OpenedGate); if (!trafficController.protection_unavailable(_number[0].ToString())) { trafficController.SetState(State.OpenedGate); messageForm.Show(); string users = ""; for (int i = 0; i < _number.Length; i++) { users += trafficController.FindName(_number[i].ToString()); } ConnectionItem connectionItem = new ConnectionItem { UserName = "******" + users, UserNumber = users, IsConv = true }; if (messageForm.ConnectionsListView.HasItems == true) //Sprawdz czy lista posiada itemy jesli nie to dodaj { foreach (ConnectionItem item in messageForm.ConnectionsListView.Items) { if (item.UserName.Contains("Konwersacja")) { znaleziony = true; } } if (znaleziony == true) //Jesli lista posiada juz ten item { Console.WriteLine("Połączenie juz istnieje"); } else { messageForm.ConnectionsListView.Items.Add(connectionItem); messageForm.Initialize(conversationConnections, _number, myNumber); } } else { messageForm.ConnectionsListView.Items.Add(connectionItem); messageForm.Initialize(conversationConnections, _number, myNumber); SetConversationBook(conversationConnections, _number); } } } }
private void ConnectionsListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { int idxconv; int idxchat; int breakid; idxchat = 0; idxconv = 0; breakid = 0; ConnectionItem selectedType = (ConnectionItem)ConnectionsListView.SelectedItems[0]; var selected = ConnectionsListView.SelectedIndex; foreach (ConnectionItem item in ConnectionsListView.Items) { if (breakid <= selected) { if (item.IsConv == true) { idxconv++; breakid++; } else { idxchat++; breakid++; } } else { break; } } if (ConnectionsListView.HasItems) { if (selectedType.IsConv == true) { _mainFrame.Navigate(conversationConnections[selected - idxchat]); } else { _mainFrame.Navigate(openedConnections[selected - idxconv]); } } else { }; // if (selectedType.IsConv == true) { _mainFrame.Navigate } // if (ConnectionsListView.HasItems) { _mainFrame.Navigate(conversationConnections[selected]); } // selected = ConnectionsListView.SelectedIndex; //if (ConnectionsListView.HasItems) { // _mainFrame.Navigate(openedConnections[selected]); } // else { }; }
private void ContextMenuEditConnection_Click(object sender, RoutedEventArgs e) { var t = sender as MenuItem; if (t != null) { ConnectionItem connectionItem = t.DataContext as ConnectionItem; ConnectionManager.CurrentConnection = connectionItem; NavigationService.Navigate(new Uri("/Pages/EditConnectionPage.xaml", UriKind.Relative)); } }
/// <summary> /// 回收 /// </summary> /// <param name="item"></param> public void Recycle(ConnectionItem item) { try { item.Connection.ClearStream(); } catch { } this.groups.Enqueue(item.Group); }
public void Dispose() { CmdTabManageFolderLoaded.TabManageFolderLoaded -= CmdTabManageFolderLoaded_TabManageFolderLoaded; CmdTabManageFolderAddFolderClick.TabManageFolderAddFolderClick -= CmdTabManageFolderAddFolderClick_TabManageFolderAddFolderClick; CmdTabManageFolderLoaded = null; CmdTabManageFolderAddFolderClick = null; _FolderList.Clear(); _SelectedFolder = null; StartupFolder = null; }
/// <summary> /// Podwójne kliknięcie na danym kontakcie otwiera z nim rozmowę, numer telefonu zostaje zapisany jako bieżący /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListViewAddressBook_DoubleClick(object sender, MouseButtonEventArgs e) { znaleziony = false; //messageForm.ConnectionsListView.Items.Add(new ConnectionItem { UserName = "******", UserNumber = "test" }); if (trafficController.GetState() == State.LoggedIn || trafficController.GetState() == State.OpenedGate) { MyItem selectedItem = (MyItem)ListViewAddressBook.SelectedItems[0]; currentNumber = trafficController.FindNumber(selectedItem.UserName); trafficController.SetState(State.OpenedGate); if (!trafficController.protection_unavailable(selectedItem.UserName)) { trafficController.SetState(State.OpenedGate); messageForm.Show(); ConnectionItem connectionItem = new ConnectionItem { UserName = selectedItem.UserName, UserNumber = currentNumber, IsConv = false }; if (messageForm.ConnectionsListView.HasItems == true) //Sprawdz czy lista posiada itemy jesli nie to dodaj { foreach (ConnectionItem item in messageForm.ConnectionsListView.Items) { if (item.UserName == selectedItem.UserName) { znaleziony = true; } } if (znaleziony == true) //Jesli lista posiada juz ten item { Console.WriteLine("Połączenie juz istnieje"); } else { messageForm.ConnectionsListView.Items.Add(connectionItem); messageForm.Initialize(openedConnections, Int32.Parse(currentNumber), myNumber); } } else { messageForm.ConnectionsListView.Items.Add(connectionItem); messageForm.Initialize(openedConnections, Int32.Parse(currentNumber), myNumber); } } } else { MessageBox.Show("Najpierw musisz ustanowić połączenie!", "Warning"); } }
/// <summary> /// When drag is completed, i.e. mouse up /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void OnDragCompleted_Connect(object sender, DragCompletedEventArgs e) { AdornerDataThumb<ModelItem, Connector> thumb = sender as AdornerDataThumb<ModelItem, Connector>; Point currentPoint = thumb.Data.Position + new Vector(e.HorizontalChange, e.VerticalChange); Connector target = HitTest(thumb, currentPoint); ModelItem item = thumb.AdornedParent; Canvas canvas = item.ContainerCanvas; #if DEBUG_ON // test value System.Console.WriteLine("{0} DragCompleted - connItem {1} ", System.DateTime.Now.Millisecond, drawingConn); #endif if (drawingConn != null) { // if target is empty, cancel the connection if (drawingConn.ContentObject.Sink == null) { Diagram diagram = Project.Current.Children.FindByCanvas(canvas); diagram.Children.Remove(drawingConn.ContentObject); } drawingConn = null; } e.Handled = true; }
/// <summary> /// Detect and show path when dragging /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void OnDragDelta_DetectPath(object sender, DragDeltaEventArgs e) { AdornerDataThumb<ModelItem, Connector> thumb = sender as AdornerDataThumb<ModelItem, Connector>; Point currentPoint = thumb.Data.Position + new Vector(e.HorizontalChange, e.VerticalChange); Connector target = HitTest(thumb, currentPoint); ModelItem item = thumb.AdornedParent; Canvas canvas = item.ContainerCanvas; #if DEBUG_ON // test value System.Console.WriteLine("{0} Dragging - connItem {1} ", System.DateTime.Now.Millisecond, drawingConn); #endif if (drawingConn == null) { // create new connection drawingConn = new ConnectionItem(); // get current connection type Window w = Window.GetWindow(canvas); ConnectionType connType = (ConnectionType)(w.FindName("CurrentConnectionType") as ComboBox).SelectedIndex; drawingConn.ContentObject.Type = connType.ToString(); drawingConn.ContentObject.Source = thumb.Data; // bind source here Diagram diagram = Project.Current.Children.FindByCanvas(canvas); diagram.Children.Add(drawingConn.ContentObject); } if ((drawingConn.ContentObject.Sink = target) != null) drawingConn.UpdatePath(); else drawingConn.UpdatePath(drawingConn.ContentObject.SinkPosition = currentPoint); drawingConn.Draw(); e.Handled = true; }