示例#1
0
        /// <summary>
        /// 查询 线路 告警类型 限定下的最新告警Id和 AlarmCount
        /// </summary>
        /// <param name="lineId">线路Id</param>
        /// <param name="alarmType"></param>
        /// <returns>最新告警Id</returns>
        public AlarmModel GetLastestAlarm(int lineId, AlarmType alarmType)
        {
            AlarmModel result = null;

            _cmdAlarmRead.CommandText = $"SELECT Id,AlarmCount,LineId FROM tb_alarm WHERE LineID = '{lineId}' AND Type = { Convert.ToInt32(alarmType)} AND State = 3;";

            lock (_lockAlarmRead)
            {
                try
                {
                    result = _connAlarmRead.Query <AlarmModel>($"SELECT Id,AlarmCount,LineId FROM tb_alarm WHERE LineID = '{lineId}' AND Type = { Convert.ToInt32(alarmType)} AND State = 3;").FirstOrDefault();
                    //using (var reader = _cmdAlarmRead.ExecuteReader())
                    //{
                    //    if (reader.Read())
                    //    {
                    //        result = new AlarmModel()
                    //        {
                    //            Id = reader.GetInt32(0),
                    //            AlarmCount = reader.GetInt32(1)
                    //        };
                    //    }
                    //    reader.Close();
                    //}
                }
                catch (Exception ex)
                {
                }
            }
            return(result);
        }
示例#2
0
        private void Opc_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            OpcClient opc = sender as OpcClient;

            if (e.PropertyName.Equals("StateCurrent"))
            {
                //if successfully produced
                if (opc.StateCurrent == 17)
                {
                    System.Diagnostics.Debug.WriteLine((int)opc.AcceptableProducts);
                    Singleton.Instance.DBManager.RegisterBatch((int)opc.AcceptableProducts, (int)opc.DefectProducts,
                                                               opc.Start.ToString("MM/dd/yyyy HH:mm:ss:fff"), DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss:fff"), DateTime.Now.AddYears(10).ToString("MM/dd/yyyy"), true, 1, 1, 1,
                                                               (int)opc.MachSpeed,
                                                               3, GetMachineId(opc.Ip), lmao, lmao, lmao);
                }
            }
            if (e.PropertyName.Equals("StopReasonId") && opc.StateCurrent != 4)
            {
                System.Diagnostics.Debug.WriteLine(opc.StopReasonId);
                Singleton.Instance.DBManager.RegisterBatchAndAlarm((int)opc.AcceptableProducts, (int)opc.DefectProducts,
                                                                   opc.Start.ToString("MM/dd/yyyy HH:mm:ss:fff"), DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss:fff"), DateTime.Now.AddYears(10).ToString("MM/dd/yyyy"), true, 1, 1, 1,
                                                                   (int)opc.MachSpeed,
                                                                   3, GetMachineId(opc.Ip), lmao, lmao, lmao, DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss:fff"), (int)opc.StopReasonId);
                IList <AlarmModel> alarmies = Singleton.Instance.DBManager.RetrieveAlarms();
                AlarmModel         a        = alarmies[alarmies.Count - 1];
                a.MachineId = GetMachineId(opc.Ip);
                System.Diagnostics.Debug.WriteLine(a.Id + a.MachineId + a.StopReason + a.StopReasonId);
                AlarmManager.ActiveAlarms.Add(a);
            }
        }
