public IHttpActionResult CreateSoftware(SofwareModel model) { try { var chksoftwarename = db.SoftwarePackageDetails.Where(s => s.PackageName == model.Name).FirstOrDefault(); if (chksoftwarename != null) { var software = new SoftwareDetail(); software.Manufacturer = model.Manufacturer; software.SelectSoftwareCategory = model.SelectSoftwareCategory; software.OnPremises = model.OnPremises; software.Cloud = model.Cloud; software.SoftwareType = model.SoftwareType; software.Name = model.Name; db.SoftwareDetails.Add(software); db.SaveChanges(); return(Ok(software)); } else { return(Ok("Software Name " + model.Name + " Does not exists in Software Package.")); } } catch (Exception ex) { return(Ok("" + ex.Message + "")); } }
/// <summary> /// 下载文章详情 /// </summary> private void DownloadDocument(string uri) { WebClient proxy = Tool.SendWebClient(uri, new Dictionary <string, string>( )); proxy.DownloadStringCompleted += (s, e) => { if (e.Error != null) { System.Diagnostics.Debug.WriteLine("获取 {0} 网络错误: {0}", this.DetailType.ToString( ), e.Error.Message); return; } }; switch (this.DetailType) { case DetailType.News: proxy.DownloadStringCompleted += (s, e) => { NewsDetail n = Tool.GetNewsDetail(e.Result); if (n != null) { this.newsDetail = n; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_News(n))); this.CheckApplicationBarByDetailType( ); this.lblCommentCount.Text = string.Format("评论({0})", this.newsDetail.commentCount); } }; break; case DetailType.Post: proxy.DownloadStringCompleted += (s, e) => { PostDetail p = Tool.GetPostDetail(e.Result); if (p != null) { this.postDetail = p; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_Post(p))); this.CheckApplicationBarByDetailType( ); this.lblCommentCount.Text = string.Format("评论({0})", this.postDetail.answerCount); } }; break; case DetailType.Blog: proxy.DownloadStringCompleted += (s, e) => { BlogDetail b = Tool.GetBlogDetail(e.Result); if (b != null) { this.blogDetail = b; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_Blog(b))); this.CheckApplicationBarByDetailType( ); this.lblCommentCount.Text = string.Format("评论({0})", this.blogDetail.commentCount); //这里特别注意 要获取一下owneruid this.commentListControl.owneruid = this.blogDetail.authorID.ToString( ); } }; break; case DetailType.Software: proxy.DownloadStringCompleted += (s, e) => { SoftwareDetail soft = Tool.GetSoftwareDetail(e.Result); if (soft != null) { this.softwareDetail = soft; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_Software(soft))); this.CheckApplicationBarByDetailType( ); } }; break; case DetailType.Tweet: proxy.DownloadStringCompleted += (s, e) => { TweetDetail t = Tool.GetTweetDetail(e.Result); if (t != null) { this.tweetDetail = t; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_Tweet(t))); this.CheckApplicationBarByDetailType( ); this.lblCommentCount.Text = string.Format("评论({0})", this.tweetDetail.commentCount); } }; break; } GC.Collect( ); }