protected void Page_Load(object sender, EventArgs e) { _user = this.LoggedInUserData(); if (this.IsPostBack) { return; } this.ddlGroup.Enabled = false; this.butApprove.Enabled = false; this.butSave.Enabled = false; this.butSubmit.Enabled = false; this.populateCenterDDL(); var repo = new DataRepo(); if (this.ClientQueryString.Contains("dg") && (this.dailyGroupId == 0)) //Manager coming from Approval Email { int dailyGroupId = int.Parse(cQCryptographyHelper.DecryptString(this.Request.QueryString["dg"])); _Session.SetVar("DAILY_GROUP_ID", dailyGroupId); } this.dailyGroupId = int.Parse(_Session.GetVar("DAILY_GROUP_ID", 0).ToString()); string role = _user.Role.ToLower(); if (this.dailyGroupId > 0) //Admin or Manager coming from Approval Email { DailyGroupDTO dailyGroup = repo.getDailyGroup(this.dailyGroupId); this.ddlCenter.SelectedValue = dailyGroup.CenterId.ToString(); this.populateGroupDDL(dailyGroup.CenterId); this.ddlGroup.SelectedValue = dailyGroup.GroupId.ToString(); this.bindData(); this.pnlCenter.Enabled = false; this.ddlGroup.Enabled = ((role == "admin" || role == "manager") && (!this.ClientQueryString.Contains("dg"))); } else { switch (role) { case "manager": var centerId = repo.getCentersByManagerIdLookup(_user.Id).FirstOrDefault().Key; this.ddlCenter.SelectedValue = centerId.ToString(); this.pnlCenter.Enabled = false; this.populateGroupDDL(centerId); this.ddlGroup.Enabled = true; break; } } }
public void Load(DataRepo repo, Action <string> log, IProtocalHostConfig hostConfig) { this._repo = repo; this._log = log; this.HostConfig = hostConfig; _task = Task.Factory.StartNew(TaskBody, _cts.Token); }
static void DeleteAddress() { DataRepo data = new DataRepo(); int response = data.DeleteAddress(); Console.WriteLine($"Response: {response}"); }
public void TestDB() { DataRepo.InitializeDB(); bool hasRecord = false; DataRepo.AddData("My Friends Name is Goof", "Jenny"); DataRepo.AddData("My Friends Name is Goof", "Jess"); DataRepo.AddData("My Friends Name is Goof", "Joey"); List <TextFileModel> files = DataRepo.GetData(); foreach (TextFileModel file in files) { string name = file.NoteName; string text = file.NoteText; int id = file.NoteID; TestContext.WriteLine(id + " " + text + " " + name); if (id == 3) { if (text == "My Friends Name is Goof" && name == "Joey") { hasRecord = true; } } } Assert.AreEqual(true, hasRecord); }
public void TestUpdate() { bool hasRecord = false; DataRepo.UpdateData(2, "My new content"); List <TextFileModel> files = DataRepo.GetData(); foreach (TextFileModel file in files) { string name = file.NoteName; string text = file.NoteText; int id = file.NoteID; TestContext.WriteLine(id + " " + text + " " + name); if (id == 2) { if (text == "My new content" && name == "Jess") { hasRecord = true; } } } Assert.AreEqual(true, hasRecord); }
private void TimerHandler(object sender, EventArgs e) { try { DataRepo ObjRepo = new DataRepo(); // var DbPath=Properties.Settings.Default["DbPath"].ToString(); //search for exist task for done List <TaskModel> ObjTaskModelList = ObjRepo.SearchForToDo(this.DbPath); foreach (var item in ObjTaskModelList) { MainWindow ObjMainWindows = new MainWindow(); ObjMainWindows.TaskBodyTxt.Text = item.Content; ObjMainWindows.TxtTaskId.Text = item.TaskId; //ObjMainWindows.ShowDoneTimeLbl.Content= item.TimeDone; DateTime dt = new DateTime(); DateTime.TryParse(item.TimeDone, out dt); ObjMainWindows.dtPicker.Value = dt; //ObjMainWindows.Test.Visibility = Visibility.Hidden; //ObjMainWindows.ShowDoneTimeLbl.Visibility = Visibility.Visible; ObjMainWindows.Left = Convert.ToDouble(item.Leftposition); ObjMainWindows.Top = Convert.ToDouble(item.TopPosition); ObjMainWindows.Show(); } } catch (Exception ee) { EventLog windwosEventLog = new EventLog("Application"); windwosEventLog.WriteEntry(ee.Message, EventLogEntryType.Error); MessageBox.Show("Error In Proram load :" + ee.Message); } }
public Accdata(ParseProtocal protocol, DataRepo dataRepo, Action <string> log, Dev dev) : base(protocol, dataRepo, log) { _dev = dev; _fluxRunModels = dataRepo.GetKJ370_FluxRunModels(); _lastWriteTime = DateTime.Now; }
private void Close_Click(object sender, RoutedEventArgs e) { DataRepo ObjRepo = new DataRepo(); ObjRepo.SetHiddingTask(this.TxtTaskId.Text); this.Close(); }
public Base(ParseProtocal protocol, DataRepo dataRepo, Action <string> log) { Parent = protocol; DataRepo = dataRepo; Log = log; MineCode = Parent.HostConfig.MineProtocalConfig.MineCode; }
private void Complete_Click(object sender, RoutedEventArgs e) { try { DataRepo ObjRepo = new DataRepo(); TaskModel task = new TaskModel() { TimeDone = DateTimeConfig.ConvertPersianToUtc(dtPicker.Text), TaskId = TxtTaskId.Text, Content = TaskBodyTxt.Text, CreatedOn = DateTimeConfig.ConvertPersianToUtc(new PersianDateTime(DateTime.Now).ToLongDateTimeString()), Leftposition = this.Left.ToString(), TopPosition = this.Top.ToString() }; if (ObjRepo.SetComplete(task)) { this.Close(); } } catch (Exception ee) { using (EventLog eventLog = new EventLog("Application")) { eventLog.Source = "Application"; eventLog.WriteEntry("Error in Complete :" + ee.Message, EventLogEntryType.Error); MessageBox.Show(this, "Error In Complete :" + ee.Message); } } }
private void onMouseDown(object sender, MouseButtonEventArgs e) { DataRepo ObjRepo = new DataRepo(); try { this.DragMove(); double leftPosition = this.Left; double TopPosition = this.Top; if (TxtTaskId.Text != "") { ObjRepo.SaveWindowsPosition(leftPosition, TopPosition, TxtTaskId.Text); } } catch (Exception ee) { ObjRepo.CloseDatabase(); using (EventLog eventLog = new EventLog("Application")) { eventLog.Source = "Application"; eventLog.WriteEntry("Error in OnMouseDown :" + ee.Message, EventLogEntryType.Error); MessageBox.Show(this, "Error In onMouseDown :" + ee.Message); } } }
private void getGroupActivities() { var repo = new DataRepo(); if (this.dailyGroupId > 0) { _dailyGroupActivities = repo.getAllDailyGroupData(this.dailyGroupId); } else //Manager or Admin { int centerid = int.Parse(this.ddlCenter.SelectedValue); int groupId = 0; int.TryParse(this.ddlGroup.SelectedValue, out groupId); if ((centerid > 0) && (groupId > 0)) { _dailyGroupActivities = repo.getDailyGroupActivitiesByCenterIdGroupId(centerid, groupId); this.dailyGroupId = _dailyGroupActivities.DailyGroup.Id; } else { _dailyGroupActivities = null; this.dailyGroupId = 0; } } }
private void Apply_Click(object sender, RoutedEventArgs e) { DataRepo ObjRepo = new DataRepo(); try { if (dtPicker.Text == null || dtPicker.Text == string.Empty || TaskBodyTxt.Text == string.Empty) { WpfMessageBox message = new WpfMessageBox(); message.Top = this.Top; message.Left = this.Left; message.MessageTextLbl.Content = ".لطفا فیلد های اطلاعات را به صورت کامل وارد کنید"; message.Show(); } else { if (DateTimeConfig.Isdate(dtPicker.Text)) { string UtcDateTimeDone = DateTimeConfig.ConvertPersianToUtc(dtPicker.Text); TaskModel ObjTaskModel = new TaskModel() { TimeDone = DateTimeConfig.ConvertPersianToUtc(dtPicker.Text), TaskId = TxtTaskId.Text, Content = TaskBodyTxt.Text, CreatedOn = DateTimeConfig.ConvertPersianToUtc(new PersianDateTime(DateTime.Now).ToLongDateTimeString()), Leftposition = this.Left.ToString(), TopPosition = this.Top.ToString() }; bool resault; if (ObjTaskModel.TaskId == "") { resault = ObjRepo.InsertRecord(ObjTaskModel, Settings.Default.DbPath); } else { resault = ObjRepo.UpdateRecord(ObjTaskModel, Settings.Default.DbPath); } if (resault) { this.Close(); } } else { MessageBox.Show("فرمت تاریخ صحیح نمی باشد"); } } } catch (Exception ee) { using (EventLog eventLog = new EventLog("Application")) { eventLog.Source = "Application"; eventLog.WriteEntry("Error in Apply :" + ee.Message, EventLogEntryType.Error); } MessageBox.Show(this, "Error In Apply :" + ee.Message); } }
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { var dataRepo = new DataRepo(); container.Register(dataRepo); base.ApplicationStartup(container, pipelines); }
public Rtdata(ParseProtocal protocol, DataRepo dataRepo, Action <string> log, Dev dev) : base(protocol, dataRepo, log) { _dev = dev; RealDatas = new List <KJ370_RealDataModel>(); _startTime = DateTime.Now; FluxRealDataModels = new List <KJ370_FluxRealDataModel>(); }
public Dev(ParseProtocal protocol, DataRepo dataRepo, Action <string> log) : base(protocol, dataRepo, log) { AnalogPointModels = dataRepo.GetAnalogPointModels(); SwitchPointModels = dataRepo.GetSwitchPointModels(); ControlPointModels = dataRepo.GetControlPointModels(); EquipmentInfoModels = dataRepo.GetEquipmentInfoModels(); }
void Application_Start(object sender, EventArgs e) { DataRepo.LoadFromExcel(); // Code that runs on application startup GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
protected void butSave_Click(object sender, EventArgs e) { try { var repo = new DataRepo(); var child = new ChildrenDTO() { CenterId = int.Parse(this.ddlCenter.SelectedValue), GroupId = int.Parse(this.ddlGroup.SelectedValue), FirstName = this.FirstName.Text, LastName = this.LastName.Text, DOB = DateTime.Parse(this.DOB.Text), ExcludedDays = this.getExcludedScheduleDayNumbers(), EnrollmentDate = DateTime.Parse(this.EnrollmentDate.Text), DismisalDate = (string.IsNullOrEmpty(this.DismisalDate.Text)) ? (DateTime?)null : DateTime.Parse(this.DismisalDate.Text), isActive = this.chkIsActive.Checked, ParentFirstName = this.ParentFirstName.Text, ParentLastName = this.ParentLastName.Text, Address = this.Address.Text, City = this.City.Text, State = (this.State.SelectedIndex == 0) ? null : this.State.SelectedValue, Zip = this.Zip.Text, Phone = this.Phone.Text, Email = this.Email.Text, Notify = this.chkNotify.Checked }; int childId = 0; int.TryParse(this.hidChildId.Value, out childId); if (childId == 0) { repo.postChild(child); this.writeMessage("The child and their supporting contact was created successfully."); } else { repo.putChild(childId, child); this.writeMessage("The child and their supporting contact was updated successfully."); } this.butSave.Text = "Add"; this.hidChildId.Value = string.Empty; this.populateChildrenGrid(ViewState["SortExpression"].ToString(), this.gridViewSortDirection); } catch (CBSException ex) { this.writeMessage(ex); } catch (Exception ex) { this.writeMessage(ex); } }
public CityViewModel() { Cities = new ObservableCollection <CityModel>(); //Gather text files from the FileRepo retrieval DataRepo.GetCitiesFromJSONFile(); _allCities = DataRepo.AllCities; offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow); }
private void bindData() { var repo = new DataRepo(); this.gvCenters.DataSource = repo.getCenters(); this.gvCenters.DataBind(); this.clearFields(); }
private void populateManagerDDL() { var repo = new DataRepo(); this.ddlManager.DataSource = repo.getManagersAndAdminsLookup(); this.ddlManager.DataTextField = "Value"; this.ddlManager.DataValueField = "Key"; this.ddlManager.DataBind(); this.ddlManager.Items.Insert(0, new ListItem("[-- select one --]", string.Empty)); }
private void populateCenterDDL() { var repo = new DataRepo(); this.ddlCenter.DataSource = repo.getCenterLookup(); this.ddlCenter.DataTextField = "Value"; this.ddlCenter.DataValueField = "Key"; this.ddlCenter.DataBind(); this.ddlCenter.Items.Insert(0, new ListItem("[-- select one --]", "0")); }
private void populateAgeCategoryDDL() { var repo = new DataRepo(); this.ddlAgeCategory.DataSource = repo.getAgeCategoryLookup(); this.ddlAgeCategory.DataTextField = "Value"; this.ddlAgeCategory.DataValueField = "Key"; this.ddlAgeCategory.DataBind(); this.ddlAgeCategory.Items.Insert(0, new ListItem("[-- select one --]", string.Empty)); }
void OnDisconnected() { if (drepo != null) { drepo.OnTopicAdded -= OnTopicAdded; drepo.OnTopicRemoved -= OnTopicRemoved; drepo = null; } topicRecs.Clear(); }
protected void butSave_Click(object sender, EventArgs e) { try { var repo = new DataRepo(); var user = new UserDTO() { FirstName = this.FirstName.Text, LastName = this.LastName.Text, UserName = this.UserName.Text, Email = this.Email.Text, isActive = this.chkIsActive.Checked, Role = this.Role.SelectedValue }; int vipUserId = 0; int.TryParse(this.hidvipUserId.Value, out vipUserId); if (vipUserId == 0) { string username = repo.postUser(user); if (string.Compare(username, user.UserName, true) != 0) { this.writeMessage(string.Format("The user was created successfully. However, the user name {0} was already assigned, so the new user was assigned the similar user name, {1}.", this.UserName.Text, username), Enumerations.enumPageMessageTypes.ERROR); } else { this.writeMessage("The user was created successfully."); } } else { repo.putUser(vipUserId, user); this.writeMessage("The user was updated successfully."); } this.UserName.Enabled = true; this.butSave.Text = "Add"; this.hidvipUserId.Value = string.Empty; this.bindData(); } catch (CBSException ex) { this.writeMessage(ex); } catch (Exception ex) { this.writeMessage(ex); } }
public async Task LoadForecasts(float lat, float lon) { await DataRepo.GetWeekForecast(lat, lon); foreach (Forecast day in DataRepo.SelectedWeekForecast.Days) //each week forecast in datarepo.selectedweekforecast { WeekForecastModel forecast = new WeekForecastModel(day.Date, day.Sunrise, day.Sunset, day.Temp.Maximum, day.Temp.Minimum, day.Pressure, day.Humidity, day.Clouds, day.Pop, day.Weather[0].Description); Forecasts.Add(forecast); //Debug.WriteLine(forecast.Date); } }
private void bindData() { var repo = new DataRepo(); var centerId = int.Parse(this.ddlCenter.SelectedValue); this.clearFields(); this.enableControls(centerId > 0); this.gvGroups.DataSource = repo.getGroups(centerId); this.gvGroups.DataBind(); }
protected void gvUsers_RowDeleting(object sender, GridViewDeleteEventArgs e) { int vipUserId = int.Parse(this.gvUsers.DataKeys[e.RowIndex].Values["Id"].ToString()); var repo = new DataRepo(); repo.deleteUser(vipUserId); this.writeMessage("The user was deleted successfully."); this.bindData(); }
private void saveData() { int dailygroupId = this.dailyGroupId; var repo = new DataRepo(); List <DailyGroupActivityDTO> dailyGroupActivity = repo.getDailyGroupActivitiesByDailyGroupId(dailygroupId); foreach (RepeaterItem item in this.rptGroupActivities.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { PlaceHolder ph = (PlaceHolder)item.FindControl("phCell"); HiddenField hid = (HiddenField)item.FindControl("hidChildId"); int childId = int.Parse(hid.Value); LinkedList <Control> llControls = new LinkedList <Control>(); cWebHelper.FindControlRecursive(ph, "ddl", ref llControls, false, false); foreach (var ctl in llControls) { DropDownList ddl = (DropDownList)ctl; int activityId = int.Parse(ddl.ID.Split("_".ToCharArray())[1]); int activityValueId = int.Parse(ddl.SelectedValue); DailyGroupActivityDTO dailyGroupactivity = (from dga in dailyGroupActivity where dga.ChildId == childId && dga.ActivityId == activityId select dga).FirstOrDefault(); if (dailyGroupactivity == null) { dailyGroupactivity = new DailyGroupActivityDTO() { DailyGroupActivityId = 0, DailyGroupId = dailygroupId, ChildId = childId, ActivityId = activityId, ActivityValueId = activityValueId }; repo.postDailyGroupActivity(dailyGroupactivity); } else { repo.putDailyGroupActivity(dailyGroupactivity.DailyGroupActivityId, activityValueId); } } } } }
protected void gvChildren_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Edit") { // Convert the row index stored in the CommandArgument // property to an Integer. int index = int.Parse(e.CommandArgument.ToString()); // Retrieve the row that contains the button clicked // by the user from the Rows collection. GridViewRow row = this.gvChildren.Rows[index]; this.hidChildId.Value = this.gvChildren.DataKeys[index].Values["Id"].ToString(); var repo = new DataRepo(); ChildrenDTO dataItem = repo.getChild(int.Parse(this.hidChildId.Value)); this.chkIsActive.Checked = dataItem.isActive; this.ddlCenter.SelectedValue = dataItem.CenterId.ToString(); ddlCenter_SelectedIndexChanged(null, new EventArgs()); this.ddlGroup.SelectedValue = dataItem.GroupId.ToString(); this.FirstName.Text = dataItem.FirstName; this.LastName.Text = dataItem.LastName; this.lblDOB.Text = string.Format("DOB (Age: {0:0#})", VIPHelpers.calculateAge(dataItem.DOB)); this.DOB.Text = dataItem.DOB.ToString("MM/dd/yyyy"); this.setExcludedScheduleDays(dataItem.ExcludedDays); this.EnrollmentDate.Text = dataItem.EnrollmentDate.ToString("MM/dd/yyyy"); this.DismisalDate.Text = (dataItem.DismisalDate.HasValue) ? ((DateTime)dataItem.DismisalDate).ToString("MM/dd/yyyy") : string.Empty; this.ParentFirstName.Text = (string.IsNullOrEmpty(dataItem.ParentFirstName)) ? string.Empty : dataItem.ParentFirstName; this.ParentLastName.Text = (string.IsNullOrEmpty(dataItem.ParentLastName)) ? string.Empty : dataItem.ParentLastName; this.Address.Text = (string.IsNullOrEmpty(dataItem.Address)) ? string.Empty : dataItem.Address; this.City.Text = (string.IsNullOrEmpty(dataItem.City)) ? string.Empty : dataItem.City; this.State.SelectedValue = dataItem.State; this.Zip.Text = (string.IsNullOrEmpty(dataItem.Zip)) ? string.Empty : dataItem.Zip; this.Phone.Text = dataItem.Phone; this.Email.Text = dataItem.Email; this.chkNotify.Checked = dataItem.Notify; this.butSave.Text = "Save"; e.Handled = true; this.FirstName.Focus(); } }
public void Delete() { DataRepo<AppInfo> repo = new DataRepo<AppInfo>(); //添加 AppInfo appInfo = new AppInfo(); appInfo.Id = StringFactory.NewGuid(); appInfo.Key = "$deleteKey"; appInfo.Secret = "test"; appInfo.Name = "测试删除App"; repo.Add(appInfo); repo.Delete(appInfo); Assert.IsTrue(repo.Read().Where(a => a.Key == "$deleteKey").Count() < 1); }
public void AddAndRead() { DataRepo<AppInfo> repo = new DataRepo<AppInfo>(); //添加 AppInfo info = new AppInfo(); info.Id = StringFactory.NewGuid(); info.Key = "test"; info.Secret = "test"; info.Name = "测试App"; repo.Add(info); //通过读取验证添加是否成功 List<AppInfo> infoList = repo.Read(); Assert.IsNotNull(infoList); Assert.IsTrue(infoList.Count > 0); repo.Delete(info); }