示例#3
0
        public ActionResult Details(AlarmModel model, string submitButton, FormCollection formColl, long OccuranceTimeTicks)
        {
            //check the other submit buttons and act on them, or continue
            switch (submitButton)
            {
            case "Cancel":
            case "Return":
                return(RedirectToAction("Index", "Alarms", new { rtn = "true" }));
            }

            // Rebind model since locale of thread has been set since original binding of model by MVC
            if (TryUpdateModel(model, formColl.ToValueProvider()))
            {
                UpdateModel(model, formColl.ToValueProvider());
            }

            // Revalidate model after rebind.
            ModelState.Clear();
            TryValidateModel(model);

            //clear the alarm and send them back to the index page
            if (ModelState.IsValid)
            {
                //update the model to use the ticks, since miliseconds are lost in the hiddenfor.
                var occuranceTime = new DateTime(OccuranceTimeTicks);
                model.TimeOccured = occuranceTime;
                (new AlarmFactory(Session[Constants.Security.ConnectionStringSessionVariableName].ToString())).ClearAlarm(model);
                return(RedirectToAction("Index", "Alarms", new { rtn = "true" }));
            }

            //might need to rebuild the time types here
            return(View(model));
        }
        public string GetAlarm()
        {
            System.Diagnostics.Debug.WriteLine("firedxxx");
            AlarmModel alarm = Singleton.Instance.opcManager.AlarmManager.ActiveAlarms[0];

            return(JsonConvert.SerializeObject(alarm, Formatting.None));
        }
        public Task Save(AlarmModel schedule)
        {
            Validate(schedule);
            var json = ToShortJson(schedule);

            return(Session.PostCommand(new AlarmCommand(save, json), alarmsResource));
        }
        public void RetrieveAlarms()
        {
            IList <AlarmModel> list1 = dbManager.RetrieveAlarms();
            IList <AlarmModel> list2 = dbManager.RetrieveAlarms(2);
            IList <AlarmModel> list3 = dbManager.RetrieveUnhandledAlarms();

            IList <AlarmModel>[] alarms = { list1, list2, list3 };

            int?alarmId = null;

            for (int i = 0; i < alarms.Length; i++)
            {
                Assert.IsNotNull(alarms[i]); // Testing RetrieveAlarms Methods

                if (alarms[i].Count != 0)    // Testing RetrieveAlarms Methods
                {
                    foreach (AlarmModel element in alarms[i])
                    {
                        Assert.IsNotNull(element); // Testing RetrieveAlarms Methods
                        if (alarmId == null)
                        {
                            alarmId = element.Id;
                        }
                    }
                }
                else
                {
                    Assert.IsNotNull(null);
                }
            }

            AlarmModel alarm = dbManager.RetrieveAlarm((int)alarmId);

            Assert.IsNotNull(alarm); // Testing RetrieveAlarm
        }
