Beispiel #1
0
 internal void UseConnection(DbMethod method, bool write)
 {
     UseConnection((DbMethod <object>) delegate(IDbConnection connection) {
         method(connection);
         return(null);
     }, write);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["LoginId"] == null)
     {
         Response.Redirect("../Login");
     }
     else
     {
         int id = DbMethod.GenerateId("ProjectId", "Project");
         LblPojectId.Text = id.ToString();
     }
 }
Beispiel #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["LoginId"] == null)
     {
         Response.Redirect("../Login");
     }
     else
     {
         int id = DbMethod.GenerateId("questionId", "Forums");
         qIdLbl.Text = id.ToString();
     }
 }
Beispiel #4
0
        public T UseConnection <T>(DbMethod <T> method, bool write)
        {
            IDbConnection theConnection;

            // Try to let any pending reads go through if we need to write,
            // since it locks everything.
            if (write)
            {
                DateTime start = DateTime.Now;
                while (workingConnections.Count > 0)
                {
                    System.Threading.Thread.Sleep(1);
                    if ((DateTime.Now - start).TotalSeconds >= 1)
                    {
                        // After a second, give up and go anyway.
                        break;
                    }
                }
            }

            lock (connections)
            {
                theConnection = connections.Find(delegate(IDbConnection c) { return(c.State == System.Data.ConnectionState.Open); });
                connections.Remove(theConnection);
            }

            if (theConnection == null)
            {
                theConnection = CreateDbConnection();
            }

            workingConnections.Add(theConnection);

            T result = method(theConnection);

            workingConnections.Remove(theConnection);

            lock (connections)
            {
                connections.Add(theConnection);
            }

            return(result);
        }
Beispiel #5
0
 internal void UseConnection(DbMethod method)
 {
     UseConnection(method, false);
 }
Beispiel #6
0
 internal T UseConnection <T> (DbMethod <T> method)
 {
     return(UseConnection(method, false));
 }
Beispiel #7
0
 public void UseConnection(DbMethod method)
 {
     UseConnection(method, false);
 }
Beispiel #8
0
 public T UseConnection <T>(DbMethod <T> method)
 {
     return(UseConnection(method, false));
 }