예제 #1
0
        public void Cancel(bool NeedNotify = true)
        {
            int hResult = XfsApi.WFSCancelAsyncRequest(hService, requestID);

            if (hResult != XFSDefinition.WFS_SUCCESS && CancelError != null && NeedNotify)
            {
                CancelError.Invoke(serviceType, hResult);
            }
            else
            {
                if (CancelComplete != null && NeedNotify)
                {
                    CancelComplete.Invoke(serviceType);
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Starts scanning
 /// </summary>
 /// <param name="callback"><see cref="ProgressUpdate"/> callback</param>
 /// <param name="complete"><see cref="ScanComplete"/> callback</param>
 /// <param name="cancelComplete"><see cref="CancelComplete"/> callback</param>
 /// <param name="fixAfterScan">A bool flag that determines is the fixing needed after finishing the scan</param>
 public override void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete, bool fixAfterScan)
 {
     Thread.CurrentThread.CurrentUICulture = new CultureInfo(CfgFile.Get("Lang"));
     if (SelectedRegistryCategoriesCount() > 0)
     {
         this.callback = callback;
         this.complete = complete;
         this.cancelComplete = cancelComplete;
         this.fixAfterScan = fixAfterScan;
         Reset();
         ABORT = false;
         ScanStart();
     }
     else
     {
         MessageBox.Show(Resources.SelectAtLeastOneItem,
                         Resources.InvalidSelection,
                         MessageBoxButton.OK, MessageBoxImage.Exclamation);
     }
 }
예제 #3
0
        /// <summary>
        /// start scanning
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="complete"></param>
        /// <param name="cancelComplete"></param>
        /// <param name="fixAfterScan"></param>
        public override void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete,
            bool fixAfterScan)
        {
            ABORT = false;

            try
            {
                TmpFiles = new List<FileInfo>();
                WinFiles = new List<FileInfo>();
                IEFiles = new List<FileInfo>();
                FFFiles = new List<FileInfo>();
                ChromeFiles = new List<FileInfo>();

                TmpSize = 0;
                WinSize = 0;
                IESize = 0;
                FFSize = 0;
                ChromeSize = 0;

                this.callback = callback;
                this.complete = complete;
                this.cancelComplete = cancelComplete;
                this.fixAfterScan = fixAfterScan;

                string winTempPath = Environment.GetEnvironmentVariable("Temp");
                string IETempPath = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
                string ffCachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
                                     "\\Mozilla\\Firefox\\Profiles";
                string chromeCachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
                                         "\\Google\\Chrome\\User Data\\Default";

                DirectoryInfo windowsTemp = Directory.Exists(winTempPath) ? new DirectoryInfo(winTempPath) : null;
                DirectoryInfo IETemp = Directory.Exists(IETempPath) ? new DirectoryInfo(IETempPath) : null;
                DirectoryInfo ffCahce = Directory.Exists(ffCachePath) ? new DirectoryInfo(ffCachePath) : null;
                DirectoryInfo chromeCache = Directory.Exists(chromeCachePath) ? new DirectoryInfo(chromeCachePath) : null;

                int WinFilesCount = windowsTemp != null ? windowsTemp.GetDirectories().Length + windowsTemp.GetFiles().Length : 0;
                int IETempCount = IETemp != null ? IETemp.GetDirectories().Length + IETemp.GetFiles().Length : 0;
                int ffCahceCount = ffCahce != null ? ffCahce.GetDirectories().Length + ffCahce.GetFiles().Length : 0;
                int chromeCacheCount = chromeCache != null ? chromeCache.GetDirectories().Length + chromeCache.GetFiles().Length : 0;

                int filesCount = WinFilesCount + IETempCount + ffCahceCount + chromeCacheCount;

                List<DriveInfo> drives = null;
                try
                {
                    drives = DriveInfo.GetDrives().Where(drive => drive.IsReady && (drive.DriveType == DriveType.Fixed || drive.DriveType == DriveType.Removable)).ToList();
                }
                catch (IOException)
                {
                }
                catch (UnauthorizedAccessException)
                {
                }

                if (drives != null)
                {
                    filesCount += drives.Count;
                    scannedFilesCount = 0;

                    foreach (DriveInfo drive in drives)
                    {
                        if (ABORT)
                        {
                            cancelComplete();
                            return;
                        }
                        try
                        {
                            FileInfo[] tmpFiles = drive.RootDirectory.GetFiles("*.tmp");
                            TmpFiles.AddRange(tmpFiles);
                        }
                        catch
                        {
                        }
                        scannedFilesCount++;
                        callback((int)((scannedFilesCount / (float)filesCount) * 100), drive.RootDirectory.FullName);
                    }
                }

                if (windowsTemp != null)
                {
                    if (ABORT)
                    {
                        cancelComplete();
                        return;
                    }

                    CollectFiles(windowsTemp, "win");

                    int firstLevelSubDirectoriesCount = windowsTemp.GetDirectories().Count() + 1;

                    if (firstLevelSubDirectoriesCount < WinFilesCount)
                    {
                        int filesPerSubDirectory = WinFilesCount / firstLevelSubDirectoriesCount;
                        int filesPerSubDirectoryMod = WinFilesCount % firstLevelSubDirectoriesCount;

                        for (int i = 0; i < firstLevelSubDirectoriesCount - 1; i++)
                        {
                            scannedFilesCount += filesPerSubDirectory;
                            callback((int)((scannedFilesCount / (float)filesCount) * 100), windowsTemp.FullName);
                            Thread.Sleep(20);
                        }
                        scannedFilesCount += filesPerSubDirectory + filesPerSubDirectoryMod;
                        callback((int)((scannedFilesCount / (float)filesCount) * 100), windowsTemp.FullName);
                    }
                    else
                    {
                        scannedFilesCount += WinFilesCount;
                        callback((int)((scannedFilesCount / (float)filesCount) * 100), windowsTemp.FullName);
                    }
                }

                if (IETemp != null)
                {
                    if (ABORT)
                    {
                        cancelComplete();
                        return;
                    }

                    CollectFiles(IETemp, "ie");
                    scannedFilesCount += IETempCount;
                    callback((int)((scannedFilesCount / (float)filesCount) * 100), windowsTemp.FullName);
                }

                if (ffCahce != null)
                {
                    if (ABORT)
                    {
                        cancelComplete();
                        return;
                    }

                    CollectFiles(ffCahce, "ff");
                    scannedFilesCount += ffCahceCount;
                    callback((int)((scannedFilesCount / (float)filesCount) * 100), windowsTemp.FullName);
                }

                if (chromeCache != null)
                {
                    if (ABORT)
                    {
                        cancelComplete();
                        return;
                    }

                    CollectFiles(chromeCache, "chrome");
                    scannedFilesCount += chromeCacheCount;
                    callback((int)((scannedFilesCount / (float)filesCount) * 100), windowsTemp.FullName);
                }
            }
            catch (Exception)
            {
                // ToDo: send exception details via SmartAssembly bug reporting!
            }

            complete(fixAfterScan);
        }
예제 #4
0
 public abstract void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete,
     bool fixAfterScan);
