///<summary>Inserts one AlertItem into the database. Returns the new priKey.</summary> public static long Insert(AlertItem alertItem) { if (DataConnection.DBtype == DatabaseType.Oracle) { alertItem.AlertItemNum = DbHelper.GetNextOracleKey("alertitem", "AlertItemNum"); int loopcount = 0; while (loopcount < 100) { try { return(Insert(alertItem, true)); } catch (Oracle.ManagedDataAccess.Client.OracleException ex) { if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")) { alertItem.AlertItemNum++; loopcount++; } else { throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return(Insert(alertItem, false)); } }
private void AddItemExcute() { INewItemView view = this.newItemsViewModel.ActiveNewItemView as INewItemView; NewItemModelBase model = this.viewDictionary[view]; AlertItem item = model.ToAlertItem(Settings.Default.DefaultAlertBeforeMinutes); this.dataService.Items.Add(item); int index = this.dataService.Branches.IndexOf(model.NoticeBranch); if (index > 0) { this.dataService.Branches.Move(index, 0); } else if (index < 0) { this.dataService.Branches.Add(model.NoticeBranch); } if (Settings.Default.ResetCountDownData) { model.Clean(); } }
private void LoadData() { if (!File.Exists(DataFileName)) { return; } string [] line; using (StreamReader sr = new StreamReader(DataFileName)) { sr.ReadLine(); sr.ReadLine(); while (!sr.EndOfStream) { line = sr.ReadLine().Split('|'); IAlertItem item = new AlertItem { Time = DateTime.Parse(line[0]), AlertTime = DateTime.Parse(line[1]), Notice = line[2] }; this.dataService.Items.Add(item); } } if (Settings.Default.Branches != null) { for (int i = 0; i < Settings.Default.Branches.Count; i++) { this.dataService.Branches.Add(Settings.Default.Branches[i]); } } }
public async Task <IActionResult> Edit(int id, [Bind("AlertId,AlertTitel,InfoText1,InfoText2,DateOfCreation,DateOfExpiry")] AlertItem alertItem) { if (id != alertItem.AlertId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(alertItem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlertItemExists(alertItem.AlertId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(alertItem)); }
private object GetEditObject() { if (this.ValidateInput()) { AlertItem model = this._AlertFacade.CreateNewAlertItem(); //if (ViewState["currentPageAction"] != null && (string)ViewState["currentPageAction"] == PageActionType.Update) //{ // model.ItemSequence = (string)ViewState["editItemPK"]; //} //else //{ model.ItemSequence = this.txtAlertItemEdit.Text; //} model.AlertType = this.txtAlertItemEdit.Text; model.Description = string.IsNullOrEmpty(this.txtAlertItemDescEdit.Text) ? txtAlertItemEdit.Text : this.txtAlertItemDescEdit.Text; model.MailSubject = this.txtAlertItemEdit.Text; model.MailContent = " "; model.MaintainUser = this.GetUserCode(); model.MaintainDate = FormatHelper.TODateInt(DateTime.Now.ToShortDateString()); model.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now); return(model); } else { return(null); } }
protected void cmdSave_ServerClick(object sender, System.EventArgs e) { AlertItem model = (AlertItem)GetEditObject(); AlertItem oldModel = new AlertItem(); oldModel.ItemSequence = txtOldAlertItemEdit.Text; if (model != null) { try { this.DataProvider.BeginTransaction(); _AlertFacade.DeleteAlertItem(oldModel); this._AlertFacade.AddAlertItem(model); this.DataProvider.CommitTransaction(); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); throw ex; } this.RequestData(); this._ButtonHelper.PageActionStatusHandle(PageActionType.Save); } //this.txtAlertItemDescEdit.Text = this.languageComponent1.GetString(this.ddlAlertTypeEdit.SelectedValue); }
//private void InitFirstClassList() //{ // DropDownListBuilder builder = new DropDownListBuilder(this.ddlItemFirstClass); // builder.HandleGetObjectList = new GetObjectListDelegate((new ItemFacade(this.DataProvider)).GetItemFirstClass); // builder.Build("FirstClass", "FirstClass"); // this.ddlItemFirstClass.Items.Insert(0, new ListItem("", "")); // this.ddlItemFirstClass.SelectedIndex = 0; // this.ddlItemSecondClass.Items.Insert(0, new ListItem("", "")); // this.ddlItemSecondClass.SelectedIndex = 0; //} //private void InitSecondClassList() //{ // this.ddlItemSecondClass.Items.Clear(); // ItemFacade itemFacade = new ItemFacade(this.DataProvider); // object[] itemClasses = itemFacade.GetItemSecondClass(FormatHelper.CleanString(this.ddlItemFirstClass.SelectedValue)); // if (itemClasses == null) // { // this.ddlItemSecondClass.Items.Insert(0, new ListItem("", "")); // this.ddlItemSecondClass.SelectedIndex = 0; // return; // } // foreach (ItemClass itemClass in itemClasses) // { // this.ddlItemSecondClass.Items.Add(new ListItem(itemClass.SecondClass, itemClass.SecondClass)); // } // this.ddlItemSecondClass.Items.Insert(0, new ListItem("", "")); // this.ddlItemSecondClass.SelectedIndex = 0; //} private void InitAlertItemInfo() { AlertItem obj = (AlertItem)_AlertFacade.GetAlertItem(Request["ITEMSEQUENCE"]); this.txtAlertItemSequence.Text = obj.ItemSequence; this.txtAlertItemDesc.Text = obj.Description; //this.txtAlertMailSubject.Text = obj.MailSubject; }
protected void cmdSaveMailSubject_ServerClick(object sender, System.EventArgs e) { if (ValidateSubjectInput()) { AlertItem obj = (AlertItem)_AlertFacade.GetAlertItem(Request["ITEMSEQUENCE"]); //obj.MailSubject = this.txtAlertMailSubject.Text.Trim(); _AlertFacade.UpdateAlertItem(obj); } }
public void AlertItemNoticeValidationTest() { AlertItem item = new AlertItem(); Assert.IsNull(item.Notice); Assert.AreNotEqual("", item.Validate("Notice")); item.Notice = "Test Alert"; Assert.AreEqual("", item.Validate("Notice")); }
public void AlertItemAlertTimeValidationTest() { AlertItem item = new AlertItem(); Assert.IsNotNull(item.AlertTime); Assert.AreEqual("", item.Validate("AlertTime")); item.AlertTime = DateTime.Now; Assert.AreEqual("", item.Validate("AlertTime")); }
public void GeneralAlertItemTest() { AlertItem item = new AlertItem(); item.Time = DateTime.Now; item.AlertTime = DateTime.Now.AddHours(1); item.Notice = "Test Alert"; item.HasAlert = false; Assert.AreEqual("", item.Validate()); }
public async Task <IActionResult> Create([Bind("AlertId,AlertTitel,InfoText1,InfoText2,DateOfCreation,DateOfExpiry")] AlertItem alertItem) { if (ModelState.IsValid) { _context.Add(alertItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(alertItem)); }
public IActionResult Create([FromBody] AlertItem item) { if (item == null) { return(BadRequest()); } _context.AlertItems.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetAlert", new { id = item.Id }, item)); }
private void InitNoticeInfo() { AlertItem item = (AlertItem)this._AlertFacade.GetAlertItem(Request["ITEMSEQUENCE"]); this.txtAlertItemSequence.Text = item.ItemSequence; this.txtAlertItemDesc.Text = item.Description; //初始化项次设定 object[] alertErrors = this._AlertFacade.GetAlertDirectPasses(item.ItemSequence); if (alertErrors != null && alertErrors.Length > 0) { this.ddlItemType.SelectedValue = ((AlertDirectPass)alertErrors[0]).ItemType; this.txtBaseOutPut.Text = ((AlertDirectPass)alertErrors[0]).BaseOutput.ToString(); this.rblTimeDimensionGroup.SelectedValue = ((AlertDirectPass)alertErrors[0]).TimeDimension; this.txtAlertStandard.Text = ((AlertDirectPass)alertErrors[0]).AlertValue.ToString(); //产生预警通告 if (((AlertDirectPass)alertErrors[0]).GenerateNotice == "Y") { this.chbGenerateNotice.Checked = true; this.chbLinePause.Enabled = true; } else { this.chbGenerateNotice.Checked = false; this.chbLinePause.Enabled = false; } //发送邮件 if (((AlertDirectPass)alertErrors[0]).SendMail == "Y") { this.chbSendMail.Checked = true; } else { this.chbSendMail.Checked = false; } //停线控制 if (((AlertDirectPass)alertErrors[0]).LinePause == "Y") { this.chbLinePause.Checked = true; } else { this.chbLinePause.Checked = false; } this.ddlItemType.SelectedValue = ((AlertDirectPass)alertErrors[0]).ItemType; } }
protected void cmdAdd_ServerClick(object sender, System.EventArgs e) { AlertItem model = (AlertItem)GetEditObject(); if (model != null) { this._AlertFacade.AddAlertItem((AlertItem)model); this.RequestData(); this._ButtonHelper.PageActionStatusHandle(PageActionType.Add); } //this.txtAlertItemDescEdit.Text = this.languageComponent1.GetString(this.ddlAlertTypeEdit.SelectedValue); }
private string[] FormatExportRecord(object obj) { AlertItem model = (AlertItem)obj; return(new string[] { model.ItemSequence, model.Description.ToString(), this.languageComponent1.GetString(model.AlertType), model.GetDisplayText("MaintainUser"), FormatHelper.ToDateString(model.MaintainDate), FormatHelper.ToTimeString(model.MaintainTime) }); }
public static void Add(string url) { var alert = m_Alert.Value.AlertPendingList.SingleOrDefault(i => i.Url == url); if (alert == null) { alert = new AlertItem() { Url = url }; m_Alert.Value.AlertPendingList.Add(alert); } alert.AlertCount++; }
private void InitNoticeInfo() { AlertItem item = (AlertItem)this._AlertFacade.GetAlertItem(Request["ITEMSEQUENCE"]); this.txtAlertItemSequence.Text = item.ItemSequence; this.txtAlertItemDesc.Text = item.Description; //初始化项次设定 object[] alertOQCNG = this._AlertFacade.GetAlertOQCNGs(item.ItemSequence); if (alertOQCNG != null && alertOQCNG.Length > 0) { string errorCode = ""; foreach (AlertOQCNG error in alertOQCNG) { errorCode += error.ErrorCode + ","; } errorCode = errorCode.TrimEnd(','); this.ddlItemType.SelectedValue = ((AlertOQCNG)alertOQCNG[0]).ItemType; this.txtErrorCode.Text = errorCode; this.txtAlertStandard.Text = ((AlertOQCNG)alertOQCNG[0]).AlertValue.ToString(); this.timeShiftBeginTimeEdit.Text = FormatHelper.ToTimeString(((AlertOQCNG)alertOQCNG[0]).StartTime); this.datStartDateWhere.Text = FormatHelper.ToDateString(((AlertOQCNG)alertOQCNG[0]).StartDate); //产生预警通告 if (((AlertOQCNG)alertOQCNG[0]).GenerateNotice == "Y") { this.chbGenerateNotice.Checked = true; } else { this.chbGenerateNotice.Checked = false; } //发送邮件 if (((AlertOQCNG)alertOQCNG[0]).SendMail == "Y") { this.chbSendMail.Checked = true; } else { this.chbSendMail.Checked = false; } this.ddlItemType.SelectedValue = ((AlertOQCNG)alertOQCNG[0]).ItemType; } }
public MainView() : base("MainView", null) { IMvxMessenger messenger = Mvx.Resolve <IMvxMessenger>(); _alertToken = messenger.SubscribeOnMainThread <AlertMessage>(OnAlertMessage); _titleToken = messenger.Subscribe <ViewTitleMessage>(OnViewTitleMessage); AlertItem.Init(); AlertItem.Alerts[AlertType.notification].Button.Clicked += (sender, e) => { ViewModel.NavigateToAsync(2); }; AlertItem.Alerts[AlertType.location].Button.Clicked += (sender, e) => { ViewModel.NavigateToAsync(3); }; HamburgerItem.Init(); HamburgerItem.Button.Clicked += (sender, e) => { PerformTableTransition(); }; }
///<summary>Inserts one AlertItem into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(AlertItem alertItem) { if (DataConnection.DBtype == DatabaseType.MySql) { return(InsertNoCache(alertItem, false)); } else { if (DataConnection.DBtype == DatabaseType.Oracle) { alertItem.AlertItemNum = DbHelper.GetNextOracleKey("alertitem", "AlertItemNum"); //Cacheless method } return(InsertNoCache(alertItem, true)); } }
///<summary>Updates one AlertItem in the database.</summary> public static void Update(AlertItem alertItem) { string command = "UPDATE alertitem SET " + "ClinicNum = " + POut.Long(alertItem.ClinicNum) + ", " + "Description = '" + POut.String(alertItem.Description) + "', " + "Type = " + POut.Int((int)alertItem.Type) + ", " + "Severity = " + POut.Int((int)alertItem.Severity) + ", " + "Actions = " + POut.Int((int)alertItem.Actions) + ", " + "FormToOpen = " + POut.Int((int)alertItem.FormToOpen) + ", " + "FKey = " + POut.Long(alertItem.FKey) + ", " + "ItemValue = '" + POut.String(alertItem.ItemValue) + "' " + "WHERE AlertItemNum = " + POut.Long(alertItem.AlertItemNum); Db.NonQ(command); }
protected DataRow GetGridRow(object obj) { AlertItem model = (AlertItem)obj; DataRow row = this.DtSource.NewRow(); row["AlertItemSequence"] = model.ItemSequence; row["AlertItemDesc"] = model.Description; row["AlertItemType"] = this.languageComponent1.GetString(model.AlertType); row["AlertMaintainUser"] = model.GetDisplayText("MaintainUser"); row["AlertMaintainDate"] = FormatHelper.ToDateString(model.MaintainDate); row["AlertMaintainTime"] = FormatHelper.ToTimeString(model.MaintainTime); return(row); }
private void InitNoticeInfo() { AlertItem item = (AlertItem)this._AlertFacade.GetAlertItem(Request["ITEMSEQUENCE"]); this.txtAlertItemSequence.Text = item.ItemSequence; this.txtAlertItemDesc.Text = item.Description; txtSSCodeWhere.TextBox.Attributes.Add("readonly", "readonly"); //初始化项次设定 object[] alertLinePauses = this._AlertFacade.GetAlertLinePauses(item.ItemSequence); if (alertLinePauses != null && alertLinePauses.Length > 0) { string SSCode = ""; foreach (AlertLinePause error in alertLinePauses) { SSCode += error.SSCode + ","; } SSCode = SSCode.TrimEnd(','); this.txtAlertStandard.Text = ((AlertLinePause)alertLinePauses[0]).AlertValue.ToString(); this.txtSSCodeWhere.Text = SSCode; this.ddlOPCode.SelectedValue = ((AlertLinePause)alertLinePauses[0]).OPCode; //产生预警通告 if (((AlertLinePause)alertLinePauses[0]).GenerateNotice == "Y") { this.chbGenerateNotice.Checked = true; } else { this.chbGenerateNotice.Checked = false; } //发送邮件 if (((AlertLinePause)alertLinePauses[0]).SendMail == "Y") { this.chbSendMail.Checked = true; } else { this.chbSendMail.Checked = false; } } }
private void SetEditObject(object obj) { AlertItem model = (AlertItem)obj; if (model == null) { //this.ddlAlertTypeEdit.SelectedIndex = 0; //this.txtAlertItemDescEdit.Text = string.Empty; this.txtAlertItemDescEdit.Text = string.Empty; this.txtAlertItemEdit.Text = string.Empty; } else { this.txtAlertItemDescEdit.Text = model.Description; this.txtAlertItemEdit.Text = model.AlertType; } }
public override AlertItem ToAlertItem(int beforeAlertMinutes) { AlertItem item = new AlertItem(); item.Time = this.date.AddHours(this.hours).AddMinutes(this.minutes); item.HasAlert = false; if (string.IsNullOrWhiteSpace(this.Notice)) { item.Notice = string.Format(Resources.OnlyNoticeBranch, this.NoticeBranch); } else { item.Notice = string.Format(Resources.NoticeFormat, this.NoticeBranch, this.Notice); } item.AlertTime = item.Time.AddMinutes(0 - beforeAlertMinutes); return(item); }
public void PropertiesWithNotification() { DateTime now = DateTime.Now; AlertItem item = new AlertItem(); Assert.AreEqual(false, item.HasAlert); AssertHelper.PropertyChangedEvent(item, x => x.Time, () => item.Time = now); Assert.AreEqual(now, item.Time); AssertHelper.PropertyChangedEvent(item, x => x.AlertTime, () => item.AlertTime = now.AddHours(1)); Assert.AreEqual(now.AddHours(1), item.AlertTime); AssertHelper.PropertyChangedEvent(item, x => x.Notice, () => item.Notice = "Test Alert"); Assert.AreEqual("Test Alert", item.Notice); item.HasAlert = true; Assert.AreEqual(true, item.HasAlert); }
protected List <AlertItem> parseAlerts(string data) { List <AlertItem> res = new List <AlertItem>(); string regexp = "(?:<tr id=\"(.*?)\" class=\"ACTIVE\">)(.*?)(?:<\\/tr>)"; string regexp2 = "(?:alert-type\" colspan=\"2\"><a href=\"[^\"]*\">)(.*?)(?:<\\/a>)"; string regexp3 = "Feed<\\/a> <a href=\"([^\"]*)\">(.*?)<\\/a>"; MatchCollection mc = Regex.Matches(data, regexp, RegexOptions.IgnoreCase | RegexOptions.Singleline); int cnt = 0; foreach (Match m in mc) { AlertItem ai = new AlertItem(); ai.id = m.Groups[1].Value; if (m.Groups[2].Value.IndexOf("Feed") > 0) { ai.type = "feed"; } else { ai.type = "email"; } MatchCollection rrow = Regex.Matches(m.Groups[2].Value, regexp2); if (rrow.Count > 0) { ai.term = rrow[0].Groups[1].Value; } rrow = Regex.Matches(m.Groups[2].Value, regexp3); if (rrow.Count > 0) { ai.url = rrow[0].Groups[1].Value; } cnt++; res.Add(ai); } return(res); }
private async Task MarkAsRead() { if (AlertItem.Alert.Read == null) { mPlatformService.ShowNetworkIndicator(); mProgressDialogService.ShowProgressDialog(); DateTimeOffset read = DateTimeOffset.Now; var response = await mApiService.SettingAlert(AlertItem.Alert.Id, read, null); mPlatformService.HideNetworkIndicator(); mProgressDialogService.HideProgressDialog(); if (response.StatusCode == System.Net.HttpStatusCode.OK || response.StatusCode == System.Net.HttpStatusCode.NoContent) { AlertItem.Alert.Read = read; AlertItem.RaisePropertyChanged("IsRead"); AlertItem.AlertsVM.RaisePropertyChanged("Title"); } } }
public IActionResult Update(long id, [FromBody] AlertItem item) { if (item == null || item.Id != id) { return(BadRequest()); } var alert = _context.AlertItems.FirstOrDefault(t => t.Id == id); if (alert == null) { return(NotFound()); } alert.IsComplete = item.IsComplete; alert.Name = item.Name; _context.AlertItems.Update(alert); _context.SaveChanges(); return(new NoContentResult()); }
///<summary>Converts a DataTable to a list of objects.</summary> public static List <AlertItem> TableToList(DataTable table) { List <AlertItem> retVal = new List <AlertItem>(); AlertItem alertItem; foreach (DataRow row in table.Rows) { alertItem = new AlertItem(); alertItem.AlertItemNum = PIn.Long(row["AlertItemNum"].ToString()); alertItem.ClinicNum = PIn.Long(row["ClinicNum"].ToString()); alertItem.Description = PIn.String(row["Description"].ToString()); alertItem.Type = (OpenDentBusiness.AlertType)PIn.Int(row["Type"].ToString()); alertItem.Severity = (OpenDentBusiness.SeverityType)PIn.Int(row["Severity"].ToString()); alertItem.Actions = (OpenDentBusiness.ActionType)PIn.Int(row["Actions"].ToString()); alertItem.FormToOpen = (OpenDentBusiness.FormType)PIn.Int(row["FormToOpen"].ToString()); alertItem.FKey = PIn.Long(row["FKey"].ToString()); alertItem.ItemValue = PIn.String(row["ItemValue"].ToString()); retVal.Add(alertItem); } return(retVal); }
protected void getList() { List<AlertItem> AlertItems = new List<AlertItem>(); try { using (SPSite site = new SPSite(SPContext.Current.Web.Url)) { using (SPWeb web = site.OpenWeb()) { SPList list = (SPList)web.Lists["AlertsList"]; for (int i = 0; i < list.ItemCount; i++) { string title = Convert.ToString(list.Items[i]["Title"]); string impact = Convert.ToString(list.Items[i]["Impact"]); string desc = Convert.ToString(list.Items[i]["Description"]); string pintotop = Convert.ToString(list.Items[i]["Pin to top"]); string modifyedDate = Convert.ToString(list.Items[i]["Modified"]); AlertItem myItem = new AlertItem(title, desc, impact, pintotop, modifyedDate); AlertItems.Add(myItem); } AlertItems.Sort((x, y) => DateTime.Compare(x.Created, y.Created)); AlertItems.Reverse(); //AlertItems.Sort((a, b) => a.ToString().CompareTo(b.ToString())); foreach (AlertItem item in AlertItems) { if (item.pinToTop) item.addLi(AlertItemsHere); } //do red ones foreach (AlertItem item in AlertItems) { if (!item.pinToTop) if (item.impact == "High") item.addLi(AlertItemsHere); } //do yellow ones foreach (AlertItem item in AlertItems) { if (!item.pinToTop) if (item.impact == "Medium") item.addLi(AlertItemsHere); } //do green ones foreach (AlertItem item in AlertItems) { if (!item.pinToTop) if (item.impact == "Low") item.addLi(AlertItemsHere); } } } } catch (Exception e) { Label lblError = new Label(); this.Controls.Add(lblError); if (e.InnerException != null) lblError.Text = "An error has occured reading from the selected list. Please check the Navi properties. " + e.InnerException.ToString(); } }