Exemplo n.º 1
0
 public TitleIDConverter(dbsettings dsettings)
 {
     raclient   = new RestClient("https://graphql.anilist.co");
     rkclient   = new RestClient("https://kitsu.io/api/edge");
     rmoeclient = new RestClient("https://notify.moe/");
     rmoeclient.FollowRedirects = false;
     this.connmanager           = new ConnectionManager(dsettings);
     this.initalized            = connmanager.isInitalized();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Ctor, just loading some Settings
        /// </summary>
        public DropBoxSynch_frm()
        {
            InitializeComponent();

            db = new dbsettings();
            dbctrl = new DropBoxController();

            LoadSettings();
            this.deckCB.CheckedChanged += new System.EventHandler(this.deckCB_CheckedChanged);
            this.allCB.CheckedChanged += new System.EventHandler(this.allCB_CheckedChanged);
            this.allCB.CheckedChanged += new System.EventHandler(this.allCB_CheckedChanged);
            this.replayCB.CheckedChanged += new System.EventHandler(this.replayCB_CheckedChanged);
            this.texturesCB.CheckedChanged += new System.EventHandler(this.texturesCB_CheckedChanged);
            this.skinsCB.CheckedChanged += new System.EventHandler(this.skinsCB_CheckedChanged);
            this.soundsCB.CheckedChanged += new System.EventHandler(this.soundsCB_CheckedChanged);
            this.FormClosing += new FormClosingEventHandler(DropBoxSynch_frm_FormClosing);
        }
Exemplo n.º 3
0
        public MappingsController()
        {
            var collection = new ServiceCollection();

            collection.AddOptions();
            var Configuration = new ConfigurationBuilder()
#if DEBUG
                                .AddJsonFile("appsettings.Development.json", optional: false, reloadOnChange: true)
#else
                                .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
#endif
                                .Build();

            collection.Configure <UserAgentControl>(Configuration.GetSection("UserAgentControl"));
            collection.Configure <dbsettings>(Configuration.GetSection("dbsettings"));
            var services = collection.BuildServiceProvider();

            allowedclients = services.GetService <IOptions <UserAgentControl> >().Value;
            dbsettings     = services.GetService <IOptions <dbsettings> >().Value;
        }
Exemplo n.º 4
0
        public ConnectionManager(dbsettings settings)
        {
            this.settings = settings;
            String connectionString;

            switch (this.settings.dbengine)
            {
            case "mysql":
                connectionString = "SERVER =" + this.settings.dbhost + ";DATABASE=" + this.settings.dbname + ";UID=" + this.settings.dbuser + ";PASSWORD="******";";
                mysqldbmgr       = new MySQLDBManager(connectionString);
                break;

            case "postgres":
                connectionString = "SERVER=" + this.settings.dbhost + ";User Id=" + this.settings.dbuser + ";Password="******";Database=" + this.settings.dbname;
                postgresdbmgr    = new PostgresDBManager(connectionString);
                break;

            default:
                throw new System.ArgumentException("Invalid engine type" + this.settings.dbengine);
            }
        }
        /// <summary>
        /// up/download all your files to dropbox automatically
        /// </summary>
        public static void filesync()
        {
            //Testing Connection

            if (!LauncherHelper.TestConnection())
                return;

            dbsettings db = new dbsettings();
            db.LoadFromString(Properties.Settings.Default.DropBoxSaveSettings);

            if (String.IsNullOrEmpty(Properties.Settings.Default.DropBoxUserToken))
            {
                MessageBox.Show("bind your account first");
            }

            if (db.Deck)
            {
                syncFolder("deck/");
            }
            if (db.Replay)
            {
                syncFolder("replay/");
            }
            if (db.Skins)
            {
                syncFolder("skins/");
            }
            if (db.Sounds)
            {
                syncFolder("sound/");
            }
            if (db.Texture)
            {
                syncFolder("textures/");
            }
        }
        /// <summary>
        /// Calls the syncFolder method asyncron
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        static void bwSync_DoWork(object sender, DoWorkEventArgs e)
        {
            dbsettings db = new dbsettings();
            db.LoadFromString(Properties.Settings.Default.DropBoxSaveSettings);

            try
            {
                if (db.Deck)
                {
                    e.Result = "starting filesync (\"\\deck\")";
                    syncFolder("deck/");
                }
                if (db.Replay)
                {
                    e.Result = "starting filesync (\"\\replay\")";
                    syncFolder("replay/");
                }
                if (db.Skins)
                {
                    e.Result = "starting filesync (\"\\skins\")";
                    syncFolder("skins/");
                }
                if (db.Sounds)
                {
                    e.Result = "sounds excluded because fileaccessviolation while sync";
                    // syncFolder("sound/");
                }
                if (db.Texture)
                {
                    e.Result = "starting filesync (\"\\textures\")";
                    syncFolder("textures/");
                }
                e.Result = "finished filesync";
            }
            catch (Exception ex)
            {
                e.Result = e.Result + "\n\n" + ex.Message;
            #if DEBUG
                e.Result = e.Result + "\n\n" + ex.StackTrace;
                MessageBox.Show(e.Result.ToString());
            #endif
            }
        }
Exemplo n.º 7
0
        public TitleIdMapping(string service, string type, string id, dbsettings dsettings)
        {
            converter = new TitleIDConverter(dsettings);
            if (converter.initalized)
            {
                switch (type)
                {
                case "anime":
                    mediatype = MediaType.Anime;
                    break;

                case "manga":
                    mediatype = MediaType.Manga;
                    break;

                default:
                    output = new Dictionary <string, object> {
                        { "data", null }, { "error", "Invalid media type. Type must be anime or manga." }
                    };
                    errored = true;
                    return;
                }
                try
                {
                    switch (service)
                    {
                    case "anidb":
                        anidb_id       = int.Parse(id);
                        currentservice = Service.AniDB;
                        lookupid       = anidb_id;
                        if (mediatype == MediaType.Manga)
                        {
                            output  = invalidtypeservice();
                            errored = true;
                        }
                        break;

                    case "anilist":
                        anilist_id     = int.Parse(id);
                        currentservice = Service.AniList;
                        lookupid       = anilist_id;
                        break;

                    case "mal":
                        mal_id         = int.Parse(id);
                        currentservice = Service.MyAnimeList;
                        lookupid       = mal_id;
                        break;

                    case "kitsu":
                        kitsu_id       = int.Parse(id);
                        currentservice = Service.Kitsu;
                        lookupid       = kitsu_id;
                        break;

                    case "notify":
                        notify_id      = id;
                        currentservice = Service.NotifyMoe;
                        lookupid       = notify_id;
                        if (mediatype == MediaType.Manga)
                        {
                            output  = invalidtypeservice();
                            errored = true;
                        }
                        break;

                    default:
                        if (mediatype == MediaType.Anime)
                        {
                            output = new Dictionary <string, object> {
                                { "data", null }, { "error", "Invalid service. Services accepted for Anime are anidb, anilist, kitsu, mal, and notify" }
                            };
                        }
                        else
                        {
                            output = new Dictionary <string, object> {
                                { "data", null }, { "error", "Invalid service. Services accepted for Manga are anilist, kitsu, and mal" }
                            };
                        }
                        errored = true;
                        break;
                    }
                    servicename = service;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    output = new Dictionary <string, object> {
                        { "data", null }, { "error", "Invalid title id." }
                    };
                    errored = true;
                }
            }
            else
            {
                output = new Dictionary <string, object> {
                    { "data", null }, { "error", "Can't connect to database." }
                };
                errored = true;
            }
        }