예제 #5
0
 /// <summary>
 /// start scanning
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="complete"></param>
 /// <param name="cancelComplete"></param>
 /// <param name="fixAfterScan"></param>
 public override void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete,
     bool fixAfterScan)
 {
     FrmTrackSel.Callback = callback;
     FrmTrackSel.Complete = complete;
     FrmTrackSel.CancelComplete = cancelComplete;
     FrmTrackSel.ScanFiles(fixAfterScan);
 }
예제 #6
0
        /// <summary>
        /// start scanning
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="complete"></param>
        /// <param name="cancelComplete"></param>
        /// <param name="fixAfterScan"></param>
        public override void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete,
            bool fixAfterScan)
        {
            ABORT = false;

            try
            {
                this.callback = callback;
                this.complete = complete;
                this.cancelComplete = cancelComplete;
                this.fixAfterScan = fixAfterScan;

                List<ListViewItem> problems = new List<ListViewItem>();
                FrmSrtUpMan.FillListview();

                for (int i = 0; i < AppsToDelete.Count; i++)
                {
                    if (ABORT)
                    {
                        cancelComplete();
                        return;
                    }

                    callback((int)(i + 1 / (double)AppsToDelete.Count * 100), AppsToDelete[i]);

                    problems = FrmSrtUpMan.RemoveAppsFromReg(AppsToDelete[i]);
                    ProblemsCount = problems.Count;

                    LstVwItemLst = problems;
                    LstProblems = ConvertLists(problems);
                }
                FrmDetails = new FrmDetails(problems);
            }
            catch (Exception)
            {
                // ToDo: send exception details via SmartAssembly bug reporting!
            }
            complete(fixAfterScan);
        }
