protected void Page_Init(object sender, EventArgs e) { ctx = new AriClinicContext("AriClinicContext"); // security control, it must be a user logged if (Session["User"] == null) Response.Redirect("Default.aspx"); else { user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx); Process proc = (from p in ctx.Processes where p.Code == "rtickets" select p).FirstOrDefault<Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); } // cheks if is call from another form if (Request.QueryString["Report"] != null) report = Request.QueryString["Report"]; if (Request.QueryString["FDate"] != null) fDate = CntWeb.ParseUrlDate(Request.QueryString["FDate"]); if (Request.QueryString["TDate"] != null) tDate = CntWeb.ParseUrlDate(Request.QueryString["TDate"]); if (Request.QueryString["Diary"] != null) diary = CntAriCli.GetDiary(int.Parse(Request.QueryString["Diary"]),ctx); if (Request.QueryString["Visit"] != null) visit = CntAriCli.GetVisit(int.Parse(Request.QueryString["Visit"]), ctx); if (Request.QueryString["Treatment"] != null) treatment = CntAriCli.GetTreatment(int.Parse(Request.QueryString["Treatment"]), ctx); if (Request.QueryString["Invoice"] != null) invoice = CntAriCli.GetInvoice(int.Parse(Request.QueryString["Invoice"]), ctx); if (Request.QueryString["PrescriptionGlasses"] != null) prescriptionGlasses = CntAriCli.GetPrescriptionGlasses(int.Parse(Request.QueryString["PrescriptionGlasses"]), ctx); }
protected void Page_Init(object sender, EventArgs e) { ctx = new AriClinicContext("AriClinicContext"); // security control, This is a general view accesible for all // Do you want to see a Diary? if (Request.QueryString["DiaryId"] != null) { diaryId = int.Parse(Request.QueryString["DiaryId"]); diary = CntAriCli.GetDiary(diaryId, ctx); if (diary != null) { lblTitle.Text = diary.Name; this.Title = diary.Name; } } else { // this view is only for specific agendas Response.Redirect("Default.aspx"); } // Do you want to see a Professional? if (Request.QueryString["ProfessionalId"] != null) { professionalId = int.Parse(Request.QueryString["ProfessionalId"]); professional = CntAriCli.GetProfessional(professionalId, ctx); if (professional != null) lblTitle.Text = professional.FullName; } }
public void UpdateDiary() { Diary mDiary = new Diary(); postsStackPanel.Children.Clear(); DateTime previousDate = DateTime.Now; int counter = 0; Style contentStyle = Application.Current.Resources["postContent"] as Style; Style dateStyle = Application.Current.Resources["postDate"] as Style; Style timeStyle = Application.Current.Resources["postTime"] as Style; foreach (DiaryPost post in mDiary) { DockPanel itemPanel = new DockPanel(); itemPanel.Tag = post.ID.ToString(); itemPanel.MouseEnter += ItemStackPanel_MouseEnter; itemPanel.MouseLeave += ItemStackPanel_MouseLeave; itemPanel.ContextMenu = DiaryContextMenu(); TextBlock postDate = new TextBlock(); postDate.Style = dateStyle; if (previousDate != post.DateTime.Date) { postDate.Text = post.DateTime.ToString("dd MMMM yyyy"); previousDate = post.DateTime.Date; postsStackPanel.Children.Add(postDate); } TextBlock postTime = new TextBlock(); postTime.Style = timeStyle; postTime.Text = post.DateTime.ToString("HH:mm"); itemPanel.Children.Add(postTime); FlowDocumentScrollViewer postContent = new FlowDocumentScrollViewer(); FlowDocument doc = new FlowDocument(); TextRange tr = new TextRange(doc.ContentStart, doc.ContentEnd); MemoryStream ms = GetMemoryStreamFromString(post.Content); tr.Load(ms, DataFormats.Rtf); postContent.Document = doc; postContent.ContextMenu = null; postContent.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; itemPanel.Children.Add(postContent); postsStackPanel.Children.Add(itemPanel); counter++; } }
public ActionResult Create([Bind(Include = "Id,Mood,SystolicPressure,DiastolicPressure,RespirationProblem,Haemorrhage,Dizziness,ChestPain,SternumPain,HeartPain,Alcohol,Coffee,Other")] Diary diary) { string coord = diary.Id; diary.Patient_AspNetUsers_Id = User.Identity.GetUserId(); diary.TimeStamp = DateTime.Now; diary.Id = UniqueId(); if (ModelState.IsValid) { db.Diary.Add(diary); db.SaveChanges(); if (coord != null) { SetGeolocation(diary, coord); } return(RedirectToAction("Index")); } ViewBag.Patient_AspNetUsers_Id = new SelectList(db.Patient, "AspNetUsers_Id", "AspNetUsers_Id", diary.Patient_AspNetUsers_Id); diary.Id = coord; return(View(diary)); }
public ActionResult <Diary> AddDiary(Diary diary) { try { string date = DateTime.Now.ToString("yyyyMMdd"); var query = _diaryService.GetDiaryByDate(date); if (query.Count() == 0) { diary.DiaryId = System.Convert.ToInt64(date + "0000"); } else { diary.DiaryId = query.First().DiaryId + 1; } _diaryService.Add(diary); return(diary); } catch (Exception e) { return(BadRequest(e.InnerException.Message)); } }
public static void Initialize(DiaryContext context) { context.Database.EnsureCreated(); if (context.Entries.Any() && context.Diaries.Any()) { return; //db has been seeded or has data } var entries = new Entry[] { new Entry { Date = DateTime.Parse("05/16/2019 05:55PM"), Text = "Wowzers, it's my bday", DiaryID = 1 } }; foreach (Entry e in entries) { context.Entries.Add(e); } var diaries = new Diary[] { new Diary { Title = "MY FIRST EDIARY", CreatedDate = DateTime.Parse("05/16/2019 05:55PM") } }; foreach (Diary e in diaries) { context.Diaries.Add(e); } context.SaveChanges(); }
public static bool ChangeMemo(int userId, string newMemo) { //var host = HostTag.GetById(userId); //var user = TagUser.All.SingleOrDefault(u => u.Id == userId); var userHost = HostTagGroupStatus.All.SingleOrDefault(h => h.HostId == userId && h.ParentGroupId == 0); if (userHost != null) { //包含更新缓存 //TagUser.UpdateMemo(user.Id, newMemo); userHost.Description = newMemo; //HostTag.UpdateHostTag(host); UpdateHostTag(userHost); //记录日志 string calling = GetGroupName(userHost.HostGroupId); Diary.Insert(ContextUser.Current.Id, 0, userHost.HostId, "修改" + calling + userHost.HostName + "的备注信息。"); return(true); } return(false); }
public async Task <List <T> > TryGetEntries(T obj, string user) { try { Diary diary = _mapper.Map <Diary>(obj); List <Diary> diaryList = await _repository.GetEntries(diary, user); List <T> result = new List <T>(); foreach (var item in diaryList) { result.Add(_mapper.Map <T>(item)); } return(result); } catch (System.Exception ex) { return(null); } }
private async Task <DiaryDto> CreateNewDiary(CreateDiaryCommand request, CancellationToken cancellationToken, int profileId) { var userProfile = await _dbContext.UserProfiles.Include(x => x.UserGoals).Where(x => x.Id == profileId).FirstOrDefaultAsync(cancellationToken); if (userProfile == null) { throw new NotFoundException(); //TODO proper exception } var entity = new Diary { Date = request.Date.Date, UserProfileId = profileId, UserGoals = userProfile.CurrentUserGoals }; await _dbContext.Diaries.AddAsync(entity, cancellationToken); await _dbContext.SaveChangesAsync(cancellationToken); return(_mapper.Map <DiaryDto>(entity)); }
public void TestCreateDiaryEntryNoStartTime() { // Create a diary. var candidateId = Guid.NewGuid(); _candidatesCommand.CreateCandidate(new Candidate { Id = candidateId }); var diary = new Diary(); _candidateDiariesCommand.CreateDiary(candidateId, diary); // Add entries. var entries = new List <DiaryEntry>(); var entry = CreateDiaryEntry(2); _candidateDiariesCommand.CreateDiaryEntry(diary.Id, entry); entries.Insert(0, entry); // Create entry with no start time, it should come last. entry = CreateDiaryEntry(1); entry.StartTime = null; _candidateDiariesCommand.CreateDiaryEntry(diary.Id, entry); entries.Add(entry); AssertAreEqual(entries, _candidateDiariesQuery.GetDiaryEntries(diary.Id)); // Create another entry. entry = CreateDiaryEntry(0); _candidateDiariesCommand.CreateDiaryEntry(diary.Id, entry); entries.Insert(1, entry); AssertAreEqual(entries, _candidateDiariesQuery.GetDiaryEntries(diary.Id)); }
private void CheckNewDiary() { DateTime recordedOn = new DateTime(_year, _month, _day); Current = Diaries.FirstOrDefault(a => a.RecordDate >= recordedOn.Date && a.RecordDate < recordedOn.Date.AddDays(1)); if (Current == null) { _lvwDiarys.SelectedIndex = -1; Current = new Diary() { ID = -1, Title = "[新日记]", Keywords = string.Empty, Content = string.Empty, IsRemindRequired = false, JobGroup = "TaskGroup", JobName = Guid.NewGuid().ToString(), JobTypeFullName = $"{typeof(RemindJob).FullName},{System.IO.Path.GetFileName(Common.CurrentAssembly.Location)}", CronExpress = string.Empty, RunningStart = null, RunningEnd = null, RecordDate = new DateTime(_year, _month, _day), RowVersion = DateTime.Now }; } for (int i = 0; i < _lvwDiarys.Items.Count; i++) { Diary diary = (Diary)_lvwDiarys.Items[i]; if (diary.Equals(Current)) { _lvwDiarys.SelectedIndex = i; break; } } _txtTitle.SelectAll(); _txtTitle.Focus(); }
private async void BtnAddDiary_Click(object sender, EventArgs e) { //添加日志 string url = "https://localhost:5001/api/diary"; XmlSerializer xmlSerializer = new XmlSerializer(typeof(Diary)); Client client = new Client(); try { string data = ""; Diary diary = new Diary(); diary.DiaryId = 0; //后端会重新赋值,此处值不重要 diary.Time = DateTime.Now; diary.Share = 0; //默认不分享 diary.Uid = Convert.ToInt32(this.Uid); using (StringWriter sw = new StringWriter()) { xmlSerializer.Serialize(sw, diary); data = sw.ToString(); } HttpResponseMessage result = await client.Post(url, data); if (result.IsSuccessStatusCode) { diary = (Diary)xmlSerializer.Deserialize(await result.Content.ReadAsStreamAsync()); //跳转至编辑日志界面 using (UC_DiaryDetail uc_DiaryDetail = new UC_DiaryDetail(diary.DiaryId.ToString(), ChangePanel)) { this.ChangePanel(uc_DiaryDetail); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// Start is called before the first frame update void Start() { diary = Diary.instance; diary.onNoteChangedCallBack += UpdatePages; totalPages = (diary.notes.Count / 6.0); textsPage1 = page1.GetComponentsInChildren <Text>(); textsPage2 = page2.GetComponentsInChildren <Text>(); if (textsPage1.Length > 0) { for (int i = 0; i < textsPage1.Length; i++) { texts.Add(textsPage1[i]); } if (textsPage2.Length > 0) { for (int i = 0; i < textsPage2.Length; i++) { texts.Add(textsPage2[i]); } } } }
private void Table_LV_MouseDown(object sender, MouseButtonEventArgs e) { if (SelectedRecord != null) { if (DiaryEdit) { SelectedRecord.Seeing_TBlock = Visibility.Visible; SelectedRecord.Seeing_TBox = Visibility.Collapsed; DiaryEdit = false; if (DiarySelectedTitle != SelectedRecord.Title) { DiarySaveTitleDB(); DiarySelectedTitle = SelectedRecord.Title; } } else { SelectedRecord.IsSelected = false; SelectedRecord = null; Records_RTB.Document.Blocks.Clear(); } } }
public HttpResponseMessage Delete(DateTime id) { try { string username = _identityService.CurrentUser; Diary entity = TheRepository.GetDiary(username, id); if (entity == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } if (TheRepository.DeleteDiary(entity.Id) && TheRepository.SaveAll()) { return(Request.CreateResponse(HttpStatusCode.OK)); } } catch { // TODO Add Logging } return(Request.CreateResponse(HttpStatusCode.BadRequest)); }
public IEnumerable <Diary> GetAll(string userID) { Diary diary = (db.Diaries.Where(di => di.UserID == userID)).FirstOrDefault(); IEnumerable <Diary> esList = (from d in db.Diaries where d.UserID == userID select new Diary() { UserID = userID, DiaryID = d.DiaryID, Tips = d.Tips, ActualDate = d.ActualDate, DateStamp = d.DateStamp, DiaryEntry = d.DiaryEntry, Country = d.Country, City = d.City, Private = d.Private, Image = d.Image }); return(esList); }
public ActionResult Create(Diary Add) { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { if (ModelState.IsValid) { Diaries AddDiary = new Diaries(); AddDiary.Diary_date = Add.Diary_date; AddDiary.Date = DateTime.Today.ToString("dd-MM-yyyy"); AddDiary.Month = DateTime.Today.ToString("MMM"); AddDiary.Year = DateTime.Today.ToString("yyyy"); AddDiary.Time = DateTime.Now.ToString("HH:mm:ss"); new Cateloge().AddDiary(AddDiary); TempData["Msg"] = "New Diary Have Added Successfully"; return(RedirectToAction("Index")); } return(View(Add)); } }
public static bool ClearAllEventStatus(string tagMac) { if (LocatingServiceUtil.IsAvailable()) { IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); bool boolean = serviceApi.ClearTagStatus(tagMac); //记录日志 using (AppDataContext db = new AppDataContext()) { Tag tag = db.Tags.SingleOrDefault(t => t.TagMac == tagMac); if (tag != null) { Diary.Insert(ContextUser.Current.Id, tag.Id, TagStatusView.SelectTagStatus(tag.Id).HostTag.HostId, "清除" + tag.TagName + "的所有报警状态。");//SecurityLog.Insert(tag.Id, TagUser.GetUserIdByTagId(tag.Id), "清除" + tag.TagName + "的所有报警状态。", Priority.High); } } return(boolean); } else { return(false); } }
public void UpdateTest001() { IQueryable <Diary> data = new List <Diary> { new Diary(1, "たいとる1(てすと)", "ほんぶん1(てすと)"), new Diary(2, "たいとる2(てすと)", "ほんぶん2(てすと)"), new Diary(3, "たいとる3(てすと)", "ほんぶん3(てすと)"), new Diary(4, "たいとる4(てすと)", "ほんぶん4(てすと)"), new Diary(5, "たいとる5(てすと)", "ほんぶん5(てすと)"), new Diary(6, "たいとる6(てすと)", "ほんぶん6(てすと)"), new Diary(7, "たいとる7(てすと)", "ほんぶん7(てすと)"), }.AsQueryable(); SetIQueryable(data); mockContext.Setup(x => x.diary).Returns(mockSet.Object); Diary diary = new Diary(2, "タイトル2(てすと)を更新", "ほんぶん2(てすと)を更新"); mockContext.Setup(x => x.SaveChanges()).Returns(1); bool result = repository.Update(diary); Assert.True(result); }
//Leafを作成する権限があるか //引数1:アクセスユーザ //引数2:leafを作る日記 //戻り値:true 作成可能、false 不可能 public static bool authCreateLeaf(ClaimsPrincipal user, Diary diary) { bool flag = false; //戻り値:作成可不可フラグ //Leafを作成する権限があるか、確認する // 交換中でない、かつ、持ち主、かつ、作成許可フラグON、ならば可能 //未ログインか if (!user.Identity.IsAuthenticated) { //未ログインのとき、不可能 } //ログイン中のとき else if ( (diary.Id == user.FindFirst(ClaimTypes.NameIdentifier).Value) && //日記の持ち主 (diary.writa == WRITA.able) && //作成可能 (diary.retTime < DateTime.Now) //返却済み ) { flag = true; } return(flag); }
static void Login() { Console.WriteLine("Please enter your name."); User newUser = new User { Name = Console.ReadLine() }; user = SqliteDataAccess.LoadProfile(newUser); if (user == null) { Register(newUser); favourites = null; diary = null; watchlist = null; } else { favourites = SqliteDataAccess.LoadFavourites(newUser); diary = SqliteDataAccess.LoadDiary(newUser); watchlist = SqliteDataAccess.LoadWatchlist(newUser); } }
public DiaryResponse(Diary diary) { Id = diary.Id; StartDate = diary.StartDate; EndDate = diary.EndDate; Conclusions = diary.Conclusions; BenchPressStart = diary.BenchPressStart; SquatStart = diary.SquatStart; DeadliftStart = diary.DeadliftStart; BenchPressEnd = diary.BenchPressEnd; SquatEnd = diary.SquatEnd; DeadliftEnd = diary.DeadliftEnd; Progress = diary.Progress; if (diary.Days != null) { Days = new List <DayResponse>(); DayService dayService = new DayService(); foreach (var day in diary.Days) { Days.Add(dayService.GetDay(day.Id)); } } }
private void AddEntry(Diary diary) { var entry = new Entry { DateEntry = new DateEntry { Year = 2028, Month = 8, Day = 5 }, Title = new Title() { Value = "Ben's 21st Birthday" }, People = new List <int>() { 1, 2 }, Locations = new List <int>() { 3, 4, 5 } }; diary.Entries.Add(entry); }
public string InsertDiaryContent(Diary diaryContent) { try { var isDiaryExist = _context.Diary.FirstOrDefault(x => x.MemberId == diaryContent.MemberId && x.Date == diaryContent.Date); if (isDiaryExist == null) { _context.Diary.Add(diaryContent); _context.SaveChanges(); return("新增成功"); } else { return(EditDiary(isDiaryExist.Id, diaryContent)); } } catch (Exception e) { return(e.ToString()); } }
private async Task <Diary> GetDiary() { //根据id获取diary string url = this.baseUrl + "/get?diaryId=" + this.DiaryId; XmlSerializer xmlSerializer = new XmlSerializer(typeof(Diary)); Client client = new Client(); Diary diary = null; try { HttpResponseMessage result = await client.Get(url); if (result.IsSuccessStatusCode) { diary = (Diary)xmlSerializer.Deserialize(await result.Content.ReadAsStreamAsync()); } } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(diary); }
//private string sectorName; public AddDiaryViewModel(Route route, Diary diary) { this.model = route; this.editingDiary = diary; if (diary != null) { this.SelectedStyleIndex = Styles.IndexOf(diary.Style); this.FeelingValue = diary.Feeling; this.Date = diary.Date; this.PartnerTextInput = diary.Partner; this.NoteTextInput = diary.Note; } else { this.selectedStyleIndex = -1; this.FeelingValue = 5; this.Date = DateTime.Now; } this.SaveCommand = new Command(SaveCommand_Execute); this.GetSectorName(); }
public long CreateNewDiary(AddNewDiaryRequest newDiaryRequest, long userId) { Diary diary = Mapper.Map <AddNewDiaryRequest, Diary>(newDiaryRequest); diary.WriterId = userId; _diaryModifier.CreateNewDiary(diary); if (newDiaryRequest.Countries != null && newDiaryRequest.Countries.Count > 0) { _diaryModifier.AddDiaryCountries(newDiaryRequest.Countries.Select( x => new DiaryCountry { DiaryId = diary.Id, Country = x }).ToList()); } if (newDiaryRequest.Cities != null && newDiaryRequest.Cities.Count > 0) { _diaryModifier.AddDiaryCities(newDiaryRequest.Cities.Select( x => new DiaryCity { DiaryId = diary.Id, City = x }).ToList()); } return(diary.Id); }
private async void BtnSave_Click(object sender, EventArgs e) { //保存修改 tbTitle.Enabled = false; btnSave.Enabled = false; btnAddPic.Enabled = false; rtbDescription.Enabled = false; //将修改传到远端 Diary diary = await GetDiary(); diary.Title = tbTitle.Text; diary.Description = rtbDescription.Text; if (await PutDiary(diary)) { using (Form_Tips tip = new Form_Tips("提示", "修改成功")) { tip.ShowDialog(); } } //将编辑激活 btnEdit.Enabled = true; btnEdit.Text = "编辑"; }
private void btnDelete_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Delete this account ? ", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == System.Windows.Forms.DialogResult.Yes) { int id = -1; DataGridView dgv = sender as DataGridView; if (dgvAccount != null && dgvAccount.SelectedRows.Count > 0) { DataGridViewRow i = dgvAccount.SelectedRows[0]; id = Int32.Parse(i.Cells[0].Value.ToString()); } Accounts acc = new Accounts(); acc.accountName = txtAcc.Text; acc.fullName = txtAccName.Text; acc.role = Int32.Parse(cbbRole.SelectedValue.ToString()); if (id != -1) { acc.id = id; accDAO.delete(id); GetSource.getTableSource(AccountDAO.READ_ALL, dgvAccount); } MessageBox.Show("Deleted", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Diary dia = new Diary(); dia.account = curent.id; dia.date = DateTime.Today; dia.description = "Delete account " + acc.accountName; diaryDAO.create(dia); GetSource.getTableSource(DiaryDAO.READ_ALL, dgvLog); } else { MessageBox.Show("Can not deleted this account ", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ApiResponseModel Create([FromBody] CreateDiaryRequest createRequest) { if (ModelState.IsValid) { ApplicationUser user = _dbContext.GetUserWithToken(createRequest.Token); if (user != null) { Diary newDiary = new Diary() { Title = createRequest.Title, Author = user.UserName, PublishDate = DateTime.Now, IsPublic = createRequest.IsPublic, Text = createRequest.Text }; _dbContext.Add(newDiary); if (_dbContext.SaveChanges() > 0) { Response.StatusCode = 201; return(new ApiResponseModel() { Status = true, Result = new CreateDiaryResultModel() { Id = newDiary.Id.ToString() } }); } } } return(new ApiResponseModel() { Status = false, Error = "Invalid authentication token." }); }
public void SavetoCollection() { foreach (var item in ListViewPage.current.diaries) { if (TitleTextBlock.Text == item.Date) { item.Weather = WeatherComboBox.SelectedItem.ToString(); item.Content = ContentTextBox.Text; item.FixContent = item.Content; item.Content = Regex.Replace(item.Content, "'", "''"); string sql = "UPDATE " + DiaryTableName + " SET CSY_CONTENT='" + item.Content + "',CSY_WEATHER='" + item.Weather + "' WHERE CSY_DATE='" + item.Date + "'"; SqliteDatabase.UpdateData(sql); MainPage.current.RightFrame.Navigate(typeof(DiaryContentPage), "1"); MainPage.current.RightFrame.BackStack.Clear(); ListViewPage.current.DiaryListView.SelectedIndex = -1; SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; return; } } Diary diary = new Diary(); diary.Date = TitleTextBlock.Text; diary.Content = ContentTextBox.Text; diary.FixContent = diary.Content; diary.Content = Regex.Replace(diary.Content, "'", "''"); diary.Weather = WeatherComboBox.SelectionBoxItem.ToString(); ListViewPage.current.diaries.Add(diary); SqliteDatabase.InsertData(diary, DBName, DiaryTableName); MainPage.current.RightFrame.Navigate(typeof(DiaryContentPage), "1"); MainPage.current.RightFrame.BackStack.Clear(); ListViewPage.current.DiaryListView.SelectedIndex = -1; SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; }
} //コメント権限ありなし //指定したidの日記の目次を表示する public async Task <IActionResult> OnGetAsync(string id) { ClaimsPrincipal user = HttpContext.User; //日記の情報を取得する Diary diary = await _context.diaries.FindAsync(id); if (diary == null) { return(StatusCode(404)); } //日記が存在するとき //閲覧権限の確認 if (!DiaryAuth.authRead(user, diary)) { return(StatusCode(403)); } //閲覧権限があるとき //内容を表示する leaves = await _context.leaves.Where(l => l.diaryId == id).ToListAsync(); if (user.Identity.IsAuthenticated) { string authId = user.FindFirst(ClaimTypes.NameIdentifier).Value; //ログイン中のとき exchaFlag = await DiaryAuth.authExcha(user, _context, diary); createFlag = DiaryAuth.authCreateLeaf(user, diary); commentFlag = ( (diary.exid == authId) && (diary.retTime > DateTime.Now) ); appliPeriod = await DiaryAuth.applied(user, _context, diary); } return(Page()); }
private void btnEdit_Click(object sender, EventArgs e) { int id = 0; DataGridView dgv = sender as DataGridView; if (dgvAccount != null && dgvAccount.SelectedRows.Count > 0) { DataGridViewRow i = dgvAccount.SelectedRows[0]; id = Int32.Parse(i.Cells[0].Value.ToString()); } Accounts acc = new Accounts(); acc.accountName = txtAcc.Text; acc.fullName = txtAccName.Text; acc.role = Int32.Parse(cbbRole.SelectedValue.ToString()); Dialog dialog = new Dialog(); dialog.ShowDialog(); acc.passWord = dialog.pass; if (id != 0 && acc.passWord != null) { acc.id = id; accDAO.update(acc); GetSource.getTableSource(AccountDAO.READ_ALL, dgvAccount); MessageBox.Show("Edited", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Diary dia = new Diary(); dia.account = curent.id; dia.date = DateTime.Today; dia.description = "Edit account " + acc.accountName; diaryDAO.create(dia); GetSource.getTableSource(DiaryDAO.READ_ALL, dgvLog); } else { MessageBox.Show("Can not edit this account ", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected void Page_Init(object sender, EventArgs e) { ctx = new AriClinicContext("AriClinicContext"); // security control, it must be a user logged if (Session["User"] == null) Response.Redirect("Default.aspx"); else { user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx); user = CntAriCli.GetUser(user.UserId, ctx); Process proc = (from p in ctx.Processes where p.Code == "agenda" select p).FirstOrDefault<Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); btnAccept.Visible = per.Modify; } if (Request.QueryString["DiaryId"] != null) { agendaId = int.Parse(Request.QueryString["DiaryId"]); agenda = CntAriCli.GetDiary(agendaId, ctx); } LoadData(agenda); }
public static IList<AppointmentInfo> GetAppointments(Diary diary, AriClinicContext ctx) { return (from a in ctx.AppointmentInfos where a.Diary.DiaryId == diary.DiaryId select a).ToList<AppointmentInfo>(); }
/// <summary> /// As its name suggest if there isn't an object /// it'll create it. If exists It modifies it. /// </summary> /// <returns></returns> protected bool CreateChange() { if (!DataOk()) return false; if (agenda == null) { agenda = new Diary(); ctx.Add(agenda); } UnloadData(agenda); ctx.SaveChanges(); return true; }
protected void LoadData(Diary agenda) { if (agenda == null) return; // There isn't any agenda to show txtDiaryId.Text = String.Format("{0:00000}", agenda.DiaryId); txtName.Text = agenda.Name; rdtmBeginHour.SelectedDate = agenda.BeginHour; rdtmEndHour.SelectedDate = agenda.EndHour; txtTimeStep.Text = agenda.TimeStep.ToString(); }
protected void UnloadData(Diary agenda) { agenda.Name = txtName.Text; agenda.BeginHour = (DateTime)rdtmBeginHour.SelectedDate; agenda.EndHour = (DateTime)rdtmEndHour.SelectedDate; agenda.TimeStep = int.Parse(txtTimeStep.Text); }
public static IList<AppointmentInfo> GetAppointments(Diary diary, DateTime start, DateTime end, AriClinicContext ctx) { return (from a in ctx.AppointmentInfos where a.Diary.DiaryId == diary.DiaryId && a.BeginDateTime >= start && a.EndDateTime <= end select a).ToList<AppointmentInfo>(); }
protected void LoadDiaryCombo(Diary diary) { rdcDiary.Items.Clear(); rdcDiary.Items.Add(new RadComboBoxItem(diary.Name, diary.DiaryId.ToString())); rdcDiary.SelectedValue = diary.DiaryId.ToString(); }
public static void ImportDiary(OleDbConnection con, AriClinicContext ctx) { //(1) Borramos las agendas anteriores ctx.Delete(ctx.Diaries); //(2) Leer las agendas OFT y darlas de alta en AriClinic string sql = "SELECT * FROM LibrosCita"; cmd = new OleDbCommand(sql, con); da = new OleDbDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, "ConLibrosCita"); foreach (DataRow dr in ds.Tables["ConLibrosCita"].Rows) { int id = (int)dr["IdLibCit"]; Diary dia = new Diary(); dia.BeginHour = (DateTime)dr["HrIni"]; dia.EndHour = (DateTime)dr["HrFin"]; dia.Name = (string)dr["NomLibCit"]; dia.TimeStep = 10; dia.OftId = id; ctx.Add(dia); } ctx.SaveChanges(); }
public static void ImportDiary(OleDbConnection con, AriClinicContext ctx) { //(1) Borramos las agendas anteriores //ctx.Delete(ctx.Diaries); //(2) Leer las agendas OFT y darlas de alta en AriClinic string sql = "SELECT * FROM LibrosCita"; cmd = new OleDbCommand(sql, con); da = new OleDbDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, "ConLibrosCita"); int nreg = ds.Tables["ConLibrosCita"].Rows.Count; int reg = 0; foreach (DataRow dr in ds.Tables["ConLibrosCita"].Rows) { reg++; Console.WriteLine("Formas de pago {0:#####0} de {1:#####0} {2}", reg, nreg, (string)dr["NomLibCit"]); int id = (int)dr["IdLibCit"]; Diary dia = (from d in ctx.Diaries where d.OftId == id select d).FirstOrDefault<Diary>(); if (dia == null) { dia = new Diary(); ctx.Add(dia); } dia.BeginHour = (DateTime)dr["HrIni"]; dia.EndHour = (DateTime)dr["HrFin"]; dia.Name = (string)dr["NomLibCit"]; dia.TimeStep = 10; dia.OftId = id; } ctx.SaveChanges(); }