public Download()
        {
            InitializeComponent();
            this.setsTableAdapter.Connection.ConnectionString = FSMasterDBContext.GetConnectionString();

            FUserLogic l = new FUserLogic();
            var v =l.GetFirst();
            if (v == null) { }
            else { lblDownloadPath.Text = v.DownloadPath; }
        }
示例#2
0
        public string GetDownloadFolderPath(string setId)
        {
            string path = "";
            var    v    = db.Sets.FirstOrDefault(r => r.SetsID == setId);

            if (v == null)
            {
            }
            else
            {
                if (string.IsNullOrEmpty(v.Path))
                {
                    FUserLogic uL = new FUserLogic();
                    var        u  = uL.GetFirst();
                    if (u == null)
                    {
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(u.DownloadPath))
                        {
                        }
                        else
                        {
                            if (Directory.Exists(u.DownloadPath))
                            {
                                path = Path.Combine(u.DownloadPath, v.Tittle);
                                try
                                {
                                    Directory.CreateDirectory(path);

                                    v.Path = path;
                                    db.SaveChanges();
                                }
                                catch (Exception)
                                {
                                    path = "";
                                }
                            }
                        }
                    }
                }
                else
                {
                    path = v.Path;
                }
            }
            return(path);
        }
        private void btnFolder_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog di = new FolderBrowserDialog();

            var r = di.ShowDialog();
            if (r == System.Windows.Forms.DialogResult.OK)
            {
                FUserLogic l = new FUserLogic();
                var v = l.Update(di.SelectedPath);
                if (v == null)
                { }
                else
                {
                    lblDownloadPath.Text = v.DownloadPath;
                }
            }
        }
        public string GetDownloadFolderPath(string setId)
        {
            string path = "";
            var v = db.Sets.FirstOrDefault(r => r.SetsID == setId);
            if (v == null)
            { }
            else
            {
                if (string.IsNullOrEmpty(v.Path))
                {
                    FUserLogic uL = new FUserLogic();
                    var u = uL.GetFirst();
                    if (u == null) { }
                    else
                    {
                        if (string.IsNullOrEmpty(u.DownloadPath))
                        { }
                        else
                        {
                            if (Directory.Exists(u.DownloadPath))
                            {
                                path = Path.Combine(u.DownloadPath, v.Tittle);
                                try
                                {
                                    Directory.CreateDirectory(path);

                                    v.Path = path;
                                    db.SaveChanges();
                                }
                                catch (Exception)
                                {
                                    path = "";
                                }
                            }
                        }
                    }
                }
                else
                {
                    path = v.Path;
                }

            }
            return path;
        }
        public static void ResetOAuth()
        {
            FUserLogic l = new FUserLogic();
            var v = l.GetFirst();
            if (v != null)
            {
                OAuthAccessToken = v.OAuthAccessToken;
                OAuthAccessTokenSecret = v.OAuthAccessTokenSecret;

                Flickr flickr = new Flickr();
                User = flickr.TestLogin();

                if (User == null || string.IsNullOrEmpty(User.UserName))
                {
                    OAuthAccessToken = "";
                    OAuthAccessTokenSecret = "";
                }
                else
                {
                    SetLogic setL = new SetLogic();
                    setL.DownloadPhotsets();

                    FFolderLogic.Scan();
                }
            }
        }
        private void loginToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //How to get token for user
            Flickr f = new Flickr();
            var r = f.OAuthGetRequestToken("oob");
            //Token = "72157637144674393-a524ed4dd4f6fe99"
            //TokenSecret = "a7f980526e160420"
            //Go to: http://www.flickr.com/services/oauth/authorize?oauth_token=72157637144674393-a524ed4dd4f6fe99

            string url = @"http://www.flickr.com/services/oauth/authorize?oauth_token=" + r.Token;
            ProcessStartInfo sInfo = new ProcessStartInfo(url);
            Process.Start(sInfo);

            Enter_Oauth_Verifier f1 = new Enter_Oauth_Verifier();
            f1.ShowDialog();
            var code = f1.Code;
            if (string.IsNullOrEmpty(code))
            {

            }
            else
            {
                //var v = f.OAuthGetAccessToken(r, "283-464-080");
                //OAuthAccessToken = "72157637144747383-7edb312576a89e3f";
                //OAuthAccessTokenSecret = "0095950bcad5ee34";

                var v = f.OAuthGetAccessToken(r, code);
                if (v != null)
                {
                    FUserLogic lo = new FUserLogic();
                    lo.CreateOrUpdate(v.UserId, v.Token, v.TokenSecret, v.Username, v.FullName);

                    //cancel any uploading process
                    FlickrLogic.CancellationTokenSrc.Cancel();

                    Flickr.ResetOAuth();
                    LoadGUIByUser();
                }
            }
        }