public virtual void CounterDelete(Counter entity) { TraceCallEnterEvent.Raise(); try { m_DataContext.BeginNestedTran(); try { m_DataContext.ndihdCounterDelete(entity.ID); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
protected void Page_Load(object sender, EventArgs e) { string counterid = Request["id"]; _srv = ServiceFactory.GetCounterService(); if (Application["Counter_" + counterid] == null) { _counter = _srv.CounterSelect( 5 ); Application["Counter_" + counterid] = _counter.Count; } int value = Convert.ToInt32( Application["Counter_" + counterid]); if (Session["CounterTemp_" + counterid] == null) { if(_counter == null) _counter = _srv.CounterSelect( 5 ); value++; _counter.Count = value; // Save counter to an application var (the locks are there to make sure noone else changes it at the same time) Application.Lock(); Application["Counter_" + counterid] = value.ToString(); Application.UnLock(); // Save counter to a text file _srv.CounterUpdate( _counter ); // Set a session variable so this counter doesn//t fire again in the current session Session.Add("CounterTemp_" + counterid, "True"); } // ***** CREATE OUTPUT GRAPHIC FOR THE COUNTER ***** // Load digits graphic (must be in 0 through 9 format in graphic w/ all digits of set width) System.Drawing.Image i = System.Drawing.Image.FromFile(Server.MapPath((Request.QueryString["src"]))); // Get digit dynamics from the graphic int dgwidth = i.Width/10; int dgheight = i.Height; // Get number of digits to display in the output graphic int digits = Convert.ToInt32(Request["digits"]); // Create output object Bitmap imgOutput = new Bitmap(dgwidth*digits, dgheight, PixelFormat.Format24bppRgb); Graphics g = Graphics.FromImage(imgOutput); int j; int dg; string srt = ("00000000000000" + value.ToString()); srt = srt.Substring( srt.Length - digits, digits ); for (j = 0; j < digits; j++) { // Extract digit from value //dg = Convert.ToInt32(Math.Truncate((double)(value/(10 ^ (digits - j - 1)))) - Math.Truncate((double)(value/(10 ^ (digits - j))))*10); dg = Convert.ToInt32( srt.Substring( j, 1 ) ); // Add digit to the output graphic g.DrawImage(i, new Rectangle(j*dgwidth, 0, dgwidth, dgheight), new Rectangle (dg*dgwidth, 0, dgwidth, dgheight), GraphicsUnit.Pixel); } // Set the content type and return output image Response.ContentType = "image/jpeg"; imgOutput.Save(Response.OutputStream, ImageFormat.Jpeg); // Clean up g.Dispose(); imgOutput.Dispose(); }
public virtual void CounterUpdate(Counter entity) { TraceCallEnterEvent.Raise(); try { m_DataContext.BeginNestedTran(); try { int count; m_DataContext.ndihdCounterUpdate(entity.ID, entity.Count, out count); if (count == 0) throw new ServiceUpdateException(); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public virtual Counter CounterSelect(DBInt IDVal) { TraceCallEnterEvent.Raise(); try { Counter result = null; DataSet entitySet = m_DataContext.ndihdCounterSelect(IDVal); if (entitySet.Tables[0].Rows.Count != 0) { result = new Counter(entitySet); } TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
// ------------------------------------------------------------------------------------- /// <summary> /// Copy constructor. /// </summary> /// <param name="IDVal">Value of 'nID' field</param> /// <param name="origInstance">Original document data to copy.</param> // ------------------------------------------------------------------------------------- public Counter(DBInt IDVal, Counter origInstance) : base(IDVal, origInstance) { }
// ------------------------------------------------------------------------------------- /// <summary> /// Copy constructor. /// </summary> /// <param name="origInstance">Original document data to copy.</param> // ------------------------------------------------------------------------------------- public Counter(Counter origInstance) : base(origInstance) { }