示例#7
0
        /// <summary>
        /// Determines she SLA times for the alarm model based on the active alarm passed in and the local time.
        /// </summary>
        private AlarmModel DetermineSlaValues(AlarmModel alarmModel, ActiveAlarm alarm, DateTime localTime)
        {
            //set the defaults
            alarmModel.ServiceDesignation                 = "N/A";
            alarmModel.ServiceDesignationId               = -1;
            alarmModel.TimeRemainingTillTargetTime        = 0;
            alarmModel.TimeRemainingTillTargetTimeDisplay = "0";

            SetTSDS(alarm.CustomerID);
            if (alarm.SLADue.HasValue)
            {
                //set the time remaining until the sla is due - have to set this against the local customer time
                var diffTime = (alarm.SLADue.Value - localTime);
                alarmModel.TimeRemainingTillTargetTime = diffTime.TotalHours;
                if (diffTime.TotalHours > 0)
                {
                    alarmModel.TimeRemainingTillTargetTimeDisplay = FormatHelper.FormatTimeFromMinutes(diffTime.TotalMinutes);
                }
                //calculate the target  service designnation here as well
                var masterId = GetTsdMasterId(diffTime.TotalHours);
                //now determine the correct TSD Master
                var tds = Tsds.FirstOrDefault(x => x.MasterId == masterId);
                if (tds != null)
                {
                    alarmModel.ServiceDesignation   = tds.Description;
                    alarmModel.ServiceDesignationId = tds.Id;
                }
            }
            return(alarmModel);
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DateTime date;

            date = dateTimePickerDate.Value.Date;
            date = date.Add(dateTimePickerTime.Value.TimeOfDay);

            if (date < DateTime.Now)
            {
                MessageBox.Show("Alarm must be in the future.", "Invalid Alarm");
                return;
            }

            AlarmModel alarm = new AlarmModel {
                AlarmDateTime = date, Name = textBoxName.Text, Message = textBoxAlarmMessage.Text
            };

            _config.Connection.SaveAlarm(alarm);
            _caller.AlarmAdded(alarm);

            textBoxAlarmMessage.Text = "";
            textBoxName.Text         = $"Alarm: {DateTime.Now.ToString("MM/dd/yy hh:mm")}";

            if (!checkBoxStayOpen.Checked)
            {
                this.Close();
            }
        }
        public void BatchAndAlarmTest()
        {
            IList <KeyValuePair <string, double> > tList = new List <KeyValuePair <string, double> >();
            IList <KeyValuePair <string, double> > hList = new List <KeyValuePair <string, double> >();
            IList <KeyValuePair <string, double> > vList = new List <KeyValuePair <string, double> >();

            for (int i = 0; i < 7; i++)
            {
                KeyValuePair <string, double> pair = new KeyValuePair <string, double>("15/02/2019 10:45:1" + i + ".500", 10.2 + i);
                tList.Add(pair);
            }
            for (int i = 0; i < 7; i++)
            {
                KeyValuePair <string, double> pair = new KeyValuePair <string, double>("15/02/2019 10:45:1" + i + ".500", 5.7 + i);
                hList.Add(pair);
            }
            for (int i = 0; i < 7; i++)
            {
                KeyValuePair <string, double> pair = new KeyValuePair <string, double>("15/02/2019 10:45:1" + i + ".500", 2.5 + i);
                vList.Add(pair);
            }

            string date    = DateTime.Now.ToString();
            bool   success = dbManager.RegisterBatch(10, 50, "15/02/2019 10:45:10.500", "15/02/2019 10:45:16.500", "15/08/2019",
                                                     true, 0.5, 0.6, 1.0, 600, 0, 1, tList, hList, vList);

            Assert.IsTrue(success); // Test RegisterBatch

            AlarmModel alarm = dbManager.RegisterBatchAndAlarm(10, 50, "15/02/2019 10:45:10.500", "15/02/2019 10:45:16.300", "15/08/2019",
                                                               true, 0.5, 0.6, 1.0, 600, 0, 1, tList, hList, vList, "15/02/2019 10:45:16.500", 11);

            Assert.IsNotNull(alarm); // Test RegisterBatchAndAlarm
        }
示例#10
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var endpointId  = Query(PageParams.ENDPOINT);
            var alarmId     = Query(PageParams.ID);
            var isDoNothing = endpointId == null && alarmId == null;
            var isAddNew    = endpointId != null && alarmId == null;
            var isUpdate    = alarmId != null;

            if (isDoNothing)
            {
            }
            else
            {
                // After updating the time (on a separate page), the user is
                // navigated back here, then the alarm is loaded from the backend
                // and the old time is reinstated. Clearing the navigation query
                // string fixes this. The alarm is then only loaded when clicked
                // from the Alarms page.
                MusicEndpoint endpoint = DetermineEndpointOrActive(PageParams.ENDPOINT);
                NavigationContext.QueryString.Clear();
                viewModel   = AlarmModel.Build(endpoint, timeHelper);
                DataContext = viewModel;
                if (isUpdate)
                {
                    await viewModel.Fill(alarmId);
                }
                await viewModel.InstallPlayer();

                //await viewModel.LoadTracks();
            }
        }
示例#11
0
        /// <summary>
        /// Handles the OnClicked event of the Apply control. Sends the settings to the server.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        /// <version author="Andre Cachopas" date="13/05/2018" version="1.0" machine="KLAP"></version>
        /// <exception cref="NotImplementedException"></exception>
        private void Apply_OnClicked(object sender, EventArgs e)
        {
            AlarmModel newAlarm = new AlarmModel();

            newAlarm.AlarmTime = AlarmTime;

            if (SelectedColors.SelectedItem != null)
            {
                newAlarm.LightColor = (EColor)SelectedColors.SelectedItem;
                Debug.WriteLine("Selected color:{0}", (EColor)SelectedColors.SelectedItem);
            }
            else
            {
                newAlarm.LightColor = EColor.None;
            }

            newAlarm.SelectedDays = new List <DaySelection>();
            Debug.WriteLine("Alarm time:{0}", AlarmTime);

            foreach (DaySelection daySelection in _selectedDays)
            {
                Debug.WriteLine("Day:{0} Active:{1}", daySelection.Weekday, daySelection.Active);
                newAlarm.SelectedDays.Add((DaySelection)daySelection.Clone());
            }

            string jsonMessage = newAlarm.Serialize();

            Console.WriteLine(jsonMessage);
            ClientSide.Instance.SetAlarm(jsonMessage);
        }
