Beispiel #1
0
        //public void AddResult()
        //{
        //    try
        //    {
        //        string strQuery = "INSERT Results.Results(Client,OrderCode,OrderId,ResultBinaryStream,ResultType,ResultName,ResultDate   ) VALUES(@Client,@OrderCode,@OrderId,@ResultBinaryStream  ,@ResultType,@ResultName,@ResultDate  )";
        //        Cmd = new CacheCommand(strQuery, GetConnection());
        //        Cmd.Parameters.Add("@Client", "test5");
        //        Cmd.Parameters.Add("@OrderCode", "test5");
        //        Cmd.Parameters.Add("@OrderId", "test5");
        //        //Cmd.Parameters.Add("@ResultBinaryFile", "N");
        //        Cmd.Parameters.Add("@ResultType", "F");
        //        Cmd.Parameters.Add("@ResultName", "test5");
        //        Cmd.Parameters.Add("@ResultDate", DateTime.Now.ToString("yyyyMMdd"));
        //        // Now insert two files from disk as streams
        //        // Open binary file and read into byte[]
        //        FileStream fbs = new System.IO.FileStream("test.pdf", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        //        int filebLen = (int)fbs.Length;
        //        byte[] filebData = new byte[filebLen];
        //        fbs.Read(filebData, 0, (int)filebLen);
        //        fbs.Close();
        //        //Cmd.Parameters.Add()
        //        CacheParameter para = new CacheParameter("@ResultBinaryStream", filebData);
        //        para.Size = filebLen;
        //        Cmd.Parameters.Add(para);

        //        Cmd.ExecuteNonQuery();
        //    }
        //    catch(Exception e)
        //    {

        //    }
        //    finally
        //    {
        //        CacheConnect.Close();
        //    }
        //}

        public ClsResultFile GetResultFile(ClsGetResultFile GetResult)
        {
            DataTable dt = new DataTable();
            //byte[] file = null;
            ClsResultFile result = new ClsResultFile();

            try
            {
                //Add Log
                //AddLog(GetResult.appId, "GetResultFile", "RemoteIP" + GetResult.remoteIP + " OrderId " + GetResult.orderId + " OrderCode " + GetResult.test);
                AddLog(GetResult.appId, "GetResultFile", " OrderId " + GetResult.orderId + " OrderCode " + GetResult.test);
                using (Cmd = new CacheCommand("select ResultBinaryStream,FileName from  Results.Results where orderId='" + GetResult.orderId + "' and OrderCode = '" +
                                              GetResult.test + "' and locationId= '" + GetResult.locationId + "' and ResultName='" + GetResult.resultName + "'", GetConnection()))
                {
                    //Cmd.Parameters.Add("@orderId", GetResult.orderId);
                    //Cmd.Parameters.Add("@orderCode", GetResult.test);
                    CacheDataReader reader = Cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        result.resultBinaryStream = reader[0] as byte[];
                        result.fileName           = reader[1] as string;
                    }
                }
            }
            finally
            {
                CacheConnect.Close();
            }
            return(result);
        }
        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();
            }
        }
Beispiel #3
0
 public static void CloseConnection()
 {
     if (_connection != null)
     {
         _connection.Close();
         _connection = null;
     }
 }
 private bool disposed = false;     // To detect redundant calls
 protected virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             cmd.Dispose();
             //make sure the connection state is open so we can close it
             if (conn != null && conn.State == ConnectionState.Open)
             {
                 conn.Close();
             }
         }
         disposed = true;
     }
 }
        //数据库断开连接 ZAM 2015-5-22
        public bool DisConnect()
        {
            bool ret = false;

            try
            {
                DataConnection.count--;
                CacheConnectionObject.Close();
                ret = true;
            }
            catch (Exception ex)
            {
                HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "", "数据库断开连接失败! error information : " + ex.Message + Environment.NewLine + ex.StackTrace);
                throw ex;
            }
            return(ret);
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            CacheConnection CacheConnect = new CacheConnection();

            CacheConnect.ConnectionString = "Server = 192.168.1.10; "
                                            + "Port = 5641; " + "Namespace = COMPANY2; "
                                            + "Password = SYS; " + "User ID = _SYSTEM;";
            CacheConnect.Open();

            var startTime = DateTime.Now;

            CacheConnect.DynamicMode = true;
            CacheMethodSignature mtdSignature = CacheConnect.GetMtdSignature();

            mtdSignature.Clear();
            mtdSignature.Add(375399, false); //id
            mtdSignature.Add(0, false);      //exclusive lock
            mtdSignature.Add(0, false);      //immediate timeout
            mtdSignature.SetReturnType(CacheConnect, ClientTypeId.tStatus);
            CacheObject.RunClassMethod(CacheConnect, "User.Customer", "%LockId", mtdSignature);
            CacheStatus status = (CacheStatus)((CacheStatusReturnValue)(mtdSignature.ReturnValue)).Value;

            if (status.IsOK)
            {
                Console.WriteLine("Lock acquired");

                Console.ReadLine();

                mtdSignature.Clear();
                mtdSignature.Add(1, false); //id
                mtdSignature.SetReturnType(CacheConnect, ClientTypeId.tStatus);
                CacheObject.RunClassMethod(CacheConnect, "Sample.Person", "%UnlockId", mtdSignature);
                Console.WriteLine("Unlocked");
            }
            else
            {
                Console.WriteLine("Already Locked");
            }
            var endTime = DateTime.Now;
            var diff    = endTime.Subtract(startTime);
            var res     = String.Format("{0} milliseconds", diff.TotalMilliseconds);

            Console.WriteLine($"Time Spend on lock checking: {res}");
            CacheConnect.Close();
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            // Create a connection to Cache
            CacheConnection conn = new CacheConnection();

            // Cache server Connection Information
            // Set Server to your IP address and port to Cache SuperServer port, Log File is optional
            conn.ConnectionString = "Server = localhost; Log File=cprovider.log;Port=1972; Namespace=Samples; Password = SYS; User ID = _SYSTEM;";

            //Open a Connection to Cache
            conn.Open();

            CacheMethodSignature ms = new CacheMethodSignature();

            ms.SetReturnType(conn, ClientTypeId.tString);
            CacheObject.RunClassMethod(conn, "%SYSTEM.Version", "GetVersion", ms);

            Console.Write("ReturnValue = " + ms.ReturnValue._Value);

            conn.Close();
        }
        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;
            }
        }
Beispiel #9
0
 public void close()
 {
     conn.Close();
 }
Beispiel #10
0
        public DataTable GetOrganization()
        {
            DataTable dt = new DataTable();

            try
            {
                using (Cmd = new CacheCommand("select * from  HICL.Organization", GetConnection()))
                {
                    dt.Load(Cmd.ExecuteReader());
                }
            }
            finally
            {
                CacheConnect.Close();
            }
            return(dt);
        }