private NextActionData fillNextAction(IDataReader rdr) { NextActionData nextAction = new NextActionData(); nextAction.NextActionID = Convert.ToInt64(rdr["nextActionID"]); nextAction.PatientID = Convert.ToInt64(rdr["PatientID"]); nextAction.ActionKind = (ActionKind)Convert.ToInt64(rdr["actionkind"]); nextAction.ActionYear = Convert.ToInt64(rdr["actionyear"]); nextAction.ActionhalfYear = Convert.ToInt64(rdr["actionhalfyear"]); nextAction.Todo = Convert.ToString(rdr["todo"]); return nextAction; }
public long Insert(NextActionData nextAction) { try { long tstart = DateTime.Now.Ticks; DbUtil.OpenConnection(); if (insertByIdCmd == null) { insertByIdCmd = DbUtil.CreateCommand(SQL_INSERT_BY_ID + DbUtil.GetAppendix("nextActionID"), DbUtil.CurrentConnection); insertByIdCmd.Parameters.Add(DbUtil.CreateParameter("@PatientID", DbType.Int64)); insertByIdCmd.Parameters.Add(DbUtil.CreateParameter("@actionkind", DbType.Int64)); insertByIdCmd.Parameters.Add(DbUtil.CreateParameter("@actionyear", DbType.Int64)); insertByIdCmd.Parameters.Add(DbUtil.CreateParameter("@actionhalfyear", DbType.Int64)); insertByIdCmd.Parameters.Add(DbUtil.CreateParameter("@todo", DbType.String)); } ((IDataParameter)insertByIdCmd.Parameters["@PatientID"]).Value = nextAction.PatientID; ((IDataParameter)insertByIdCmd.Parameters["@actionkind"]).Value = (long)nextAction.ActionKind; ((IDataParameter)insertByIdCmd.Parameters["@actionyear"]).Value = nextAction.ActionYear; ((IDataParameter)insertByIdCmd.Parameters["@actionhalfyear"]).Value = nextAction.ActionhalfYear; ((IDataParameter)insertByIdCmd.Parameters["@todo"]).Value = nextAction.Todo; //bool ok = insertByIdCmd.ExecuteNonQuery() == 1; Object insertRet = insertByIdCmd.ExecuteScalar(); long tend = DateTime.Now.Ticks; log.Info("Insert next action: Patient: " + insertRet + " " + ((tend - tstart) / 10000) + "ms"); return DbUtil.getGeneratedId((IDbCommand)insertByIdCmd, lastInsertedRowCmd, insertRet); } catch (Exception e) { log.Error(e.Message); throw e; } finally { DbUtil.CloseConnection(); } }
public bool Update(NextActionData nextAction) { try { long tstart = DateTime.Now.Ticks; DbUtil.OpenConnection(); if (updateByIdCmd == null) { updateByIdCmd = DbUtil.CreateCommand(SQL_UPDATE_BY_ID, DbUtil.CurrentConnection); updateByIdCmd.Parameters.Add(DbUtil.CreateParameter("@PatientID", DbType.Int64)); updateByIdCmd.Parameters.Add(DbUtil.CreateParameter("@actionkind", DbType.Int64)); updateByIdCmd.Parameters.Add(DbUtil.CreateParameter("@actionyear", DbType.Int64)); updateByIdCmd.Parameters.Add(DbUtil.CreateParameter("@actionhalfyear", DbType.Int64)); updateByIdCmd.Parameters.Add(DbUtil.CreateParameter("@todo", DbType.String)); updateByIdCmd.Parameters.Add(DbUtil.CreateParameter("@nextActionID", DbType.Int64)); } ((IDataParameter)updateByIdCmd.Parameters["@PatientID"]).Value = nextAction.PatientID; ((IDataParameter)updateByIdCmd.Parameters["@actionkind"]).Value = (long)nextAction.ActionKind; ((IDataParameter)updateByIdCmd.Parameters["@actionyear"]).Value = nextAction.ActionYear; ((IDataParameter)updateByIdCmd.Parameters["@actionhalfyear"]).Value = nextAction.ActionhalfYear; ((IDataParameter)updateByIdCmd.Parameters["@todo"]).Value = nextAction.Todo; ((IDataParameter)updateByIdCmd.Parameters["@nextActionID"]).Value = nextAction.NextActionID; bool ok = updateByIdCmd.ExecuteNonQuery() == 1; long tend = DateTime.Now.Ticks; log.Info("Update next Action: " + nextAction.NextActionID + " " + ok + " " + ((tend - tstart) / 10000) + "ms"); return ok; } catch (Exception e) { log.Error(e.Message); throw e; } finally { DbUtil.CloseConnection(); } }
/// <summary> /// Inserts the Action. /// </summary> /// <param name="nextActionData">The image data.</param> /// <returns></returns> public NextActionData InsertNextAction(NextActionData nextActionData) { using(ChannelFactory<ISPDBL> cf = new ChannelFactory<ISPDBL>(binding, endpointAddress)) { ISPDBL spdBL = cf.CreateChannel(); return spdBL.InsertNextAction(nextActionData); } }
/// <summary> /// Adds the next action. /// </summary> /// <param name="nad">The nad.</param> public void addNextAction(NextActionData nad) { if (nextActions == null) { nextActions = new List<NextActionData>(); } nextActions.Add(nad); }
/// <summary> /// Deletes the Action. /// </summary> /// <param name="nextActionData">The Next Action data.</param> /// <returns></returns> public override bool DeleteNextAction(NextActionData nextActionData) { bool ok = base.DeleteNextAction(nextActionData); if (ok && nextActionBuffer != null) { // delete in buffer as well nextActionBuffer.Remove(nextActionData); } return ok; }
/// <summary> /// Inserts the next action. /// </summary> /// <param name="nextActionData">The next action data.</param> /// <returns></returns> public override NextActionData InsertNextAction(NextActionData nextActionData) { NextActionData nextAction = base.InsertNextAction(nextActionData); if (nextAction != null) { if (nextActionBuffer != null) { nextActionBuffer.Add(nextAction); // Add new next Action also to buffer } return nextAction; } else { return null; } }
/// <summary> /// Deletes the Action. /// </summary> /// <param name="nextActionData">The Next Action data.</param> /// <returns></returns> public virtual bool DeleteNextAction(NextActionData nextActionData) { INextAction nextActionDB = Database.CreateNextAction(); return nextActionDB.Delete(nextActionData.NextActionID); }
/// <summary> /// Inserts the next action. /// </summary> /// <param name="nextActionData">The next action data.</param> /// <returns></returns> public virtual NextActionData InsertNextAction(NextActionData nextActionData) { INextAction nextActionDB = Database.CreateNextAction(); long id = nextActionDB.Insert(nextActionData); if (id != 0) { nextActionData.NextActionID = id; return nextActionData; } else { return null; } }
public void NextActionInsertTest() { INextAction nextActionDB = Database.CreateNextAction(); NextActionData nextAction = new NextActionData(0, pID, ActionKind.control, 1981, 5, "todotodo"); long naID = nextActionDB.Insert(nextAction); NextActionData nextActionID = new NextActionData(naID, pID, nextAction.ActionKind, nextAction.ActionYear, nextAction.ActionhalfYear, nextAction.Todo); nextAction = nextActionDB.FindById(naID); Assert.AreEqual(nextAction.ActionhalfYear, nextActionID.ActionhalfYear); Assert.AreEqual(nextAction.ActionKind, nextActionID.ActionKind); Assert.AreEqual(nextAction.ActionYear, nextActionID.ActionYear); Assert.AreEqual(nextAction.NextActionID, nextActionID.NextActionID); Assert.AreEqual(nextAction.PatientID, nextActionID.PatientID); Assert.AreEqual(nextAction.Todo, nextActionID.Todo); Assert.IsTrue(nextActionDB.Delete(naID)); Assert.IsNull(nextActionDB.FindById(naID)); }
private NextActionData createRandomNextAction(long pId) { NextActionData nextAction = new NextActionData(); nextAction.PatientID = pId; nextAction.ActionhalfYear = rand.Next(0, 2); nextAction.ActionYear = DateTime.Now.Year - 2 + rand.Next(0, 7); nextAction.Todo = getRandomString(10, 50, true); switch (rand.Next(0,2)) { case 0: nextAction.ActionKind = ActionKind.control; break; case 1: nextAction.ActionKind = ActionKind.operation; break; } return nextAction; }
/// <summary> /// Parses the Next Actions. /// </summary> /// <param name="jsonNextActions">The json Next Actions.</param> /// <returns></returns> private static IList<NextActionData> parseNextActions(ArrayList jsonNextActions) { IList<NextActionData> nextActionList = new List<NextActionData>(); foreach (Hashtable htnexAct in jsonNextActions) { NextActionData nextAction = new NextActionData(); if (htnexAct.ContainsKey(nextAction_nextActionID)) { nextAction.NextActionID = Convert.ToInt64(htnexAct[nextAction_nextActionID]); } if (htnexAct.ContainsKey(nextAction_PatientID)) { nextAction.PatientID = Convert.ToInt64(htnexAct[nextAction_PatientID]); } if (htnexAct.ContainsKey(nextAction_actionkind)) { nextAction.ActionKind = (ActionKind)Convert.ToInt64(htnexAct[nextAction_actionkind]); } else { throw new SPDJsonParseException(null, "Json Next Action Action Type not set.", null); } if (htnexAct.ContainsKey(nextAction_actionyear)) { nextAction.ActionhalfYear = Convert.ToInt64(htnexAct[nextAction_actionyear]); } if (htnexAct.ContainsKey(nextAction_actionhalfyear)) { nextAction.ActionhalfYear = Convert.ToInt64(htnexAct[nextAction_actionhalfyear]); } if (htnexAct.ContainsKey(nextAction_todo)) { nextAction.Todo = Convert.ToString(htnexAct[nextAction_todo]); } nextActionList.Add(nextAction); } return nextActionList; }