示例#1
0
 /// <summary>
 /// Create a new Counter object.
 /// </summary>
 /// <param name="rowNo">Initial value of the RowNo property.</param>
 /// <param name="counterType">Initial value of the CounterType property.</param>
 /// <param name="numberOfHits">Initial value of the NumberOfHits property.</param>
 public static Counter CreateCounter(global::System.Int32 rowNo, global::System.String counterType, global::System.Int64 numberOfHits)
 {
     Counter counter = new Counter();
     counter.RowNo = rowNo;
     counter.CounterType = counterType;
     counter.NumberOfHits = numberOfHits;
     return counter;
 }
示例#2
0
        void Session_Start(object sender, EventArgs e)
        {
            // Increase the two counters
            totalNumberOfUsers += 1;
            currentNumberOfUsers += 1;

            try
            {
                // Save the Total Number of Users to the database
                using (GESEntities db = new GESEntities())
                {
                    string execPath = Server.HtmlEncode(Request.CurrentExecutionFilePath);
                    DateTime sDate = DateTime.Now.Date;

                    var editCounters = (from c in db.Counters where c.CounterType == "UserCounter" && c.ExecutionPath == execPath && c.DateInserted == sDate select c).FirstOrDefault();
                    if (editCounters != null)
                    {
                        //Edit
                        editCounters.NumberOfHits += 1;
                        db.SaveChanges();
                    }
                    else
                    {
                        //Insert
                        Counter newCounter = new Counter();
                        newCounter.CounterType = "UserCounter";
                        newCounter.NumberOfHits = 1;
                        newCounter.ExecutionPath = Server.HtmlEncode(Request.CurrentExecutionFilePath);
                        newCounter.DateInserted = DateTime.Now.Date;
                        db.Counters.AddObject(newCounter);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception exp)
            {
                throw new Exception("ERROR: Unable to update counter - " + exp.Message.ToString(), exp);
            }
        }
示例#3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Counters EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCounters(Counter counter)
 {
     base.AddObject("Counters", counter);
 }