示例#1
0
        public bool AddArticle(ArticleInformation aInfo)
        {
            ScoopArticle newArticle = new ScoopArticle();

            newArticle.BigHeadline   = aInfo.BigHeadline;
            newArticle.BigText       = aInfo.BigText;
            newArticle.BigImageURL   = aInfo.BigImageURL;
            newArticle.SmallHeadline = aInfo.SmallHeadline;
            newArticle.SmallText     = aInfo.SmallText;
            newArticle.SmallImageURL = aInfo.SmallImageURL;
            newArticle.ContentBlock  = aInfo.ContentBlock;
            newArticle.Title         = aInfo.Title;
            newArticle.PubDate       = aInfo.PubDate;
            newArticle.AuthorID      = aInfo.AuthorID;
            newArticle.Rank          = aInfo.Rank;
            newArticle.ShowBigImage  = aInfo.ShowBigImage;
            newArticle.ArticleType   = aInfo.ArticleType;
            newArticle.Keywords      = aInfo.Keywords;
            newArticle.DBKeywords    = SearchText.GetKeywordList(new List <string>()
            {
                aInfo.Keywords
            });

            database.ScoopArticles.Add(newArticle);

            return(database.SaveChanges() > 0);
        }
示例#2
0
        public bool EditArticle(ArticleInformation aInfo)
        {
            var dbArticle = database.ScoopArticles.FirstOrDefault(a => a.ArticleID == aInfo.ArticleID);

            if (dbArticle == null)
            {
                throw new Exception("Unable to find article.");
            }

            dbArticle.BigHeadline   = aInfo.BigHeadline;
            dbArticle.BigText       = aInfo.BigText;
            dbArticle.BigImageURL   = aInfo.BigImageURL;
            dbArticle.SmallHeadline = aInfo.SmallHeadline;
            dbArticle.SmallText     = aInfo.SmallText;
            dbArticle.SmallImageURL = aInfo.SmallImageURL;
            dbArticle.ContentBlock  = aInfo.ContentBlock;
            dbArticle.Title         = aInfo.Title;
            dbArticle.PubDate       = aInfo.PubDate;
            dbArticle.AuthorID      = aInfo.AuthorID;
            dbArticle.ShowBigImage  = aInfo.ShowBigImage;
            dbArticle.ArticleType   = aInfo.ArticleType;
            dbArticle.Rank          = aInfo.Rank;
            dbArticle.Keywords      = aInfo.Keywords;
            dbArticle.DBKeywords    = SearchText.GetKeywordList(new List <string>()
            {
                aInfo.Keywords
            });

            return(database.SaveChanges() > 0);
        }
