コード例 #1
0
 public Post(PostFile setFile, RemoveChoices setChoices, int setRemoveUnapprovedCommentsDays = 60)
 {
     file = setFile;
     Choices = setChoices;
     RemoveUnapprovedCommentsDays = setRemoveUnapprovedCommentsDays;
     Name = file.Root.Element("title").Value;
     Date = file.Root.Element("pubDate").Value.ToDateTime() ?? DateTime.Now;
     LoadComments();
 }
コード例 #2
0
        public List<Post> GetAllPosts(RemoveChoices choices, int setRemoveUnapprovedCommentsDays = 60)
        {
            var posts = new List<Post>();
            var files = Directory.GetFiles(postsPath);
            foreach (var file in files)
                posts.Add(new Post(new PostFile(file), choices, setRemoveUnapprovedCommentsDays));

            log(0, files.Length, "Starting ..", Comment.TotalCommentsRemoved,
                Comment.TotalComments, "");

            if (choices.HasFlag(RemoveChoices.Unapproved))
                RemoveAllUnapprovedComments(posts);

            return posts;
        }
コード例 #3
0
ファイル: Installer.cs プロジェクト: caoxk/coapp
        public Installer(string filename)
        {
            try {
                MsiFilename = filename;
                Quiet       = ((AppDomain.CurrentDomain.GetData("QUIET") as string) ?? "false").IsTrue();
                Passive     = ((AppDomain.CurrentDomain.GetData("PASSIVE") as string) ?? "false").IsTrue();
                Remove      = ((AppDomain.CurrentDomain.GetData("REMOVE") as string) ?? "false").IsTrue();

                Logger.Message("Quiet {0}/Passive {1}/Remove {2}", Quiet, Passive, Remove);

                // was coapp just installed by the bootstrapper?
                var tsk = Task.Factory.StartNew(() => {
                    if (((AppDomain.CurrentDomain.GetData("COAPP_INSTALLED") as string) ?? "false").IsTrue())
                    {
                        // we'd better make sure that the most recent version of the service is running.
                        EngineServiceManager.InstallAndStartService();
                        EnvironmentUtility.BroadcastChange();
                    }
                    bool wasCreated;
                    var ewhSec = new EventWaitHandleSecurity();
                    ewhSec.AddAccessRule(new EventWaitHandleAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), EventWaitHandleRights.FullControl, AccessControlType.Allow));
                    _ping = new EventWaitHandle(false, EventResetMode.ManualReset, "BootstrapperPing", out wasCreated, ewhSec);
                });

                // force the explorer process to pick up changes to the environment.
                EnvironmentUtility.BroadcastChange();

                var ts2 = tsk.Continue(() => {
                    // gets the package data for the likely suspects.
                    _packageManager.AddSessionFeed(Path.GetDirectoryName(Path.GetFullPath(MsiFilename))).Continue(() => {
                        _packageManager.GetPackageFromFile(Path.GetFullPath(MsiFilename)).Continue(pkg =>
                                                                                                   Task.WaitAll(new[] { pkg.InstalledNewest, pkg.AvailableNewestUpdate, pkg.AvailableNewestUpgrade }
                                                                                                                .Select(each => each != null ? _packageManager.GetPackage(each.CanonicalName, true)
                                                                                                                        .Continue(() => { _packageManager.GetPackageDetails(each.CanonicalName); })
                                : "".AsResultTask())
                                                                                                                .UnionSingleItem(_packageManager.GetPackageDetails(pkg).Continue(() => { PrimaryPackage = pkg; }))
                                                                                                                .ToArray()));
                    });
                });

                tsk.ContinueOnFail(error => {
                    DoError(InstallerFailureState.FailedToGetPackageFromFile, error);
                    ExitQuick();
                });

                try {
                    Application.ResourceAssembly = Assembly.GetExecutingAssembly();
                } catch {
                }

                ts2.Wait();

                if (!Quiet)
                {
                    _window = new InstallerMainWindow(this);
                    if (Remove)
                    {
                        _window.Loaded += (sender, args) => _window.RemoveButtonClick(sender, args);
                    }
                    else if (Passive)
                    {
                        _window.Loaded += (sender, args) => _window.InstallButtonClick(sender, args);
                    }

                    _window.ShowDialog();

                    if (Application.Current != null)
                    {
                        Application.Current.Shutdown(0);
                    }
                }
                else
                {
                    // when quiet
                    var discard  = RemoveChoices.ToArray();
                    var discard2 = InstallChoices.ToArray();

                    if (Remove)
                    {
                        if (CanRemove)
                        {
                            RemoveAll().Wait();
                        }
                    }
                    else
                    {
                        Logger.Message("Thinkin' about installin' {0}", CanInstall);
                        Debugger.Break();
                        if (CanInstall)
                        {
                            Install().Wait();
                        }
                    }
                }
                ExitQuick();
            }
            catch (Exception e) {
                DoError(InstallerFailureState.FailedToGetPackageDetails, e);
            }
        }
コード例 #4
0
 private static Comment LoadComment(string xmlPostText, RemoveChoices choices)
 {
     var doc = XDocument.Parse(xmlPostText);
     var post = new Post(new PostFile(doc), choices);
     return post.Comments[0];
 }