Ejemplo n.º 1
0
        public async Task <DataSet> ExecuteAsync(RequestCollection requests)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            // the code that you want to measure comes here

            this.LastError = "";

            var ds = await DataProvider.ExcuteAsync(requests, SessionID); //await DataService.ExecuteAsync(requests, SessionID);

            var table = ds.Tables[0];

            if (table != null)
            {
                if (table.TableName == "Error")
                {
                    var row = table.Rows[0];

                    var message    = row["Message"].ToString();
                    var source     = row["Source"].ToString();
                    var stackTrace = row["StackTrace"].ToString();
                    var helpLink   = row["HelpLink"].ToString();

                    this.LastError = message;
                    ds             = null;
                }
            }
            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            Console.WriteLine(DateTime.Now.ToString() + "Total time load data from sql server=" + elapsedMs);
            return(ds);
        }
Ejemplo n.º 2
0
 public async Task <DataSet> ExecuteAsync(RequestCollection requests)
 {
     if (clientServices == null)
     {
         clientServices = new ClientServices("");
     }
     return(await clientServices.ExecuteAsync(requests));
 }
        public static DataSet Excute(RequestCollection requests)
        {
            var session = Guid.NewGuid().ToString();
            var response = new DataSet();
        
            SqlTransaction transaction = null;

            try
            {
                string connectString = string.Format(@"Server={0};User Id=sa;
Password=dkcnyh20081992;",QA.QAFunction.ReadFromConfigXMlFile("ServerName"));
                using (SqlConnection connection = new SqlConnection(connectString))
                {
                    connection.Open();
                    transaction = connection.BeginTransaction();

                    foreach (var request in requests)
                    {
                        var category = request["Attributes"]["Category"].Value;
                        var command = request["Attributes"]["Command"].Value;
                        var parameters = request["Parameters"];

                        if (command.StartsWith("ws_"))
                        {
                            if (ProcessNative(session, category, command, parameters, response) == false)
                            {
                                ProcessSql(connection, transaction, session, category, command, parameters, response);
                            }
                        }
                    }

                    transaction.Commit();
                }
            }
            catch (Exception e)
            {
                var table = new DataTable("Error");
                table.Columns.Add("Message");
                table.Columns.Add("Source");
                table.Columns.Add("StackTrace");
                table.Columns.Add("HelpLink");

                var row = table.NewRow();
                row["Message"] = e.Message;
                row["Source"] = e.Source;
                row["StackTrace"] = e.StackTrace;
                row["HelpLink"] = e.HelpLink;

                table.Rows.Add(row);

                response = new DataSet();
                response.Tables.Add(table);
            }

            return response;
        }
        //private static string servername = "113.161.97.235,6969\\Kadence";

        public DataSet Excute(RequestCollection requests)
        {
            var session  = Guid.NewGuid().ToString();
            var response = new DataSet();

            SqlTransaction transaction = null;

            try
            {
                using (SqlConnection connection = new SqlConnection(_serverString))
                {
                    connection.Open();
                    transaction = connection.BeginTransaction();

                    foreach (var request in requests)
                    {
                        var category   = request["Attributes"]["Category"].Value;
                        var command    = request["Attributes"]["Command"].Value;
                        var parameters = request["Parameters"];

                        if (command.StartsWith("ws_"))
                        {
                            if (ProcessNative(session, category, command, parameters, response) == false)
                            {
                                ProcessSql(connection, transaction, session, category, command, parameters, response);
                            }
                        }
                    }

                    transaction.Commit();
                }
            }
            catch (Exception e)
            {
                var table = new DataTable("Error");
                table.Columns.Add("Message");
                table.Columns.Add("Source");
                table.Columns.Add("StackTrace");
                table.Columns.Add("HelpLink");

                var row = table.NewRow();
                row["Message"]    = e.Message;
                row["Source"]     = e.Source;
                row["StackTrace"] = e.StackTrace;
                row["HelpLink"]   = e.HelpLink;

                table.Rows.Add(row);

                response = new DataSet();
                response.Tables.Add(table);
            }

            return(response);
        }
        public static RequestCollection FromXml(string xml)
        {
            var result = new RequestCollection();


            var docX     = XDocument.Load(xml);
            var requests = docX.Descendants("//Request");

            foreach (XElement node in requests)
            {
                var request = new Request();
                //var id = node.Value;


                ////var id = node.SelectSingleNode("Id").InnerText;

                //request.Id = new Guid(id);


                //var sections = node.SelectSingleNode("Sections");

                //var sections = node.SelectSingleNode("Sections");
                //if (sections != null)
                //{
                //    foreach (XNode section_node in sections.ChildNodes)
                //    {
                //        var section = section_node.Name;

                //        foreach (XNode item in section_node.ChildNodes)
                //        {
                //            var item_isnull = Convert.ToBoolean(item.SelectSingleNode("IsNull").InnerText);
                //            var item_name = item.SelectSingleNode("Name").InnerText;
                //            var item_value = item.SelectSingleNode("Value").InnerText;

                //            if (item_isnull)
                //                item_value = null;

                //            request[section].Add(item_name, item_value);
                //        }
                //    }
                //}

                result += request;
            }



            return(result);
        }
Ejemplo n.º 6
0
        public static RequestCollection FromXml(string xml)
        {
            var result = new RequestCollection();

            var doc = new XmlDocument();

            doc.LoadXml(xml);

            var requests = doc.SelectNodes("//Request");

            foreach (XmlNode node in requests)
            {
                var request = new Request();

                var id = node.SelectSingleNode("Id").InnerText;

                request.Id = new Guid(id);

                var sections = node.SelectSingleNode("Sections");
                if (sections != null)
                {
                    foreach (XmlNode section_node in sections.ChildNodes)
                    {
                        var section = section_node.Name;

                        foreach (XmlNode item in section_node.ChildNodes)
                        {
                            var item_isnull = Convert.ToBoolean(item.SelectSingleNode("IsNull").InnerText);
                            var item_name   = item.SelectSingleNode("Name").InnerText;
                            var item_value  = item.SelectSingleNode("Value").InnerText;

                            if (item_isnull)
                            {
                                item_value = null;
                            }

                            request[section].Add(item_name, item_value);
                        }
                    }
                }

                result += request;
            }

            return(result);
        }
Ejemplo n.º 7
0
 public DataSet Execute(RequestCollection requests, string sessionID)
 {
     return(DataProvider.Excute(requests, sessionID));
 }
Ejemplo n.º 8
0
 public async Task <DataSet> ExecuteAsync(RequestCollection requests, string sessionID)
 {
     return(await Task.Run(() => Execute(requests, sessionID)));
 }
Ejemplo n.º 9
0
        public static async Task <DataSet> ExcuteAsync(RequestCollection requests, string session)
        {
            var response = new DataSet();

            SqlTransaction transaction   = null;
            string         connectString = string.Format(@"Server={0};User Id=sa;
Password=@Dkcnyh20081992;", servername);


            using (SqlConnection connection = new SqlConnection(connectString))
            {
                try
                {
                    await connection.OpenAsync();

                    transaction = connection.BeginTransaction();

                    foreach (var request in requests)
                    {
                        var category   = request["Attributes"]["Category"].Value;
                        var command    = request["Attributes"]["Command"].Value;
                        var parameters = request["Parameters"];

                        if (1 == 1 || command.StartsWith("sp_"))
                        {
                            if (ProcessNative(session, category, command, parameters, response) == false)
                            {
                                await ProcessSqlAsync(connection, transaction, session, category, command, parameters, response);
                            }
                        }
                    }

                    transaction.Commit();
                    connection.Close();
                }
                catch (Exception e)
                {
                    var table = new DataTable("Error");
                    table.Columns.Add("Message");
                    table.Columns.Add("Source");
                    table.Columns.Add("StackTrace");
                    table.Columns.Add("HelpLink");

                    var row = table.NewRow();
                    row["Message"]    = e.Message;
                    row["Source"]     = e.Source;
                    row["StackTrace"] = e.StackTrace;
                    row["HelpLink"]   = e.HelpLink;

                    table.Rows.Add(row);

                    response = new DataSet();
                    response.Tables.Add(table);
                }
                finally
                {
                    connection.Close();
                }
            }



            return(response);
        }