コード例 #1
0
ファイル: Timers.cs プロジェクト: CorbinDallas/Rendition
 /// <summary>
 /// Starts the shipment update queue.
 /// </summary>
 internal static void startShipmentUpdateQueue()
 {
     shipmentUpdateQueue = new Admin.Timer();
     shipmentUpdateQueue.Interval = 30000;
     shipmentUpdateQueue.Name = "Shipment Update Queue";
     shipmentUpdateQueue.elapsed += new EventHandler(emptyShipmentQueue);
     shipmentUpdateQueue.AutoReset = false;
     shipmentUpdateQueue.Start();
 }
コード例 #2
0
ファイル: Timers.cs プロジェクト: CorbinDallas/Rendition
 /// <summary>
 /// Starts the email queue.
 /// </summary>
 internal static void startEmailQueue()
 {
     emailQueue = new Admin.Timer();
     emailQueue.Interval = 30000;
     emailQueue.Name = "Email Queue";
     emailQueue.elapsed += new EventHandler(emptyEmailQueue);
     emailQueue.AutoReset = false;
     emailQueue.Start();
 }
コード例 #3
0
ファイル: Timers.cs プロジェクト: CorbinDallas/Rendition
 /// <summary>
 /// Starts database connection checking.
 /// </summary>
 internal static void startConnectionChecking()
 {
     connectionChecker = new Admin.Timer();
     connectionChecker.Interval = 30000;
     connectionChecker.elapsed += new EventHandler(connectionChecker_elapsed);
     connectionChecker.Start();
     connectionChecker.Name = "Database Connection Checker/Reconnector";
     connectionChecker.AutoReset = false;
 }
コード例 #4
0
ファイル: main.cs プロジェクト: CorbinDallas/Rendition
 public imageImport()
 {
     Admin.Timer importItemImages = new Admin.Timer();
     importItemImages.Name = "Auto Image Import";
     importItemImages.Interval = interval;
     importItemImages.elapsed+=new EventHandler(importItemImages_elapsed);
     importItemImages.AutoReset=false;
     importItemImages.Start();
     this.Message="Loaded";
 }
コード例 #5
0
ファイル: main.cs プロジェクト: CorbinDallas/Rendition
 public main()
 {
     this.Message = "Starting up...";
     /* load XML containing DB path */
     XmlDocument xmlDoc=new XmlDocument();
     this.Message="Reading config file from "+configFilePath;
     xmlDoc.Load((configFilePath).VirtualToPhysicalSitePath());
     XmlNodeList dataNode = xmlDoc.GetElementsByTagName( "quickbooks_10_iif" );
     if( dataNode != null) {
         if( dataNode.Count == 1 ){
             XmlAttribute _xa = dataNode[0].Attributes[ "outputPath" ];
             if(_xa == null){
                 outputPath = "~/";
             } else {
                 outputPath = _xa.Value;
             }
             _xa = dataNode[ 0 ].Attributes[ "discountRevenueAccount" ];
             if( _xa == null ) {
                 discRevAcct = "Sales Discounts";
             } else {
                 discRevAcct = _xa.Value;
             }
             _xa = dataNode[ 0 ].Attributes[ "taxRevenueAccount" ];
             if( _xa == null ) {
                 taxRevAcct = "Sales Tax Payable";
             } else {
                 taxRevAcct = _xa.Value;
             }
             _xa = dataNode[ 0 ].Attributes[ "shippingRevenueAccount" ];
             if( _xa == null ) {
                 shippingRevAcct = "Shipping Revenue";
             } else {
                 shippingRevAcct = _xa.Value;
             }
             _xa = dataNode[ 0 ].Attributes[ "anonymousExportToAccount" ];
             if( _xa == null ) {
                 defaultExportToAccount = "Anonymous Customer";
             }else{
                 defaultExportToAccount = _xa.Value;
             }
         }
     }
     if(!Directory.Exists(outputPath)&&outputPath!=""){
         string msg = string.Format("The path '{0}' specified in {1} in the export.xml file "+
         "( @ export > quickbooks_10_iif : outputPath ) does not exist.  " +
         " Output directory set to application root.",outputPath,configFilePath);
         this.Message = "Warning: Outputting to application root";
         msg.Debug(0);
         outputPath=Admin.GetApplicationPath();
     }else{
         ("Quickbooks 10 Export: Output path ="+outputPath).Debug(10);
     }
     /* start a Timer - every five minutes try and export data */
     this.Message="Starting Timer.";
     ("Quickbooks 10 Export: "+this.Message).Debug(10);
     timer = new Admin.Timer();
     timer.Name = "Quickbooks 10 Export";
     timer.elapsed+=this.OnElapsed;
     timer.Interval = 30000;/*five min*/
     timer.AutoReset = false;
     timer.Start();
     this.Message="Loaded";
     this.Message.Debug(10);
 }
