Run methods from all users in the queue

My setup: the user has a page where he performs some actions and data transformations.
I store these actions in a dataset (in a session).
 Then, by clicking the button, I need to do some more conversion and call the user database function, which will insert every row from each datatable into the database. I have everything that worked, and it works very well.

However, now I need to change the button click event so that it does not start immediately, but put this action in the queue (this is a common queue for all users). Therefore, if user1 presses the button, then user2 presses the button, then we need to take the dataset user1 and run the method on it, and only after that take the dataset user2 and run the method. one turn for everyone.

private void btnclick()
{
  DataSet ds = Session["test"] as DataSet;
  PerformFinalTransformation(ds);
  foreach (DataTable dt in ds.Tables)
  {
     foreach (DataRow dr in dt.Rows)
     {
        CallCustomSqlFunction(dr);
     }
  }
}

, , ( /). , asp.net/#. ( quartz.net -, ?). ? ? asp.net ? - ? , , . , DotNetNuke , -.

+5
7
  • , . xml xml nvarchar(max).

  • - Windows, . IIS ( Application_Start), ( IIS, ..).

+2

. - . . , :

  • : , ? ?
  • ? ASP.Net()? Windows?
  • concurrency?

:

  • , [ConcurrentQueue][1], . Singleton . , .

  • , WCF ASP.Net. [ConcurrentQueue][2], .. ( ).

  • MSMQ. ASP.Net( MS.Net ASP.Net) (MSMQ ).

. , , ( ).

+2

, , WCF MSMQ - , . , , . , AutoIncrement .

:

:

, . .

0

, , , ? SQL Server 2008 , .

. , , , , .

:

private void btnclick()
{
    DataSet ds = Session["test"] as DataSet;
    PerformFinalTransformation(ds);
    using (SqlConnection conn = new SqlConnection(my_connection_string)) {
        conn.Open();
        using (SqlCommand cmd = new SqlCommand("insert_multiple_tables", conn)) {
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter param = new SqlParameter("@table0", SqlDbType.Structured);
            param.Value = ds.Tables[0];
            cmd.Parameters.Add(param);
            SqlParameter param = new SqlParameter("@table1", SqlDbType.Structured);
            param.Value = ds.Tables[1];
            cmd.Parameters.Add(param);
            cmd.ExecuteNonQuery();
        }
    }
}

:

CREATE TYPE udt_mytable0 AS TABLE (
    col1 int,
    col2 varchar(255),
    col3 datetime,
    -- and so on
)

CREATE TYPE udt_mytable1 AS TABLE (
    col1 bigint
)

CREATE PROCEDURE insert_multiple_tables
    @mytable0 udt_mytable0 READONLY,
    @mytable1 udt_mytable1 READONLY
AS

INSERT INTO mydatabase0
    (col1, col2, col3)
SELECT 
    col1, col2, col3
FROM 
    @mytable0

INSERT INTO mydatabase1
    (col1)
SELECT 
    col1
FROM 
    @mytable1
0

, , , :

( , . ), - , reset . , , db, SQL Server, .

SQL Server db , , ​​ RavenDB, (XML-) ( - , , , ). , , , , , .

, , 5 . .

- "" . , .

, , . , - .

: , , ;)

0

, "" ...

http://msdn.microsoft.com/en-us/library/dd537609.aspx

asinc.

, , db .

. IIS Windows, appPool .

0

I think you can achieve this using the cache . Create a queue that has all the session data and store the queue in the cache. Then use the cache to perform a custom database operation. Since you are using the queue, this will be FCFS. Thus, the data of user 2 will be used only after using user 1.

-1
source

All Articles