Example #1
0
        private void UpdateStatus(WipeStatus status)
        {
            TotalPanel.Title = "Total";
            TotalProgressbar.Style = ProgressBarStyle.Continuous;
            EnsureContextNumber(status);

            if(wipeTask != null) {
                wipeTask.ProgressStyle = ProgressBarStyle.Continuous;
            }

            // total status
            if(status.BytesToWipe > 0) {
                double progress = Math.Max(0, Math.Min(100.0, ((double)status.BytesWiped /
                                                               (double)status.BytesToWipe) * 100.0));
                TotalProgressbar.Value = (int)Math.Floor(progress);
                PercentLabel.Text = string.Format("{0:f2} %", progress);
                TotalPanel.Subtitle = GetDurationString(totalSpeed.UpdateSpeed(status.BytesWiped),
                                                        status.BytesWiped, status.BytesToWipe);
                if(wipeTask != null) {
                    wipeTask.ProgressValue = progress;
                }
            }

            // main member
            UpdateViewStatus(status);

            // children
            if(status.Children != null && status.Children.Length > 0) {
                int count = status.Children.Length;
                for(int i = 0; i < count; i++) {
                    UpdateViewStatus(status.Children[i]);
                }
            }
        }
Example #2
0
        private void UpdateViewStatus(WipeStatus status)
        {
            ItemStatus itemStatus = GetItemStatus(status.ContextId);
            if(itemStatus != null) {
                // reset the speed calculator if a new object is wiped
                if(status.ObjectIndex != itemStatus.ObjectIndex) {
                    itemStatus.ObjectIndex = status.ObjectIndex;
                    itemStatus.Speed.Reset();
                    itemStatus.View.Subtitle = "";
                }

                if(status.ObjectBytesToWipe > 0) {
                    double progress = Math.Max(0, Math.Min(100.0, ((double)status.ObjectBytesWiped /
                                                                   (double)status.ObjectBytesToWipe) * 100.0));
                    itemStatus.View.ItemProgressBar.Value = (int)Math.Floor(progress);
                    itemStatus.View.PercentLabel.Text = string.Format("{0:f2} %", progress);
                }

                itemStatus.View.MainText = status.MainMessage;
                itemStatus.View.SecondaryStatusLabel.Text = status.AuxMessage;

                // don't show step status for drives
                if(status.ObjectType != WipeObjectType.Drive && status.ObjectType != WipeObjectType.MFT) {
                    itemStatus.View.StepLabel.Text = "Step " + status.ActualStep.ToString() + " of " + status.Steps.ToString();
                }
                else {
                    itemStatus.View.StepLabel.Text = "";
                }

                itemStatus.View.Subtitle = GetDurationString(itemStatus.Speed.UpdateSpeed(status.ObjectBytesWiped),
                                                             status.ObjectBytesWiped, status.ObjectBytesToWipe);
                if(status.ObjectType == WipeObjectType.ClusterTips) {
                    itemStatus.View.SizeLabel.Text = GetClusterTipsString(status.ObjectBytesWiped, status.ObjectBytesToWipe);
                }
                else if(status.ObjectType == WipeObjectType.MFT) {
                    itemStatus.View.SizeLabel.Text = GetMFTString(status.ObjectBytesWiped, status.ObjectBytesToWipe);
                }
                else {
                    itemStatus.View.SizeLabel.Text = GetSizeString(status.ObjectBytesWiped, status.ObjectBytesToWipe);
                }
            }
        }
Example #3
0
        private void StatusTimer_Tick(object sender, EventArgs e)
        {
            if(_session.Context.Status != ContextStatus.Stopped) {
                WipeStatus status = new WipeStatus();

                if(_session.GetWipeStatus(ref status, true)) {
                    UpdateStatus(status);
                }
            }
            else {
                if(_session.Status != SessionStatus.BeginStart) {
                    ExecuteAfterWipeActions();
                }
            }
        }