示例#3
0
        private void dgv_SearchArticle_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            int currentMouseOverRow = dgv_SearchArticle.HitTest(e.X, e.Y).RowIndex;

            if (currentMouseOverRow >= 0)
            {
                dgv_SearchArticle.ClearSelection();

                dgv_SearchArticle.Rows[currentMouseOverRow].Selected = true;
            }

            if (dgv_SearchArticle.SelectedRows == null || dgv_SearchArticle.SelectedRows.Count == 0)
            {
                return;
            }

            DeleteInformationRow row    = (dgv_SearchArticle.SelectedRows[0] as DeleteInformationRow);
            ArticleInformation   target = row.ArticleInformation;

            string msg = "상태 : " + (target.IsGalleryDeleted ? "삭제됨" : "삭제안됨") + Environment.NewLine
                         + "메시지 : " + (target.DeleteMessage);

            MessageBox.Show(msg, "글 삭제 정보", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
示例#4
0
        public ArticleViewDetails GetArticlePreview(ArticleInformation aInfo)
        {
            var dbUser = database.Users.FirstOrDefault(u => u.UserID == aInfo.AuthorID);

            return(new ArticleViewDetails()
            {
                Headline = aInfo.BigHeadline,
                Content = aInfo.ContentBlock,
                ImageURL = aInfo.ShowBigImage ? aInfo.BigImageURL : null,
                PublishDate = aInfo.PubDate.HasValue ? aInfo.PubDate.Value.ToString("MMMM dd, yyyy") : "",
                AuthorName = dbUser != null ? dbUser.FullName : "",
                AuthorImage = dbUser != null ? dbUser.ImageFileName : null,
                AuthorCredit = dbUser != null ? dbUser.AuthorCredit : null,
                ArticleType = aInfo.ArticleType,
                RecentArticles = database.ScoopArticles
                                 .Where(a => a.PubDate < DateTime.Now && a.ArticleType == aInfo.ArticleType)
                                 .OrderByDescending(a => a.PubDate)
                                 .Take(ArticleCount)
                                 .ToList()
                                 .Select(s => new ArticleViewDetails.RecentArticleDetails()
                {
                    ArticleID = s.ArticleID,
                    Headline = s.BigHeadline
                })
            });
        }
示例#5
0
        public async Task <Article> DeleteArticleAsync(int articleId)
        {
            Article article = await _context.Articles.FirstOrDefaultAsync(s => s.Id == articleId);

            InternalArticleInformation internalInfo = null;
            ArticleInformation         articleInfo  = null;

            if (article != null)
            {
                internalInfo = await _context.InternalArticleInformations.FirstOrDefaultAsync(i => i.Id == article.InternalArticleInformationId);

                articleInfo = await _context.ArticleInformations.FirstOrDefaultAsync(a => a.Id == article.ArticleInformationId);
            }

            if (article != null && internalInfo != null && articleInfo != null)
            {
                _context.Articles.Remove(article);
                await _context.SaveChangesAsync();

                _context.ArticleInformations.Remove(articleInfo);
                await _context.SaveChangesAsync();

                _context.InternalArticleInformations.Remove(internalInfo);
                await _context.SaveChangesAsync();

                return(article);
            }
            return(null);
        }
        public async Task <ArticleInformation> AddArticleInformation(ArticleInformation articleInformation)
        {
            var result = await _context.ArticleInformations.AddAsync(articleInformation);

            await _context.SaveChangesAsync();

            return(result.Entity);
        }
        public JsonResult SavePreview(ArticleInformation aInfo)
        {
            Session["PreviewArticle"] = aInfo;

            return(Json(new
            {
                success = true
            },
                        JsonRequestBehavior.AllowGet));
        }
示例#8
0
        private async void menu_DeleteArticle_Clicked(object sender, EventArgs e)
        {
            if (dgv_ArticleList.SelectedRows == null || dgv_ArticleList.SelectedRows.Count == 0)
            {
                return;
            }

            DeleteInformationRow row    = (dgv_ArticleList.SelectedRows[0] as DeleteInformationRow);
            ArticleInformation   target = row.ArticleInformation;

            if (currentTask != CleanerTask.None)
            {
                return;
            }

            SetStatusMessage("글을 삭제하는 중입니다...");

            currentTask = CleanerTask.DeleteGallogArticles;

            try
            {
                await conn.DeleteArticle(target, true);
            }
            catch
            {
                return;
            }

            // 갤로그와 갤러리 둘다 삭제 되었을 경우
            if (target.IsGalleryDeleted && target.IsGallogDeleted)
            {
                if (row.DataGridView != null)
                {
                    row.DataGridView.Rows.Remove(row);
                }
                gb_ArticleGroup.Text = "내가 쓴 글 [" + dgv_ArticleList.Rows.Count.ToString() + "]";
                SetStatusMessage("글을 삭제하였습니다.");
            }
            else
            {
                string rmErrMsg = "";
                if (!target.IsGalleryDeleted)
                {
                    rmErrMsg = "글을 삭제하는데 실패하였습니다. - 갤러리 삭제 실패";
                }
                else
                {
                    rmErrMsg = "글을 삭제하는데 실패하였습니다. - 갤로그 삭제 실패";
                }

                SetStatusMessage(rmErrMsg);
            }

            currentTask = CleanerTask.None;
        }
示例#9
0
 public DeleteInformationRow(ArticleInformation articleInfo, DataGridView dgv, bool useDate)
 {
     ArticleInformation = articleInfo;
     if (useDate)
     {
         this.CreateCells(dgv, ArticleInformation.Title, ArticleInformation.Date);
     }
     else
     {
         this.CreateCells(dgv, ArticleInformation.Title);
     }
 }
        public ActionResult Edit(ArticleInformation aInfo)
        {
            if (ModelState.IsValid)
            {
                using (var aRepository = new ArticleRepository())
                {
                    aRepository.EditArticle(aInfo);

                    return(RedirectToAction("Manage"));
                }
            }

            return(View(aInfo));
        }
示例#11
0
        protected override async Task OnInitializedAsync()
        {
            costType = await InformCostTypeService.GetInformCostTypes();

            ArticleInformation article = await ArticleInformationService.GetArticleInformation(Article.ArticleInformationId);

            Article.ArticleInformation.OtherCostsForArticles = article.OtherCostsForArticles;

            NumberOfOtherCosts = 0;

            foreach (OtherCostsForArticle cost in Article.ArticleInformation.OtherCostsForArticles)
            {
                NumberOfOtherCosts += cost.InformCostType != "" && cost.Amount != 0 ? 1 : 0;
            }
        }
        public async Task <ActionResult <ArticleInformation> > UpdateArticleInformation(int id, ArticleInformation articleInformation)
        {
            try
            {
                if (id != articleInformation.Id)
                {
                    return(BadRequest());
                }

                var articleInformationToUpdate = await _articleInformationRepository.GetArticleInformation(id);

                if (articleInformationToUpdate == null)
                {
                    return(NotFound($"ArticleInformation with id = {id} not found"));
                }

                return(await _articleInformationRepository.UpdateArticleInformation(articleInformation));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from the database."));
            }
        }
示例#13
0
        private async void DeleteSearchedArticleAsync(DeleteInformationRow row, GalleryType gallType, string password)
        {
            ArticleInformation info = row.ArticleInformation;
            ArticleInformation res  = null;

            try
            {
                if (!conn.LoginInfo.IsLoggedIn)
                {
                    info.GalleryDeleteParameter.Password = password;
                }
                res = await conn.DeleteArticle(info, gallType, false);
            }
            catch { }

            if (!res.IsGalleryDeleted)
            {
                for (int j = 0; j < deleteRetryCnt; j++)
                {
                    // 실패시, Sleep 후 재시도
                    await Task.Delay(deleteRetryTime);

                    res = await conn.DeleteArticle(info, gallType, false);

                    if (res.IsGalleryDeleted)
                    {
                        break;
                    }
                }
            }

            info.IsGalleryDeleted = res.IsGalleryDeleted;
            info.IsGallogDeleted  = res.IsGallogDeleted;
            info.DeleteMessage    = res.DeleteMessage;

            deleteEndCnt++;

            if (!info.IsGalleryDeleted)
            {
                if (deleteStartCnt <= deleteEndCnt)
                {
                    currentTask = CleanerTask.None;

                    SetStatusMessage("검색된 글 삭제 완료");
                }
                return;
            }

            if (row.DataGridView != null)
            {
                row.DataGridView.Rows.Remove(row);
            }
            gb_SearchedArticleList.Text = "검색된 글 [" + dgv_SearchArticle.Rows.Count.ToString() + "]";

            if (deleteStartCnt <= deleteEndCnt)
            {
                currentTask = CleanerTask.None;

                SetStatusMessage("검색된 글 삭제 완료");
            }
        }
示例#14
0
        private async void DeleteArticleAsync(DeleteInformationRow row, bool both)
        {
            ArticleInformation info = row.ArticleInformation;
            ArticleInformation res  = null;

            try
            {
                res = await conn.DeleteArticle(info, both);
            }
            catch { }

            if (!res.IsGalleryDeleted || (both && !res.IsGallogDeleted))
            {
                for (int j = 0; j < deleteRetryCnt; j++)
                {
                    // 실패시, Sleep 후 재시도
                    await Task.Delay(deleteRetryTime);

                    res = await conn.DeleteArticle(info, both);

                    if (res.IsGalleryDeleted && (!both || res.IsGallogDeleted))
                    {
                        break;
                    }
                }
            }

            info.IsGalleryDeleted = res.IsGalleryDeleted;
            info.IsGallogDeleted  = res.IsGallogDeleted;
            info.DeleteMessage    = res.DeleteMessage;

            deleteEndCnt++;

            if (!info.IsGalleryDeleted || (both && !info.IsGallogDeleted))
            {
                if (deleteStartCnt <= deleteEndCnt)
                {
                    currentTask = CleanerTask.None;

                    if (both)
                    {
                        SetStatusMessage("쓴 글 - 갤로그도 삭제 완료");
                    }
                    else
                    {
                        SetStatusMessage("쓴 글 - 갤러리만 삭제 완료");
                    }
                }
                return;
            }

            // 갤로그도 삭제일 경우에만 화면 지움
            if (both)
            {
                if (row.DataGridView != null)
                {
                    row.DataGridView.Rows.Remove(row);
                }
                gb_ArticleGroup.Text = "내가 쓴 글 [" + dgv_ArticleList.Rows.Count + "]";
            }

            if (deleteStartCnt <= deleteEndCnt)
            {
                currentTask = CleanerTask.None;

                if (both)
                {
                    SetStatusMessage("쓴 글 - 갤로그도 삭제 완료");
                }
                else
                {
                    SetStatusMessage("쓴 글 - 갤러리만 삭제 완료");
                }
            }
        }
        public async Task <ArticleInformation> UpdateArticleInformation(ArticleInformation articleInformation)
        {
            var result = await _context.ArticleInformations.Include(a => a.OtherCostsForArticles)
                         .FirstOrDefaultAsync(a => a.Id == articleInformation.Id);

            if (result != null)
            {
                result.CompanyLocation       = articleInformation.CompanyLocation;
                result.CompanyName           = articleInformation.CompanyName;
                result.FreightResponsibility = articleInformation.FreightResponsibility;
                result.PalletExchange        = articleInformation.PalletExchange;
                result.ArticlesPerSalesunit  = articleInformation.ArticlesPerSalesunit;
                result.CartonsPerLayer       = articleInformation.CartonsPerLayer;
                result.CartonsPerPallet      = articleInformation.CartonsPerPallet;
                result.Class = articleInformation.Class;
                result.ClassificationCode = articleInformation.ClassificationCode;
                result.CountryOfOrigin    = articleInformation.CountryOfOrigin;
                result.DangerousGoods     = articleInformation.DangerousGoods;
                result.Email = articleInformation.Email;
                result.GrossWeightPrSalesunit = articleInformation.GrossWeightPrSalesunit;
                result.Gtinnumber             = articleInformation.Gtinnumber;
                result.HeightPrSalesunit      = articleInformation.HeightPrSalesunit;
                result.ImportedFrom           = articleInformation.ImportedFrom;
                result.LeadTime                     = articleInformation.LeadTime;
                result.LengthPrSalesunit            = articleInformation.LengthPrSalesunit;
                result.MinimumOrderQuantity         = articleInformation.MinimumOrderQuantity;
                result.MinimumShelflife             = articleInformation.MinimumShelflife;
                result.NetWeightPrSalesunit         = articleInformation.NetWeightPrSalesunit;
                result.OrganicArticle               = articleInformation.OrganicArticle;
                result.OtherCosts                   = articleInformation.OtherCosts;
                result.PurchasePrice                = articleInformation.PurchasePrice;
                result.Salesunit                    = articleInformation.Salesunit;
                result.SetCurrency                  = articleInformation.SetCurrency;
                result.Shelflife                    = articleInformation.Shelflife;
                result.SpecialInformation           = articleInformation.SpecialInformation;
                result.SupplierArticleName          = articleInformation.SupplierArticleName;
                result.ArticleName                  = articleInformation.ArticleName;
                result.TemperatureStorageMax        = articleInformation.TemperatureStorageMax;
                result.TemperatureStorageMin        = articleInformation.TemperatureStorageMin;
                result.TemperatureTransportationMax = articleInformation.TemperatureTransportationMax;
                result.TemperatureTransportationMin = articleInformation.TemperatureTransportationMin;
                result.TollTarifNumber              = articleInformation.TollTarifNumber;
                result.TransitTime                  = articleInformation.TransitTime;
                result.TransportBooking             = articleInformation.TransportBooking;
                result.WidthPrSalesunit             = articleInformation.WidthPrSalesunit;
                await _context.SaveChangesAsync();

                foreach (OtherCostsForArticle cost in articleInformation.OtherCostsForArticles)
                {
                    var resultCost = await _context.OtherCostsForArticles.FirstOrDefaultAsync(c => c.Id == cost.Id);

                    if (resultCost != null)
                    {
                        resultCost.Amount         = cost.Amount;
                        resultCost.InformCostType = cost.InformCostType;
                    }
                    else
                    {
                        await _context.OtherCostsForArticles.AddAsync(cost);
                    }
                    await _context.SaveChangesAsync();
                }

                return(result);
            }

            return(null);
        }
示例#16
0
        private async void menu_DeleteSearchedArticle_Clicked(object sender, EventArgs e)
        {
            if (dgv_SearchArticle.SelectedRows == null || dgv_SearchArticle.SelectedRows.Count == 0)
            {
                return;
            }

            DeleteInformationRow row    = (dgv_SearchArticle.SelectedRows[0] as DeleteInformationRow);
            ArticleInformation   target = row.ArticleInformation;

            if (currentTask != CleanerTask.None)
            {
                return;
            }

            if (!conn.LoginInfo.IsLoggedIn)
            {
                if (string.IsNullOrWhiteSpace(tb_DeletePassword.Text))
                {
                    tb_DeletePassword.Focus();
                    SetStatusMessage("삭제할 비밀번호를 입력해주세요.");
                    return;
                }
            }

            string      password = tb_DeletePassword.Text.Trim();
            GalleryType gallType = GalleryType.Normal;

            if (rb_NormalGallery.Checked)
            {
                gallType = GalleryType.Normal;
            }
            else if (rb_MinorGallery.Checked)
            {
                gallType = GalleryType.Minor;
            }

            SetStatusMessage("글을 삭제하는 중입니다...");

            currentTask = CleanerTask.DeleteGalleryArticles;

            try
            {
                if (!conn.LoginInfo.IsLoggedIn)
                {
                    target.GalleryDeleteParameter.Password = password;
                }
                await conn.DeleteArticle(target, gallType, false);
            }
            catch
            {
                return;
            }

            // 갤로그와 갤러리 둘다 삭제 되었을 경우
            if (target.IsGalleryDeleted)
            {
                this.Invoke(new Action(() =>
                {
                    if (row.DataGridView != null)
                    {
                        row.DataGridView.Rows.Remove(row);
                    }
                    gb_SearchedArticleList.Text = "검색된 글 [" + dgv_SearchArticle.Rows.Count.ToString() + "]";
                    SetStatusMessage("글을 삭제하였습니다.");
                }));
            }
            else
            {
                string rmErrMsg = "";
                if (!target.IsGalleryDeleted)
                {
                    rmErrMsg = "글을 삭제하는데 실패하였습니다.";
                }

                SetStatusMessage(rmErrMsg);
            }

            currentTask = CleanerTask.None;
        }
 public async Task UpdateArticleInformation(int id, ArticleInformation articleInformation)
 {
     await httpClient.PutAsJsonAsync($"/api/articleInformations/{id}", articleInformation);
 }