Esempio n. 1
0
        static void Main(string[] args)
        {

            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID = "user";
                conn_str.Password = "******";
                conn_str.Server = "localhost";
                conn_str.Database = "HS.SALES";
                conn_str.ServerType = "UNIVERSE";
                conn_str.Pooling = false;
                string s = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");
                con.Close();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                if (e.InnerException != null)
                {
                   Console.WriteLine(e.InnerException.Message); 
                }

            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 2
0
        public static List <Orders> ReadExistingOrders(String OrderID)
        {
            List <Orders> Cart = new List <Orders>();

            OrderID = OrderID;
            string connection = ConfigurationManager.AppSettings["MVWriter"];

            U2Connection con = new U2Connection();

            con.ConnectionString = connection;
            con.Open();
            U2Command cmd = con.CreateCommand();

            cmd.CommandText = "SELECT PROD, QUAN, COST FROM UNNEST SHOPPINGCART ON CARTS WHERE RECID = '" + OrderID + "'";
            DataSet       ds = new DataSet();
            U2DataAdapter da = new U2DataAdapter(cmd);

            da.Fill(ds);
            DataTable dt = ds.Tables[0];

            foreach (DataRow dr in dt.Rows)
            {
                Orders ExistingLineItems = new Orders {
                    Cost = dr["COST"].ToString(), Quantity = dr["QUAN"].ToString(), Serial = dr["PROD"].ToString()
                };
                Cart.Add(ExistingLineItems);
            }

            con.Close();


            return(Cart);
        }
Esempio n. 3
0
 private void ExecuteCommand(U2Connection con)
 {
     try
     {
         if (settings.AccessMode == "Native")
         {
             // Native mode
             UniSession us1    = con.UniSession;
             UniCommand uniCmd = us1.CreateUniCommand();
             uniCmd.Command = settings.CommandText;
             uniCmd.Execute();
             // Get response string but not output
             string strNative = uniCmd.Response;
         }
         else
         {
             // SQL mode
             U2Command cmd = con.CreateCommand();
             cmd.Connection  = con;
             cmd.CommandText = settings.CommandText;
             cmd.ExecuteNonQuery();
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
     finally
     {
     }
 }
        public static async Task <List <Customer> > CallSubroutine()
        {
            try
            {
                List <Customer> lRetList = new List <Customer>();
                U2Connection    conn     = CreateConnection.GetConnection();
                await conn.OpenAsync();

                U2Command command = conn.CreateCommand();

                Console.WriteLine("Connected.........................");
                command.CommandText = "CALL *HS.SALES*GETCUSTOMER()"; // UniVerse subroutine, returns multi-value data
                U2DataReader dr = await command.ExecuteReaderAsync();

                while (await dr.ReadAsync())
                {
                    Customer lCust = new Customer();
                    lCust.CustomerId = await dr.GetFieldValueAsync <int>(0);

                    lCust.FirstName = await dr.GetFieldValueAsync <string>(1);

                    lCust.LastName = await dr.GetFieldValueAsync <string>(2);

                    lRetList.Add(lCust);
                }
                conn.Close();
                return(lRetList);
            }
            catch (Exception ee)
            {
                string lErr = ee.Message;
                throw;
            }
        }
Esempio n. 5
0
 static void Main(string[] args)
 {
     try
     {
         U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
         conn_str.UserID     = "user";
         conn_str.Password   = "******";
         conn_str.Server     = "localhost";
         conn_str.Database   = "HS.SALES";
         conn_str.ServerType = "UNIVERSE";
         conn_str.Pooling    = false;
         string       s   = conn_str.ToString();
         U2Connection con = new U2Connection();
         con.ConnectionString = s;
         con.Open();
         Console.WriteLine("Connected.........................");
         con.Close();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         if (e.InnerException != null)
         {
             Console.WriteLine(e.InnerException.Message);
         }
     }
     finally
     {
         Console.WriteLine("Enter to exit:");
         string line = Console.ReadLine();
     }
 }
Esempio n. 6
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                this.textBox1.Clear();
                var connection_str = System.Configuration.ConfigurationManager.ConnectionStrings["DEMO_UD"];

                string s = connection_str.ConnectionString;
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                this.textBox1.AppendText("Connected.........................(UniData Account)" + Environment.NewLine);

                U2Command cmd = con.CreateCommand();

                cmd.CommandText = "SELECT ID, FNAME,LNAME FROM STUDENT_NF_SUB";

                DataSet ds = new DataSet();
                m_da = new U2DataAdapter(cmd);
                m_da.Fill(ds);
                m_U2CommandBuilder = new U2CommandBuilder(m_da);

                this.dataGridView1.DataSource = ds.Tables[0].DefaultView;

                this.textBox1.AppendText("Done........................." + Environment.NewLine);

            }
            catch (Exception e3)
            {
                this.textBox1.AppendText(e3.Message);
                MessageBox.Show(e3.Message);
            }
        }
Esempio n. 7
0
 private void ExecuteDataReader(U2Connection con)
 {
     try
     {
         if (settings.AccessMode == "Native")
         {
             // Need to confirm how to use UniDataSet
         }
         else
         {
             U2Command cmd = con.CreateCommand();
             cmd.Connection  = con;
             cmd.CommandText = settings.CommandText;
             U2DataReader dr = cmd.ExecuteReader();
             while (dr.Read())
             {
                 // Do something
             }
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 8
0
        private void ExecuteDataSet(U2Connection con)
        {
            try
            {
                if (settings.AccessMode == "Native")
                {
                    // Need to confirm how to use UniDataSet
                }
                else
                {
                    U2Command cmd = con.CreateCommand();
                    cmd.Connection  = con;
                    cmd.CommandText = settings.CommandText;

                    U2DataAdapter da = new U2DataAdapter();
                    da.SelectCommand = cmd;
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 9
0
        public async Task <string> QueryUsers(int pageNumber, int pageSize)
        {
            string lRetJsonData = string.Empty;

            try
            {
                U2ConnectionStringBuilder l = new U2ConnectionStringBuilder();
                l.UserID          = "admjjin";
                l.Password        = "******";
                l.Server          = "192.168.102.132";
                l.Database        = "HS.SALES";
                l.ServerType      = "universe";
                l.Connect_Timeout = 360;
                l.RpcServiceType  = "uvcs";
                l.AccessMode      = "Native";

                string       lconnstr = l.ToString();
                U2Connection c        = new U2Connection();
                c.ConnectionString = lconnstr;
                await c.OpenAsync();

                U2Command cmd = c.CreateCommand();
                cmd.CommandText = string.Format("Action=Select;File=CUSTOMER;Attributes=CUSTID,FNAME,LNAME,PRODID,BUY_DATE;Where=CUSTID>0;Sort=CUSTID");
                lRetJsonData    = await cmd.ExecuteJsonAsync();


                c.Close();
            }
            catch (Exception ee)
            {
                throw ee;
            }
            return(lRetJsonData);
        }
Esempio n. 10
0
        public Boolean connect(string host, String user, String path, String pass, String service, ref String errText)
        {
            if (service == String.Empty)
            {
                service = "uvcs";
            }
            conn = new U2Connection();
            U2ConnectionStringBuilder connBuilder = new U2ConnectionStringBuilder();

            connBuilder.Server         = host;
            connBuilder.UserID         = user;
            connBuilder.Password       = pass;
            connBuilder.Database       = path;
            connBuilder.ServerType     = "UNIVERSE";
            connBuilder.AccessMode     = "Native"; // FOR UO
            connBuilder.RpcServiceType = service;  // FOR UO
            connBuilder.Pooling        = false;

            try {
                conn.ConnectionString = connBuilder.ToString();
                conn.Open();
                _sess = conn.UniSession;
            } catch (Exception ex) {
                _sess   = null;
                errText = ex.Message;
                return(false);
            }
            return(true);
        }
Esempio n. 11
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                this.textBox1.Clear();
                var connection_str = System.Configuration.ConfigurationManager.ConnectionStrings["DEMO_UD"];

                string       s   = connection_str.ConnectionString;
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                this.textBox1.AppendText("Connected.........................(UniData Account)" + Environment.NewLine);

                U2Command cmd = con.CreateCommand();

                cmd.CommandText = "SELECT ID, FNAME,LNAME FROM STUDENT_NF_SUB";

                DataSet ds = new DataSet();
                m_da = new U2DataAdapter(cmd);
                m_da.Fill(ds);
                m_U2CommandBuilder = new U2CommandBuilder(m_da);

                this.dataGridView1.DataSource = ds.Tables[0].DefaultView;

                this.textBox1.AppendText("Done........................." + Environment.NewLine);
            }
            catch (Exception e3)
            {
                this.textBox1.AppendText(e3.Message);
                MessageBox.Show(e3.Message);
            }
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID         = "user";
                conn_str.Password       = "******";
                conn_str.Server         = "localhost";
                conn_str.Database       = "HS.SALES";
                conn_str.ServerType     = "UNIVERSE";
                conn_str.AccessMode     = "Native"; // FOR UO
                conn_str.RpcServiceType = "uvcs";   // FOR UO
                conn_str.Pooling        = false;
                string       s   = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");

                // get RECID

                UniSession us1 = con.UniSession;

                UniSelectList sl = us1.CreateUniSelectList(2);

                // Select UniFile
                UniFile fl = us1.CreateUniFile("CUSTOMER");
                sl.Select(fl);

                bool          lLastRecord = sl.LastRecordRead;
                List <string> lRecIdList  = new List <string>();
                while (!lLastRecord)
                {
                    string sRecID = sl.Next();
                    lRecIdList.Add(sRecID);
                    Console.WriteLine("Record ID:" + sRecID);
                    lLastRecord = sl.LastRecordRead;
                }

                UniDataSet uSet = fl.ReadRecords(lRecIdList.ToArray());
                // use for each statement to print the record
                foreach (UniRecord item in uSet)
                {
                    Console.WriteLine(item.ToString());
                }

                con.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID         = "user";
                conn_str.Password       = "******";
                conn_str.Server         = "localhost";
                conn_str.Database       = "demo";
                conn_str.ServerType     = "UNIDATA";
                conn_str.AccessMode     = "Native"; // FOR UO
                conn_str.RpcServiceType = "udcs";   // FOR UO
                conn_str.Pooling        = false;
                string       s   = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");

                // get RECID

                UniSession us1 = con.UniSession;

                UniSelectList sl = us1.CreateUniSelectList(2);

                // Select UniFile
                UniFile fl = us1.CreateUniFile("STUDENT");
                sl.Select(fl);

                bool lLastRecord = sl.LastRecordRead;

                while (!lLastRecord)
                {
                    string s2 = sl.Next();
                    Console.WriteLine("Record ID:" + s2);
                    lLastRecord = sl.LastRecordRead;
                }



                con.Close();
            }
            catch (Exception e)
            {
                string s = e.Message;
                if (e.InnerException != null)
                {
                    s += e.InnerException.Message;
                }

                Console.WriteLine(s);
            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 14
0
 public void disconnect()
 {
     if (conn != null)
     {
         conn.Close();
         conn  = null;
         _sess = null;
     }
 }
Esempio n. 15
0
 /// <summary>
 /// Close active connection
 /// </summary>
 private void DoDisconnection()
 {
     if (con != null && con.State == ConnectionState.Open)
     {
         con.Close();
         con.Dispose();
         con = null;
     }
 }
Esempio n. 16
0
        static void Main(string[] args)
        {


            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID = "user";
                conn_str.Password = "******";
                conn_str.Server = "localhost";
                conn_str.Database = "HS.SALES";
                conn_str.ServerType = "UNIVERSE";
                conn_str.AccessMode = "Native";   // FOR UO
                conn_str.RpcServiceType = "uvcs"; // FOR UO
                conn_str.Pooling = false;
                string s = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");

                

                UniSession us1 = con.UniSession;

                string RoutineName = "!TIMDAT";
                int IntTotalAtgs = 1;
                string[] largs = new string[IntTotalAtgs];
                largs[0] = "1";
                UniDynArray tmpStr2;
                UniSubroutine sub = us1.CreateUniSubroutine(RoutineName, IntTotalAtgs);

                for (int i = 0; i < IntTotalAtgs; i++)
                {
                    sub.SetArg(i, largs[i]);
                }

                sub.Call();
                tmpStr2 = sub.GetArgDynArray(0);
                string result = "\n" + "Result is :" + tmpStr2;
                Console.WriteLine("  Response from UniSubRoutineSample :" + result);

                
                con.Close();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 17
0
        static void Main(string[] args)
        {

            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID = "user";
                conn_str.Password = "******";
                conn_str.Server = "localhost";
                conn_str.Database = "HS.SALES";
                conn_str.ServerType = "UNIVERSE";
                conn_str.AccessMode = "Native";   // FOR UO
                conn_str.RpcServiceType = "uvcs"; // FOR UO
                conn_str.Pooling = false;
                string s = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");

                // get RECID

                UniSession us1 = con.UniSession;
                UniSelectList sl = us1.CreateUniSelectList(2);

                // Select UniFile
                UniFile fl = us1.CreateUniFile("CUSTOMER");
                sl.Select(fl);

                bool lLastRecord = sl.LastRecordRead;

                while (!lLastRecord)
                {
                    string s2 = sl.Next();
                    Console.WriteLine("Record ID:" + s2);
                    lLastRecord = sl.LastRecordRead;
                }

                

                con.Close();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Get an U2 connection object
        /// </summary>
        /// <returns></returns>
        private U2Connection GetU2Connection()
        {
            U2ConnectionStringBuilder conStr = new U2ConnectionStringBuilder();

            // Login settings
            conStr.UserID     = settings.UserName;
            conStr.Password   = settings.Password;
            conStr.Server     = settings.Server;
            conStr.Database   = settings.Database;
            conStr.ServerType = settings.ServerType;

            conStr.Connect_Timeout    = settings.ConnTimeOut;
            conStr.ConnectionLifeTime = settings.ConnLifeTime;

            // Access mode
            if (settings.AccessMode == "Native")
            {
                conStr.AccessMode = settings.AccessMode;
                if (conStr.ServerType == "UNIDATA")
                {
                    conStr.RpcServiceType = "udcs";
                }
                else
                {
                    conStr.RpcServiceType = "uvcs";
                }
            }
            else
            {
                // If not Native mode and set the property like bellow, an error occurred
                //conStr.AccessMode = "Uci"; // settings.AccessMode;
                //conStr.RpcServiceType = "defcs"; // settings.RpcServiceType;
            }

            // SSL settings
            conStr.SSLConnection = settings.EnableSSLConnection;
            if (conStr.SSLConnection == true)
            {
                conStr.SslIgnoreCertificateNameMismatch = settings.EnableSSLIgnCertNameMismatch;

                if (settings.CertificateFilePath.Length > 0)
                {
                    conStr.ClientCertificatePath = settings.CertificateFilePath;
                }
                conStr.SslIgnoreIncompleteCertificateChain = settings.EnableSSLIgnIncompCertChain;
                conStr.SslCheckCertificateRevocation       = settings.EnableSSLChkCertRevocation;
            }

            U2Connection con = new U2Connection();

            con.ConnectionString = conStr.ToString();
            return(con);
        }
Esempio n. 19
0
        static void Main(string[] args)
        {
            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID         = "user";
                conn_str.Password       = "******";
                conn_str.Server         = "localhost";
                conn_str.Database       = "HS.SALES";
                conn_str.ServerType     = "UNIVERSE";
                conn_str.AccessMode     = "Native"; // FOR UO
                conn_str.RpcServiceType = "uvcs";   // FOR UO
                conn_str.Pooling        = false;
                string       s   = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");



                UniSession us1 = con.UniSession;

                string   RoutineName  = "!TIMDAT";
                int      IntTotalAtgs = 1;
                string[] largs        = new string[IntTotalAtgs];
                largs[0] = "1";
                UniDynArray   tmpStr2;
                UniSubroutine sub = us1.CreateUniSubroutine(RoutineName, IntTotalAtgs);

                for (int i = 0; i < IntTotalAtgs; i++)
                {
                    sub.SetArg(i, largs[i]);
                }

                sub.Call();
                tmpStr2 = sub.GetArgDynArray(0);
                string result = "\n" + "Result is :" + tmpStr2;
                Console.WriteLine("  Response from UniSubRoutineSample :" + result);


                con.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 20
0
        static void Main(string[] args)
        {

            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID = "user";
                conn_str.Password = "******";
                conn_str.Server = "localhost";
                conn_str.Database = "demo";
                conn_str.ServerType = "UNIDATA";
                conn_str.AccessMode = "Native";   // FOR UO
                conn_str.RpcServiceType = "udcs"; // FOR UO
                conn_str.Pooling = false;
                string s = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");


                UniSession us1 = con.UniSession;

                UniCommand cmd = us1.CreateUniCommand();
                cmd.Command = "LIST STUDENT ALL  SAMPLE 10";
                cmd.Execute();
                string response_str = cmd.Response;
                Console.WriteLine("UniCommand Output" + response_str + Environment.NewLine);

                con.Close();

            }
            catch (Exception e)
            {
                string s = e.Message;
                if (e.InnerException != null)
                {
                    s += e.InnerException.Message;
                }

                Console.WriteLine(s);

            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }

        }
Esempio n. 21
0
        public ActionResult Index()
        {
            List <APMST> sample = new List <APMST>();

            try
            {
                string       s   = ConfigurationManager.AppSettings["TESTString"];
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();

                U2Command cmd = con.CreateCommand();
                cmd.CommandText = "SELECT PROD,SALE, DESC1 FROM IVMST"; // FNAME = SingleValue, PRICE = multivalue



                DataSet       ds = new DataSet();
                U2DataAdapter da = new U2DataAdapter(cmd);
                da.Fill(ds);
                DataTable dt = ds.Tables[0];

                foreach (DataRow dr in dt.Rows)
                {
                    //APMST loadRecord = new APMST {  NAME = dr["NAME"].ToString() };
                    APMST loadRecord = new APMST {
                        NAME = dr["PROD"].ToString()
                    };

                    sample.Add(loadRecord);
                }


                con.Close();
            }
            catch (Exception e)
            {
                // Console.WriteLine(e.Message);
                if (e.InnerException != null)
                {
                }
            }
            finally
            {
                // string line = Console.ReadLine();
            }


            return(View(sample));
        }
Esempio n. 22
0
        /// <summary>
        /// Create and open connection
        /// </summary>
        private void DoConnection()
        {
            try
            {
                // Close current connection if exists
                DoDisconnection();

                con = GetU2Connection();
                con.Open();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public static async Task <DataTable> CallSubroutine()
        {
            try
            {
                DataTable lRetDT = new DataTable("EmpTable");
                lRetDT.Columns.Add("ID", typeof(Int32));
                lRetDT.Columns.Add("Name", typeof(string));
                lRetDT.Columns.Add("HireDate", typeof(DateTime));

                U2Connection conn = CreateConnection.GetConnection();
                await conn.OpenAsync();

                U2Command command = conn.CreateCommand();
                Console.WriteLine("Connected.........................");

                command.CommandText = "CALL *HS.SALES*SELECT_SUBROUTINE(?,?)"; // UniVerse subroutine, returns multi-value data

                command.Parameters.Clear();

                command.CommandType = CommandType.StoredProcedure;
                U2Parameter p1 = new U2Parameter();
                p1.Direction = ParameterDirection.InputOutput;

                p1.Value         = "1";//INPUT
                p1.ParameterName = "@arg1";

                U2Parameter p2 = new U2Parameter();
                p2.Direction     = ParameterDirection.InputOutput;
                p2.Value         = "";//OUTPUT (multi-value data
                p2.ParameterName = "@arg2";

                command.Parameters.Add(p1);
                command.Parameters.Add(p2);

                await command.ExecuteNonQueryAsync();

                string s1 = command.Parameters[0].Value.ToString(); //INPUT
                string s2 = command.Parameters[1].Value.ToString(); // OUTPUT
                p2.MV_To_DataTable(lRetDT);                         //Convert multi-value data to C# DataTable using Schema
                conn.Close();
                return(lRetDT);
            }
            catch (Exception ee)
            {
                string lErr = ee.Message;
                throw;
            }
        }
Esempio n. 24
0
        public ActionResult GetProduct(string term)
        {
            List <Product> ProductsFound = new List <Product>();

            string Upperterm = term.ToUpper();

            try
            {
                string s = ConfigurationManager.AppSettings["TESTString"];

                U2Connection con = new U2Connection();
                U2Command    cmd = con.CreateCommand();
                con.ConnectionString = s;
                con.Open();

                cmd.CommandText = "SELECT PROD,SALE, DESC1 FROM IVMST WHERE UPPER(DESC1) LIKE '%" + Upperterm + "%'";

                U2DataReader dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    Product ProductList = new Product {
                        DESC1 = dr["DESC1"].ToString(),
                        PROD  = dr["PROD"].ToString(),
                        SALE  = dr["SALE"].ToString()
                    };

                    ProductsFound.Add(ProductList);
                }


                con.Close();
            }
            catch (Exception e)
            {
                // Console.WriteLine(e.Message);
                if (e.InnerException != null)
                {
                }
            }
            finally
            {
                // string line = Console.ReadLine();
            }


            return(Json(ProductsFound, JsonRequestBehavior.AllowGet));
        }
        public static U2Connection GetConnection()
        {
            U2ConnectionStringBuilder l = new U2ConnectionStringBuilder();
            l.UserID = "admin";
            l.Password = "******";
            l.Server = "9.21.45.89";
            l.Database = "HS.SALES";
            l.ServerType = "universe";
            l.Connect_Timeout = 360;
            l.AccessMode = "Uci";

            string lconnstr = l.ToString();
            U2Connection conn = new U2Connection();
            conn.ConnectionString = lconnstr;
            return conn;
        }
Esempio n. 26
0
        static void Main(string[] args)
        {
            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID         = "user";
                conn_str.Password       = "******";
                conn_str.Server         = "localhost";
                conn_str.Database       = "demo";
                conn_str.ServerType     = "UNIDATA";
                conn_str.AccessMode     = "Native"; // FOR UO
                conn_str.RpcServiceType = "udcs";   // FOR UO
                conn_str.Pooling        = false;
                string       s   = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");


                UniSession us1 = con.UniSession;

                UniCommand cmd = us1.CreateUniCommand();
                cmd.Command = "LIST STUDENT ALL  SAMPLE 10";
                cmd.Execute();
                string response_str = cmd.Response;
                Console.WriteLine("UniCommand Output" + response_str + Environment.NewLine);

                con.Close();
            }
            catch (Exception e)
            {
                string s = e.Message;
                if (e.InnerException != null)
                {
                    s += e.InnerException.Message;
                }

                Console.WriteLine(s);
            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 27
0
        public static bool UpdateProducts(List <Orders> Cart, string OrderID, string Product)
        {
            try
            {
                int lRecID = 99;

                U2ConnectionStringBuilder conn_bldr = new U2ConnectionStringBuilder();
                conn_bldr.UserID         = "administrator";
                conn_bldr.Password       = "******";
                conn_bldr.Server         = "myserver";
                conn_bldr.ServerType     = "universe";
                conn_bldr.Database       = "HS.SALES";
                conn_bldr.AccessMode     = "Native";
                conn_bldr.RpcServiceType = "uvcs";
                string       lConnStr = conn_bldr.ConnectionString;
                U2Connection lConn    = new U2Connection();
                lConn.ConnectionString = lConnStr;
                lConn.Open();
                UniSession lUniSession = lConn.UniSession;
                U2Command  cmd         = lConn.CreateCommand();

                //CUSTID,FNAME,LNAME : Single Value
                //PRODID, BUY_DATE    : Multi Value
                //Syntax : Action=Update;File=?;Attributes=?;Where=?;Sort


                UniDynArray lArr = new UniDynArray(lUniSession, "2/1/1991");
                lArr.Insert(1, -1, "3/9/1991");
                lArr.Insert(1, -1, "4/1/1991");

                string lCmd = string.Format("UPDATE SHOPPINGCART SET FNAME={0},BUY_DATE='{1}'  WHERE CUSTID={2} ", "Fred2", lArr.StringValue, lRecID);
                cmd.CommandText = lCmd;
                int l2 = cmd.ExecuteNonQuery();

                lConn.Close();
            }
            catch (Exception e2)
            {
                string lErr = e2.Message;
                if (e2.InnerException != null)
                {
                    lErr += lErr + e2.InnerException.Message;
                }
            }
            return(true);
        }
Esempio n. 28
0
        public static async Task <string> CallSubroutine()
        {
            try
            {
                string lRetJsonData = string.Empty;

                U2Connection conn = CreateConnection.GetConnection();
                await conn.OpenAsync();

                U2Command command = conn.CreateCommand();
                Console.WriteLine("Connected.........................");

                command.CommandText = "CALL *HS.SALES*SELECT_SUBROUTINE(?,?)"; // UniVerse subroutine, returns multi-value data

                command.Parameters.Clear();

                command.CommandType = CommandType.StoredProcedure;
                U2Parameter p1 = new U2Parameter();
                p1.Direction = ParameterDirection.InputOutput;

                p1.Value         = "1";//INPUT
                p1.ParameterName = "@arg1";

                U2Parameter p2 = new U2Parameter();
                p2.Direction     = ParameterDirection.InputOutput;
                p2.Value         = "";//OUTPUT (multi-value data
                p2.ParameterName = "@arg2";

                command.Parameters.Add(p1);
                command.Parameters.Add(p2);

                await command.ExecuteNonQueryAsync();

                string          s1          = command.Parameters[0].Value.ToString(); //INPUT
                string          s2          = command.Parameters[1].Value.ToString(); // OUTPUT
                List <Employee> lRetEmpList = p2.MV_To_POCO <Employee>();             //Convert multi-value data to C# POCO Class using Schema
                lRetJsonData = Newtonsoft.Json.JsonConvert.SerializeObject(lRetEmpList);
                conn.Close();
                return(lRetJsonData);
            }
            catch (Exception ee)
            {
                string lErr = ee.Message;
                throw;
            }
        }
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("start.........................");
                Stopwatch sw = new Stopwatch();
                sw.Start();

                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID     = "administrator";
                conn_str.Password   = "******";
                conn_str.Server     = "localhost";
                conn_str.Database   = "XDEMO";
                conn_str.ServerType = "UNIVERSE";
                conn_str.Pooling    = false;
                string       s   = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;

                con.Open();
                Console.WriteLine("Connected...");
                U2Command cmd = con.CreateCommand();
                cmd.CommandText = "SELECT * FROM PRODUCTS";
                DataSet       ds = new DataSet();
                U2DataAdapter da = new U2DataAdapter(cmd);
                da.Fill(ds);

                sw.Stop();

                TimeSpan elapsed     = sw.Elapsed;
                string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", elapsed.Hours, elapsed.Minutes, elapsed.Seconds, elapsed.Milliseconds / 10);
                int      nSec        = elapsed.Seconds;
                con.Close();
                Console.WriteLine("Time Taken in seconds:" + elapsedTime);
                Console.WriteLine("End........................... ");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 30
0
        public static List <Orders> GetProducts(List <Orders> Cart)
        {
            List <Orders> shoppingCart = Cart;


            U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();

            conn_str.UserID     = "Demo";
            conn_str.Password   = "******";
            conn_str.Server     = "localhost";
            conn_str.Database   = "pwdemo";
            conn_str.ServerType = "UNIVERSE";
            conn_str.Pooling    = false;
            string       s    = conn_str.ToString();
            U2Connection con1 = new U2Connection();

            con1.ConnectionString = s;
            con1.Open();

            U2Command cmd1 = con1.CreateCommand();

            foreach (var Product in shoppingCart)
            {
                try
                {
                    cmd1.CommandText = "SELECT [DESC_POS] FROM IVMST WHERE ID=" + Product.Serial.ToString();
                    U2DataReader dr1 = cmd1.ExecuteReader();

                    while (dr1.Read())
                    {
                        Product.ProdDescription = string.Format(dr1["DESC_POS"].ToString());
                        dr1.Close();
                    }
                }
                catch (Exception ex)
                {
                }
            }



            con1.Close();

            return(shoppingCart);
        }
        public static U2Connection GetConnection()
        {
            U2ConnectionStringBuilder l = new U2ConnectionStringBuilder();

            l.UserID          = "admin";
            l.Password        = "******";
            l.Server          = "9.21.45.89";
            l.Database        = "HS.SALES";
            l.ServerType      = "universe";
            l.Connect_Timeout = 360;
            l.AccessMode      = "Uci";

            string       lconnstr = l.ToString();
            U2Connection conn     = new U2Connection();

            conn.ConnectionString = lconnstr;
            return(conn);
        }
Esempio n. 32
0
        public static bool  DeleteProducts(List <Orders> Cart, string OrderID, string Product)
        {
            ///     // First Insert, then Print, then Delete
            try
            {
                Console.WriteLine(Environment.NewLine + "Start...");
                U2ConnectionStringBuilder conn_bldr = new U2ConnectionStringBuilder();
                conn_bldr.UserID         = "Demo";
                conn_bldr.Password       = "******";
                conn_bldr.Server         = "localhost";
                conn_bldr.ServerType     = "universe";
                conn_bldr.Database       = "pwdemo";
                conn_bldr.AccessMode     = "Native";
                conn_bldr.RpcServiceType = "uvcs";
                string       lConnStr = conn_bldr.ConnectionString;
                U2Connection lConn    = new U2Connection();
                lConn.ConnectionString = lConnStr;
                lConn.Open();
                UniSession lUniSession = lConn.UniSession;

                U2Command cmd = lConn.CreateCommand();

                // delete inserted value

                cmd.CommandText = string.Format("Action=Delete;File=SHOPPINGCART;Where=newrecid={0}", OrderID);
                int l2 = cmd.ExecuteNonQuery();


                //close connection
                lConn.Close();
            }
            catch (Exception e2)
            {
                string lErr = e2.Message;
                if (e2.InnerException != null)
                {
                    lErr += lErr + e2.InnerException.Message;
                }
            }
            // public static bool InsertOrderItem(List<Orders> LineItem, string OrderNumber)


            return(true);
        }
Esempio n. 33
0
        private U2Connection GetConnection()
        {
            var connectionString = new U2ConnectionStringBuilder
            {
                UserID          = this.Username,
                Password        = this.Password,
                Server          = this.Hostname,
                Database        = this.Account,
                AccessMode      = "Native",
                RpcServiceType  = "uvcs",
                ServerType      = "UniVerse",
                Connect_Timeout = 1200
            }.ToString();

            var con = new U2Connection(connectionString);

            con.Open();
            return(con);
        }
Esempio n. 34
0
        static void Main(string[] args)
        {

            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID = "user";
                conn_str.Password = "******";
                conn_str.Server = "localhost";
                conn_str.Database = "demo";
                conn_str.ServerType = "UNIDATA";
                conn_str.Pooling = false;
                string s = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");
                U2Command cmd = con.CreateCommand();
                cmd.CommandText = "SELECT * FROM STUDENT_NF_SUB";
                DataSet ds = new DataSet();
                U2DataAdapter da = new U2DataAdapter(cmd);
                da.Fill(ds);
                DataTable dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    Console.WriteLine(dr["FNAME"]);
                }

                con.Close();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
           
        }
Esempio n. 35
0
        public async Task <string> UpdateUser(object customer)
        {
            int lRet = -1;

            try
            {
                var cust = (IDictionary <string, object>)customer;
                foreach (var property in (IDictionary <String, Object>)cust)
                {
                    Console.WriteLine(property.Key + ": " + property.Value);
                    var t1 = property.Key;
                    var t2 = property.Value;
                }
                U2ConnectionStringBuilder l = new U2ConnectionStringBuilder();
                l.UserID          = "admin";
                l.Password        = "******";
                l.Server          = "192.168.102.132";
                l.Database        = "HS.SALES";
                l.ServerType      = "universe";
                l.Connect_Timeout = 360;
                l.RpcServiceType  = "uvcs";
                l.AccessMode      = "Native";

                string       lconnstr = l.ToString();
                U2Connection c        = new U2Connection();
                c.ConnectionString = lconnstr;
                await c.OpenAsync();

                U2Command cmd = c.CreateCommand();
                //cmd.CommandText = string.Format("Action=Select;File=CUSTOMER;Attributes=CUSTID,FNAME,LNAME,PRODID,BUY_DATE;Where=CUSTID>0;Sort=CUSTID");
                //cmd.CommandText = string.Format("Action=Update;File=CUSTOMER;Attributes=FNAME={0},LNAME={1},DISCOUNT{2};Where=CUSTID={3}", cust["FNAME"], cust["LNAME"], cust["DISCOUNT"], cust["CUSTID"]);
                cmd.CommandText = string.Format("Action=Update;File=CUSTOMER;Attributes=FNAME={0},LNAME={1};Where=CUSTID={2}", cust["FNAME"], cust["LNAME"], cust["CUSTID"]);
                lRet            = await cmd.ExecuteNonQueryAsync();

                c.Close();
            }
            catch (Exception ee)
            {
                throw ee;
            }
            return("200");
        }
Esempio n. 36
0
        private static void FillDataSetWithUNNEST()
        {
            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID = "user";
                conn_str.Password = "******";
                conn_str.Server = "localhost";
                conn_str.Database = "HS.SALES";
                conn_str.ServerType = "UNIVERSE";
                conn_str.FirstNormalForm = false;
                conn_str.Pooling = false;
                string s = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");
                U2Command cmd = con.CreateCommand();
                cmd.CommandText = "SELECT FNAME, PRICE FROM UNNEST CUSTOMER ON ORDERS"; // FNAME = SingleValue, PRICE = multivalue
                DataSet ds = new DataSet();
                U2DataAdapter da = new U2DataAdapter(cmd);
                da.Fill(ds);
                DataTable dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    Console.WriteLine(dr["FNAME"] + "==" + dr["PRICE"]);
                }

                con.Close();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

            }
            finally
            {
                //Console.WriteLine("Enter to exit:");
                //string line = Console.ReadLine();
            }
        }
Esempio n. 37
0
        static void Main(string[] args)
        {

            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID = "user";
                conn_str.Password = "******";
                conn_str.Server = "localhost";
                conn_str.Database = "demo";
                conn_str.ServerType = "UNIDATA";
                conn_str.Pooling = false;
                string s = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");
                U2Command cmd = con.CreateCommand();
                cmd.CommandText = "SELECT * FROM STUDENT_NF_SUB";
                U2DataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    string s1 = string.Format("FNAME={0}     LNAME={1}", dr["FNAME"], dr["LNAME"] + Environment.NewLine);
                    Console.WriteLine(s1);
                }
                
                con.Close();
                
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
               
            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
           
        }
Esempio n. 38
0
        static void Main(string[] args)
        {
            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID = "user";
                conn_str.Password = "******";
                conn_str.Server = "localhost";
                conn_str.Database = "HS.SALES";
                conn_str.ServerType = "UNIVERSE";
                conn_str.Pooling = false;
                string s = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");
                U2Command cmd = con.CreateCommand();
                cmd.CommandText = "LIST CUSTOMER";
                DataSet ds = new DataSet();
                U2DataAdapter da = new U2DataAdapter(cmd);
                da.FillWithTOXML(ds);
               

                 Console.WriteLine(ds.GetXml());
                

                
                con.Close();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 39
0
        static void Main(string[] args)
        {
            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID          = "user";
                conn_str.Password        = "******";
                conn_str.Server          = "localhost";
                conn_str.Database        = "demo";
                conn_str.ServerType      = "UNIDATA";
                conn_str.Pooling         = false;
                conn_str.FirstNormalForm = false;
                string       s   = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");
                U2Command cmd = con.CreateCommand();
                cmd.CommandText = "SELECT * FROM STUDENT UNNEST NL_ALL CGA ;";
                DataSet       ds = new DataSet();
                U2DataAdapter da = new U2DataAdapter(cmd);
                da.Fill(ds);
                DataTable dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    Console.WriteLine(dr["FNAME"] + "==" + dr["SEMESTER"]);
                }

                con.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 40
0
        private static void FillDataSetWithUNNEST()
        {
            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID          = "user";
                conn_str.Password        = "******";
                conn_str.Server          = "localhost";
                conn_str.Database        = "HS.SALES";
                conn_str.ServerType      = "UNIVERSE";
                conn_str.FirstNormalForm = false;
                conn_str.Pooling         = false;
                string       s   = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");
                U2Command cmd = con.CreateCommand();
                cmd.CommandText = "SELECT FNAME, PRICE FROM UNNEST CUSTOMER ON ORDERS"; // FNAME = SingleValue, PRICE = multivalue
                DataSet       ds = new DataSet();
                U2DataAdapter da = new U2DataAdapter(cmd);
                da.Fill(ds);
                DataTable dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    Console.WriteLine(dr["FNAME"] + "==" + dr["PRICE"]);
                }

                con.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                //Console.WriteLine("Enter to exit:");
                //string line = Console.ReadLine();
            }
        }
Esempio n. 41
0
        public async Task<string> UpdateUser(object customer)
        {
            int lRet = -1;
            try
            {
                var cust = (IDictionary<string, object>)customer;
                foreach (var property in (IDictionary<String, Object>)cust)
                {
                    Console.WriteLine(property.Key + ": " + property.Value);
                    var t1 = property.Key;
                    var t2 = property.Value;
                }
                U2ConnectionStringBuilder l = new U2ConnectionStringBuilder();
                l.UserID = "admin";
                l.Password = "******";
                l.Server = "192.168.102.132";
                l.Database = "HS.SALES";
                l.ServerType = "universe";
                l.Connect_Timeout = 360;
                l.RpcServiceType = "uvcs";
                l.AccessMode = "Native";

                string lconnstr = l.ToString();
                U2Connection c = new U2Connection();
                c.ConnectionString = lconnstr;
                await c.OpenAsync();
                U2Command cmd = c.CreateCommand();
                //cmd.CommandText = string.Format("Action=Select;File=CUSTOMER;Attributes=CUSTID,FNAME,LNAME,PRODID,BUY_DATE;Where=CUSTID>0;Sort=CUSTID");
                //cmd.CommandText = string.Format("Action=Update;File=CUSTOMER;Attributes=FNAME={0},LNAME={1},DISCOUNT{2};Where=CUSTID={3}", cust["FNAME"], cust["LNAME"], cust["DISCOUNT"], cust["CUSTID"]);
                cmd.CommandText = string.Format("Action=Update;File=CUSTOMER;Attributes=FNAME={0},LNAME={1};Where=CUSTID={2}", cust["FNAME"], cust["LNAME"], cust["CUSTID"]);
                lRet = await cmd.ExecuteNonQueryAsync();
                c.Close();
            }
            catch (Exception ee)
            {
                throw ee;
            }
            return "200";
        }
Esempio n. 42
0
 private void ExecuteCommand(U2Connection con)
 {
     try
     {
         if (settings.AccessMode=="Native")
         {
             // Native mode
             UniSession us1 = con.UniSession;
             UniCommand uniCmd = us1.CreateUniCommand();
             uniCmd.Command = settings.CommandText;
             uniCmd.Execute();
             // Get response string but not output
             string strNative = uniCmd.Response;
             
         }
         else
         {
             // SQL mode
             U2Command cmd = con.CreateCommand();
             cmd.Connection = con;
             cmd.CommandText = settings.CommandText;
             cmd.ExecuteNonQuery();
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
     finally
     {
     }
 }
Esempio n. 43
0
        private void ExecuteDataReader(U2Connection con)
        {
            try
            {
                if (settings.AccessMode == "Native")
                {
                    // Need to confirm how to use UniDataSet
                }
                else
                {
                U2Command cmd = con.CreateCommand();
                cmd.Connection = con;
                cmd.CommandText = settings.CommandText;
                U2DataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                        // Do something
                }
            }
                
            }
            catch (System.Exception ex)
            {
                throw ex;
            }

        }
Esempio n. 44
0
        private void ExecuteDataSet(U2Connection con)
        {
            try
            {
                if (settings.AccessMode == "Native")
                {
                    // Need to confirm how to use UniDataSet
                }
                else
                {
                U2Command cmd = con.CreateCommand();
                cmd.Connection = con;
                cmd.CommandText = settings.CommandText;

                U2DataAdapter da = new U2DataAdapter();
                da.SelectCommand = cmd;
                DataSet ds = new DataSet();
                da.Fill(ds);
            }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 45
0
        static void Main(string[] args)
        {
            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID = "user";
                conn_str.Password = "******";
                conn_str.Server = "localhost";
                conn_str.Database = "HS.SALES";
                conn_str.ServerType = "UNIVERSE";
                conn_str.Pooling = false;
                string s = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");
                U2Command command = con.CreateCommand();
                command.CommandText = "CALL *GETXMLSUB(?,?,?,?,?,?)"; // UniVerse subroutine

                command.Parameters.Clear();

                command.CommandType = CommandType.StoredProcedure;
                U2Parameter p1 = new U2Parameter();
                p1.Direction = ParameterDirection.InputOutput;

                p1.Value = "LIST CUSTOMER";
                p1.ParameterName = "@arg1";

                U2Parameter p2 = new U2Parameter();
                p2.Direction = ParameterDirection.InputOutput;
                p2.Value = "";
                p2.ParameterName = "@arg2";


                U2Parameter p3 = new U2Parameter();
                p3.Direction = ParameterDirection.InputOutput;
                p3.Value = "";
                p3.ParameterName = "@arg3";


                U2Parameter p4 = new U2Parameter();
                p4.Direction = ParameterDirection.InputOutput;
                p4.Value = "";
                p4.ParameterName = "@arg4";

                U2Parameter p5 = new U2Parameter();
                p5.Direction = ParameterDirection.InputOutput;
                p5.Value = "";
                p5.ParameterName = "@arg5";

                U2Parameter p6 = new U2Parameter();
                p6.Direction = ParameterDirection.InputOutput;
                p6.Value = "";
                p6.ParameterName = "@arg6";


                command.Parameters.Add(p1);
                command.Parameters.Add(p2);
                command.Parameters.Add(p3);
                command.Parameters.Add(p4);
                command.Parameters.Add(p5);
                command.Parameters.Add(p6);

                command.ExecuteNonQuery();

                string s1 = command.Parameters[0].Value.ToString();//command
                string s2 = command.Parameters[1].Value.ToString();// command option
                string s3 = command.Parameters[2].Value.ToString(); // xml
                string s4 = command.Parameters[3].Value.ToString(); //xsd
                string s5 = command.Parameters[4].Value.ToString(); // msg #
                string s6 = command.Parameters[5].Value.ToString(); // msg description

                Console.WriteLine("Subroutine Output:" + s3 + Environment.NewLine);
                Console.WriteLine("Subroutine Output:" + s4 + Environment.NewLine);

                con.Close();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 46
0
        static void Main(string[] args)
        {

            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID = "user";
                conn_str.Password = "******";
                conn_str.Server = "localhost";
                conn_str.Database = "demo";
                conn_str.ServerType = "UNIDATA";
                conn_str.AccessMode = "Native";   // FOR UO
                conn_str.RpcServiceType = "udcs"; // FOR UO
                conn_str.Pooling = false;
                string s = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");
                UniSession us1 = con.UniSession;

                string RoutineName = "*GETXMLSUB";
                int IntTotalAtgs = 6;
                string[] largs = new string[IntTotalAtgs];
                largs[0] = "LIST STUDENT ALL";
                largs[1] = "arg2";
                largs[2] = "arg3";
                largs[3] = "arg4";
                largs[4] = "arg5";
                largs[5] = "arg6";
                UniDynArray tmpStr2;
                UniSubroutine sub = us1.CreateUniSubroutine(RoutineName, IntTotalAtgs);

                for (int i = 0; i < IntTotalAtgs; i++)
                {
                    sub.SetArg(i, largs[i]);
                }

                sub.Call();
                tmpStr2 = sub.GetArgDynArray(2);
                string result = "\n" + "Result is :" + tmpStr2;
                Console.WriteLine("  Response from UniSubRoutineSample :" + result);

               
                con.Close();

            }
            catch (Exception e)
            {
                string s = e.Message;
                if (e.InnerException != null)
                {
                    s += e.InnerException.Message;
                }

                Console.WriteLine(s);

            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 47
0
        /// <summary>
        /// Get dataset in SQL mode
        /// </summary>
        /// <param name="conStrBdr"></param>
        /// <param name="strTableName"></param>
        /// <returns></returns>
        private DataSet GetSQLDataSet(U2ConnectionStringBuilder conStrBdr, string strTableName)
        {
            try
            {
            U2Connection con = new U2Connection();
            con.ConnectionString = conStrBdr.ToString();

            con.Open();

            U2Command cmd = con.CreateCommand();
            cmd.CommandText = string.Format("SELECT * FROM [{0}]", strTableName);
            U2DataAdapter da = new U2DataAdapter();
            da.SelectCommand = cmd;
            DataSet ds = new DataSet();            
            da.Fill(ds);

            con.Close();
            return ds;
        }
            catch (Exception e)
            {

                throw  e ;
            }
           
        }
Esempio n. 48
0
        /// <summary>
        /// Create and open connection
        /// </summary>
        private void DoConnection()
        {
            try
            {
            // Close current connection if exists
            DoDisconnection();

            con = GetU2Connection();
            con.Open();
        }
            catch (Exception e)
            {

                throw e;
            }
            
        }
Esempio n. 49
0
        static void Main(string[] args)
        {


            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID = "user";
                conn_str.Password = "******";
                conn_str.Server = "localhost";
                conn_str.Database = "demo";
                conn_str.ServerType = "UNIDATA";
                conn_str.AccessMode = "Native";   // FOR UO
                conn_str.RpcServiceType = "udcs"; // FOR UO
                conn_str.Pooling = false;
                string s = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");
                UniSession us1 = con.UniSession;

                UniSelectList sl = us1.CreateUniSelectList(2);
                // Select UniFile
                UniFile fl = us1.CreateUniFile("STUDENT");
                sl.Select(fl);

                // read records as unidataset
                string[] sArray = { "291222021", "521814564","424325656" };
                UniDataSet uSet = fl.ReadRecords(sArray);

                // use for each statement to print the record
                foreach (UniRecord item in uSet)
                {
                    Console.WriteLine(item.ToString());

                }

                // use index to print the record
                int lCount = uSet.RowCount;
                for (int ii = 0; ii < lCount; ii++)
                {
                    UniRecord ee = uSet[ii];
                    Console.WriteLine(ee.ToString());
                }

                // print one by one record
                UniRecord q2 = uSet["291222021"];
                string sq2 = q2.ToString();
                Console.WriteLine("  Record data for rec id 291222021:" + sq2);
                UniRecord q3 = uSet["521814564"];
                string sq3 = q3.ToString();
                Console.WriteLine("  Record data for rec id 521814564:" + sq3);
                UniRecord q4 = uSet["424325656"];
                string sq4 = q4.ToString();
                Console.WriteLine("  Record data for rec id 424325656:" + sq4);

                 //create UniDataSet in the Client Side
                UniDataSet uSet3 = us1.CreateUniDataSet();
                uSet3.Insert("3", "aaa");
                uSet3.Insert("4", "bbb");
                uSet3.Insert("5", "vvv");
                uSet3.Insert(2, "8", "www");


                

                con.Close();

            }
            catch (Exception e)
            {
                string s = e.Message;
                if (e.InnerException != null)
                {
                    s += e.InnerException.Message;
                }

                Console.WriteLine(s);

            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 50
0
 public async Task<string> QueryUsers(int pageNumber, int pageSize)
 {
     
     string lRetJsonData = string.Empty;
     
     try
     {
         U2ConnectionStringBuilder l = new U2ConnectionStringBuilder();
         l.UserID = "admjjin";
         l.Password = "******";
         l.Server = "192.168.102.132";
         l.Database = "HS.SALES";
         l.ServerType = "universe";
         l.Connect_Timeout = 360;
         l.RpcServiceType = "uvcs";
         l.AccessMode = "Native";
         
         string lconnstr = l.ToString();
         U2Connection c = new U2Connection();
         c.ConnectionString = lconnstr;
         await c.OpenAsync();
         U2Command cmd = c.CreateCommand();
         cmd.CommandText = string.Format("Action=Select;File=CUSTOMER;Attributes=CUSTID,FNAME,LNAME,PRODID,BUY_DATE;Where=CUSTID>0;Sort=CUSTID");
         lRetJsonData  = await cmd.ExecuteJsonAsync();
         
        
         c.Close();
     }
     catch (Exception ee)
     {
         throw ee;
     }
     return lRetJsonData;
 }
Esempio n. 51
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                this.textBox1.AppendText("Start..." + Environment.NewLine);

                //strat get U2 data

                U2ConnectionStringBuilder conn_bldr = new U2ConnectionStringBuilder();
                conn_bldr.UserID = "admin";
                conn_bldr.Password = "******";
                conn_bldr.Server = "192.168.102.132";
                conn_bldr.ServerType = "universe";
                conn_bldr.Database = "HS.SALES";
                conn_bldr.AccessMode = "Native";
                conn_bldr.RpcServiceType = "uvcs";
                string lConnStr = conn_bldr.ConnectionString;
                U2Connection lConn = new U2Connection();
                lConn.ConnectionString = lConnStr;
                lConn.Open();
                Console.WriteLine("Connected...");
                U2Command cmd = lConn.CreateCommand();

                // CUSTID,FNAME,LNAME : Single Value
                //PRODID, BUY_DATE    : Multi Value
                //Syntax : Action=?;File=?;Attributes=?;Where=?;Sort

                cmd.CommandText = string.Format("Action=Select;File=CUSTOMER;Attributes=CUSTID,FNAME,LNAME,PRODID,BUY_DATE;Where=CUSTID>0;Sort=CUSTID");

                U2DataAdapter da = new U2DataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                DataTable dt = ds.Tables[0];

                //end get U2 data

                //load table storage
                string lTableStorageName = "CUSTOMER3";
                StorageCredentials creds = new StorageCredentials(accountName, accountKey);
                CloudStorageAccount account = new CloudStorageAccount(creds, useHttps: true);
                CloudTableClient client = account.CreateCloudTableClient();
                CloudTable table = client.GetTableReference("CUSTOMER6");
                table.CreateIfNotExists();
                string lUri = table.Uri.ToString();
                //  Console.WriteLine(table.Uri.ToString());
                this.textBox1.AppendText(lUri + Environment.NewLine);
                foreach (DataRow item in dt.Rows)
                {
                    var t1 = item["CUSTID"].ToString();
                    var t2 = item["Z_MV_KEY"].ToString();
                    DateTime lhiredate;
                    if (item["BUY_DATE"] == DBNull.Value)
                    {
                        lhiredate = DateTime.Now;// new DateTime();
                    }
                    else
                    {
                        lhiredate = (DateTime)item["BUY_DATE"];
                    }
                    CustomerEntity entity = new CustomerEntity(t1,t2)
                    {
                        FNAME = (string)item["FNAME"],
                        LNAME = (string)item["LNAME"],
                        PRODID = (string)item["PRODID"],
                        BUY_DATE = lhiredate
                    };
                    TableOperation insertOperation = TableOperation.InsertOrReplace(entity);
                    table.Execute(insertOperation);
                    this.textBox1.AppendText("Entity inserted!" + Environment.NewLine);
                }
                this.textBox1.AppendText("End..." + Environment.NewLine);
            }

            catch (Exception ex)
            {

                this.textBox1.AppendText(ex.Message + Environment.NewLine);

            }

        }
Esempio n. 52
0
 /// <summary>
 /// Close active connection
 /// </summary>
 private void DoDisconnection()
 {
     if (con != null && con.State == ConnectionState.Open)
     {
         con.Close();
         con.Dispose();
         con = null;
     }
 }
Esempio n. 53
0
        /// <summary>
        /// Get an U2 connection object
        /// </summary>
        /// <returns></returns>
        private U2Connection GetU2Connection()
        {
            U2ConnectionStringBuilder conStr = new U2ConnectionStringBuilder();

            // Login settings
            conStr.UserID = settings.UserName;
            conStr.Password = settings.Password;
            conStr.Server = settings.Server;
            conStr.Database = settings.Database;
            conStr.ServerType = settings.ServerType;            

            conStr.Connect_Timeout = settings.ConnTimeOut;
            conStr.ConnectionLifeTime = settings.ConnLifeTime;

            // Access mode
            if (settings.AccessMode == "Native")
            {
                conStr.AccessMode = settings.AccessMode;
                if (conStr.ServerType == "UNIDATA")
                {
                    conStr.RpcServiceType = "udcs";
                }
                else
                {
                    conStr.RpcServiceType = "uvcs";
                }
            }
            else
            {
                // If not Native mode and set the property like bellow, an error occurred
                //conStr.AccessMode = "Uci"; // settings.AccessMode;
                //conStr.RpcServiceType = "defcs"; // settings.RpcServiceType;
            }

            // SSL settings
            conStr.SSLConnection = settings.EnableSSLConnection;
            if (conStr.SSLConnection == true)
            {
                conStr.SslIgnoreCertificateNameMismatch = settings.EnableSSLIgnCertNameMismatch;

                if (settings.CertificateFilePath.Length > 0)
                {
                    conStr.ClientCertificatePath = settings.CertificateFilePath;
                }
                conStr.SslIgnoreIncompleteCertificateChain = settings.EnableSSLIgnIncompCertChain;
                conStr.SslCheckCertificateRevocation = settings.EnableSSLChkCertRevocation;
            }

            U2Connection con = new U2Connection();
            con.ConnectionString = conStr.ToString();
            return con;
        }
Esempio n. 54
0
        /// <summary>
        /// Get an U2 connection object
        /// </summary>
        /// <returns></returns>
        private static U2Connection GetU2Connection()
        {
            U2ConnectionStringBuilder conStr = new U2ConnectionStringBuilder();

            // Login
            conStr.UserID = settings.UserName;
            conStr.Password = settings.Password;
            conStr.Server = settings.Server;
            conStr.Database = settings.Database;
            conStr.ServerType = settings.ServerType;

            // Pool
            conStr.Pooling = settings.EnablePooling;
            conStr.MinPoolSize = settings.MinPoolSize;
            conStr.MaxPoolSize = settings.MaxPoolSize;
            conStr.ConnectionReset = settings.EnableConnReset;
            conStr.Connect_Timeout = settings.ConnTimeOut;
            conStr.ConnectionLifeTime = settings.ConnLifeTime;

            // Access mode
            if (settings.AccessMode == "Native")
            {
                conStr.AccessMode = settings.AccessMode;
                if (conStr.ServerType == "UNIDATA")
                {
                    conStr.RpcServiceType = "udcs";
                }
                else
                {
                    conStr.RpcServiceType = "uvcs";
                }
            }

            U2Connection con = new U2Connection();
            con.ConnectionString = conStr.ToString();
            return con;
        }
Esempio n. 55
0
        /// <summary>
        /// Get native string in Native mode
        /// </summary>
        /// <param name="conStrBdr"></param>
        /// <param name="strFileName"></param>
        /// <returns></returns>
        private string GetNativeString(U2ConnectionStringBuilder conStrBdr, string strFileName)
        {
            try
            {
            U2Connection con = new U2Connection();
            con.ConnectionString = conStrBdr.ToString();
            con.Open();

            string strInfo = string.Format("Connected......{0}{0}",Environment.NewLine);
            // 0 is meaningless
            bwkRetrieve.ReportProgress(0, strInfo);
            string strNative = string.Empty;
            UniSession us1 = con.UniSession;
            UniCommand cmd = us1.CreateUniCommand();

            // List no more than 10 records for sample
            if (conStrBdr.ServerType=="UNIDATA")
            {
                cmd.Command = string.Format("LIST {0} ALL SAMPLE 10", strFileName);
            }
            else
            {
                cmd.Command = string.Format("LIST {0} SAMPLE 10", strFileName);
            }
            cmd.Execute();
            
            if (cmd.Response != null)
            {
                strNative = cmd.Response.Trim();
            }
                        
            con.Close();
            return strNative;
        }
            catch (Exception e)
            {

                throw e;
            }
           
        }
Esempio n. 56
0
        static void Main(string[] args)
        {

            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID = "user";
                conn_str.Password = "******";
                conn_str.Server = "localhost";
                conn_str.Database = "HS.SALES";
                conn_str.ServerType = "UNIVERSE";
                conn_str.AccessMode = "Native";   // FOR UO
                conn_str.RpcServiceType = "uvcs"; // FOR UO
                conn_str.Pooling = false;
                string s = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");

                // get RECID

                UniSession us1 = con.UniSession;

                // open customer file
                UniFile fl = us1.CreateUniFile("CUSTOMER");

                // read records as unidataset
                string[] sArray = { "2", "12", "3", "4" };
                UniDataSet uSet = fl.ReadRecords(sArray);

                // use for each statement to print the record
                foreach (UniRecord item in uSet)
                {
                    Console.WriteLine(item.ToString());

                }

                // use index to print the record
                int lCount = uSet.RowCount;
                for (int ii = 0; ii < lCount; ii++)
                {
                    UniRecord ee = uSet[ii];
                    Console.WriteLine(ee.ToString());
                }

                // print one by one record
                UniRecord q2 = uSet["2"];
                string sq2 = q2.ToString();
                Console.WriteLine("  Record data for rec id 2:" + sq2);
                UniRecord q3 = uSet["3"];
                string sq3 = q3.ToString();
                Console.WriteLine("  Record data for rec id 3:" + sq3);
                UniRecord q4 = uSet["4"];
                string sq4 = q4.ToString();
                Console.WriteLine("  Record data for rec id 4:" + sq4);

                // create UniDataSet in the Client Side
                UniDataSet uSet3 = us1.CreateUniDataSet();
                uSet3.Insert("3", "aaa");
                uSet3.Insert("4", "bbb");
                uSet3.Insert("5", "vvv");
                uSet3.Insert(2, "8", "www");

                con.Close();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
Esempio n. 57
0
        static void Main(string[] args)
        {


            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID = "user";
                conn_str.Password = "******";
                conn_str.Server = "localhost";
                conn_str.Database = "demo";
                conn_str.ServerType = "UNIDATA";
                conn_str.AccessMode = "Native";   // FOR UO
                conn_str.RpcServiceType = "udcs"; // FOR UO
                conn_str.Pooling = false;
                string s = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");

                // get RECID

                UniSession us1 = con.UniSession;

                UniSelectList sl = us1.CreateUniSelectList(2);

                // Select UniFile
                UniFile fl = us1.CreateUniFile("STUDENT");
                sl.Select(fl);

                bool lLastRecord = sl.LastRecordRead;
                List<string> lRecIdList = new List<string>();
                while (!lLastRecord)
                {
                    string sRecID = sl.Next();
                    lRecIdList.Add(sRecID);
                    Console.WriteLine("Record ID:" + sRecID);
                    lLastRecord = sl.LastRecordRead;
                }

                UniDataSet uSet = fl.ReadRecords(lRecIdList.ToArray());
                // use for each statement to print the record
                foreach (UniRecord item in uSet)
                {

                    Console.WriteLine(item.ToString());
                }

                con.Close();

            }
            catch (Exception e)
            {
                string s = e.Message;
                if (e.InnerException != null)
                {
                    s += e.InnerException.Message;
                }

                Console.WriteLine(s);

            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }

        }