public string DeleteUserTasks(string json) { log4net.ILog log = log4net.LogManager.GetLogger(typeof(Soap)); new ConfigHelper().Load(); try { if (string.IsNullOrEmpty(json)) { return(string.Empty); } AdminObject deleteObject = JsonHelper.OnlyJsonToObject <AdminObject>(json); if (deleteObject == null) { return(string.Empty); } string userId = deleteObject.UserId; string password = deleteObject.Password; if (ServicesConstants.DELETE_PASSWORD.Equals(password) == false || string.IsNullOrEmpty(userId)) { return(string.Empty); } GenericDbHelper.RunDirectSql(string.Format("DELETE FROM TASK WHERE USER_ID = '{0}'", userId)); return("OK"); } catch (Exception e) { log.Error(e); return(e.ToString()); } }
public void Update() { this.LastModifyDate = DateTime.Now; // this.LastModifyDateString = this.LastModifyDate.ToString(); // this.DateRemainderString = this.DateRemainder.ToString(); GenericDbHelper.UpdateAndFlush(this); }
public static Info FindByUniqueCode(string uniqueCode) { if (string.IsNullOrEmpty(uniqueCode)) { return(null); } Info result = null; if (m_infosCache.TryGetValue(uniqueCode, out result)) { return(result); } List <Info> allInfos = GenericDbHelper.Get <Info>(); foreach (Info info in allInfos) { if (info.UniqueCode.Equals(uniqueCode)) { result = info; break; } } if (result != null) { m_infosCache.Add(uniqueCode, result); } return(result); }
public void Version6() { Info infoSyncDate = new Info(); infoSyncDate.UniqueCode = Static.StaticData.InfoUniqueCodes.InfoLastSyncDate; infoSyncDate.Value1 = new DateTime(2012, 1, 1).ToString(); GenericDbHelper.SaveAndFlush(infoSyncDate); }
public void InitOnce() { ConfigLoader.Load(@"CoreConfig.xml"); try { GenericDbHelper.DropAllTables(); new AllDbVersions().Version(); } catch {} }
public void Delete(int id) { Task task = GenericDbHelper.GetById <Task>(id); if (task != null) { task.IsDeleted = true; GenericDbHelper.UpdateAndFlush(task); } }
private List <TaskSync> LoadAllTasksByUserId(string userId, DateTime lastSyncDate) { List <TaskSync> result = new List <TaskSync>(); if (string.IsNullOrEmpty(userId)) { return(result); } result = GenericDbHelper.Get <TaskSync>(string.Format("LAST_MODIFY_DATE >= '{0}' and USER_ID = '{1}'", lastSyncDate.ToString("yyyy.MM.dd hh:mm:ss"), userId)); return(result); }
public void InitOnce() { ConfigLoader.Load(@"CoreConfig.xml"); // DbHelper.TestMode = true; try { using (IConnection con = new ConnectionCollector().GetConnection()) { GenericDbHelper.DropAllTables(); new DbHelper().CreateTable(); } } catch (Exception ex) { ex.ToString(); } }
public void SetEvents() { m_form.TrayIcon.DoubleClick += delegate { m_mainForm.ShowHide(); }; Application.ApplicationExit += delegate { if (Minder.Static.StaticData.Settings.Sync.Enable) { // using(new WaitingForm2("Syncing tasks...", "Minder. Please wait", false)) // { m_syncController.Sync(); Info infoSync = InfoFinder.FindByUniqueCode(Minder.Static.StaticData.InfoUniqueCodes.InfoLastSyncDate); infoSync.Value1 = Minder.Static.StaticData.Settings.Sync.LastSyncDate.ToString(); GenericDbHelper.UpdateAndFlush(infoSync); // } } }; m_syncController.Synced += delegate { // m_form.TrayIcon.BalloonTipIcon = ToolTipIcon.Info; // m_form.TrayIcon.BalloonTipTitle = "Minder synced!"; // m_form.TrayIcon.BalloonTipText = String.Format("Added {0} new task(s)!", m_syncController.NewTasks); // m_form.TrayIcon.ShowBalloonTip(5); m_syncController.NewTasks = 0; }; m_form.TrayIcon.BalloonTipClicked += delegate { new TasksFormController().PrepareWindow(); }; m_form.TrayIcon.MouseMove += delegate { m_form.TrayIcon.Text = FormatNextTaskRemindingDate(); }; m_mainForm.MTextBox.TextChanged += ParseRealTimeAndDisplay; m_mainForm.MWindow.Deactivated += delegate { m_mainForm.MWindow.Hide(); }; }
private void SaveTasksToDb(List <TaskSync> taskFromDb, List <TaskSync> mergedTasks, DateTime lastSyncDate) { string userId = string.Empty; if (mergedTasks.Count != 0) { userId = mergedTasks[0].UserId; } foreach (TaskSync task in mergedTasks) { string deleteQuery = string.Format("DELETE FROM TASK WHERE SOURCE_ID = '{0}' AND USER_ID = '{1}'", task.SourceId, userId); GenericDbHelper.RunDirectSql(deleteQuery); } foreach (TaskSync task in mergedTasks) { GenericDbHelper.Save(task); } GenericDbHelper.Flush(); }
public string GetUserTasks(string json) { log4net.ILog log = log4net.LogManager.GetLogger(typeof(Soap)); new ConfigHelper().Load(); try { if (string.IsNullOrEmpty(json)) { return(string.Empty); } AdminObject adminObject = JsonHelper.OnlyJsonToObject <AdminObject>(json); if (adminObject == null) { return(string.Empty); } string userId = adminObject.UserId; string password = adminObject.Password; if (ServicesConstants.DELETE_PASSWORD.Equals(password) == false || string.IsNullOrEmpty(userId)) { return(string.Empty); } List <TaskSync> tasks = GenericDbHelper.Get <TaskSync>(string.Format("USER_ID = '{0}'", userId)); SyncObject result = new SyncObject(); result.Tasks = tasks; return(JsonHelper.ConvertToJson <SyncObject>(result)); } catch (Exception e) { log.Error(e); return(e.ToString()); } }
public void Delete() { GenericDbHelper.DeleteAndFlush(this); }
public void Update() { GenericDbHelper.UpdateAndFlush(this); }
public void Save() { GenericDbHelper.SaveAndFlush(this); }
public static void DeleteAll() { GenericDbHelper.RunDirectSql("DELETE FROM DB_VERSION"); }
public void Delete() { this.LastModifyDate = DateTime.Now; this.IsDeleted = true; GenericDbHelper.UpdateAndFlush(this); }
public void CreateTable() { GenericDbHelper.CreateTable(typeof(Task)); }
public void Sync() { if (string.IsNullOrEmpty(Static.StaticData.Settings.Sync.Id)) { return; } try { DateTime startSync = DateTime.Now; DateTime lastSyncDate = Minder.Static.StaticData.Settings.Sync.LastSyncDate; string dateSync = DBTypesConverter.ToFullDateStringByCultureInfo(lastSyncDate); // new ErrorBox(dateSync); List <Task> allTasks = GenericDbHelper.Get <Task>(string.Format("LAST_MODIFY_DATE >= '{0}'", dateSync)); SyncObject syncObject = new SyncObject(); syncObject.UserId = Static.StaticData.Settings.Sync.Id; syncObject.Tasks = new List <Task>(); syncObject.LastSyncDate = lastSyncDate.ToUniversalTime(); foreach (Task task in allTasks) { task.UserId = Static.StaticData.Settings.Sync.Id; syncObject.Tasks.Add(task); // task.LastModifyDate = task.LastModifyDate.ToUniversalTime(); // task.DateRemainder = task.DateRemainder.ToUniversalTime(); } //Paruošti taskai siuntimui List <Task> tasksFromServer = GetSyncedTasksFromServer(syncObject); SetLocalDate(allTasks.ToArray()); m_newTasks = tasksFromServer.Count; m_log.DebugFormat("Tasks' count retrieved from server {0}", m_newTasks); // using(IConnection con = new ConnectionCollector().GetConnection()) // { foreach (Task task in tasksFromServer) { task.LastModifyDate = task.LastModifyDate.ToLocalTime(); task.DateRemainder = task.DateRemainder.ToLocalTime(); foreach (Task localTask in allTasks) { if (localTask.Equals(task)) { m_newTasks--; } } if (ExistTask(task)) { //Negalime updatinti pagal ID, nes serveryje kitoks id. GenericDbHelper.RunDirectSql(string.Format("DELETE FROM TASK WHERE SOURCE_ID = '{0}'", task.SourceId)); GenericDbHelper.Save(task); m_log.DebugFormat("Updated existing task {0}", task); } else { GenericDbHelper.Save(task); m_log.DebugFormat("Created new task {0}", task); } } GenericDbHelper.Flush(); // } if (m_newTasks > 0) { if (Synced != null) { Synced(); } } Minder.Static.StaticData.Settings.Sync.LastSyncDate = DateTime.Now; TimeSpan span = DateTime.Now - startSync; m_log.InfoFormat("Synced in {0} seconds", span.TotalSeconds); } catch (Exception e) { m_log.Error(e); } }
public static void DeleteAll() { GenericDbHelper.RunDirectSql("DELETE FROM TASK"); }
public void Version() { GenericDbHelper.RunDirectSql("CREATE TABLE DB_VERSION (ID INTEGER PRIMARY KEY, VERSION_NR INTEGER NOT NULL, " + "DATE_VERSION TEXT, COMMENT TEXT)"); }
public void Version() { GenericDbHelper.RunDirectSql("CREATE TABLE TROL_TEST (ID INTEGER PRIMARY KEY, VERSION_NR INTEGER NOT NULL, " + "COMMENT VARCHAR(255))"); GenericDbHelper.RunDirectSql("INSERT INTO TROL_TEST (VERSION_NR, COMMENT) VALUES (5, \"Komentaras\")"); }
public void DbCreator_1() { ConfigLoader.Load(@"CoreConfig.xml"); GenericDbHelper.DropAllTables(); GenericDbHelper.CreateTable(typeof(TaskSync)); }
public void Version2() { GenericDbHelper.RunDirectSql("ALTER TABLE TASK ADD LAST_MODIFY_DATE TEXT"); GenericDbHelper.RunDirectSql("ALTER TABLE TASK ADD IS_DELETED TEXT"); }
public void Version3() { GenericDbHelper.RunDirectSql("ALTER TABLE TASK ADD LAST_MODIFY_DATE_STRING TEXT"); GenericDbHelper.RunDirectSql("ALTER TABLE TASK ADD DATE_REMAINDER_STRING TEXT"); }
public void Version4() { GenericDbHelper.RunDirectSql("UPDATE TASK set LAST_MODIFY_DATE_STRING = LAST_MODIFY_DATE, DATE_REMAINDER_STRING = DATE_REMAINDER"); }
public void Version5() { GenericDbHelper.CreateTable(typeof(Info)); }