示例#1
0
        public int TakeDislikeBack(int postID)
        {
            User      current = Session["user"] as User;
            AddonRepo ar      = new AddonRepo();

            return(ar.SetAddonState(postID, current.UserID, 4, true));
        }
示例#2
0
        public void DoShow()
        {
            AddonLocal = new AptLocal(AddonEnv);

            if (InitializeRepository())
            {
                if (AddonRepo.IsAddonInRepository(ArgAddons[0]))
                {
                    RepositoryAddonInfo info = AddonRepo.GetAddonInfo(ArgAddons[0]);

                    PrintAddonInfo("Name", info.Name);
                    if (AddonLocal.IsInstalled(info.Name))
                    {
                        PrintAddonInfo("State", "Installed");
                        Output.Append(String.Format(" (Version {0})", AddonLocal.GetAddonInfo(info.Name).Version.Major.ToString()));
                    }
                    else
                    {
                        PrintAddonInfo("State", "Not installed");
                    }
                    if (info.Category != null)
                    {
                        PrintAddonInfo("Category", info.Category);
                    }
                    if (info.Author != null)
                    {
                        PrintAddonInfo("Author", info.Author);
                    }
                    PrintAddonInfo("Version", info.Version.Major.ToString());
                    PrintAddonInfo("Interface", info.InterfaceVersion.ToString());
                    if (info.IsStable)
                    {
                        PrintAddonInfo("Stable", "Yes");
                    }
                    else
                    {
                        PrintAddonInfo("Stable", "No");
                    }
                    if (info.PubDate != null)
                    {
                        PrintAddonInfo("Published", info.PubDate);
                    }
                    if (info.RequiredDeps != null)
                    {
                        PrintAddonInfo("Dependencies", String.Join(", ", info.RequiredDeps.ToArray()));
                    }
                    if (info.Description != null)
                    {
                        Output.NewLine();
                        PrintAddonInfo(info.Description);
                        Output.NewLine();
                    }
                }
                else
                {
                    Output.Info("Addon not found in repository.");
                }
            }
        }
示例#3
0
        public int DislikePost(int postID)
        {
            User      current      = Session["user"] as User;
            AddonRepo ar           = new AddonRepo();
            int       dislikeCount = ar.AddDislike(postID, current.UserID);

            if (dislikeCount == 0)
            {
                dislikeCount = ar.SetAddonState(postID, current.UserID, 4, false);
            }

            if (ar.IsAddonThere(postID, current.UserID, 2) && ar.IsAddonThere(postID, current.UserID, 2, false))
            {
                ar.SetAddonState(postID, current.UserID, 2, true);
            }

            return(dislikeCount);
        }
示例#4
0
        public void DoInstall()
        {
            AddonLocal  = new AptLocal(AddonEnv);
            AddonRemote = new AptRemote(AddonEnv);

            if (Cfg.AutoUpdateIndex)
            {
                DoUpdate();
            }

            Output.Info("Action: install addon(s).");

            int installedAddons = 0;

            if (InitializeRepository())
            {
                if (!Cfg.AutoUpdateIndex)
                {
                    Output.Info(String.Format("There are currently {0} addons in the database.", AddonRepo.GetAddonNum()));
                    PrintEnvInfo();
                }

                AptActionInstall install = new AptActionInstall(AddonEnv, AddonLocal, AddonRemote, AddonRepo);
                install.AddStatusListener(new AptAction.StatusMessageEventHandler(InstallStatusMessage));

                foreach (string addon in ArgAddons)
                {
                    if (AddonRepo.IsAddonInRepository(addon))
                    {
                        if (install.Install(addon, false))
                        {
                            installedAddons++;
                        }
                    }
                    else
                    {
                        Output.Error(String.Format("Addon not found: {0}", addon));
                    }
                }

                Output.Info(String.Format("Addons installed: {0}", installedAddons));
            }
        }
示例#5
0
        public void DoUpdate()
        {
            AddonRemote = new AptRemote(AddonEnv);

            Output.Info("Action: update repository database.");
            PrintEnvInfo();
            try
            {
                if (AddonRepo == null)
                {
                    AddonRepo = new AptRepository(AddonEnv);
                }
                Output.Info(String.Format("Current index from: {0}", AddonRepo.GetRepositoryDate()));
                Output.Info(String.Format("There are currently {0} addons in the database.", AddonRepo.GetAddonNum()));
            }
            catch (Exception e)
            {
                Output.Error("Failed to load current index file.");
            }

            Output.Info("Downloading index file...");

            if (AddonRemote.UpdateIndexFile())
            {
                Output.Info("Download successful.");

                try
                {
                    AddonRepo = new AptRepository(AddonEnv);
                    Output.Info(String.Format("Updated index from: {0}", AddonRepo.GetRepositoryDate()));
                    Output.Info(String.Format("There are now {0} addons in the database.", AddonRepo.GetAddonNum()));
                }
                catch (Exception e)
                {
                    Output.Error("Failed to downloaded index file.");
                }
            }
            else
            {
                Output.Error("Download failed.");
            }
        }
示例#6
0
        public void DoUpgrade()
        {
            AddonLocal  = new AptLocal(AddonEnv);
            AddonRemote = new AptRemote(AddonEnv);

            if (Cfg.AutoUpdateIndex)
            {
                DoUpdate();
            }

            if (InitializeRepository())
            {
                if (!Cfg.AutoUpdateIndex)
                {
                    Output.Info(String.Format("There are currently {0} addons in the database.", AddonRepo.GetAddonNum()));
                    PrintEnvInfo();
                }

                int updatedAddons;

                AptActionUpgrade upgrade = new AptActionUpgrade(AddonEnv, AddonLocal, AddonRemote, AddonRepo);
                upgrade.AddStatusListener(new AptAction.StatusMessageEventHandler(UpgradeStatusMessage));

                foreach (string excludeAddon in ArgExclude)
                {
                    upgrade.Exclude(excludeAddon);
                }

                if (ArgAddons.Count == 0)
                {
                    Output.Info("Action: upgrade all addons.");
                    updatedAddons = upgrade.Prepare();
                }
                else
                {
                    Output.Info("Action: upgrade some addons.");

                    for (int i = 0; i < ArgAddons.Count; ++i)
                    {
                        upgrade.AddPattern(ArgAddons[i]);
                    }
                    updatedAddons = upgrade.Prepare();
                }

                if (updatedAddons > 0)
                {
                    Output.Info("An update is available for the following addons");

                    List <string> updated = upgrade.GetQueue();

                    // calculate download size
                    int downloadSize = 0;
                    foreach (string addon in updated)
                    {
                        downloadSize += AddonRepo.GetAddonInfo(addon).ZipFileSize;
                    }

                    Output.Append(String.Format(" (approx. {0} KB to download):\n\n", (downloadSize / 1024)));

                    Output.Append("  " + String.Join(", ", updated.ToArray()));

                    if (!Cfg.SilentMode)
                    {
                        Output.Append("\n\nDo you want to proceed? [Y/N]: ");

                        if (Convert.ToChar(Console.Read()).ToString().ToLower() == "y")
                        {
                            upgrade.Run();
                        }
                    }
                    else
                    {
                        upgrade.Run();
                    }
                }
                else
                {
                    Output.Info("No updates available.");
                }
            }
        }