public menuEnseignant(IEnseignant obj) { this.obj = obj; InitializeComponent(); emp = new dashboardEnseignant(obj); objNotif = (NotificationClass)Activator.GetObject(typeof(NotificationClass), "tcp://localhost:1235/ObjNotification"); // Create a proxy from remote object. //Create an instance of wrapper class. NotifWrapper notifWrapper = new NotifWrapper(); //Associate remote object event with wrapper method. objNotif.EmploiChanged += new EmploiChangedEvent(notifWrapper.WrapperNotificationReceivedHandler); //Associate wrapper event with current form event handler. notifWrapper.WrapperNotificationReceived += new EmploiChangedEvent(NotificationReceivedHandler); prenomLabel.Text = loginForm.user.prenom; emp.TopLevel = false; emp.AutoScroll = false; container.Controls.Clear(); container.Controls.Add(emp); emp.Show(); }
/// <summary> /// Initialize standard WM notification options in "Sound and Notifications" system page /// </summary> /// <returns></returns> private static bool InitNotification() { bool needToSave = false; //if (Device.PlatformType == PlatformType.Standard) // return true; // Not yet supported on Smartphone NotificationClass programNotification = NotificationClass.Get(NotificationCLSID); if (programNotification == null) { programNotification = new NotificationClass(); programNotification.Options = NotificationOptions.Message | NotificationOptions.Vibrate | NotificationOptions.Sound; programNotification.WaveFile = @"\Windows\Alert-Dopple.wma"; programNotification.Duration = 10; needToSave = true; } if (String.IsNullOrEmpty(programNotification.Name)) { programNotification.Name = @"""В Контакте"" cобытия:";// This string have to be from the localize resources needToSave = true; } //programNotification.Options |= NotificationOptions.EnableRepeatSoundCheckBox; if (needToSave) { NotificationClass.Set(NotificationCLSID, programNotification); } return(true); }
/// <summary> /// Adds the main window to opened. /// </summary> /// <param name="viewModel">The view model.</param> /// <param name="window">The window.</param> public static void AddMainWindowToOpened(NotificationClass viewModel, Window window) { if (viewModel != null && window != null) { openedWindows[viewModel] = window; } }
static void Main(string[] args) { while (true) { Console.WriteLine(); Console.WriteLine("Type one of these commands: Topic/Id/Exit"); string command = Console.ReadLine(); switch (command.ToLower()) { case "topic": NotificationClass messageForTopic = GetTheMessage(); SendMessageToTopic(messageForTopic); break; case "id": NotificationClass messageForId = GetTheMessage(); break; case "exit": return; default: Console.WriteLine("Your input was not correct! Try another one."); break; } } }
/// <summary> /// Shows the dialog. /// </summary> /// <param name="viewModel">The view model.</param> /// <param name="parent">The parent.</param> public static void ShowDialog(NotificationClass viewModel, NotificationClass parent = null) { Type windowType; if (registeredViews.TryGetValue(viewModel.GetType(), out windowType)) { Window window = Activator.CreateInstance(windowType) as Window; if (window != null) { window.DataContext = viewModel; openedWindows[viewModel] = window; if (parent != null) { Window parentWindow; if (openedWindows.TryGetValue(parent, out parentWindow)) { window.Owner = parentWindow; } } window.ShowDialog(); } } }
protected void Session_Start(object sender, EventArgs e) { NotificationClass nc = new NotificationClass(); var currentTime = DateTime.Now; HttpContext.Current.Session["LastUpdated"] = currentTime; nc.RegisterNotification(currentTime); }
public gestionEmploiFom(IScolarite obj) { this.obj = obj; notifObj = (NotificationClass)Activator.GetObject(typeof(NotificationClass), "tcp://localhost:1235/ObjNotification"); InitializeComponent(); this.ajouterNiveaux(); }
/// <summary> /// Closes the dialog. /// </summary> /// <param name="viewModel">The view model.</param> public static void CloseDialog(NotificationClass viewModel) { Window windowToClose; if (openedWindows.TryGetValue(viewModel, out windowToClose)) { windowToClose.Close(); openedWindows.Remove(viewModel); } }
//Database change when new product added notification public JsonResult getProductNotification() { var notificationregisterTime = Session["LastUpdate"] != null?Convert.ToDateTime(Session["LastUpdate"]) : DateTime.Now; NotificationClass nc = new NotificationClass(); var list = nc.GetProduct(notificationregisterTime); //update session here to get only new added contacts(notification) Session["LastUpdate"] = DateTime.Now; return(Json(list, JsonRequestBehavior.AllowGet)); }
private static NotificationClass GetTheMessage() { NotificationClass message = new NotificationClass(); Console.WriteLine("Insert the title:"); message.title = Console.ReadLine(); Console.WriteLine("Insert the body"); message.body = Console.ReadLine(); return(message); }
public Task5ViewModel(ApplicationViewModel app) : base(app) { dispatcher = App.Current.Dispatcher; aTimer = new Timer(500) { Interval = 20 }; aTimer.Elapsed += new ElapsedEventHandler(MoveAroundZOnTimer); minZ = new NotificationClass <int>(-5); maxZ = new NotificationClass <int>(5); loadAction = notify; }
public Object SendToClass([FromBody] NotificationClass notification) { Payload payload = BAccount.ConfirmToken(this.Request); if (payload == null || payload.rol.Contains(1) || payload.rol.Contains(4) || payload.rol.Contains(5)) { return(new { result = false, info = "Não autorizado." }); } var result = BNotification.SendNotificationToClass(notification, payload.aud); if (!result) { return(new { result = false, info = "Não foi possivel enviar a notificação." }); } return(new { result = true }); }
private void HandleMessage(string content) { try { EmailNotificationModel emailObj = new EmailNotificationModel(); emailObj = JsonConvert.DeserializeObject <EmailNotificationModel>(content); NotificationClass.SendEmail(emailObj); // Send Update to Log Service. ApplicationLogs applogs = new ApplicationLogs(); applogs.LogMessage = emailObj.Emailfrom + "\t" + emailObj.Emailto + "\t" + emailObj.CC + "\t" + emailObj.Content; _queueProvider.RegisterApplicationLog(applogs); } catch { } }
private void GetNotification() { NotificationClass clas = new NotificationClass(); //Intent intent = new Intent(this, typeof(NotificationClass)); MessagingCenter.Subscribe <StartForegroundService>(this, "Show Notification", y => { clas.IssueNotification(); //IssueNotification(); }); MessagingCenter.Subscribe <StopForegroundService>(this, "Remove Notification", y => { clas.RemoveNotification(); }); MessagingCenter.Subscribe <CancelledMessage>(this, "Update Notification", z => { clas.UpdateNotification(); }); }
public static Boolean SendNotificationToClass(NotificationClass notification, int userID) { try { using (var db = new DBContextModel()) { TblNotifications notif = new TblNotifications { Description = notification.Description, Hour = DateTime.Now, Subject = notification.Subject, Urgency = notification.Urgency, Approval = notification.Approval, UserFK = notification.SenderFK }; db.TblNotifications.Add(notif); db.SaveChanges(); var students = BClass.GetStudentsByClass(notification.ClassFK); foreach (var student in students) { TblValidations valid = new TblValidations { ReceiverFK = BParenting.GetGuardians(student).FirstOrDefault(), StudentFK = student, Accepted = false, Read = false }; db.TblValidations.Add(valid); db.SaveChanges(); } var cla = db.TblClasses.Find(notification.ClassFK); BAction.SetActionToUser(String.Format("enviou uma notificação a turma '{0}'", cla.Year + cla.ClassDesc), userID); return(true); } } catch (Exception) { return(false); } }
private static void SendMessageToTopic(NotificationClass message) { Console.WriteLine("Insert the topic name"); string topicName = Console.ReadLine(); RequestClass req = new RequestClass(); req.to = StaticHelper.TOPIC_NAME_FORMAT + topicName; req.notification.title = message.title; req.notification.body = message.body; ResponseForTopic response = StaticHelper.SendMessageToTopic(req); if (response.ErrorCode == null && response.error == null) { Console.Write("Message sent successfully."); } else { Console.Write("Failed to send message"); } }
/// <summary> /// /// </summary> /// <param name="polled"></param> /// <param name="request"></param> /// <param name="result"></param> /// <returns></returns> public CommandStatus GetEventStatusNotification(bool polled, NotificationClass request, out EventStatusNotification result) { if (m_logger != null) { string args = polled.ToString() + ", " + request.ToString() + ", out result"; m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.GetEventStatusNotification(" + args + ")")); } ushort len = 0; result = null; using (Command cmd = new Command(ScsiCommandCode.GetEventStatusNotification, 10, 4, Command.CmdDirection.In, 10)) { if (polled) cmd.SetCDB8(1, 1); cmd.SetCDB8(4, (byte)request); cmd.SetCDB16(7, 4); CommandStatus st = SendCommand(cmd); if (st != CommandStatus.Success) return st; byte n = cmd.GetBuffer8(2); if ((n & 0x80) != 0) { // There are no events, just capture the header result = new EventStatusNotification(cmd.GetBuffer(), cmd.BufferSize); return CommandStatus.Success; } // // There are event notifications to be grabbed, allocate space for these // len = cmd.GetBuffer16(0); len += 4; // For the length field } using (Command cmd = new Command(ScsiCommandCode.GetEventStatusNotification, 10, len, Command.CmdDirection.In, 10)) { if (polled) cmd.SetCDB8(1, 1); cmd.SetCDB8(4, (byte)request); cmd.SetCDB16(7, len); CommandStatus st = SendCommand(cmd); if (st != CommandStatus.Success) return st; result = new EventStatusNotification(cmd.GetBuffer(), cmd.BufferSize); } return CommandStatus.Success; }
/// <summary> /// Отображение уведомления /// </summary> /// <param name="aText">Текст для отображения</param> /// <param name="aSilent">Иконка</param> /// <param name="aStraightToTray">Silent режим</param> static void OnNotificationShow(string aText, System.Drawing.Icon aIcon, bool aSilent) { DebugHelper.WriteLogEntry("OnNotificationShow " + aText + aSilent); _notification.Caption = Properties.Resources.Program_OnNtfnShow_Caption; _notification.Text = aText; _notification.Icon = aIcon; _notification.StraightToTray = aSilent; _notification.Silent = true; _notification.DisplayOn = !aSilent; _notification.Visible = true; //Get info from the registry about the notification type and the options DebugHelper.WriteLogEntry("OnNotificationShow NotificationClass.Get"); var nc = NotificationClass.Get(NotificationCLSID); //Application.DoEvents(); DebugHelper.WriteLogEntry("OnNotificationShow Vibrate"); if (!aSilent) { #region vibrate if need if ((nc.Options & NotificationOptions.Vibrate) > 0) { try { VibrateLED.Vibrate(); } catch (Exception ex) { DebugHelper.WriteLogEntry(ex, "Vibrate error"); } } #endregion DebugHelper.WriteLogEntry("OnNotificationShow Sound"); #region play music if need try { if ((nc.Options & NotificationOptions.Sound) > 0) { if (!String.IsNullOrEmpty(nc.WaveFile)) { if (PlatformDetection.IsWM5()) { WCE_PlaySound(nc.WaveFile, IntPtr.Zero, (int)(Flags.SND_FILENAME | Flags.SND_ASYNC)); } else { string ext = null; try { ext = Path.GetExtension(nc.WaveFile); } catch (ArgumentException) { } int esuccess = 0; switch (ext) { //case ".wav": // esuccess = WCE_PlaySound(nc.WaveFile, IntPtr.Zero, (int)(Flags.SND_FILENAME | Flags.SND_ASYNC)); // break; case ".wav": case ".mp3": case ".wma": case ".mid": case ".midi": //Application.DoEvents(); using (SoundPlayer player = new SoundPlayer(nc.WaveFile)) { player.Play(); esuccess = 1; } break; } if (esuccess == 0) { //WCE_PlaySound("Default", IntPtr.Zero, (int)(Flags.SND_ALIAS_ID | Flags.SND_ASYNC)); WCE_PlaySound("\\Windows\\asterisk.wav", IntPtr.Zero, (int)(Flags.SND_FILENAME | Flags.SND_ASYNC)); } } } } } catch (Exception ex) { DebugHelper.WriteLogEntry(ex, "Play sound error"); } #endregion } DebugHelper.WriteLogEntry("OnNotificationShow End"); }
/*****************************************************************************************************/ static void InitDeviceObjects() { // create the device object with StructuredView acceptation device = new DeviceObject(deviceId, "Device test", "A test Device", true); // ANALOG_INPUT:0 uint // initial value 0 ana0 = new AnalogInput <double> ( 0, "Ana0 Sin double", "Ana0 Sin double", 0, BacnetUnitsId.UNITS_AMPERES ); ana0.m_PROP_HIGH_LIMIT = 50; ana0.m_PROP_LOW_LIMIT = -50; ana0.m_PROP_DEADBAND = 5; ana0.Enable_Reporting(true, 0); device.AddBacnetObject(ana0); // don't forget to do this // Binary Output device.AddBacnetObject(new BinaryOutput(0, "Bin Out", "An output", false)); // Create A StructuredView StructuredView s = new StructuredView(0, "Content", "A View"); // register it device.AddBacnetObject(s); // don't forget to do this BaCSharpObject b; // ANALOG_VALUE:0 double with Priority Array // b = new AnalogValue <double> ( 0, "Ana0 Double", "Ana0 Double", 5465.23, BacnetUnitsId.UNITS_BARS, true ); s.AddBacnetObject(b); // Put it in the view b.OnWriteNotify += new BaCSharpObject.WriteNotificationCallbackHandler(handler_OnWriteNotify); // ANALOG_OUTPUT:1 int with Priority Array on Present Value b = new AnalogOutput <int> ( 1, "Ana1 int", "Ana1 int", (int)56, BacnetUnitsId.UNITS_DEGREES_CELSIUS ); s.AddBacnetObject(b); // Put it in the view b.OnWriteNotify += new BaCSharpObject.WriteNotificationCallbackHandler(handler_OnWriteNotify); // MULTI_STATE_OUTPUT:4 with 6 states MultiStateOutput m = new MultiStateOutput ( 4, "MultiStates", "MultiStates", 1, 6 ); for (int i = 1; i < 7; i++) { m.m_PROP_STATE_TEXT[i - 1] = new BacnetValue("Text Level " + i.ToString()); } s.AddBacnetObject(m); // in the view StructuredView s2 = new StructuredView(1, "Complex objects", "Complex objects"); s.AddBacnetObject(s2); // TREND_LOG:0 with int values // new TrendLog can be changed by new TrendLogCustom trend0 = new TrendLog(0, "Trend signed int", "Trend signed int", 200, BacnetTrendLogValueType.TL_TYPE_SIGN); s2.AddBacnetObject(trend0); // in the second level view // fill Log with more values than the size for (int i = 0; i < 300; i++) { DateTime current = DateTime.Now.AddSeconds(-300 + i); if ((i > 200) && (i < 210)) // simulate some errors in the trend { trend0.AddValue(new BacnetError(), current, 0, BacnetTrendLogValueType.TL_TYPE_ERROR); } else { trend0.AddValue((int)(i * Math.Sin((float)i / 0.01)), current, 0); } } trend0.AddValue(new BacnetError(), DateTime.Now, 0, BacnetTrendLogValueType.TL_TYPE_ERROR); // BACFILE:0 // File access right me be allowed to the current user // for read and for write if any b = new BacnetFile ( 0, "A file", "File description", "c:\\RemoteObject.xml", false ); s2.AddBacnetObject(b); // in the second level view NotificationClass nc = new NotificationClass ( 0, "An alarm sender", "Alarm description", device.PROP_OBJECT_IDENTIFIER ); device.AddBacnetObject(nc); // Put two elements into the NC recipient List // Valid Day BacnetBitString week = new BacnetBitString(); for (int i = 0; i < 7; i++) { week.SetBit((byte)i, true); // Monday to Sunday } // transition BacnetBitString transition = new BacnetBitString(); transition.SetBit(0, true); // To OffNormal transition.SetBit(1, true); // To Fault transition.SetBit(2, true); // To Normal DeviceReportingRecipient r = new DeviceReportingRecipient ( week, // week days DateTime.MinValue.AddDays(10), // fromTime DateTime.MaxValue, // toTime new BacnetObjectId(BacnetObjectTypes.OBJECT_DEVICE, 4000), (uint)4, // processid true, // Ack required transition // transition ); nc.AddReportingRecipient(r); r = new DeviceReportingRecipient ( week, DateTime.MinValue.AddDays(10), DateTime.MaxValue, new BacnetAddress(BacnetAddressTypes.IP, 0, new Byte[6] { 255, 255, 255, 255, 0xBA, 0xC0 }), (uint)4, true, transition ); nc.AddReportingRecipient(r); // Create a Schedule Schedule sch = new Schedule(0, "Schedule", "Schedule"); // MUST be added to the device list before modification device.AddBacnetObject(sch); // a link to the internal analog output sch.AddPropertyReference(new BacnetDeviceObjectPropertyReference ( new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_OUTPUT, 1), BacnetPropertyIds.PROP_PRESENT_VALUE) ); // a link to analog output through the network : could be on another device than itself sch.AddPropertyReference(new BacnetDeviceObjectPropertyReference ( new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_OUTPUT, 1), BacnetPropertyIds.PROP_PRESENT_VALUE, new BacnetObjectId(BacnetObjectTypes.OBJECT_DEVICE, 4000)) ); sch.PROP_SCHEDULE_DEFAULT = (int)452; // Schedule a change today in 60 seconds sch.AddSchedule ( DateTime.Now.DayOfWeek == 0 ? 6 : (int)DateTime.Now.DayOfWeek - 1, // Monday=0, Sunday=6 DateTime.Now.AddSeconds(10), (int)900 ); sch.PROP_OUT_OF_SERVICE = false; // needed after all initialization to start the service // One empty Calendar, could be fullfill with yabe Calendar cal = new Calendar(0, "Test Calendar", "A Yabe calendar"); device.AddBacnetObject(cal); }
public TaskViewModel(ApplicationViewModel app) { this.app = app; workWithBoundingBox = clearBoxAndLines; value = new NotificationClass <bool>(false); }