예제 #7
0
 private void OnCancelComplete(CancelCompleteEventArgs e)
 {
     CancelComplete?.Invoke(this, e);
 }
예제 #8
0
        /// <summary>
        /// start scanning
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="complete"></param>
        /// <param name="cancelComplete"></param>
        /// <param name="fixAfterScan"></param>
        public override void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete, bool fixAfterScan)
        {
            ABORT = false;

            BrokenShortcuts.Clear();

            this.callback = callback;
            this.complete = complete;
            this.cancelComplete = cancelComplete;
            this.fixAfterScan = fixAfterScan;

            string root = Path.GetPathRoot(Environment.SystemDirectory);
            string user = Environment.UserName;

            HashSet<string> places = new HashSet<string>();

            if (OSIsXP())
            {
                places.Add(root + @"Documents and Settings\All Users\Desktop");
                places.Add(root + @"Documents and Settings\All Users\Start Menu");
                places.Add(root + @"Documents and Settings\Default User\Desktop");
                places.Add(root + @"Documents and Settings\Default User\Start Menu");
                places.Add(root + @"Documents and Settings\" + user + @"\Desktop");
                places.Add(root + @"Documents and Settings\" + user + @"\Start Menu");
            }
            places.Add(root + @"ProgramData\Desktop");
            places.Add(root + @"ProgramData\Microsoft\Windows\Start Menu");
            places.Add(root + @"ProgramData\Start Menu");
            places.Add(root + @"Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu");
            places.Add(root + @"Users\Default\Desktop");
            places.Add(root + @"Users\Default\Start Menu");
            places.Add(root + @"Users\Public\Desktop");
            places.Add(root + @"Users\" + user + @"\AppData\Roaming\Microsoft\Windows\Start Menu");
            places.Add(root + @"Users\" + user + @"\Desktop");
            places.Add(root + @"Users\" + user + @"\Start Menu");
            places.Add(GetSpecialFolderPath(CSIDL_COMMON_DESKTOPDIRECTORY));
            places.Add(GetSpecialFolderPath(CSIDL_COMMON_STARTMENU));
            places.Add(GetSpecialFolderPath(CSIDL_DESKTOP));
            places.Add(GetSpecialFolderPath(CSIDL_DESKTOPDIRECTORY));
            places.Add(GetSpecialFolderPath(CSIDL_STARTMENU));

            List<FileInfo> shortcutList = new List<FileInfo>();
            foreach (string s in places)
            {
                try
                {
                    DirectoryInfo dir = new DirectoryInfo(s);
                    FileAttributes att = dir.Attributes;
                    if ((att & FileAttributes.ReparsePoint) != FileAttributes.ReparsePoint)
                    {
                        shortcutList.AddRange(dir.GetFiles("*.lnk", SearchOption.AllDirectories));
                    }
                }
                catch { }
            }

            int shortcutsFound = shortcutList.Count;

            int shortcutsProcessed = 0;

            foreach (FileInfo shortcut in shortcutList)
            {
                if (ABORT)
                {
                    cancelComplete();
                    return;
                }

                try
                {
                    WshShellClass wshShellClass = new WshShellClass();
                    IWshShortcut shortcutInfo = (IWshShortcut)wshShellClass.CreateShortcut(shortcut.FullName);
                    string linkTarget = shortcutInfo.TargetPath;
                    string linkfile = linkTarget;
                    if (linkTarget.Contains("\\"))
                    {
                        linkfile = linkTarget.Substring(linkTarget.LastIndexOf("\\"));
                    }
                    if (string.IsNullOrEmpty(linkTarget))
                    {
                        continue;
                    }
                    var drive = new DriveInfo(linkTarget.Substring(0, 1));
                    if (drive.DriveType == DriveType.CDRom)
                    {
                        continue;
                    }
                    if (shortcutInfo.TargetPath.Contains("Program Files"))
                    {
                        IWshShortcut shortcutInfox86 = (IWshShortcut)wshShellClass.CreateShortcut(shortcut.FullName);
                        shortcutInfox86.TargetPath = shortcutInfox86.TargetPath.Replace(" (x86)", string.Empty);

                        if (!File.Exists(shortcutInfo.TargetPath) && !Directory.Exists(shortcutInfo.TargetPath)
                            && !File.Exists(shortcutInfox86.TargetPath.Replace(" (x86)", string.Empty)) && !Directory.Exists(shortcutInfox86.TargetPath.Replace(" (x86)", string.Empty)))
                        {
                            Shortcut brokenShortcut = new Shortcut
                                                    {
                                                        Name = shortcut.Name,
                                                        Target = shortcutInfox86.TargetPath,
                                                        Location = shortcut.DirectoryName,
                                                        Description = shortcutInfox86.Description
                                                    };

                            BrokenShortcuts.Add(brokenShortcut);
                            ProblemsCount++;
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(shortcutInfo.TargetPath) && !File.Exists(shortcutInfo.TargetPath) && !Directory.Exists(shortcutInfo.TargetPath)
                            && !File.Exists(Environment.ExpandEnvironmentVariables(@"%systemroot%\Sysnative") + "\\" + linkfile)
                            && !File.Exists(Environment.SystemDirectory + "\\" + linkfile)
                            && !File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\" + linkfile))
                        {
                            var brokenShortcut = new Shortcut
                                                    {
                                                        Name = shortcut.Name,
                                                        Target = shortcutInfo.TargetPath,
                                                        Location = shortcut.DirectoryName,
                                                        Description = shortcutInfo.Description
                                                    };

                            BrokenShortcuts.Add(brokenShortcut);
                            ProblemsCount++;
                        }
                    }
                }
                catch (Exception)
                {
                    // ToDo: send exception details via SmartAssembly bug reporting!
                }

                shortcutsProcessed++;
                callback((int)((double)shortcutsProcessed / shortcutsFound * 100), shortcut.FullName);
            }
            complete(fixAfterScan);
        }
예제 #9
0
        /// <summary>
        /// Starts the scanning process
        /// </summary>
        /// <param name="callback">The callback method to update progress</param>
        public override void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete,
            bool fixAfterScan)
        {
            this.callback = callback;
            this.complete = complete;
            this.cancelComplete = cancelComplete;
            this.fixAfterScan = fixAfterScan;

            isCancel = false;
            scanBackgroundWorker = new BackgroundWorker();
            scanBackgroundWorker.WorkerSupportsCancellation = true;
            scanBackgroundWorker.WorkerReportsProgress = true;
            scanBackgroundWorker.DoWork += ScanBackgroundWorkerDoWork;
            scanBackgroundWorker.RunWorkerCompleted += scanBackgroundWorker_RunWorkerCompleted;
            scanBackgroundWorker.ProgressChanged += scanBackgroundWorker_ProgressChanged;

            scanBackgroundWorker.RunWorkerAsync();
        }