Exemple #1
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"]);
            }
        }
Exemple #2
0
        /// <summary>
        /// Execute command string
        ///  Close connection database
        /// </summary>
        /// <param name="cmdString"></param>
        /// <param name="conString"></param>
        /// <returns>DataSet</returns>
        public static DataSet DsBindDataCommand(string cmdString, string conString)
        {
            var ds = new DataSet();

            using (var con = ConnectCache.DBUtils.GetDBConnection())
            {
                try
                {
                    con.Open();
                    using (var adp = new CacheDataAdapter(cmdString, conString))
                    {
                        adp.Fill(ds);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
                finally
                {
                    con.Close();
                    con.Dispose();
                }
            }

            return(ds);
        }
Exemple #3
0
        protected override void initializeDataSource()
        {
            _dataAdapter   = new CacheDataAdapter(SQL_SELECT_ALL, DbHelper.GetConnection());
            ItemsDataTable = new DataTable("USERS");
            _dataAdapter.Fill(ItemsDataTable);

            /*
             * Users = new List<User.User>();
             *
             * foreach (DataRow row in ItemsDataTable.Rows)
             * {
             *  Users.Add(User.User.OpenId(DbHelper.GetConnection(), row["ID"].ToString()));
             * }*/
        }
Exemple #4
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);
        }
Exemple #5
0
        protected override void initializeDataSource()
        {
            _dataAdapter   = new CacheDataAdapter(SQL_SELECT_ALL, DbHelper.GetConnection());
            ItemsDataTable = new DataTable("CATEGORIES");
            _dataAdapter.Fill(ItemsDataTable);

            /*
             * Categories = new List<Category>();
             *
             * foreach (DataRow row in ItemsDataTable.Rows)
             * {
             *  Categories.Add(Category.OpenId(DbHelper.GetConnection(), row["ID"].ToString()));
             * }*/
        }
Exemple #6
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;
        }
        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);
        }
        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);
        }
Exemple #9
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);
        }
Exemple #10
0
        public static DataTable DtBindDataCommand(string cmdString, CacheConnection con)
        {
            var dt = new DataTable();

            try
            {
                using (var adp = new CacheDataAdapter(cmdString, con))
                {
                    adp.Fill(dt);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(dt);
        }
Exemple #11
0
        protected override void initializeDataSource()
        {
            try
            {
                _dataAdapter   = new CacheDataAdapter(SQL_SELECT_ALL, DbHelper.GetConnection());
                ItemsDataTable = new DataTable("RESERVATIONS");
                _dataAdapter.Fill(ItemsDataTable);

                Reservations = new List <User.Reservations>();

                foreach (DataRow row in ItemsDataTable.Rows)
                {
                    Reservations.Add(User.Reservations.OpenId(DbHelper.GetConnection(), row["ID"].ToString()));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #12
0
        public IList <ClsResult> GetResult(ClsGetResult GetResult)
        {
            DataTable         dt = new DataTable();
            IList <ClsResult> os = null;
            String            str;

            try
            {
                //Add Log
                AddLog(GetResult.appId, "GetResult", "RemoteIP:" + GetResult.remoteIP + ";OrderId:" + GetResult.orderId);

                if (GetResult.test == null)
                {
                    str = "select clientId,resultName,resultDate,resultType,resultText,flag,units,normalRange,OrderCode , OrderId, resCode, supplierSite    from  Results.Results where orderId=@orderId and locationid=@locationid";
                }
                else
                {
                    str = "select clientId,resultName,resultDate,resultType,resultText,flag,units,normalRange,OrderCode , OrderId, resCode, supplierSite    from  Results.Results where orderId=@orderId and OrderCode = @test and locationid=@locationid";
                }

                using (Cmd = new CacheCommand(str, GetConnection()))
                {
                    if (GetResult.test == null)
                    {
                        Cmd.Parameters.Add("@orderId", GetResult.orderId);
                        Cmd.Parameters.Add("@locationid", GetResult.locationId);
                    }
                    else
                    {
                        Cmd.Parameters.Add("@orderId", GetResult.orderId);
                        Cmd.Parameters.Add("@test", GetResult.test);
                        Cmd.Parameters.Add("@locationid", GetResult.locationId);
                    }


                    //Cmd.Parameters.Add("@orderId", GetResult.orderId);
                    //Cmd.Parameters.Add("@orderCode", GetResult.test);
                    //dt.Load(Cmd.ExecuteReader());
                    CacheDataAdapter da = new CacheDataAdapter(Cmd);
                    da.Fill(dt);

                    var query = from p in dt.AsEnumerable()
                                select new ClsResult
                    {
                        clientId     = p.Field <string>("clientId"),
                        resultName   = p.Field <string>("ResultName"),
                        resultDate   = p.Field <string>("ResultDate"),
                        resultType   = p.Field <string>("ResultType"),
                        resultText   = p.Field <string>("ResultText"),
                        resultFlag   = p.Field <string>("Flag"),
                        resultUnits  = p.Field <string>("Units"),
                        normalRange  = p.Field <string>("NormalRange"),
                        orderCode    = p.Field <string>("OrderCode"),
                        orderId      = p.Field <string>("OrderId"),
                        resCode      = p.Field <string>("resCode"),
                        supplierSite = p.Field <string>("supplierSite")
                    };

                    // os = query.FirstOrDefault();
                    os = query.ToList();
                }
            }
            finally
            {
                CacheConnect.Close();
            }
            return(os);
        }