Exemplo n.º 1
0
        public static Patient GetPatient(string epiRowId)
        {
            Patient pt = new Patient();

            using (var con = new CacheConnection(conString))
            {
                con.Open();
                using (var cmd = new CacheCommand(QueryString.GetPatient(epiRowId), con))
                {
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            string hn = reader["PAPMI_No"].ToString();
                            pt.HN     = hn;
                            pt.Name   = string.IsNullOrEmpty(reader["TTL_Desc"].ToString()) ? reader["PAPMI_Name"].ToString() + " " + reader["PAPMI_Name2"].ToString() : reader["TTL_Desc"].ToString() + reader["PAPMI_Name"].ToString() + " " + reader["PAPMI_Name2"].ToString();
                            pt.Gender = reader["CTSEX_Desc"].ToString();
                            DateTime dt = Convert.ToDateTime(reader["PAPMI_DOB"].ToString());
                            pt.DOB       = dt.ToString("dd/MM/") + dt.Year.ToString();
                            pt.EpisodeNo = reader["PAADM_ADMNo"].ToString();
                            pt.Age       = reader["PAPER_AgeYr"].ToString();
                            pt.Allergys  = _ICPOERepository.GetAllergys(hn);
                        }
                    }
                }
            }

            return(pt);
        }
Exemplo n.º 2
0
        public static List <QuestionAnswer> GetQuestionAnswer(string OEORI_RowId)
        {
            List <QuestionAnswer> listQuestionAnswer = new List <QuestionAnswer>();

            using (var con = new CacheConnection(conString))
            {
                con.Open();
                using (var cmd = new CacheCommand(QueryString.GetQuesAns(OEORI_RowId), con))
                {
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            QuestionAnswer qa    = new QuestionAnswer();
                            string         item  = reader["QUES_Code"].ToString();
                            string[]       items = item.Split('_');
                            qa.OrdItemType = items.Length > 1 ? items[1].ToString() : "";
                            qa.QUES        = items.Length > 2 ? items[2].ToString() : "";
                            qa.QUES_Desc   = reader["QUES_Desc"].ToString();
                            qa.QA_Answer   = reader["QA_Answer"].ToString();

                            listQuestionAnswer.Add(qa);
                        }
                    }
                }
            }

            return(listQuestionAnswer);
        }
