Beispiel #1
0
        public override void Transform(RavenEtlItem item)
        {
            Current = item;

            if (item.IsDelete == false)
            {
                if (_script.Transformation != null)
                {
                    if (_script.LoadToCollections.Length > 1 || _script.IsLoadedToDefaultCollection(item, _script.LoadToCollections[0]) == false)
                    {
                        // first, we need to delete docs prefixed by modified document ID to properly handle updates of
                        // documents loaded to non default collections

                        ApplyDeleteCommands(item, OperationType.Put);
                    }

                    SingleRun.Run(Context, "execute", new object[] { Current.Document }).Dispose();
                }
                else
                {
                    _commands.Add(new PutCommandDataWithBlittableJson(item.DocumentId, null, item.Document.Data));
                }
            }
            else
            {
                if (_script.Transformation != null)
                {
                    ApplyDeleteCommands(item, OperationType.Delete);
                }
                else
                {
                    _commands.Add(new DeleteCommandData(item.DocumentId, null));
                }
            }
        }
Beispiel #2
0
        public int Load()
        {
#if !NET4_5
            if (singrun)
            {
                return(-1);
            }
            singrun = true;
#else
            if (SingleRun.HasAlreadyRan(GetHashCode()))
            {
                return(0);
            }
#endif
            ds = new DataSet();
            Open();
            int res = Adapter.Fill(ds);
            Close();
            BindingSource   = new BindingSource(ds, ds.Tables[0].TableName);
            grid.DataSource = BindingSource;
            Process();
            if (BindingAndLoadingCompleted != null)
            {
                BindingAndLoadingCompleted(this, res);
            }
            IsBoundAndLoaded = true;
            return(res);
        }
Beispiel #3
0
 public ReturnRun GetRunner(out SingleRun run)
 {
     if (_cache.TryDequeue(out run) == false)
     {
         run = new SingleRun(_db, _configuration, this, ScriptsSource);
     }
     Interlocked.Increment(ref Runs);
     return(new ReturnRun(this, run));
 }
Beispiel #4
0
 public void Dispose()
 {
     if (_run == null)
     {
         return;
     }
     _run.ReadOnly  = false;
     _run.DebugMode = false;
     _run.DebugOutput?.Clear();
     _run.DebugActions?.Clear();
     _parent._cache.Enqueue(_run);
     _run    = null;
     _parent = null;
 }
        public override void Transform(RavenEtlItem item)
        {
            Current = item;

            if (item.IsDelete == false)
            {
                if (_script.Transformation != null)
                {
                    if (_script.LoadToCollections.Length > 1 || _script.IsLoadedToDefaultCollection(item, _script.LoadToCollections[0]) == false)
                    {
                        // first, we need to delete docs prefixed by modified document ID to properly handle updates of
                        // documents loaded to non default collections

                        ApplyDeleteCommands(item, OperationType.Put);
                    }

                    SingleRun.Run(Context, Context, "execute", new object[] { Current.Document }).Dispose();
                }
                else
                {
                    _commands.Add(new PutCommandDataWithBlittableJson(item.DocumentId, null, item.Document.Data));

                    if ((item.Document.Flags & DocumentFlags.HasAttachments) == DocumentFlags.HasAttachments)
                    {
                        HandleDocumentAttachments(item);
                    }
                }
            }
            else
            {
                if (_script.Transformation != null)
                {
                    Debug.Assert(item.IsAttachmentTombstone == false, "attachment tombstones are tracked only if script is empty");
                    ApplyDeleteCommands(item, OperationType.Delete);
                }
                else
                {
                    if (item.IsAttachmentTombstone == false)
                    {
                        _commands.Add(new DeleteCommandData(item.DocumentId, null));
                    }
                    else
                    {
                        var(doc, attachmentName) = AttachmentsStorage.ExtractDocIdAndAttachmentNameFromTombstone(Context, item.AttachmentTombstoneId);

                        _commands.Add(new DeleteAttachmentCommandData(doc, attachmentName, null));
                    }
                }
            }
        }
Beispiel #6
0
 private void StartAllTwoHour()
 {
     if (applist.Count != 0)
     {
         CMDprint("一键2小时");
         MessageBox.Show("一键2小时的时候别挂机,挂机别2小时", "注意");
         int i = 0;
         foreach (AppMember item in applist)
         {
             if (Convert.ToDouble(item.Time) < 2.00 && i < 30)
             {
                 SingleRun srtwo = new SingleRun(item);
                 srtwo.StartTwoApp();
                 i++;
             }
         }
     }
 }
Beispiel #7
0
 private void Start()
 {
     try
     {
         sr = new SingleRun(applist[AppIndex]);
         sr.StartApp();
         LoadAppMsg((int)Status.Start, applist[AppIndex].Id);
         appTimer          = new System.Timers.Timer();
         appTimer.Interval = Settings.Default.CardTime * 60000;
         appTimer.Start();
         appTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
     }
     catch (Exception e)
     {
         Settings.Default.AppEnabled = false;
         LoadAppMsg((int)Status.Exit, applist[AppIndex].Id);
         CMDprintError(e.Message);
         MessageBox.Show(e.Message);
     }
 }
        public override void Transform(ToSqlItem item)
        {
            if (item.IsDelete == false)
            {
                Current = item;

                SingleRun.Run(Context, "execute", new object[] { Current.Document }).Dispose();
            }

            // ReSharper disable once ForCanBeConvertedToForeach
            for (int i = 0; i < _config.SqlTables.Count; i++)
            {
                // delete all the rows that might already exist there

                var sqlTable = _config.SqlTables[i];

                if (sqlTable.InsertOnlyMode)
                {
                    continue;
                }

                GetOrAdd(sqlTable.TableName).Deletes.Add(item);
            }
        }
Beispiel #9
0
 private void OnTimedEvent(object source, ElapsedEventArgs e)
 {
     if (--sr.Virtualcard < 1)
     {
         sr.StopApp();
         LoadAppMsg((int)Status.End, applist[AppIndex].Id);
         ++AppIndex;
         try
         {
             sr = new SingleRun(applist[AppIndex]);
             sr.StartApp();
             LoadAppMsg((int)Status.Start, applist[AppIndex].Id);
         }
         catch (Exception ex)
         {
             Settings.Default.AppEnabled = false;
             Kill();
             appTimer.Stop();
             appTimer.Close();
             LoadAppMsg((int)Status.Exit, applist[AppIndex - 1].Id);
             CMDprintError(ex.Message);
         }
     }
 }
Beispiel #10
0
 public ReturnRun(ScriptRunner parent, SingleRun run)
 {
     _parent = parent;
     _run    = run;
 }