示例#12
0
        /// <summary>
        /// 查询 线路 告警类型 限定下的最新告警Id和 AlarmCount
        /// </summary>
        /// <param name="lineId">线路Id</param>
        /// <param name="alarmType"></param>
        /// <returns>最新告警Id</returns>
        public AlarmModel GetLastestAlarm(int lineId, AlarmType alarmType)
        {
            AlarmModel result = null;

            _cmd.CommandText = $"select CONCAT(id,'-',AlarmCount) from tb_alarm WHERE LineID = '{lineId}' AND Type = { Convert.ToInt32(alarmType)} AND Confirm = 0  AND ISNULL(RecoverDate)";
            object obj = _cmd.ExecuteScalar();

            if (obj != null)
            {
                temp              = obj.ToString();
                result            = new AlarmModel();
                result.Id         = Convert.ToInt32(temp.Split('-')[0]);
                result.AlarmCount = Convert.ToInt32(temp.Split('-')[1]);
            }
            return(result);


            //_reader = _cmdSelect.ExecuteReader();
            //if (_reader.HasRows)
            //{
            //    _reader.Read();
            //    result = new AlarmModel();
            //    result.Id = Convert.ToInt32(_reader["Id"]);
            //    result.AlarmCount = Convert.ToInt32(_reader["AlarmCount"]);
            //}
            //_connSelect.Close();
            //return result;
        }
示例#13
0
 public ActionResult Create(AlarmModel Model)
 {
     Model.ID     = Guid.NewGuid();
     Model.UserID = CurrentUser.ID;
     DB.Alarms.Add(Model);
     DB.SaveChanges();
     return(RedirectToAction("Index", "Alarm"));
 }
 public void UpdateAlarm(AlarmModel alarm)
 {
     try
     {
         db.AlarmRecords.ReplaceOne(filter: g => g.Id == alarm.Id, replacement: alarm);
     }
     catch { throw; }
 }
示例#15
0
        public void AddRecoverDate(AlarmModel alarm)
        {
            string sql = $"update tb_alarm set RecoverDate = @RecoverDate,State = @State where Id = @Id ";

            using (MySqlConnection conn = new MySqlConnection(_connStr))
            {
                conn.Execute(sql, alarm);
            }
        }
 public void DeleteAlarm(AlarmModel alarm)
 {
     using (IDbConnection connection = new SQLiteConnection(_config.ConnectionString()))
     {
         var p = new DynamicParameters();
         p.Add("@Id", alarm.Id);
         connection.Execute("DELETE FROM Alarms WHERE Id=@Id", p);
     }
 }
示例#17
0
        /// <summary>
        /// 只修改告警状态,确认状态
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="item"></param>
        public void Update(string condition, AlarmModel item)
        {
            string sql = string.Format("update tb_alarm set Confirm = @Confirm,State = {1}  where 1=1 {0}", condition, Convert.ToInt32(item.State));

            using (MySqlConnection conn = new MySqlConnection(_connStr))
            {
                conn.Execute(sql, item);
            }
        }
示例#18
0
        /// <summary>
        /// Called when clock application terminates.
        /// It happens when clock application exits via BACK key
        /// </summary>
        public void Terminate()
        {
            if (ClockInfo != null)
            {
                ClockInfo.Dispose();
            }

            System.Diagnostics.Debug.WriteLine("                                       Terminate...");
            AlarmModel.PrintAll("App.Terminate()");
        }
