GreenQloud.Persistence.SQLite.SQLiteEventDAO.CombineMultipleMoves C# (CSharp) Method

CombineMultipleMoves() public method

public CombineMultipleMoves ( Event e ) : void
e GreenQloud.Model.Event
return void
        public void CombineMultipleMoves(Event e)
        {
            Event toCombine = null;
            Event combineWith = null;
            if (e.EventType == EventType.MOVE)
                toCombine = e;

            if(e == null) {
                List<Event> list = Select (string.Format("SELECT * FROM EVENT WHERE ItemId ='{0}' AND TYPE = '{1}' AND EventID > '{2}'  AND SYNCHRONIZED <> '{3}'  AND RepositoryId = '{4}'", e.Item.Id, EventType.MOVE, e.Id, bool.TrueString, repo.Id));
                if(list.Count > 0) {
                    toCombine = list.First ();
                }
            }

            //do while move.hasnext
            //ignore o next
            try {
                if (toCombine != null){
                    List<Event> list2;
                    do {
                        list2 = Select (string.Format("SELECT * FROM EVENT WHERE ItemId ='{0}' AND TYPE = '{1}' AND EventID > '{2}'  AND SYNCHRONIZED <> '{3}' AND RepositoryId = '{4}'", toCombine.Item.ResultItemId, EventType.MOVE, e.Id, bool.TrueString, repo.Id));
                        if (list2.Count > 0) {
                            combineWith = list2.First ();
                            database.ExecuteNonQuery (string.Format("UPDATE EVENT SET  SYNCHRONIZED = '{0}', RESPONSE = '{1}' WHERE EventID = '{2}'", bool.TrueString, RESPONSE.IGNORED.ToString(), combineWith.Id));
                            repositoryItemDAO.MarkAsMoved (toCombine.Item.ResultItem);
                            toCombine.Item.ResultItem = combineWith.Item.ResultItem;
                            database.ExecuteNonQuery (string.Format("UPDATE RepositoryItem SET  ResultItemId ='{0}' WHERE RepositoryItemID = '{1}'  AND RepositoryId = '{2}'", combineWith.Item.ResultItemId, toCombine.Item.Id, repo.Id));
                        }
                    } while (list2 != null && list2.Count > 0);
                }
            } catch (Exception ex) {
                Logger.LogInfo("ERROR ON COMBINING MOVE EVENTS", ex.Message);
            }
        }