Esempio n. 1
0
        private void btnAddManually_Click(object sender, EventArgs e)
        {
            //string renamedFolderTitle = Prompt.ShowDialog("Rename folder", "Input folder title",node.Text);

            AddManually add = new AddManually();

            if (add.ShowDialog() == DialogResult.OK)
            {
                JournalArticle newArticle = add.article;

                TreeNode currentNode = treeView1.SelectedNode;
                if (currentNode == null)
                {
                    newArticle.setFolder(0);
                }
                else
                {
                    newArticle.setFolder(Convert.ToInt32(currentNode.Tag));
                }

                //PHP: 2017-09-28 06:57:34
                //JAVA: Tue Oct 24 16:41:50 GMT+07:00 2017
                newArticle.setCreated_at(DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"));

                int newArticleId = func.addLocalArticle(newArticle);
                newArticle.setLocal_id(newArticleId);

                articlesList.Add(newArticle);
                initDataGrid();
            }
        }
Esempio n. 2
0
        private void getFirstTimeArticles()
        {
            NameValueCollection formData = HttpUtility.ParseQueryString(String.Empty);

            formData.Add("type", "windows");
            string postData = formData.ToString();

            string articlesResponse = RESTful.PostRequest(EndPoints.URL_SYNC_ARTICLES, postData);

            var settings = new JsonSerializerSettings
            {
                NullValueHandling     = NullValueHandling.Ignore,
                MissingMemberHandling = MissingMemberHandling.Ignore
            };

            var articles = JsonConvert.DeserializeObject <List <JournalArticleResponse> >(articlesResponse, settings);

            foreach (JournalArticleResponse responseArticle in articles)
            {
                /*Console.WriteLine("Article id: "+responseArticle.id+", title: "+responseArticle.title
                 +", pages: "+responseArticle.pages);*/

                int volume  = responseArticle.volume == 0 ? -1 : responseArticle.volume;
                int issue   = responseArticle.issue == 0 ? -1 : responseArticle.issue;
                int year    = responseArticle.year == 0 ? -1 : responseArticle.year;
                int pages   = responseArticle.pages == 0 ? -1 : responseArticle.pages;
                int ArXivID = responseArticle.ArXivID == 0 ? -1 : responseArticle.ArXivID;
                int DOI     = responseArticle.DOI == 0 ? -1 : responseArticle.DOI;
                int PMID    = responseArticle.PMID == 0 ? -1 : responseArticle.PMID;

                JournalArticle article = new JournalArticle(responseArticle.id, responseArticle.title,
                                                            responseArticle.authors, responseArticle.@abstract, responseArticle.journal_id,
                                                            volume, issue, year, pages, ArXivID, DOI, PMID, responseArticle.folder,
                                                            responseArticle.filepath, responseArticle.created_at, responseArticle.updated_at, responseArticle.favorite);

                articlesList.Add(article);
            }

            func.recreateAllArticles(articlesList);
            articlesList = func.getRootFolderArticles();

            initDataGrid();

            //Console.WriteLine("All articles: "+articlesResponse);
        }
Esempio n. 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            String title         = txtTitle.Text;
            String authors       = txtAuthors.Text;
            String abstractField = txtAbstract.Text;
            String journal       = txtJournal.Text;

            if (String.IsNullOrEmpty(authors) || String.IsNullOrEmpty(journal))
            {
                MessageBox.Show("Проверьте поля авторы и журнал");
                return;
            }

            int volume = -1;

            if (!String.IsNullOrEmpty(txtVolume.Text))
            {
                volume = Convert.ToInt32(txtVolume.Text);
            }

            int issue = -1;

            if (!String.IsNullOrEmpty(txtIssue.Text))
            {
                issue = Convert.ToInt32(txtIssue.Text);
            }

            int year = -1;

            if (!String.IsNullOrEmpty(txtYear.Text))
            {
                year = Convert.ToInt32(txtYear.Text);
            }

            int pages = -1;

            if (!String.IsNullOrEmpty(txtPages.Text))
            {
                pages = Convert.ToInt32(txtPages.Text);
            }

            int ArXivID = -1;

            if (!String.IsNullOrEmpty(txtArXivID.Text))
            {
                ArXivID = Convert.ToInt32(txtArXivID.Text);
            }

            int DOI = -1;

            if (!String.IsNullOrEmpty(txtDOI.Text))
            {
                DOI = Convert.ToInt32(txtDOI.Text);
            }

            int PMID = -1;

            if (!String.IsNullOrEmpty(txtPMID.Text))
            {
                PMID = Convert.ToInt32(txtPMID.Text);
            }

            string filePath = null;

            if (!String.IsNullOrEmpty(fileName))
            {
                //MessageBox.Show("Saving file");
                string fileDestPath = Path.Combine(func.getWorkspacePath(), fileName);
                //MessageBox.Show("Save file: "+fileDestPath);
                File.Copy(ofd.FileName, fileDestPath, true);
                filePath = fileDestPath;
            }

            //MessageBox.Show("File is "+filePath);

            article = new JournalArticle(title, authors, abstractField, journal, volume, issue, year, pages, ArXivID, DOI, PMID, filePath);

            this.DialogResult = DialogResult.OK;
            this.Close();
        }