示例#19
0
        public App()
        {
            // Get locale information
            UpdateLocale();
            InitializeComponent();
            var alarmModel = new AlarmModel();

            firstPage = (MainPage)AlarmPageController.GetInstance(AlarmPages.MainPage, new MainPageModel());
            MainPage  = new NavigationPage(firstPage);
        }
 private void listBoxAlarms_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBoxAlarms.SelectedItem != null)
     {
         AlarmModel selected = (AlarmModel)listBoxAlarms.SelectedItem;
         lblName.Text        = $"Name: {selected.Name}";
         lblExpires.Text     = $"Set for: {selected.AlarmDateTime}";
         textBoxMessage.Text = selected.Message;
     }
 }
示例#21
0
 /// <summary>
 /// 只拿到 未确认 未恢复 的 最新 告警
 /// </summary>
 /// <param name="id">线路Id</param>
 /// <param name="alarmType"></param>
 /// <returns></returns>
 public AlarmModel GetLastestAlarm(int id, AlarmType alarmType)
 {
     using (MySqlConnection conn = new MySqlConnection(_connStr))
     {
         string     sql        = $"select * from tb_alarm WHERE LineID = '{id}' AND Type = { Convert.ToInt32(alarmType)} AND Confirm = 0  AND ISNULL(RecoverDate)";
         var        alarmQuery = conn.Query <AlarmModel>(sql);
         AlarmModel alarm      = alarmQuery.FirstOrDefault();
         return(alarm);
     }
 }
        /// <summary>
        /// Delete current AlarmRecord
        /// </summary>
        public void Dismiss()
        {
            AlarmNativeHandler.StopSound();
            AlarmNativeHandler.StopVibration();

            if (_alarmRecord != null)
            {
                AlarmModel.DeleteAlarm(_alarmRecord);
            }
        }
示例#23
0
 /// <summary>
 /// Adds the time types to the alarm model based on the historic alarm passed in.
 /// </summary>
 private void AddTimeTypes(HistoricalAlarm alarm, AlarmModel alarmModel)
 {
     alarmModel.TimeTypes = new List <TimeType>();
     if (alarm.TimeType1 != null)
     {
         var tt = PemsEntities.TimeTypes.FirstOrDefault(x => x.TimeTypeId == alarm.TimeType1);
         if (tt != null)
         {
             alarmModel.TimeTypes.Add(new TimeType {
                 Description = tt.TimeTypeDesc, Id = tt.TimeTypeId
             });
         }
     }
     if (alarm.TimeType2 != null)
     {
         var tt = PemsEntities.TimeTypes.FirstOrDefault(x => x.TimeTypeId == alarm.TimeType2);
         if (tt != null)
         {
             alarmModel.TimeTypes.Add(new TimeType {
                 Description = tt.TimeTypeDesc, Id = tt.TimeTypeId
             });
         }
     }
     if (alarm.TimeType3 != null)
     {
         var tt = PemsEntities.TimeTypes.FirstOrDefault(x => x.TimeTypeId == alarm.TimeType3);
         if (tt != null)
         {
             alarmModel.TimeTypes.Add(new TimeType {
                 Description = tt.TimeTypeDesc, Id = tt.TimeTypeId
             });
         }
     }
     if (alarm.TimeType4 != null)
     {
         var tt = PemsEntities.TimeTypes.FirstOrDefault(x => x.TimeTypeId == alarm.TimeType4);
         if (tt != null)
         {
             alarmModel.TimeTypes.Add(new TimeType {
                 Description = tt.TimeTypeDesc, Id = tt.TimeTypeId
             });
         }
     }
     if (alarm.TimeType5 != null)
     {
         var tt = PemsEntities.TimeTypes.FirstOrDefault(x => x.TimeTypeId == alarm.TimeType5);
         if (tt != null)
         {
             alarmModel.TimeTypes.Add(new TimeType {
                 Description = tt.TimeTypeDesc, Id = tt.TimeTypeId
             });
         }
     }
 }
        private void btnDeleteAlarm_Click(object sender, EventArgs e)
        {
            AlarmModel selectedAlarm = (AlarmModel)listBoxAlarms.SelectedItem;

            if (selectedAlarm != null)
            {
                _alarms.Remove(selectedAlarm);
                _config.Connection.DeleteAlarm(selectedAlarm);
                UpdateForm();
            }
        }
