Exemplo n.º 1
0
 public ActivityItem(ActivityItem fci, string path)
 {
     Path        = path;
     ProjectPath = path;
     DateTime    = fci.DateTime;
     ChangeType  = fci.ChangeType;
     AuxInfo     = fci.AuxInfo;
 }
Exemplo n.º 2
0
 internal void Add(ActivityItem fci)
 {
     if (fci != null)
     {
         // to straight listing
         Collection.Add(fci);
         fci.Project = this;
         // to day schedule listing
         FileChangeDay projectDay = _getDay(fci.DateTime);
         projectDay?.Add(fci);
     }
 }
Exemplo n.º 3
0
 internal static bool EqualPathAndTime(ActivityItem fci1, ActivityItem fci2)
 {
     if (fci1 == null || fci2 == null)
     {
         return(false);
     }
     if (fci1.Path == null || fci2.Path == null)
     {
         return(false);
     }
     return(
         fci1.Path == fci2.Path &&
         FileChangeTable.Equal(fci1.DateTime, fci2.DateTime, oneSec));
 }
Exemplo n.º 4
0
        private void FolderChangeWatcher_Changed(object sender, DoWorkEventArgs e)
        {
            ActivityItem fci = e.Argument as ActivityItem;

            if (fci != null)
            {
                if (textBoxWATCHOUTPUT.InvokeRequired)
                {
                    AppendTextCallback d = new AppendTextCallback(FolderChangeWatcher_Changed);
                    textBoxWATCHOUTPUT.BeginInvoke(d, new object[] { sender, e });
                }
                else
                {
                    textBoxWATCHOUTPUT.AppendText(fci.ToString() + Environment.NewLine);
                }
            }
            _dirtyTable = true;
        }
Exemplo n.º 5
0
        public ActivityItem GetFileChangeTestItem(DateTime dt)
        {
            if (files.Count == 0)
            {
                return(null);
            }
            // given number of events to generate
            // randomly get a matching file
            int ic = 1000;

            while (ic >= 0)
            {
                ic--;
                string       path = files[rand.Next(files.Count)];
                ActivityItem fci  = ActivityItem.GetFileChangeItem(path, dt, _randomChange());
                if (fci != null)
                {
                    return(fci);
                }
            }
            return(null);
        }
Exemplo n.º 6
0
        public static void Build(FileChangeTable table)
        {
            ClearActivity(table);

            // 1 . MAKE list of everything selected
            List <ActivityItem> masterList = new List <ActivityItem>();

            foreach (var proj in table.ProjectCollection)
            {
                if (proj.Visible)
                {
                    foreach (var fci in proj.Collection)
                    {
                        bool isEdit =
                            !fci.ChangeType.HasAny(ActionTypes.RESUME | ActionTypes.SUSPEND | ActionTypes.USER_IDLE);

                        if (isEdit)
                        {
                            fci.Project.EditCount++;
                        }

                        if (fci.IsInSelectedRange)
                        {
                            masterList.Add(fci);
                            if (isEdit)
                            {
                                fci.Project.SelectedEditCount++;
                            }
                        }
                    }
                }
            }

            // sort nicely
            masterList.Sort((x, y) => DateTime.Compare(x.DateTime, y.DateTime));


            // apply smoothing
            ActivityItem             s0                 = null;
            DateTime                 endActivity        = DateTime.MinValue;
            List <ActivityBaseBlock> activityBaseBlocks = new List <ActivityBaseBlock>();

            int editCount = 0;

            foreach (var fci in masterList)
            {
                if (fci.ChangeType.HasFlag(ActionTypes.RESUME))
                {
                    continue;
                }
                else if (UseIdleEvents && fci.ChangeType.HasAny(ActionTypes.SUSPEND | ActionTypes.USER_IDLE))
                { // end at the user's idle
                    endActivity = fci.DateTime;
                    AddActivityBlock();
                    s0 = null;
                }
                else
                {
                    editCount++;
                    if (fci.DateTime > endActivity)
                    {
                        AddActivityBlock();
                        s0 = fci;
                    }
                    endActivity = fci.DateTime.AddMinutes(ActivityTraceBuilder.PerEditMinutes);
                }
            }
            AddActivityBlock();

            table.Activity.Collection   = activityBaseBlocks;
            table.Activity.EditCount    = editCount;
            table.Activity.TotalMinutes = activityBaseBlocks.Sum(blk => (blk.EndDate - blk.StartDate).TotalMinutes);

            void AddActivityBlock()
            {
                if (s0 != null)
                {
                    ActivityBaseBlock blk = new ActivityBaseBlock(s0.DateTime, endActivity);
                    activityBaseBlocks.Add(blk);
                }
            }
        }
Exemplo n.º 7
0
        public static ActivityItem GetFileChangeItem(string path, DateTime dt, ActionTypes changeType)
        {
            var fci = new ActivityItem(path, dt, changeType);

            return(fci.IsValid ? fci : null);
        }
Exemplo n.º 8
0
        public static ActivityItem GetFileChangeItem(string str)
        {
            var fci = new ActivityItem(str);

            return(fci.IsValid ? fci : null);
        }
Exemplo n.º 9
0
 internal void Add(ActivityItem fci)
 {
     Collection.Add(fci);
     fci.Day = this;
 }