//--------< send file content each time 512 size >------- private bool SendFile(ICommService service, string file) { long blockSize = 512; try { string filename = Path.GetFileName(file); service.OpenFileForWrite(filename); FileStream fs = File.Open(file, FileMode.Open, FileAccess.Read); int bytesRead = 0; while (true) { long remainder = (int)(fs.Length - fs.Position); if (remainder == 0) { break; } long size = Math.Min(blockSize, remainder); byte[] block = new byte[size]; bytesRead = fs.Read(block, 0, block.Length); service.WriteFileBlock(block); } fs.Close(); service.CloseFile(); return(true); } catch (Exception ex) { Console.Write("\n can't open {0} for writing - {1}", file, ex.Message); return(false); } }
public void CreateMessageChannel(string url) { int tryCount = 0; int maxCount = 10; EndpointAddress address = new EndpointAddress(url); WSDualHttpBinding binding = new WSDualHttpBinding(); ChannelFactory <ICommService> factory = new ChannelFactory <ICommService>(binding, address); channel = factory.CreateChannel(); while (true) { try { channel = factory.CreateChannel(); tryCount = 0; break; } catch (Exception ex) { if (++tryCount <= maxCount) { Thread.Sleep(500); } else { throw ex; } } } }
void CreateBasicHttpChannel(string url) { EndpointAddress address = new EndpointAddress(url); BasicHttpBinding binding = new BasicHttpBinding(); channel = ChannelFactory <ICommService> .CreateChannel(binding, address); }
private async void OnReceivedAsync(ICommService sender, MessageEventArgs args) { var msg = args.Message; await writer.Notice(msg); foreach (var s in Scanners) { var info = s.Scan(msg); if (info.Valid) { await writer.Info(info.ToString()); if (info.WolTrigger) { if (CheckInterval()) { lastWolTime = DateTimeOffset.Now; await writer.Debug("WOL!"); WOLHelper.WakeUpAll(); } } break; } } }
void CreateNetTcpChannel(string url) { EndpointAddress address = new EndpointAddress(url); NetTcpBinding binding = new NetTcpBinding(); channel = ChannelFactory <ICommService> .CreateChannel(binding, address); }
public NavigationPageViewModel(IContainerProvider container, ICommService commService) { CommService = commService; ShutdownDialog = container.Resolve <ShutdownDialog>(); RestartDialog = container.Resolve <RestartDialog>(); ItemInvokedCommand = new RelayCommand <NavigationViewItemInvokedEventArgs>(OnItemInvoked); }
public PacketLogModel(ICommService logReceiveServer) { textLog = new List <string>(); tagInfo = new TagInfo(); commService = logReceiveServer; commService.Received += this.OnReceived; _ = commService.ConnectAsync(); }
//----< Create proxy to another Peer's Communicator >------------ public void CreateSendChannel(string address) { ChannelFactory <ICommService> factory = new ChannelFactory <ICommService>(new WSHttpBinding(), new EndpointAddress(address)); channel = factory.CreateChannel(); Console.Write("\n service proxy created for {0}", address); }
private static void ExecuteOnMainProcess(Action action, bool doAsync) { ICommService service = GetChannel(); if (service == null || service.ExecuteOnMainProcess(DelToByte(action), doAsync)) { action(); } }
public static void AddToTrayIcon(IntPtr tabBarHandle, IntPtr explorerHandle, string currentPath, string[] tabNames, string[] tabPaths) { ICommService service = GetChannel(); if (service != null) { service.AddToTrayIcon(tabBarHandle, explorerHandle, currentPath, tabNames, tabPaths); } }
public static void RemoveFromTrayIcon(IntPtr tabBarHandle) { ICommService service = GetChannel(); if (service != null) { service.RemoveFromTrayIcon(tabBarHandle); } }
public static void SelectTabOnOtherTabBar(IntPtr tabBarHandle, int index) { ICommService service = GetChannel(); if (service != null) { service.SelectTabOnOtherTabBar(tabBarHandle, index); } }
public static void StaticBroadcast(Action action) { ICommService service = GetChannel(); if (service != null) { service.Broadcast(DelToByte(action)); } }
public static bool EnsureMainProcess(Action action) { ICommService service = GetChannel(); if (service != null && service.IsMainProcess()) { return(true); } ExecuteOnMainProcess(action, false); return(false); }
private void OnReceived(ICommService sender, MessageEventArgs args) { TagInfo tagValue = TagInfo.FromString(args.Message); if (tagValue.Valid) { Tag = tagValue; } while (textLog.Count > LOG_CAPACITY) { textLog.RemoveAt(0); } textLog.Add(string.Format(CultureInfo.InvariantCulture, "{0} {1} {2} {3}", args.Timestamp, args.Priority, args.Tag, args.Message)); RaisePropertyChanged(nameof(LogList)); }
public static void PushTabBarInstance(QTTabBarClass tabbar) { IntPtr handle = tabbar.Handle; using (new Keychain(rwLockTabBar, true)) { dictTabInstances[Thread.CurrentThread] = tabbar; sdTabHandles.Push(handle, tabbar); } ICommService service = GetChannel(); if (service != null) { service.PushInstance(handle); } }
public bool Connect(string url) { for (int i = 0; i < 100; ++i) { try { svc = CreateProxy(url); return(true); } catch { Thread.Sleep(100); } } return(false); }
public bool Connect(string url) { for (int i = 0; i < 100; ++i) { try { svc = CreateProxy(url); return true; } catch { Thread.Sleep(100); } } return false; }
public static bool UnregisterTabBar() { using (new Keychain(rwLockTabBar, true)) { QTTabBarClass tabbar; if (dictTabInstances.TryGetValue(Thread.CurrentThread, out tabbar)) { IntPtr handle = tabbar.Handle; dictTabInstances.Remove(Thread.CurrentThread); sdTabHandles.Remove(handle); ICommService service = GetChannel(); if (service != null) { service.DeleteInstance(handle); } } return(false); } }
//--------< connect with server >------- public void UploadToServer(string targetfile) { ICommService cs = null; int count = 0; while (true) { try { cs = Sender.CreateProxy(main.ServerUrl); break; } catch { Console.Write("\n connection to service failed {0} times - trying again", ++count); Thread.Sleep(500); continue; } } SendFile(cs, targetfile); }
//----< Connect repeatedly tries to send messages to service >------- public bool Connect(string remoteUrl) { if (Util.verbose) { sendMsgNotify("attempting to connect"); } if (isConnected(remoteUrl)) { return(true); } proxy = CreateProxy(remoteUrl); int attemptNumber = 0; Message startMsg = new Message(); startMsg.fromUrl = localUrl; startMsg.toUrl = remoteUrl; startMsg.content = "connection start message"; while (attemptNumber < MaxConnectAttempts) { try { proxy.sendMessage(startMsg); // will throw if server isn't listening yet proxyStore[remoteUrl] = proxy; // remember this proxy if (Util.verbose) { sendMsgNotify("connected"); } return(true); } catch { ++attemptNumber; sendAttemptNotify(attemptNumber); Thread.Sleep(100); } } return(false); }
/// <summary> /// Sends email info using the specified communication service. /// </summary> /// <param name="commService">The comm service.</param> /// <author>Jurie.smit</author> /// <datetime>2013/01/14-09:20 AM</datetime> /// <exception cref="System.NullReferenceException">ICommService of type EmailCommMessage</exception> public void Send(ICommService <EmailCommMessage> commService) { Dev2Logger.Log.Debug(""); if (commService == null) { throw new NullReferenceException("ICommService<EmailCommMessage>"); } var message = new EmailCommMessage { To = StringResources.FeedbackEmail, Subject = String.Format("Some Real Live Feedback{0}{1}" , String.IsNullOrWhiteSpace(SelectedCategory) ? "" : " : ", SelectedCategory), Content = Comment }; if (HasRecordingAttachment) { Attachments += !string.IsNullOrEmpty(RecordingAttachmentPath) ? RecordingAttachmentPath : ""; } if (HasServerLogAttachment) { Attachments += !string.IsNullOrEmpty(Attachments) ? ";" : ""; Attachments += !string.IsNullOrEmpty(ServerLogAttachmentPath) ? ServerLogAttachmentPath : ""; } if (HasStudioLogAttachment) { Attachments += !string.IsNullOrEmpty(Attachments) ? ";" : ""; Attachments += !string.IsNullOrEmpty(StudioLogAttachmentPath) ? StudioLogAttachmentPath : ""; } message.AttachmentLocation = Attachments; commService.SendCommunication(message); RequestClose(ViewModelDialogResults.Okay); }
//----< close connection - not used in this demo >------------------- public void CloseConnection() { proxy = null; }
//----< Connect repeatedly tries to send messages to service >------- public bool Connect(string remoteUrl) { if(Util.verbose) sendMsgNotify("attempting to connect"); if (isConnected(remoteUrl)) return true; proxy = CreateProxy(remoteUrl); int attemptNumber = 0; Message startMsg = new Message(); startMsg.fromUrl = localUrl; startMsg.toUrl = remoteUrl; startMsg.content = "connection start message"; while (attemptNumber < MaxConnectAttempts) { try { proxy.sendMessage(startMsg); // will throw if server isn't listening yet proxyStore[remoteUrl] = proxy; // remember this proxy if(Util.verbose) sendMsgNotify("connected"); return true; } catch { ++attemptNumber; sendAttemptNotify(attemptNumber); Thread.Sleep(100); } } return false; }
public SearchesController(ISearchesService service, UserManager <ApplicationUser> manager, ICommService communication) { this._manager = manager; this._service = service; this._communication = communication; }
public void CreateBasicHttpChannel(string url) { EndpointAddress address = new EndpointAddress(url); BasicHttpBinding binding = new BasicHttpBinding(); channel = ChannelFactory<ICommService>.CreateChannel(binding, address); }
public CommClient() { pipeFactory = new ChannelFactory <ICommService>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/beRemoteInterComm")); pipeProxy = pipeFactory.CreateChannel(); }
public static int GetTotalInstanceCount() { ICommService service = GetChannel(); return(service == null ? dictTabInstances.Count : service.GetTotalInstanceCount()); }
public CommsController(ICommService service, UserManager <ApplicationUser> manager) { this._service = service; this._manager = manager; }
public CommController(ICommService commService) { _commService = commService; }