示例#25
0
 public bool IsTriggeredAlarm(AlarmModel alarm, BatteryModel battery)
 {
     if (alarm.AlarmTrigger == battery.Value || alarm.AlarmTrigger >= battery.Value)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
示例#26
0
 public void Validate(AlarmModel schedule)
 {
     if (schedule.Track == null)
     {
         throw new PimpException("Please supply a track.");
     }
     if (schedule.EnabledDays.Count == 0)
     {
         throw new PimpException("Please choose at least one day.");
     }
 }
 public void AddAlarm(AlarmModel alarm)
 {
     try
     {
         db.AlarmRecords.InsertOne(alarm);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#28
0
 public void InsertAlarm(AlarmModel alarm)
 {
     try
     {
         var sql = $"INSERT INTO tb_alarm(IP,Confirm,Type,LineName,OrganName,LineId,OrganId,State,FirstTime,LastTime,AlarmCount)VALUES('{alarm.IP}',{Convert.ToInt32(alarm.Confirm)},{Convert.ToInt32(alarm.Type)},'{alarm.LineName}','{alarm.OrganName}',{alarm.LineId},{alarm.OrganId},{Convert.ToInt32(alarm.State)},'{alarm.FirstTime.ToString("yyyy-MM-dd HH:mm:ss")}','{alarm.LastTime.ToString("yyyy-MM-dd HH:mm:ss")}',{alarm.AlarmCount});";
         AddSql(sql);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#29
0
        public ActionResult Edit(Guid id, AlarmModel Model)
        {
            var alarm = DB.Alarms.Find(id);

            alarm.Begin  = Model.Begin;
            alarm.End    = Model.End;
            alarm.Hint   = Model.Hint;
            alarm.Remind = Model.Remind;
            alarm.Title  = Model.Title;
            DB.SaveChanges();
            return(RedirectToAction("Index", "Alarm"));
        }
示例#30
0
        public object FindFilteredOrderedAlarmsByStructCount([FromUri] int structId, [FromBody] AlarmModel_1 alarm_1)
        {
            try
            {
                int count = 0;
                // 分解告警等级
                string[]   levels    = alarm_1.FilteredLevel.Split(',');
                var        levelList = levels.Select(s => Convert.ToInt32(s)).ToList();
                AlarmModel alarm     = new AlarmModel
                {
                    FilteredDeviceType = alarm_1.FilteredDeviceType,
                    FilteredStatus     = alarm_1.FilteredStatus,
                    FilteredLevel      = levelList,
                    FilteredStartTime  = alarm_1.FilteredStartTime,
                    FilteredEndTime    = alarm_1.FilteredEndTime,
                    OrderedDevice      = alarm_1.OrderedDevice,
                    OrderedLevel       = alarm_1.OrderedLevel,
                    OrderedTime        = alarm_1.OrderedTime
                };
                int roleId = 5; // 5-"普通用户"角色(Client).
                if (Request.Properties.ContainsKey("AuthorizationInfo"))
                {
                    var info = Request.Properties["AuthorizationInfo"] as AuthorizationInfo;
                    roleId = info != null && info.RoleId != null ? (int)info.RoleId : 5;
                }

                using (SecureCloud_Entities entity = new SecureCloud_Entities())
                {
                    var objAlarm  = new Alarm();
                    var condition = objAlarm.GetFilteredOrderedConditionOfAlarm(alarm, roleId);

                    DataTable dt = objAlarm.GetFilteredOrderedAlarmsByStruct(structId, condition);
                    foreach (var dataRow in dt.AsEnumerable())
                    {
                        if (dataRow.Field <int>("StructId") == structId)
                        {
                            count++;
                        }
                    }
                    return(new AlarmCount {
                        Count = count
                    });
                }
            }
            catch (Exception e)
            {
                return(new AlarmCount {
                    Count = 0
                });
                //throw e;
            }
        }
        private void UpdateLables()
        {
            if (listBoxMissedAlarms.SelectedItem != null)
            {
                AlarmModel selected = (AlarmModel)listBoxMissedAlarms.SelectedItem;
                TimeSpan   overdue  = DateTime.Now - selected.AlarmDateTime;

                lblName.Text        = $"Name: {selected.Name}";
                lblOverdue.Text     = $"Overdue: {overdue.Days} Days {overdue.Hours} Hours {overdue.Minutes} Minutes {overdue.Seconds} Seconds";
                lblExpires.Text     = $"Set for: {selected.AlarmDateTime}";
                textBoxMessage.Text = selected.Message;
            }
        }
示例#32
0
 public AlarmModel SetAlarm(AlarmModel model)
 {
     try
     {
         return new AlarmModel()
         {
             AlarmName = model.AlarmName,
             AlarmTrigger = model.AlarmTrigger,
             ImagePath = model.ImagePath,
             VoicePath = model.VoicePath,
         };
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#33
0
 private void TriggerAlarmSound(AlarmModel alarmModel)
 {
     try
     {
         _soundPlayer.SoundLocation = alarmModel.VoicePath;
         _soundPlayer.Play();
     }
     catch (Exception)
     {
         _soundPlayer.SoundLocation = Constant.DefaultSoundPath;
         _soundPlayer.Play();
     }
 }
示例#34
0
        public BatteryAlarmForm()
        {
            InitializeComponent();

            //Registry Model
            _regModel = new RegistryModel()
            {
                KeyName = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run",
                ValueName = "ARTHA.BatteryAlarm.AutoRun",
                Value = "C:\\Program Files\\ARTHA.BatteryAlarm\\ARTHA.BatteryAlarm.exe\" -autorun",
                RegValueKind = RegistryValueKind.String
            };

            //registry Factory Instansiate
            _regFactory = new RegistryFactory(_regModel);

            //Checked or not
            if (_regFactory.IsRegistryExist())
            {
                chkAutorun.Checked = true;
            }
            else
            {
                chkAutorun.Checked = false;
            }

            // general seting for xml model and factory
            _xmlFactory = new XmlValueFactory(XmlConstant.XmlFileLocation);
            _xmlModel = new XmlModel()
            {
                ElementName = XmlConstant.XmlElementName,
                AttrKeyName = XmlConstant.XmlKey,
                AttrValueName = XmlConstant.XmlValue
            };

            this.ShowInTaskbar = false;

            //sound Player
            _soundPlayer = new SoundPlayer();

            //timer
            _timer = new Timer();
            _timer.Tick += new EventHandler(BatteryTimer_Tick);
            _timer.Interval = Constant.DefaultIntervalTimer;
            _timer.Start();

            //instansiate service and model
            _batteryService = new BatteryService();
            _alarmService = new AlarmService();
            _alarmModel = new AlarmModel();
            _batteryModel = new BatteryModel();

            //populate Batery Level combobox
            cmbBateryLevel.DataSource = PopulateComboBox(Constant.MinBateryLevel, Constant.MaxBateryLevel, Constant.MultipleIterationValue);

            InitializeAlarmTrigger();

            //button close Event Handler
            btnMinimize.Click += new EventHandler(btnMinimize_Click);

            //button open file event Handler
            btnOpenFile.Click += new EventHandler(btnOpenFile_Click);

            //button save setting event handler
            btnSaveSetting.Click += new EventHandler(btnSaveSetting_Click);

            //label Warning
            LabelTitle.Text = Constant.AppName;
            LabelTitle.AutoSize = Constant.LabelSet.AutoSize;
            LabelTitle.Font = Constant.LabelSet.Font;

            //button Stop Sound Event Handler
            btnStopSound.Click += new EventHandler(btnStopSound_Click);

            //label prosen
            label2.Text = Constant.Prosen;
        }