private void btnEdit_Click(object sender, EventArgs e) { if (this.Dispatch == null) { return; } var manager = DispatchManager.Create(this.Dispatch); using (XF_DispatchNewEdit form = new XF_DispatchNewEdit(manager)) { var result = form.ShowDialog(); if (result == DialogResult.Yes) { if (form.IsDeleted) { ClearDispatch(); } else { this.LoadDispatch(manager.ActiveModel); } } if (DispatchChanged != null) { DispatchChanged(this, new DispatchEventArgs(manager.ActiveModel, result)); } } }
protected override void ProcessNewChannel(string object_path, uint initiator_handle, uint target_handle, ChannelDetails c) { string service_name = (string)c.Properties[Constants.CHANNEL_TYPE_DBUSTUBE + ".ServiceName"]; Contact contact = Connection.Roster.GetContact(target_handle); DBusTubeChannel tube = null; try { tube = new DBusTubeChannel(this.Connection, object_path, initiator_handle, target_handle, service_name); DBusActivity activity = new DBusActivity(contact, tube); DispatchManager dm = Connection.DispatchManager; dm.Add(contact, activity.Service, activity, false); } catch (Exception e) { Console.WriteLine(e.ToString()); if (tube != null) { tube.Dispose(); } } }
private Socket GetServerSocket(Socket client) { TrackInfo track = Banshee.ServiceStack.ServiceManager.PlayerEngine.CurrentTrack; if (track == null) { return(null); } Socket stream_socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP); Contact contact = ContactTrackInfo.From(track).Contact; if (contact != null) { DispatchManager dm = contact.DispatchManager; StreamActivity activity = dm.Get <StreamActivity> (contact, StreamingServer.ServiceName); if (activity != null) { stream_socket.Connect(new UnixEndPoint(activity.Address)); } } return(stream_socket); }
private void gridViewDisp_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { if (this.DesignMode) { return; } var row = gridViewDisp.GetRow(e.RowHandle) as DispatchCatalogModel; if (row != null) { xU_Dispatch.LoadDispatch(row); } if (e.Clicks == 2) { var manager = DispatchManager.CreateEdit(row.DispatchID); using (XF_DispatchNewEdit form = new XF_DispatchNewEdit(manager)) { if (form.ShowDialog() == System.Windows.Forms.DialogResult.Yes) { LoadDispatches(); if (form.IsDeleted) { xU_Dispatch.ClearDispatch(); } } } } }
private void btnNextDay_Click(object sender, EventArgs e) { if (this.Dispatch == null) { return; } var copy = this.Dispatch.NewCopy(); copy.FromDateTime = copy.FromDateTime.AddDays(1); copy.ToDateTime = copy.ToDateTime.AddDays(1); var manager = DispatchManager.Create(copy); using (XF_DispatchNewEdit form = new XF_DispatchNewEdit(manager)) { var result = form.ShowDialog(); if (result == DialogResult.Yes) { this.LoadDispatch(manager.ActiveModel); } if (DispatchChanged != null) { DispatchChanged(this, new DispatchEventArgs(this.Dispatch, result)); } } }
private void btnNewDispatch_Click(object sender, EventArgs e) { DispatchModel disp = new DispatchModel(); if (this.Dispatch != null) { disp = this.Dispatch.NewCopy(); } disp.FromDateTime = DateTime.Now.Date.AddHours(9); disp.ToDateTime = disp.FromDateTime.AddHours(8); disp.CompanyID = 0; disp.LocationID = 0; var manager = DispatchManager.Create(disp); using (XF_DispatchNewEdit form = new XF_DispatchNewEdit(manager)) { var result = form.ShowDialog(); if (result == DialogResult.Yes) { this.LoadDispatch(manager.ActiveModel); } if (DispatchChanged != null) { DispatchChanged(this, new DispatchEventArgs(this.Dispatch, result)); } } }
private void CleanUpIfClosed(uint target_handle, object key) { if (target_handle < 1) { throw new ArgumentException("target_handle should be > 0"); } else if (key == null) { throw new ArgumentNullException("key"); } Contact contact = Connection.Roster.GetContact(target_handle); DispatchManager dm = contact.DispatchManager; Dispatchable d = dm.Get(contact, key, DispatchObject); if (d != null) { if (d.IsClosed) { dm.Remove(contact, key, DispatchObject); } else { throw new InvalidOperationException(String.Format("{0} already has dispatchable object type {1} with key {2}", contact.Name, DispatchObject.FullName, key) ); } } }
public void Awake() { _gameManager = GameManager.Instance; _dispatcher = _gameManager.Dispatcher; _commandMap = _gameManager.CommandMap; _gameManager.AddContext(this); OnRegister(); }
public void addListener(string name, Action <MainEvent> fun) { if (instance == null) { instance = new DispatchManager(); } instance.Register(name, fun); }
public void Test_Search_Truck_From_Vin_Number() { IDispatchManager dm = new DispatchManager(); Assert.IsNull(dm.SearchTruck(new Mock.TruckAPI(), string.Empty)); Assert.AreEqual(dm.SearchTruck(new Mock.TruckAPI(), "abc").ErrorCode, "7 - Manufacturer is not registered with NHTSA for sale or importation in the U.S. for use on U.S roads; Please contact the manufacturer directly for more information."); Assert.AreEqual(dm.SearchTruck(new Mock.TruckAPI(), "5UXWX7C5*BA").ErrorCode, "6 - Incomplete VIN."); }
public Service1() { InitializeComponent(); this.logger.Info($"This is Service1 ctor start..."); DispatchManager.Init().GetAwaiter().GetResult(); this.logger.Info($"This is Service1 ctor end..."); }
/// <summary> /// Create new instance. /// </summary> public VlogRequestPeriodicHostedService(DispatchManager dispatchManager, ILogger <PeriodicHostedService> logger) : base(logger) { _dispatchManager = dispatchManager ?? throw new ArgumentNullException(nameof(dispatchManager)); // Override the timer interval. Interval = TimeSpan.FromMinutes(1); }
public static IEnumerable <IncomingFileTransfer> GetAll(Connection conn) { foreach (Contact contact in conn.Roster.GetAllContacts()) { DispatchManager dm = contact.DispatchManager; foreach (IncomingFileTransfer ft in dm.GetAll <IncomingFileTransfer> (contact)) { yield return(ft); } } }
static void Main(string[] args) { try { DispatchManager.Init().GetAwaiter().GetResult(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Read(); }
protected override void ProcessNewChannel(string object_path, uint initiator_handle, uint target_handle, ChannelDetails c) { Console.WriteLine("Processing new channel for file transfer"); string filename = (string)c.Properties[Constants.CHANNEL_TYPE_FILETRANSFER + ".Filename"]; string content_type = (string)c.Properties[Constants.CHANNEL_TYPE_FILETRANSFER + ".ContentType"]; ulong size = (ulong)c.Properties[Constants.CHANNEL_TYPE_FILETRANSFER + ".Size"]; Contact contact = Connection.Roster.GetContact(target_handle); FileTransferChannel ft = null; FileTransfer transfer = null; try { ft = new FileTransferChannel(this.Connection, object_path, initiator_handle, target_handle, filename, content_type, (long)size); if (initiator_handle != Connection.SelfHandle) { transfer = new IncomingFileTransfer(contact, ft); } else { transfer = new OutgoingFileTransfer(contact, ft); } if (transfer != null) { DispatchManager dm = Connection.DispatchManager; dm.Add(contact, transfer.OriginalFilename, transfer); } } catch (Exception e) { Console.WriteLine(e.ToString()); if (transfer != null) { transfer.Dispose(); } else if (ft != null) { ft.Dispose(); } } }
public override void _PhysicsProcess(float delta) { Profiler.Stop("Physics"); Profiler.Start("Physics"); DispatchManager.Dispatch(new Events.FixedUpdate() { delta_time = delta }); DispatchManager.Dispatch(new Events.LateFixedUpdate() { delta_time = delta }); }
private void EnsureDBusActivity() { if (Contact == null) { return; } if (CurrentActivity == null) { DispatchManager dm = Contact.DispatchManager; CurrentActivity = dm.Get <DBusActivity> (Contact, MetadataProviderService.BusName); } }
/// <summary> /// Create new instance. /// </summary> public NotificationService(INotificationClient notificationClient, INotificationRegistrationRepository notificationRegistrationRepository, DispatchManager dispatchManager, IUserRepository userRepository, INotificationFactory notificationFactory, ILogger <NotificationService> logger) { _notificationClient = notificationClient ?? throw new ArgumentNullException(nameof(notificationClient)); _notificationRegistrationRepository = notificationRegistrationRepository ?? throw new ArgumentNullException(nameof(notificationRegistrationRepository)); _dispatchManager = dispatchManager ?? throw new ArgumentNullException(nameof(dispatchManager)); _userRepository = userRepository ?? throw new ArgumentNullException(nameof(userRepository)); _notificationFactory = notificationFactory ?? throw new ArgumentNullException(nameof(notificationFactory)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public override void _Process(float delta) { DispatchManager.Dispatch(new Debug()); Profiler.Stop("Update"); Profiler.Start("Update"); DispatchManager.Dispatch(new Events.FrameUpdate() { delta_time = delta }); DispatchManager.Dispatch(new Events.LateFrameUpdate() { delta_time = delta }); }
public IActionResult PostVlog([FromServices] DispatchManager dispatchManager, [FromServices] Core.AppContext appContext, [FromBody] VlogDto input) { // Act. var postVlogContext = new PostVlogContext { IsPrivate = input.IsPrivate, UserId = appContext.UserId, VlogId = input.Id, }; dispatchManager.Dispatch <PostVlogBackgroundTask>(postVlogContext); // Return. return(NoContent()); }
protected override void ProcessNewChannel(string object_path, uint initiator_handle, uint target_handle, ChannelDetails c) { string service_name = (string)c.Properties[Constants.CHANNEL_TYPE_STREAMTUBE + ".Service"]; Contact contact = Connection.Roster.GetContact(target_handle); StreamTubeChannel tube = null; Activity activity = null; try { tube = new StreamTubeChannel(this.Connection, object_path, initiator_handle, target_handle, service_name); if (initiator_handle == Connection.SelfHandle) { tube.ServerAddress = Connection.SupportedChannels.GetChannelInfo <StreamTubeChannelInfo> (service_name).Address; activity = new StreamActivityListener(contact, tube); } else { activity = new StreamActivity(contact, tube); } if (activity != null) { DispatchManager dm = Connection.DispatchManager; dm.Add(contact, activity.Service, activity); } } catch (Exception e) { Console.WriteLine(e.ToString()); if (activity != null) { activity.Dispose(); } else if (tube != null) { tube.Dispose(); } } }
public override void Queue() { DispatchManager dm = Contact.DispatchManager; if (!dm.Exists <OutgoingFileTransfer> (Contact, Name)) { IDictionary <string, object> properties = new Dictionary <string, object> (); properties.Add("Filename", Name); properties.Add("Description", "Telepathy extension for Banshee transfer"); properties.Add("ContentType", ContentType); properties.Add("Size", (ulong)Key.Track.FileSize); dm.Request <OutgoingFileTransfer> (Contact, properties); } base.Queue(); }
protected virtual void OnClosed(EventArgs args) { IsClosed = true; EventHandler <EventArgs> handler = Closed; if (handler != null) { handler(this, args); } if (!disposed && key != null && AutoRemoveOnClose && Contact != null) { DispatchManager dm = contact.DispatchManager; dm.Remove(contact, key, this.GetType()); } }
public void Test_Search_Multi_Truck_From_Vin_Number_String() { IDispatchManager dm = new DispatchManager(); Assert.IsNull(dm.SearchMultiTruck(new Mock.TruckAPI(), string.Empty)); string errorCode = "abc"; Assert.IsNotNull(dm.SearchMultiTruck(new Mock.TruckAPI(), errorCode)[0]); string moreThanFive = "ONE|TWO|THREE|FOUR|FIVE|SIX"; Assert.IsNull(dm.SearchMultiTruck(new Mock.TruckAPI(), moreThanFive)); string correctCodes = "5UXWX7C5*BA|5UXCA7C5*BA|5UEFX7C5*BA"; Assert.AreEqual(dm.SearchMultiTruck(new Mock.TruckAPI(), correctCodes).Count(), 3); }
void gridViewDisp_CellValueChanged(object sender, CellValueChangedEventArgs e) { var row = gridViewDisp.GetRow(e.RowHandle) as DispatchCatalogModel; if (row != null) { var manager = DispatchManager.Create(row); var res = manager.SaveDispatch(row); if (res.Failed) { Mess.Warning(res.Message); this.TryShowPopup(res.Property); } else { LoadDispatches(); this.BoldColumn = e; } } }
public void Test_Save_Truck() { IDispatchManager dm = new DispatchManager(); Truck truck = new Truck() { Id = 7, TruckName = "Truck Name is not null " }; var rs = dm.SaveTruck(truck); Assert.IsTrue(rs.Ok); truck = null; rs = dm.SaveTruck(truck); Assert.IsTrue((!rs.Ok) && rs.Errors.Contains("truck can not be null")); truck = new Truck() { }; Assert.IsFalse(rs.Ok && rs.Errors.Contains("Truck name is required!")); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); DevExpress.UserSkins.BonusSkins.Register(); DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(GLOB.Settings.Get <string>(2)); GLOB.ConfigureMap(); if (Updater.CheckVersion()) { Updater.UpdateApplication(); } if (XF_Login.ShowWindow() == DialogResult.Yes) { var dispManager = DispatchManager.CreateEmpty(); Application.Run(new XF_Dispatches(dispManager)); } //XF_TestForm.ShowWindow(); }
public static int Count <T> (Connection conn) where T : Dispatchable { if (conn == null) { throw new ArgumentNullException("conn"); } int count = 0; foreach (Contact contact in conn.Roster.GetAllContacts()) { DispatchManager dm = contact.DispatchManager; foreach (T obj in dm.GetAll <T> (contact)) { if (obj != null) { count++; } } } return(count); }
public void TestDispatchEventParsing() { string tag = "CC51-FWFC"; using (var db = new StationCADDb()) { string data; using (StreamReader sr = new StreamReader(@"TestData\UnitDispatchReport-F16001716.htm")) { data = sr.ReadToEnd(); } DispatchManager dispMgr = new DispatchManager(); Organization org = db.Organizations.Where(x => x.Tag == tag).FirstOrDefault(); if (org == null) { org = new Organization(); org.Name = "First West Chester Fire Company"; org.Status = OrganizationStatus.Active; org.Type = OrganizationType.Fire; org.Tag = tag; org.ContactEmail = "*****@*****.**"; org.ContactPhone = "610.883.3253"; db.Organizations.Add(org); try { db.SaveChanges(); } catch (Exception ex) { ex.ToString(); } } // Add UserProfile string email = "*****@*****.**"; User user; UserProfile usrp; user = db.Users .Include("Profile") .Include("Profile.OrganizationAffiliations") .Include("Profile.MobileDevices") .Where(w => w.Email == email) .FirstOrDefault(); if (user == null) { user = new User { Id = Guid.NewGuid().ToString(), UserName = email, Email = email }; usrp = new UserProfile(); usrp.FirstName = string.Format("FirstName_{0}", DateTime.Now.Ticks); usrp.LastName = string.Format("LastName_{0}", DateTime.Now.Ticks); usrp.AccountEmail = email; usrp.IdentificationNumber = DateTime.Now.Ticks.ToString(); //usrp.UserName = string.Format("{0}.{1}", usrp.FirstName, usrp.LastName); usrp.OrganizationAffiliations = new List<OrganizationUserAffiliation>(); usrp.OrganizationAffiliations.Add(new OrganizationUserAffiliation { Status = OrganizationUserStatus.Active, Role = OrganizationUserRole.User }); usrp.NotificationEmail = email; usrp.MobileDevices = new List<UserMobileDevice>(); usrp.MobileDevices.Add(new UserMobileDevice { Carrier = MobileCarrier.ATT, EnableSMS = true, MobileNumber = "6108833253" }); user.Profile = usrp; user.Profile.OrganizationAffiliations = new List<OrganizationUserAffiliation>(); OrganizationUserAffiliation uoa = new OrganizationUserAffiliation(); uoa.CurrentOrganization = org; uoa.Role = OrganizationUserRole.User; uoa.Status = OrganizationUserStatus.Active; user.Profile.OrganizationAffiliations.Add(uoa); db.Users.Add(user); } //usr2 = db.UserProfiles // .Include("OrganizationAffiliations")b // .Include("MobileDevices") // .Where(w => w.NotificationEmail == "*****@*****.**") // .FirstOrDefault(); //if (usr2 == null) //{ // usr2 = new UserProfile(); // usr2.FirstName = "Michael"; // usr2.LastName = "Lam"; // usr2.IdentificationNumber = DateTime.Now.Ticks.ToString(); //// usr2.UserName = string.Format("{0}.{1}", usr2.FirstName, usr2.LastName); // usr2.OrganizationAffiliations = new List<UserOrganizationAffiliation>(); // usr2.OrganizationAffiliations.Add(new UserOrganizationAffiliation { Status = OrganizationUserStatus.Active, Role = OrganizationUserRole.User }); // usr2.NotificationEmail = "*****@*****.**"; // usr2.MobileDevices = new List<UserMobileDevice>(); // usr2.MobileDevices.Add(new UserMobileDevice { Carrier = MobileCarrier.ATT, EnableSMS = true, MobileNumber = "6108833253" }); // db.UserProfiles.Add(usr2); //} db.SaveChanges(); dispMgr.ProcessEvent(org, data, DispatchManager.MessageType.Html); //db.UserProfiles.Remove(usrp); //db.SaveChanges(); } }
/// <summary> /// Create new instance. /// </summary> public BackgroundTaskDispatcher(DispatchManager dispatchManager) => _dispatchManager = dispatchManager ?? throw new ArgumentNullException(nameof(dispatchManager));
public ActionResult Process(FormCollection oColl) { HttpStatusCodeResult httpResult; string recipient = string.Empty; Organization org; string sender = string.Empty; string body = string.Empty; string attachmentData = string.Empty; string userIP = string.Empty; string userDomain = string.Empty; string json = string.Empty; string err = string.Empty; string uvFileCnt = string.Empty; string vFileCnt = string.Empty; int fileLen = 0; byte[] fileContent = new byte[0]; string attachmentName = string.Empty; StringBuilder sb = new StringBuilder(); try { recipient = Request.Unvalidated.Form["recipient"]; string[] recipientParts = recipient.Split('@'); using (var db = new StationCADDb()) { string tag = recipientParts[0]; org = db.Organizations .Include("NotificationRules") .Where(x => x.Tag == tag).FirstOrDefault(); if (org == null) throw new InvalidProgramException(string.Format("Invalid Organization tag: {0}", tag)); } sender = Request.Unvalidated.Form["sender"]; body = Request.Unvalidated.Form["body-plain"]; DateTime eventRecieved = DateTime.Now; // Validate the sender userIP = Request.UserHostAddress; userDomain = Request.UserHostName; sb.AppendLine(string.Format("User IP:{1}{0}{0}", Environment.NewLine, userIP)); sb.AppendLine(string.Format("User Domain:{1}{0}{0}", Environment.NewLine, userDomain)); var formkeys = Request.Unvalidated.Form.Keys; sb.AppendLine(string.Format("Keys:{0}", Environment.NewLine)); foreach (var item in formkeys) { string value = Request.Unvalidated.Form[item.ToString()]; sb.AppendLine(string.Format("Keys: {1}; Value: {2}{0}", Environment.NewLine, item.ToString(), value)); } vFileCnt = Request.Files.Count.ToString(); uvFileCnt = Request.Unvalidated.Files.Count.ToString(); sb.AppendLine(string.Format("Attachment Count: {1}, {2}{0}{0} ", Environment.NewLine, vFileCnt, uvFileCnt)); if (Request.Unvalidated.Files.Count > 0) { // for this example; processing just the first file HttpPostedFileBase file = Request.Unvalidated.Files[0]; fileLen = file.ContentLength; attachmentName = file.FileName; sb.AppendLine(string.Format("Length:{0}{1}{0}{0}", Environment.NewLine, fileLen)); if (fileLen >= 0) { // throw an error here if content length is not > 0 // you'll probably want to do something with file.ContentType and file.FileName fileContent = new byte[file.ContentLength]; file.InputStream.Read(fileContent, 0, file.ContentLength); sb.AppendLine(string.Format("File Content Length:{0}{1}{0}{0}", Environment.NewLine, fileContent.Length)); // fileContent now contains the byte[] of your attachment... attachmentData = System.Text.Encoding.Default.GetString(fileContent); sb.AppendLine(string.Format("Attachment Data:{0}{1}{0}{0}", Environment.NewLine, attachmentData)); } } DispatchManager dispMgr = new DispatchManager(); DispatchEvent eventMsg; if (attachmentData.Length > 0) { eventMsg = dispMgr.ProcessEvent(org, attachmentData, DispatchManager.MessageType.Html); eventMsg.FileName = attachmentName; } else eventMsg = dispMgr.ProcessEvent(org, body, DispatchManager.MessageType.Text); json = JsonUtil<DispatchEvent>.ToJson(eventMsg); sb.AppendLine(string.Format("Json Body:{0} {1}{0}{0}", Environment.NewLine, json)); httpResult = new HttpStatusCodeResult(HttpStatusCode.OK); } catch (Exception ex) { string errMsg = string.Format("An error occurred in EventController.Process(). Exception: {0}", ex.Message); base.LogException(errMsg, ex); sb.AppendLine(string.Format("Error:{0}{1}{0}{0}", Environment.NewLine, err)); httpResult = new HttpStatusCodeResult(HttpStatusCode.InternalServerError, string.Format("Error encountered processing the event. Message: {0}", ex.Message)); } finally { base.LogInfo(sb.ToString()); } return httpResult; }
public void Awake() { _commandManager = new CommandBinder(); _dispatcher = new DispatchManager(); _contexts = new Dictionary <Type, IContext>(); }
public void TestDispatchHtmlParsing() { string data; using (StreamReader sr = new StreamReader(@"TestData\UnitClearReport22.htm")) { data = sr.ReadToEnd(); } if (data.Length > 0) { //var html = new HtmlDocument(); //html.LoadHtml(data); // load a string //var root = html.DocumentNode; //var nodes = root.Descendants("td"); //int index = 0; //foreach(var item in nodes) //{ // Console.WriteLine(string.Format("[{0}] - {1}", index,item.InnerText)); // index++; //} DispatchManager dispMgr = new DispatchManager(); ChesCoPAEventMessage eventInc = dispMgr.ParseEventHtml(data); string json = JsonUtil<ChesCoPAEventMessage>.ToJson(eventInc); Console.WriteLine(json); } }