Example #4
0
        public void EnsureContextNumber(WipeStatus status)
        {
            usedViews.Clear();

            // add main view to the used list
            if(status.WipeStopped == false) {
                usedViews.Add(status.ContextId);
            }

            // main member
            if(GetItemStatus(status.ContextId) == null && status.WipeStopped == false) {
                views.Add(new ItemStatus(status.ContextId));
                RegisterView(views[views.Count - 1].View);
            }

            // children
            if(status.Children != null && status.Children.Length > 0) {
                int count = status.Children.Length;
                WipeStatus[] children = status.Children;

                for(int i = 0; i < count; i++) {
                    // skip contexts that don't wipe anymore
                    if(children[i].WipeStopped) {
                        continue;
                    }

                    if(GetItemStatus(children[i].ContextId) == null) {
                        views.Add(new ItemStatus(children[i].ContextId));
                        RegisterView(views[views.Count - 1].View);
                    }

                    usedViews.Add(children[i].ContextId);
                }
            }

            // remove unused views
            int position = 0;

            while(position < views.Count) {
                if(usedViews.IndexOf(views[position].ContextId) == -1) {
                    // remove
                    UnregisterView(views[position]);
                    position--;
                }

                position++;
            }
        }
Example #5
0
        private NativeMethods.WStatus GetChildrenStatus(WipeStatus s, NativeMethods.WStatus wipeStatus, int childrenNumber)
        {
            // allocate the array
            bool needsInit = false;

            if(s.Children == null || (s.Children != null && s.Children.Length != childrenNumber)) {
                s.Children = new WipeStatus[childrenNumber];
                needsInit = true;
            }

            // get the status
            for(int i = 0; i < childrenNumber; i++) {
                if(needsInit) {
                    s.Children[i] = new WipeStatus();
                }

                if(context.GetChildWipeStatus(i, out wipeStatus) == false) {
                    s.Children[i] = null;
                }
                else {
                    // set child data
                    s.Children[i].FromNative(wipeStatus);
                }
            }

            return wipeStatus;
        }
Example #6
0
        private void GenerateStatistics()
        {
            WipeStatus status = new WipeStatus();
            GetWipeStatus(ref status, false);

            statistics.EndTime = DateTime.Now;
            statistics.Duration = statistics.EndTime - statistics.StartTime;
            statistics.TotalWipedBytes = status.BytesWiped;
            statistics.BytesInClusterTips = statistics.BytesInClusterTips;

            if(statistics.Duration.TotalSeconds > 0) {
                statistics.AverageWriteSpeed = (long)(statistics.TotalWipedBytes / statistics.Duration.TotalSeconds);
            }

            int number;
            context.GetFailedObjectNumber(out number);
            statistics.FailedObjects = number;
            context.GetErrorNumber(out number);
            statistics.Errors = number + _beforeWipeErrors.Count + _afterWipeErrors.Count;
        }
Example #7
0
        /// <summary>
        /// Get the status of the wiping process
        /// </summary>
        /// <param name="s">The WipeStatus object where to store the status</param>
        /// <param name="includeChildren">Include the status of all children of the context</param>
        public bool GetWipeStatus(ref WipeStatus s, bool includeChildren)
        {
            s.SessionStatus = status;

            // get context status
            if(s.GetContextStatus(context) == false) {
                Debug.ReportWarning("Failed to get context status");
            }

            // get wipe status
            NativeMethods.WStatus wipeStatus = new NativeMethods.WStatus();

            if(context.GetWipeStatus(out wipeStatus) == true) {
                s.FromNative(wipeStatus);

                // get the status of the children
                int childrenNumber;

                if(includeChildren) {
                    if(context.GetChildrenNumber(out childrenNumber) == false) {
                        // failed to get number
                        s.Children = null;
                    }
                    else {
                        if(childrenNumber == 0) {
                            s.Children = null;
                        }
                        else {
                            wipeStatus = GetChildrenStatus(s, wipeStatus, childrenNumber);
                        }
                    }
                }
            }
            else {
                Debug.ReportWarning("Failed to read wipe status");
                return false;
            }

            return true;
        }