Exemplo n.º 3
0
        public static DataTable DTBindProcedure(string procedureName, string conString, Dictionary <string, object> para)
        {
            dt = new DataTable();

            using (var con = new CacheConnection(conString))
            {
                con.Open();
                using (var cmd = new CacheCommand(procedureName, con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    foreach (KeyValuePair <string, object> kvp in para)
                    {
                        cmd.Parameters.Add(kvp.Key, kvp.Value);
                    }
                    if (para != null)
                    {
                        using (CacheDataReader dr = cmd.ExecuteReader())
                        {
                            dt.Load(dr);
                            return(dt);
                        }
                    }
                }
            }

            return(dt);
        }
Exemplo n.º 4
0
        CacheConnection GetConnection(bool firstCall = true)
        {
            try
            {
                if (CacheConnect == null)
                {
                    string connStr = ConfigurationManager.ConnectionStrings["CacheDB"].ConnectionString;
                    CacheConnect = new CacheConnection();
                    CacheConnect.ConnectionString = connStr;
                }

                if (CacheConnect.State == System.Data.ConnectionState.Closed)
                {
                    CacheConnect.Open();
                }
            }
            catch (CacheInternalException e)
            {
                if (firstCall)
                {
                    Thread.Sleep(30);
                    GetConnection(false);
                }
            }


            return(CacheConnect);
        }
        public void WorklistDataItem_OpenId_ShouldReturnAnInstanceOfWorklistDataItem()
        {
            var cacheConnect = new CacheConnection();

            cacheConnect.ConnectionString = "Server=Cache3; Namespace = RMH; Password = PASSWORD01; User ID = GAOG;";
            cacheConnect.Open();

            GGTestProduct product = null;

            try
            {
                product = GGTestProduct.OpenId(cacheConnect, "1");
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
            finally
            {
                if (product != null)
                {
                    Assert.AreEqual("Test Product 1", product.Name, "product name does not matched");
                    Assert.AreEqual("Test", product.Category.ToString(), "product category does not matched");

                    product.Close();
                }
                else
                {
                    Assert.Inconclusive("Test data does not exist");
                }

                cacheConnect.Close();
            }
        }
Exemplo n.º 6
0
        public static string GetAllergyCategory(string algName, CacheConnection con)
        {
            var cmdString = QueryString.GetAllergyCategory(algName);
            var result    = InterSystemsDa.BindDataCommand(cmdString, con);

            return(result);
        }
Exemplo n.º 7
0
 public static void CloseConnection()
 {
     if (_connection != null)
     {
         _connection.Close();
         _connection = null;
     }
 }
Exemplo n.º 8
0
 private void CreateTableIfNotExists(List <string> tables, string tableName, CacheConnection connection)
 {
     if (tables.Count(x => x == tableName) == 0)
     {
         using (var command = new CacheCommand(GetTableQuery(tableName), connection))
             command.ExecuteScalar();
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Returns the ADO.NET IDbCommand for this database.
        /// </summary>
        /// <param name="connectionString">Database connection string</param>
        /// <returns></returns>
        public override IDbConnection CreateNewDbConnection(string connectionString)
        {
            var con = new CacheConnection(connectionString);

            con.Open();
            con.SetQueryRuntimeMode(InterSystems.Data.CacheTypes.QueryRuntimeMode.LOGICAL);
            return(con);
        }
Exemplo n.º 10
0
        //public static

        internal static bool IsImage(string hn, CacheConnection con)
        {
            var dt = InterSystemsDa.DtBindDataCommand(QueryString.GetPatientImage(hn), con);

            var flag = Helper.CheckPatientImage(dt);

            return(flag);
        }
Exemplo n.º 11
0
        //Constructor for the CacheConnectionPool intializing ZAM 2015-5-22
        public DataConnection()
        {
            this.ConnectID = ++ConnectIDTrack;
            ServiceConfiguration Config = new ServiceConfiguration();
            CacheConnectionObject = new CacheConnection();
            CacheConnectionObject.ConnectionString = "Server=" + Config.Server + "; Port=" + Config.Port + "; Namespace=" + Config.NameSpace + "; "
+ "Password="******"; User ID=" + Config.UserID + "; Min Pool Size = 2;" + " Max Pool Size = 6;" + " Connection Reset = true;"
    + " Connection Lifetime = 2;";
        }
Exemplo n.º 12
0
        public static List <Allergy> GetAllergys(string hn, CacheConnection con)
        {
            var cmdString = QueryString.GetAllergy(hn);
            var dtAlg     = InterSystemsDa.DtBindDataCommand(cmdString, con);

            var results = Helper.DataTableToAllergy(dtAlg, con);

            return(results);
        }
Exemplo n.º 13
0
        public void AddCacheConnection(CacheServer server, int latency)
        {
            var connection = new CacheConnection();

            connection.latency = latency;
            connection.server  = server;
            ServerLatencies.Add(server, latency);
            CacheConnections.Add(connection);
        }
Exemplo n.º 14
0
        GetDBConnection(string server, string port, string _namespace, string username, string password, bool pooling)
        {
            // Server=10.104.10.89; Port=1972; Namespace=PROD-TRAK;Password=sys; User ID=superuser
            var connString = $"Server={server}; Port={port}; Namespace={_namespace}; Password={password}; User ID={username}; Pooling={pooling}";

            Conn = new CacheConnection(connString);

            return(Conn);
        }
Exemplo n.º 15
0
        private CacheConnection BuildConnection(DbContext context)
        {
            var connection = new CacheConnection();

            connection.ConnectionString = context.Database.Connection.ConnectionString;
            connection.Open();

            return(connection);
        }
Exemplo n.º 16
0
        //Constructor for the CacheConnectionPool intializing ZAM 2015-5-22
        public DataConnection()
        {
            this.ConnectID = ++ConnectIDTrack;
            ServiceConfiguration Config = new ServiceConfiguration();

            CacheConnectionObject = new CacheConnection();
            CacheConnectionObject.ConnectionString = "Server=" + Config.Server + "; Port=" + Config.Port + "; Namespace=" + Config.NameSpace + "; "
                                                     + "Password="******"; User ID=" + Config.UserID + "; Min Pool Size = 2;" + " Max Pool Size = 6;" + " Connection Reset = true;"
                                                     + " Connection Lifetime = 2;";
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            CacheConnection CacheConnect = new CacheConnection();

            CacheConnect.ConnectionString = "Server=192.168.1.10;Port=5641;User=_SYSTEM;Password=SYS;Namespace=company2;Pooling=false;";
            CacheConnect.Open();

            //Lock Query List Example
            Console.WriteLine("Lock Query List Example");
            CacheDataAdapter cadpt    = new CacheDataAdapter();
            DataSet          ds       = new DataSet();
            CacheCommand     cmdCache = new CacheCommand("%SYS.LockQuery_List", CacheConnect);

            cmdCache.CommandType = CommandType.StoredProcedure;
            cadpt.SelectCommand  = cmdCache;
            cadpt.Fill(ds, "Locks");
            bool   locked = false;
            int    id     = 13395;
            string table  = "Invoice";

            foreach (DataRow row in ds.Tables["Locks"].Rows) //loop through locks
            {
                Console.WriteLine(row["LockString"]);
                if (row["LockString"].Equals("^oo" + table + "D(" + id + ")")) //depends on class storage definition data location
                {
                    locked = true;
                    break;
                }
            }
            if (locked)
            {
                Console.WriteLine("Record is locked");
            }
            else
            {
                Console.WriteLine("Record is unlocked");
            }
            Console.WriteLine();
            //Process Query Example
            Console.WriteLine("Process Query Example");
            CacheCommand cmdCache2 = new CacheCommand("%SYS.ProcessQuery_CONTROLPANEL", CacheConnect);

            cmdCache2.CommandType = CommandType.StoredProcedure;
            CacheParameter JNparam = new CacheParameter("JobNumber", CacheDbType.Int);

            JNparam.Value = 1;
            cmdCache2.Parameters.Add(JNparam);
            cadpt.SelectCommand = cmdCache2;
            cadpt.Fill(ds, "Processes");
            foreach (DataRow row in ds.Tables["Processes"].Rows) //loop through processes
            {
                Console.WriteLine("Job Number: " + row["Job#"] + ", Namespace: " + row["Nspace"]);
            }
        }
Exemplo n.º 18
0
        public static List <Allergy> DataTableToAllergy(DataTable dt, CacheConnection con)
        {
            var algs = new List <Allergy>();

            foreach (DataRow row in dt.Rows)
            {
                var    alg = new Allergy();
                string algName;
                if (!string.IsNullOrEmpty(row["ALG_Comments"].ToString()))
                {
                    algName      = row["ALG_Comments"].ToString();
                    alg.Name     = algName;
                    alg.Category = GetData.GetAllergyCategory(algName, con);
                    algs.Add(alg);
                }
                else if (!string.IsNullOrEmpty(row["PHCGE_Name"].ToString()))
                {
                    algName      = row["PHCGE_Name"].ToString();
                    alg.Name     = algName;
                    alg.Category = GetData.GetAllergyCategory(algName, con);
                    algs.Add(alg);
                }
                else if (!string.IsNullOrEmpty(row["ALG_Desc"].ToString()))
                {
                    algName      = row["ALG_Desc"].ToString();
                    alg.Name     = algName;
                    alg.Category = GetData.GetAllergyCategory(algName, con);
                    algs.Add(alg);
                }
                else if (!string.IsNullOrEmpty(row["ALGR_Desc"].ToString()))
                {
                    algName      = row["ALGR_Desc"].ToString();
                    alg.Name     = algName;
                    alg.Category = GetData.GetAllergyCategory(algName, con);
                    algs.Add(alg);
                }
                else if (!string.IsNullOrEmpty(row["PHCD_Name"].ToString()))
                {
                    algName      = row["PHCD_Name"].ToString();
                    alg.Name     = algName;
                    alg.Category = GetData.GetAllergyCategory(algName, con);
                    algs.Add(alg);
                }
                else if (!string.IsNullOrEmpty(row["INGR_Desc"].ToString()))
                {
                    algName      = row["INGR_Desc"].ToString();
                    alg.Name     = algName;
                    alg.Category = GetData.GetAllergyCategory(algName, con);
                    algs.Add(alg);
                }
            }

            return(algs);
        }
Exemplo n.º 19
0
        public static DataSet DSBindDataCommand(string cmdString, string conString)
        {
            DataSet ds = new DataSet();

            using(var con = new CacheConnection(conString))
            {
                using(var adp = new CacheDataAdapter(cmdString, conString))
                {
                    adp.Fill(ds);
                }
            }

            return ds;
        }
Exemplo n.º 20
0
        public static DataTable DTBindDataCommand(string cmdString, string conString)
        {
            DataTable dt = new DataTable();

            using (var con = new CacheConnection(conString))
            {
                using (var adp = new CacheDataAdapter(cmdString, con))
                {
                    adp.Fill(dt);
                }
            }

            return(dt);
        }
Exemplo n.º 21
0
        public static List <QAModel> GetQAModel(string OEORI_RowId)
        {
            List <QAModel> results = new List <QAModel>();

            using (var con = new CacheConnection(conString))
            {
                con.Open();
                using (var cmd = new CacheCommand(QueryString.GetQuesAns(OEORI_RowId), con))
                {
                    using (var reader = cmd.ExecuteReader())
                    {
                        string type = string.Empty;
                        while (reader.Read())
                        {
                            QAModel  qam    = new QAModel();
                            string[] spilts = reader["QUES_Code"].ToString().Split('_');

                            if (Regex.IsMatch(reader["QUES_Desc"].ToString(), @"<[^>]*>"))
                            {
                                type = spilts.Length > 2 ? spilts[2] : "";

                                qam.QUES_Code        = reader["QUES_Code"].ToString();
                                qam.QUES_Desc        = reader["QUES_Desc"].ToString();
                                qam.QA_Answer        = reader["QA_Answer"].ToString();
                                qam.QUES_ControlType = reader["QUES_ControlType"].ToString();
                                qam.QUES_Type        = type;

                                results.Add(qam);
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(reader["QA_Answer"].ToString()))
                                {
                                    qam.QUES_Code        = reader["QUES_Code"].ToString();
                                    qam.QUES_Desc        = reader["QUES_Desc"].ToString();
                                    qam.QA_Answer        = reader["QA_Answer"].ToString();
                                    qam.QUES_ControlType = reader["QUES_ControlType"].ToString();
                                    qam.QUES_Type        = type;

                                    results.Add(qam);
                                }
                            }
                        }
                    }
                }
            }

            return(results);
        }
Exemplo n.º 22
0
        private List <string> GetExistingTables(CacheConnection connection)
        {
            var tables = new List <string>();

            using (var command = new CacheCommand(ExistingTablesQuery, connection))
                using (var tablesReader = command.ExecuteReader())
                {
                    while (tablesReader.Read())
                    {
                        tables.Add(tablesReader[0].ToString());
                    }
                }

            return(tables);
        }
Exemplo n.º 23
0
        public static string ExecuteScalarBindDataCommand(string cmdString, string connectionString)
        {
            string result = string.Empty;

            using (var con = new CacheConnection(connectionString))
            {
                using (var cmd = new CacheCommand(cmdString, con))
                {
                    con.Open();
                    result = Convert.ToString(cmd.ExecuteScalar());
                }
            }

            return(result);
        }
Exemplo n.º 24
0
        public static DataSet DataSetBindDataCommand(string cmdString, string connectionString)
        {
            DataSet ds = new DataSet();

            using (CacheConnection con = new CacheConnection(connectionString))
            {
                using (CacheDataAdapter adt = new CacheDataAdapter(cmdString, con))
                {
                    con.Open();
                    adt.Fill(ds);
                }
            }

            return(ds);
        }
Exemplo n.º 25
0
        public static DataTable DataTableBindDataCommand(string cmdString, string connectionString)
        {
            DataTable dt = new DataTable();

            using (CacheConnection con = new CacheConnection(connectionString))
            {
                con.Open();
                using (CacheDataAdapter da = new CacheDataAdapter(cmdString, con))
                {
                    da.Fill(dt);
                }
            }

            return(dt);
        }
Exemplo n.º 26
0
        public static string BindDataCommand(string cmdString, string conString)
        {
            string result = string.Empty;

            using(var con = new CacheConnection(conString))
            {
                con.Open();
                using(var cmd = new CacheCommand(cmdString, con))
                {
                    result = cmd.ExecuteScalar().ToString();
                }
            }

            return result;
        }
Exemplo n.º 27
0
        public static DataSet DSBindDataCommand(string cmdString, string conString)
        {
            DataSet ds = new DataSet();

            using (var con = new CacheConnection(conString))
            {
                con.Open();
                using (var da = new CacheDataAdapter(cmdString, con))
                {
                    da.Fill(ds);
                }
            }

            return(ds);
        }
Exemplo n.º 28
0
        public static IEnumerable <Appointment> GetAppointment(string hn, CacheConnection con)
        {
            List <Appointment> apps = new List <Appointment>();
            var dtApp     = InterSystemsDa.DtBindDataCommandWithValuesMultiple(QueryString.GetAppointments(hn), con, hn);
            var dtAppCur  = InterSystemsDa.DtBindDataCommandWithValues(QueryString.GetAppointmentsCurrent(hn), con, hn);
            var dtAppPast = InterSystemsDa.DtBindDataCommandWithValuesMultiple(QueryString.GetAppointmentsPast(hn), con, hn);

            List <Appointment> lstApp     = dtApp.ToList <Appointment>();
            List <Appointment> lstAppCur  = dtAppCur.ToList <Appointment>();
            List <Appointment> lstAppPast = dtAppPast.ToList <Appointment>();

            var results = lstApp.Concat(lstAppCur).Concat(lstAppPast);

            foreach (var item in results)
            {
                var tupleDatetime = string.IsNullOrEmpty(item.AS_Date)
                    ? new Tuple <string, string>("", "")
                    : new Tuple <string, string>(item.AS_Date, item.AS_SessStartTime);
                var datetimeString = Helper.ConvertToISO_8601(tupleDatetime.Item1, tupleDatetime.Item2);
                var datetime       = DateTime.Parse(datetimeString);

                Appointment app = new Appointment()
                {
                    APPT_Status       = item.APPT_Status,
                    AS_Date           = datetime.ToString("dd/MM/yyyy"),
                    AS_SessStartTime  = datetime.ToString("HH:mm"),
                    CTLOC_Code        = item.CTLOC_Code,
                    CTLOC_Desc        = item.CTLOC_Desc,
                    CTPCP_Desc        = item.CTPCP_Desc,
                    PAADM_VisitStatus = item.PAADM_VisitStatus,
                    SER_Desc          = item.SER_Desc
                };
                apps.Add(app);
            }

            try
            {
                apps = apps.OrderByDescending(a => string.IsNullOrEmpty(a.AS_Date) ? (DateTime?)null : DateTime.ParseExact(a.AS_Date, "dd/MM/yyyy", null))
                       .ThenByDescending(a => string.IsNullOrEmpty(a.AS_SessStartTime) ? (DateTime?)null : DateTime.ParseExact(a.AS_SessStartTime, "HH:mm", null)).ToList();
            }
            catch (Exception)
            {
                return(apps);
            }


            return(apps);
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            string    connString = "Server=192.168.1.10;Port=5641;User=_SYSTEM;Password=SYS;Namespace=company2;Pooling=false;";
            const int ErrLogID   = 354159;

            Console.WriteLine("\nProgram starting.");

            try
            {
                CacheConnection conn = new CacheConnection(connString);

                conn.Open();

                var locked = Lock(conn, "ErrLog", ErrLogID);

                if (locked != null)
                {
                    Console.WriteLine("Lock Successfully");
                }
                //Doing things

                //another program
                //Now another program is trying to edit the same row. I want to check if the row is locked.
                CacheConnection conn2 = new CacheConnection(connString);

                conn2.Open();

                var startTime = DateTime.Now;
                Console.WriteLine(startTime.ToString());
                locked = Lock(conn2, "ErrLog", ErrLogID);
                if (locked == null)
                {
                    Console.WriteLine("The row is locked");
                }
                var endTime = DateTime.Now;
                Console.WriteLine(endTime.ToString());
                var diff = endTime.Subtract(startTime);
                var res  = String.Format("{0}:{1}:{2}", diff.Hours, diff.Minutes, diff.Seconds);
                Console.WriteLine($"Time Spend on lock checking {res}");
            }
            catch (Exception ee)
            {
                Console.WriteLine("ERROR: " + ee.Message);
            }

            Console.WriteLine("Program exited.");
        }
Exemplo n.º 30
0
        public static Episode GetEpisode(string hn, CacheConnection con)
        {
            Episode epi = new Episode();

            var dtEpiIn = InterSystemsDa.DtBindDataCommand(QueryString.GetEpisodeInquiry(hn), con);

            if (dtEpiIn.Rows.Count > 0)
            {
                epi = Helper.DataTableToEpisode(dtEpiIn, con);
            }
            else
            {
                epi.EpisodeInquiry = new List <EpisodeInquiry>();
            }

            return(epi);
        }
Exemplo n.º 31
0
        public static Tuple <User, string> GetUser(string username, string password)
        {
            var    model   = new User();
            string message = string.Empty;

            var query = TrakCareQuery.GetUser(username);

            using (CacheConnection con = new CacheConnection(Constants.Cache))
            {
                con.Open();
                using (CacheCommand cmd = new CacheCommand(query.Item1, con))
                {
                    foreach (KeyValuePair <string, string> pair in query.Item2)
                    {
                        var key = pair.Key;
                        cmd.AddInputParameters(new { key = pair.Value });
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            User user = new User()
                            {
                                SSUSR_Initials = reader["SSUSR_Initials"].ToString(),
                                SSUSR_Name     = reader["SSUSR_Name"].ToString(),
                                SSUSR_Password = reader["SSUSR_Password"].ToString()
                            };

                            if (Helper.CheckPassword(user, password))
                            {
                                model   = user;
                                message = "Login Success.";
                            }
                            else
                            {
                                message = "Login fail.";
                            }
                        }
                    }
                }
            }

            return(new Tuple <User, string>(model, message));
        }
Exemplo n.º 32
0
        private void TestConnection()
        {
            try
            {
                CacheConnection cacheConnection = new CacheConnection();
                cacheConnection.ConnectionString = String.Format(
                                                                "Server = {0};Port = 1972;Namespace=SAMPLES;Password={1}; User ID={2}",
                                                                ConnectionHost,
                                                                ConnectionPass,
                                                                ConnectionUser);

                cacheConnection.Open();
                if (cacheConnection.State == System.Data.ConnectionState.Open)
                {
                    // ViewModelNotification = String.Format("Successfully connected to {0}!",ConnectionHost);
                }
                cacheConnection.Close();
            }
            catch (Exception ex)
            {
                //ViewModelNotification = ex.Message;
            }
        }