// Export protected void btnExport_Click(object sender, EventArgs e) { string userName = User.Identity.Name; DateTime dateTime = DateTime.Now; string filename = string.Format("{0}'s ToDos - {1}", userName, dateTime.ToString("s")); filename = filename.Replace(':', '-'); string outputFileName = Request.PhysicalApplicationPath + string.Format("Download/{0}.xml", filename); // Server.MapPath() issues //string outputFileName = HttpContext.Current.Server.MapPath(string.Format("/ToDo/Download/{0}.xml", filename)); //string dir = HttpContext.Current.Server.MapPath("/ToDo/Download"); string dir = Request.PhysicalApplicationPath + "Download"; /*Trace.Warn("Exists " + Directory.Exists(dir).ToString() + "\n"); * if (Directory.Exists(dir)) * { * string[] files = Directory.GetFiles(dir); * foreach (string file in files) * Trace.Warn(" - " + file + "\n"); * }*/ XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Indent = true; XmlWriter xml = XmlTextWriter.Create(outputFileName, xmlSettings); xml.WriteStartElement("ToDos"); xml.WriteAttributeString("User", userName); xml.WriteAttributeString("DateTime", dateTime.ToString()); ToDoDataContext db = new ToDoDataContext(); // Tasks var tasks = from task in db.Tasks join timeFrame in db.TimeFrames on task.TimeFrame equals timeFrame.ID where task.UserName == userName orderby task.TimeFrame select new { TimeFrame = timeFrame.Name, Name = task.Name }; xml.WriteStartElement("Tasks"); foreach (var task in tasks) { xml.WriteStartElement("Task"); xml.WriteAttributeString("TimeFrame", task.TimeFrame); xml.WriteAttributeString("Name", task.Name); xml.WriteEndElement(); } xml.WriteEndElement(); // Activities var activities = from activity in db.Activities where activity.UserName == userName orderby activity.Priority select activity; xml.WriteStartElement("Activities"); foreach (var activity in activities) { xml.WriteStartElement("Activity"); xml.WriteAttributeString("Priority", activity.Priority.ToString()); xml.WriteAttributeString("Name", activity.Name); xml.WriteEndElement(); } xml.WriteEndElement(); // Priorities var priorities = from priority in db.Priorities where priority.UserName == userName orderby priority.Priority select priority; xml.WriteStartElement("Priorities"); foreach (var priority in priorities) { xml.WriteStartElement("Priority"); xml.WriteAttributeString("Priority", priority.Priority.ToString()); xml.WriteAttributeString("Name", priority.Name); xml.WriteEndElement(); } xml.WriteEndElement(); // Goals var goals = from goal in db.Goals where goal.UserName == userName orderby goal.Priority select goal; xml.WriteStartElement("Goals"); foreach (var goal in goals) { xml.WriteStartElement("Goal"); xml.WriteAttributeString("Priority", goal.Priority.ToString()); xml.WriteAttributeString("Name", goal.Name); xml.WriteEndElement(); } xml.WriteEndElement(); // Desires var desires = from desire in db.Desires where desire.UserName == userName orderby desire.Priority select desire; xml.WriteStartElement("Desires"); foreach (var desire in desires) { xml.WriteStartElement("Desire"); xml.WriteAttributeString("Priority", desire.Priority.ToString()); xml.WriteAttributeString("Name", desire.Name); xml.WriteEndElement(); } xml.WriteEndElement(); // Notes var notes = from note in db.Notes where note.UserName == userName select note; xml.WriteStartElement("Notes"); foreach (var note in notes) { xml.WriteStartElement("Note"); xml.WriteAttributeString("Text", note.Text); xml.WriteEndElement(); } xml.WriteEndElement(); xml.WriteEndElement(); xml.Close(); Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=" + filename); Response.ContentType = "text/xml"; Response.TransmitFile(outputFileName); Response.Flush(); Response.End(); }
/// <summary> /// /// </summary> /// <param name="context"></param> public TypeController(ToDoDataContext context) { _context = context; }
public void Dispose() { Db = null; }
public ToDoTaskController(ToDoDataContext context) { _context = context; }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Disable the application idle detection by setting the UserIdleDetectionMode property of the // application's PhoneApplicationService object to Disabled. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } // Specify the local database connection string. string DBConnectionString = "Data Source=isostore:/ToDo.sdf"; //ToDoDataContext db = new ToDoDataContext(DBConnectionString); ToDoDataContext db = new ToDoDataContext(); if (db.DatabaseExists() == false) { ToDoCategory homeCat = new ToDoCategory { Name = "Home" }; ToDoCategory workCat = new ToDoCategory { Name = "Work" }; ToDoCategory hobbiesCat = new ToDoCategory { Name = "Hobbies" }; db.CreateDatabase(); db.Categories.InsertOnSubmit(homeCat); db.Categories.InsertOnSubmit(workCat); db.Categories.InsertOnSubmit(hobbiesCat); db.SubmitChanges(); //db.Items.InsertOnSubmit(new ToDoItem { ItemName = "Finish App", Category = hobbiesCat }); db.SubmitChanges(); } toDoViewModel = new ToDoViewModel(db); toDoViewModel.LoadCollectionsFromDatabase(); }
/// <summary> /// Initializes a new instance of the <see cref="Context" /> class. /// </summary> /// <param name="toDoDbConnectionString">Path of connection to the database.</param> protected Context(string toDoDbConnectionString) { this.DataBaseContext = new ToDoDataContext(toDoDbConnectionString); }
public ToDoQueryRepository(ToDoDataContext toDoDataContext) { _toDoDataContext = toDoDataContext; _toDoDataContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; }
// Class constructor, create the data context object. public ToDoViewModel(string toDoDBConnectionString) { toDoDBContext = new ToDoDataContext(toDoDBConnectionString); }
public ToDoController() { _dataContext = new ToDoDataContext(); }
public ToDoService(ToDoDataContext context) { this._context = context; }
public ToDoCommandRepository(ToDoDataContext toDoDataContext) { _toDoDataContext = toDoDataContext; }
public ToDoViewModel(ToDoDataContext database) { toDoDb = database; }
public ToDoDataViewModel(string connectionString) { db = new ToDoDataContext(connectionString); }
public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard Silverlight initialization InitializeComponent(); // 特定于电话的初始化 InitializePhoneApplication(); setting abc = new setting(); switch (abc.ListBoxSetting) { case 0: System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("zh-CN"); txtnote.Resources.StringLibrary.Culture = ci; break; case 1: System.Globalization.CultureInfo en = new System.Globalization.CultureInfo("en-US"); txtnote.Resources.StringLibrary.Culture = en; break; case 2: System.Globalization.CultureInfo ciJA = new System.Globalization.CultureInfo("ja"); txtnote.Resources.StringLibrary.Culture = ciJA; break; default: break; } // 调试时显示图形分析信息。 if (System.Diagnostics.Debugger.IsAttached) { // 显示当前帧速率计数器。 Application.Current.Host.Settings.EnableFrameRateCounter = true; // 显示在每个帧中重绘的应用程序区域。 //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // 该模式显示递交给 GPU 的包含彩色重叠区的页面区域。 //Application.Current.Host.Settings.EnableCacheVisualization = true; // Disable the application idle detection by setting the UserIdleDetectionMode property of the // application's PhoneApplicationService object to Disabled. // 注意: 仅在调试模式下使用此设置。禁用用户空闲检测的应用程序在用户不使用电话时将继续运行 // 并且消耗电池电量。 PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } // Specify the local database connection string. string DBConnectionString = "Data Source=isostore:/ToDo.sdf"; // Create the database if it does not exist. using (ToDoDataContext db = new ToDoDataContext(DBConnectionString)) { if (db.DatabaseExists() == false) { // Create the local database. db.CreateDatabase(); // Prepopulate the categories. db.Categories.InsertOnSubmit(new ToDoCategory { Name = txtnote.Resources.StringLibrary.richang }); db.Categories.InsertOnSubmit(new ToDoCategory { Name = txtnote.Resources.StringLibrary.gongzuo }); db.Categories.InsertOnSubmit(new ToDoCategory { Name = txtnote.Resources.StringLibrary.xingqu }); // Save categories to the database. db.SubmitChanges(); } } // Create the ViewModel object. viewModel = new ToDoViewModel(DBConnectionString); // Query the local database and load observable collections. viewModel.LoadCollectionsFromDatabase(); }
public ToDoDataService(ToDoDataContext dataContext) { _dataContext = dataContext; }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Disable the application idle detection by setting the UserIdleDetectionMode property of the // application's PhoneApplicationService object to Disabled. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } // Specify the local database connection string. string DBConnectionString = "Data Source=isostore:/ToDo.sdf"; // Create the database if it does not exist. using (ToDoDataContext db = new ToDoDataContext(DBConnectionString)) { if (db.DatabaseExists() == false) { // Create the local database. db.CreateDatabase(); // Prepopulate the categories. db.Categories.InsertOnSubmit(new ToDoCategory { Name = "Vegetables" }); db.Categories.InsertOnSubmit(new ToDoCategory { Name = "Fish" }); db.Categories.InsertOnSubmit(new ToDoCategory { Name = "Medicine" }); // Save categories to the database. db.SubmitChanges(); //vegetables db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 1, ItemName = "Asparagus" }); db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 1, ItemName = "Onion" }); db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 1, ItemName = "Potato" }); db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 1, ItemName = "Carrot" }); db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 1, ItemName = "Tomato" }); //fish db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 2, ItemName = "Common carp" }); db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 2, ItemName = "Silver carp" }); db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 2, ItemName = "Grass carp" }); db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 2, ItemName = "Hilsa shad" }); db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 2, ItemName = "Catla" }); //medecine db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 3, ItemName = "Paracetamol" }); db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 3, ItemName = "Ranitidine" }); db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 3, ItemName = "Loratadine" }); db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 3, ItemName = "Aceclofenac" }); db.Items.InsertOnSubmit(new ToDoItem { _categoryId = 3, ItemName = "Ciprofloxacin" }); db.SubmitChanges(); } } // Create the ViewModel object. viewModel = new ToDoViewModel(DBConnectionString); // Query the local database and load observable collections. viewModel.LoadCollectionsFromDatabase(); }
public ToDoItemDataService(ToDoDataContext context) { _context = context; }
public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard XAML initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Language display initialization InitializeLanguage(); // Show graphics profiling information while debugging. if (Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Prevent the screen from turning off while under the debugger by disabling // the application's idle detection. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } // Specify the local database connection string. string DBConnectionString = "Data Source=isostore:/ToDo.sdf"; // Create the database if it does not exist. using (ToDoDataContext db = new ToDoDataContext(DBConnectionString)) { if (db.DatabaseExists() == false) { // Create the local database. db.CreateDatabase(); // Prepopulate the categories. db.Categories.InsertOnSubmit(new ToDoCategory { Name = "Home" }); db.Categories.InsertOnSubmit(new ToDoCategory { Name = "Work" }); db.Categories.InsertOnSubmit(new ToDoCategory { Name = "Hobbies" }); // Save categories to the database. db.SubmitChanges(); } } // Create the ViewModel object. viewModel = new ToDoViewModel(DBConnectionString); // Query the local database and load observable collections. viewModel.LoadCollectionsFromDatabase(); }
public SQLToDoRepository(ToDoDataContext context, IUserService userService) { _context = context; _userName = userService?.UserName; }
// Class constructor, create the data context object. public ToDoViewModel(string toDoDBConnectionString) { toDoDB = new ToDoDataContext(toDoDBConnectionString); }