コード例 #6
0
ファイル: Scheduler.cs プロジェクト: CorbinDallas/Rendition
        /// <summary>
        /// Executes a scheduled task.
        /// </summary>
        /// <param name="taskId">The task id.</param>
        /// <param name="name">The name.</param>
        /// <param name="interval">The interval.</param>
        /// <param name="sourceCode">The source code.</param>
        /// <param name="language">The language.</param>
        /// <param name="lastRun">The last run.</param>
        /// <param name="lastErrorId">The last error id.</param>
        /// <param name="lastErrorJSON">The last error JSON.</param>
        /// <returns></returns>
        public Admin.Timer ExecuteScheduledTask( Guid taskId, string name, int interval,
		string sourceCode, string language, DateTime lastRun, string lastErrorId, string lastErrorJSON )
        {
            ( "FUNCTION executeScheduledTask (init and start task event timers) /W ADHOC (!PRIVATE!)" ).Debug( 10 );
            Admin.Timer timer = new Admin.Timer();
            /* last time this ran, minus the interval is the starting interval */
            timer.Interval = interval;
            timer.Name = "Compiled DB Timer Event" + Utilities.Iif( name.Length > 0, ":", "" );
            timer.elapsed += new EventHandler( delegate( object e, EventArgs args ) {
                List<object> errors = new List<object>();
                DateTime startDate = new DateTime();
                startDate = DateTime.Now;
                DateTime endDate = new DateTime();
                endDate = DateTime.MinValue;
                string errorJSON = "";
                string errorNumber = "0";
                string consoleOut = "";
                try { /* and and run someone elses code */
                    ( "EVENT DELEGATE Task " + name + " started." ).Debug( 6 );
                    if( timer.Interval != interval ) {
                        timer.Interval = interval;/* now interval should be set to the actual interval */
                    }
                    using( SqlConnection cn = Site.CreateConnection( true, true ) ) {
                        cn.Open();
                        using( SqlTransaction trns = cn.BeginTransaction( "Scheduled Task" ) ) {
                            using( SqlCommand cmd = new SqlCommand( "update eventHandlers set startTime = @startTime, lock = 1 where taskId = @taskId", cn ) ) {
                                cmd.Parameters.Add( "@taskId", SqlDbType.UniqueIdentifier ).Value = new Guid( taskId.ToString() );
                                cmd.Parameters.Add( "@startTime", SqlDbType.DateTime ).Value = startDate;
                                cmd.ExecuteNonQuery();
                                TimerEventArgs evntArgs = new TimerEventArgs( cn, trns, lastRun, taskId, name, lastErrorId, lastErrorJSON );
                                object[] scriptArguments = { Main.Site, evntArgs };
                                object obj = Admin.ExecuteScript( sourceCode, language, "script", "main", ref scriptArguments, ref errors );
                                if( errors.Count == 0 ) {
                                    if( obj.GetType() == typeof( string ) ) {
                                        consoleOut = ( string )obj;
                                    }
                                    Dictionary<string, object> s = new Dictionary<string, object>();
                                    s.Add( "errorNumber", 0 );
                                    s.Add( "errorDesc", "Timer Event " + name + " completed without error." );
                                    s.Add( "console", consoleOut );
                                    errorNumber = "0";
                                    errorJSON = s.ToJson();
                                    trns.Commit();/* no errors occured in the script so commit the transaction */
                                } else {
                                    errorJSON = errors.ToJson();
                                    errorNumber = ( ( Dictionary<string, object> )( errors[ 0 ] ) )[ "errorNumber" ].ToString();
                                    trns.Rollback();/* one or more errors occured so rollback the transaction */
                                }
                                endDate = DateTime.Now;
                                updateEventTaskStatus( taskId, startDate, false, endDate, errorNumber, errorJSON );
                                ( "EVENT DELEGATE Task " + name + " ended." ).Debug( 6 );
                            }
                        }
                    }
                } catch( Exception excp ) {
                    String.Format( "EVENT DELEGATE Task {0} threw and exception. {1}", name, excp.Message ).Debug( 1 );
                }
            } );
            timer.Start();
            return timer;
        }