예제 #1
0
 public IAsyncAction AddAsync(GalleryInfo gallery, string note)
 {
     return(Run(async token =>
     {
         var response = await postAddFav(gallery.ID, gallery.Token, note);
     }));
 }
예제 #2
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="mod">GalleryInfo</param>
 /// <returns>受影响行数</returns>
 public int Update(GalleryInfo mod)
 {
     using (DbConnection conn = db.CreateConnection())
     {
         conn.Open();
         using (DbTransaction tran = conn.BeginTransaction())
         {
             try
             {
                 using (DbCommand cmd = db.GetStoredProcCommand("SP_Gallery_Update"))
                 {
                     db.AddInParameter(cmd, "@GalleryID", DbType.Int32, mod.GalleryID);
                     db.AddInParameter(cmd, "@GalleryName", DbType.String, mod.GalleryName);
                     db.AddInParameter(cmd, "@State", DbType.Int32, mod.State);
                     db.AddInParameter(cmd, "@IsDeleted", DbType.Int32, mod.IsDeleted);
                     db.AddInParameter(cmd, "@Sort", DbType.Int32, mod.Sort);
                     tran.Commit();
                     return(db.ExecuteNonQuery(cmd));
                 }
             }
             catch (Exception e)
             {
                 tran.Rollback();
                 throw e;
             }
             finally
             {
                 conn.Close();
             }
         }
     }
 }
예제 #3
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="mod">GalleryInfo</param>
        /// <returns>受影响行数</returns>
        public int Update(GalleryInfo mod)
        {
           using (DbConnection conn = db.CreateConnection())
			{
				conn.Open();
				using (DbTransaction tran = conn.BeginTransaction())
				{ 
					try
					{ 
						using (DbCommand cmd = db.GetStoredProcCommand("SP_Gallery_Update"))
						{
							db.AddInParameter(cmd, "@GalleryID", DbType.Int32, mod.GalleryID); 
							db.AddInParameter(cmd, "@GalleryName", DbType.String, mod.GalleryName); 
							db.AddInParameter(cmd, "@State", DbType.Int32, mod.State); 
							db.AddInParameter(cmd, "@IsDeleted", DbType.Int32, mod.IsDeleted); 
							db.AddInParameter(cmd, "@Sort", DbType.Int32, mod.Sort); 
							tran.Commit();
							return db.ExecuteNonQuery(cmd);
						} 
					}
					catch (Exception e)
					{
						tran.Rollback();
						throw e;
					}
					finally
					{
						conn.Close();
					}
				}
			}
        }  
예제 #4
0
        internal void Analyze(HtmlDocument doc)
        {
            var gdd        = doc.GetElementbyId("gdd");
            var parentNode = gdd.FirstChild.ChildNodes[1].Descendants("a").FirstOrDefault();

            if (parentNode != null)
            {
                ParentInfo = GalleryInfo.Parse(parentNode.GetAttribute("href", default(Uri)));
            }

            var descendantsNode = doc.GetElementbyId("gnd");

            if (descendantsNode != null)
            {
                var count       = descendantsNode.ChildNodes.Count / 3;
                var descendants = new RevisionInfo[count];
                for (var i = 0; i < descendants.Length; i++)
                {
                    var aNode    = descendantsNode.ChildNodes[i * 3 + 1];
                    var textNode = descendantsNode.ChildNodes[i * 3 + 2];
                    var link     = aNode.GetAttribute("href", default(Uri));
                    var dto      = DateTimeOffset.ParseExact(textNode.GetInnerText(), "', added' yyyy-MM-dd HH:mm", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AllowWhiteSpaces);
                    descendants[i] = new RevisionInfo(GalleryInfo.Parse(link), dto);
                }
                DescendantsInfo = descendants;
            }
            else
            {
                DescendantsInfo = Array.Empty <RevisionInfo>();
            }
        }
예제 #5
0
 public PageInfo(GalleryInfo galleryInfo, List<Article> articles, int page, int totalPages)
 {
     this.galleryInfo = galleryInfo;
     this.articles = articles;
     this.page = page;
     this.totalPages = totalPages;
 }
예제 #6
0
        /// <summary>
        /// 根据分页获得数据列表
        /// </summary>
        /// <param name="TbFields">返回字段</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="OrderField">排序字段</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页尺寸</param>
        /// <param name="TotalCount">返回总记录数</param>
        /// <returns>IList<GalleryInfo></returns>
        public IList <GalleryInfo> Find(string tbFields, string strWhere, string orderField, int pageIndex, int pageSize, out int totalCount)
        {
            IList <GalleryInfo> list = new List <GalleryInfo>();

            using (DbCommand cmd = db.GetStoredProcCommand("SP_SqlPagenation"))
            {
                db.AddInParameter(cmd, "@TbName", DbType.String, "Gallery");
                db.AddInParameter(cmd, "@TbFields", DbType.String, tbFields);
                db.AddInParameter(cmd, "@StrWhere", DbType.String, strWhere);
                db.AddInParameter(cmd, "@OrderField", DbType.String, orderField);
                db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageIndex);
                db.AddInParameter(cmd, "@PageSize", DbType.Int32, pageSize);
                db.AddOutParameter(cmd, "@Total", DbType.Int32, int.MaxValue);
                using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
                {
                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            GalleryInfo model = new GalleryInfo();
                            model.LoadFromDataRow(dr);
                            list.Add(model);
                        }
                    }
                }

                totalCount = (int)db.GetParameterValue(cmd, "@Total");
                return(list);
            }
        }
예제 #7
0
 private IAsyncOperation <LoadItemsResult <Gallery> > loadCore(bool reIn)
 {
     return(AsyncInfo.Run(async token =>
     {
         var doc = await Client.Current.HttpClient.GetDocumentAsync(DomainProvider.Eh.RootUri);
         var pp = doc.GetElementbyId("pp");
         if (pp is null) // Disabled popular
         {
             if (reIn)
             {
                 return LoadItemsResult.Empty <Gallery>();
             }
             else
             {
                 await DomainProvider.Eh.Settings.FetchAsync();
                 await DomainProvider.Eh.Settings.SendAsync();
                 return await loadCore(true);
             }
         }
         var nodes = (from div in pp.Elements("div")
                      where div.HasClass("id1")
                      select div).ToList();
         var ginfo = nodes.Select(n =>
         {
             var link = n.Descendants("a").First().GetAttribute("href", default(Uri));
             return GalleryInfo.Parse(link);
         }).ToList();
         var galleries = await Gallery.FetchGalleriesAsync(ginfo);
         for (var i = 0; i < ginfo.Count; i++)
         {
             handleAdditionalInfo(nodes[i], galleries[i]);
         }
         return LoadItemsResult.Create(0, galleries);
     }));
 }
예제 #8
0
        public static async Task <ExpungeInfo> FetchAsync(GalleryInfo galleryInfo, CancellationToken token = default)
        {
            var r = new ExpungeInfo(galleryInfo);
            await r.RefreshAsync(token);

            return(r);
        }
예제 #9
0
 private void SerializeInternal(GalleryInfo model, IDictionary<string, object> result)
 { 
     result.Add("galleryid", model.GalleryID);
     result.Add("galleryname", model.GalleryName);
     result.Add("state", model.State);
     result.Add("isdeleted", model.IsDeleted);
     result.Add("sort", model.Sort);
 }
예제 #10
0
 public static IAsyncOperation <RenameInfo> FetchAsync(GalleryInfo galleryInfo)
 {
     return(AsyncInfo.Run(async token =>
     {
         var r = new RenameInfo(galleryInfo);
         var u = r.RefreshAsync();
         token.Register(u.Cancel);
         await u;
         return r;
     }));
 }
예제 #11
0
        internal TaggingRecord(HtmlNode trNode)
        {
            var td = trNode.Elements("td").ToList();

            Tag   = Tag.Parse(td[1].GetInnerText());
            Score = int.Parse(td[2].GetInnerText());
            var uri = td[3].Element("a").GetAttribute("href", default(Uri));

            GalleryInfo = GalleryInfo.Parse(uri);
            Timestamp   = DateTimeOffset.Parse(td[4].GetInnerText(), null, System.Globalization.DateTimeStyles.AssumeUniversal);
        }
예제 #12
0
 public static IAsyncOperation <ExpungeInfo> FetchAsync(GalleryInfo galleryInfo)
 {
     return(AsyncInfo.Run(async token =>
     {
         var r = new ExpungeInfo(galleryInfo);
         var u = r.RefreshAsync();
         token.Register(u.Cancel);
         await u;
         token.ThrowIfCancellationRequested();
         return r;
     }));
 }
예제 #13
0
        internal TaggingRecord(HtmlNode trNode)
        {
            var td = trNode.Elements("td").ToList();

            Tag   = Tag.Parse(td[0].InnerText.DeEntitize());
            Score = int.Parse(td[1].InnerText.DeEntitize());
            var uri = new Uri(td[2].Element("a").GetAttributeValue("href", "").DeEntitize());

            GalleryInfo = GalleryInfo.Parse(uri);
            Timestamp   = DateTimeOffset.Parse(td[3].InnerText.DeEntitize(), null, System.Globalization.DateTimeStyles.AssumeUniversal);
            UsageCount  = long.Parse(td[4].InnerText.DeEntitize());
            IsBlocked   = td[5].InnerText.DeEntitize() == "B";
            IsSlaved    = td[6].InnerText.DeEntitize() == "S";
        }
예제 #14
0
 private SearchResult GetGalleryInfo(GalleryInfo x, ParsingState currentParsingState, bool isSelected = false)
 {
     return(new SearchResult
     {
         GalleryId = x.Id,
         Token = x.Token,
         FullName = x.FullName,
         Url = x.Url,
         PreviewUrl = x.PreviewUrl,
         ParsingStateId = currentParsingState.Id,
         Source = (Source)(int)x.Source,
         IsSelected = isSelected
     });
 }
예제 #15
0
        internal RevisionCollection(Gallery owner, HtmlDocument doc)
        {
            this.Owner = owner;
            var gdd        = doc.GetElementbyId("gdd");
            var parentNode = gdd.FirstChild.ChildNodes[1].Descendants("a").FirstOrDefault();

            if (parentNode != null)
            {
                this.ParentInfo = GalleryInfo.Parse(new Uri(parentNode.GetAttributeValue("href", "").DeEntitize()));
            }
            var descendantsNode = doc.GetElementbyId("gnd");

            if (descendantsNode != null)
            {
                var count       = descendantsNode.ChildNodes.Count / 3;
                var descendants = new(DateTimeOffset UpdatedTime, GalleryInfo Gallery)[count];
예제 #16
0
        private GalleryInfo ParseGallery(HtmlNode trNode)
        {
            var galleryInfo = new GalleryInfo {
                Source = Source.Chaika
            };

            var aNode = trNode.SelectSingleNode("a");

            galleryInfo.Url = BASE_CHAIKA_URL + aNode.Attributes["href"].Value.Substring(1);
            galleryInfo.Id  = Convert.ToInt32(aNode.Attributes["href"].Value.Split(new [] { "/" }, StringSplitOptions.RemoveEmptyEntries).Last());

            var imgNode = aNode.SelectSingleNode("img");

            galleryInfo.PreviewUrl = imgNode.Attributes["src"].Value;
            galleryInfo.FullName   = imgNode.Attributes["title"].Value;

            return(galleryInfo);
        }
예제 #17
0
        public static GalleryVM GetVM(Gallery gallery)
        {
            var gi = new GalleryInfo(gallery.ID, gallery.Token);

            if (Cache.TryGet(gi, out var vm))
            {
                vm.Gallery = gallery;
                if (gallery.Count <= vm.currentIndex)
                {
                    vm.currentIndex = -1;
                }
            }
            else
            {
                vm = new GalleryVM(gallery);
                Cache.Add(gi, vm);
            }
            return(vm);
        }
예제 #18
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <param name="keyValue">编号</param>
        /// <returns>GalleryInfo</returns>
        public GalleryInfo Get(int keyValue)
        {
            GalleryInfo model = null;

            using (DbCommand cmd = db.GetStoredProcCommand("SP_GetRecord"))
            {
                db.AddInParameter(cmd, "@TableName", DbType.String, "Gallery");
                db.AddInParameter(cmd, "@KeyName", DbType.String, "GalleryID");
                db.AddInParameter(cmd, "@KeyValue", DbType.Int32, keyValue);
                using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
                {
                    if (dt.Rows.Count > 0)
                    {
                        model = new GalleryInfo();
                        model.LoadFromDataRow(dt.Rows[0]);
                    }
                }
                return(model);
            }
        }
예제 #19
0
    /// <summary>
    /// Downloads one doujin from Hitomi.la
    /// </summary>
    /// <param name="doujinUri">Gallery's uri</param>
    /// <returns></returns>
    internal static async ValueTask DownloadDoujin(Uri doujinUri)
    {
        int galleryId = ParseUri(doujinUri);

        HttpClient client   = new HttpClient();
        string     response = await client.GetStringAsync(GetHitomiGalleryJsString(galleryId))
                              .ConfigureAwait(false);

        string json = response.Replace(ReplaceInResponse, string.Empty);

        byte[] bytes = Encoding.UTF8.GetBytes(json);

        GalleryInfo gi = JsonSerializer.Deserialize <GalleryInfo>(GetReadOnlySpan(bytes));

        //TODO pass output paths to the method
        DirectoryInfo directoryInfo = new DirectoryInfo($"{galleryId}");

        directoryInfo.Create();

        await DownloadImages(gi?.Images, directoryInfo).ConfigureAwait(false);
    }
예제 #20
0
        private Gallery(long id, EToken token, int recordCount)
            : base(recordCount)
        {
            Id         = id;
            Token      = token;
            Rating     = new RatingStatus(this);
            GalleryUri = new GalleryInfo(id, token).Uri;
            if (Client.Current.Settings.RawSettings.TryGetValue("tr", out var trv))
            {
                switch (trv)
                {
                case "1": _PageSize = 50; break;

                case "2": _PageSize = 100; break;

                case "3": _PageSize = 200; break;

                default: _PageSize = 20; break;
                }
            }
        }
예제 #21
0
 protected override IAsyncOperation <IEnumerable <Gallery> > LoadMoreItemsImplementAsync(int count)
 {
     return(AsyncInfo.Run <IEnumerable <Gallery> >(async token =>
     {
         var doc = await Client.Current.HttpClient.GetDocumentAsync(UriProvider.Eh.RootUri);
         var pp = doc.GetElementbyId("pp");
         var nodes = (from div in pp.Elements("div")
                      where div.GetAttributeValue("class", "") == "id1"
                      select div).ToList();
         var ginfo = nodes.Select(n =>
         {
             var link = n.Descendants("a").First().GetAttributeValue("href", "").DeEntitize();
             return GalleryInfo.Parse(new Uri(link));
         }).ToList();
         var galleries = await Gallery.FetchGalleriesAsync(ginfo);
         for (var i = 0; i < ginfo.Count; i++)
         {
             handleAdditionalInfo(nodes[i], galleries[i]);
         }
         return galleries;
     }));
 }
예제 #22
0
        protected override IAsyncOperation <LoadItemsResult <Gallery> > LoadItemsAsync(int count)
        {
            var page = Count / 50;

            return(AsyncInfo.Run(async token =>
            {
                var uri = new Uri($"https://e-hentai.org/toplist.php?tl={(int)Toplist}&p={page}");
                var doctask = Client.Current.HttpClient.GetDocumentAsync(uri);
                token.Register(doctask.Cancel);
                var doc = await doctask;
                token.ThrowIfCancellationRequested();
                var records = doc.DocumentNode.SelectNodes("//table[@class='itg']/tr[position()>1]/td[5]/div/div[3]/a/@href").ToList();
                var gr = new List <GalleryInfo>(records.Count);
                foreach (var item in records)
                {
                    var guri = item.GetAttribute("href", DomainProvider.Eh.RootUri, null);
                    gr.Add(GalleryInfo.Parse(guri));
                }
                var galleries = await Gallery.FetchGalleriesAsync(gr);
                return LoadItemsResult.Create(page * 50, galleries);
            }));
        }
예제 #23
0
        private GalleryInfo ParseGallery(HtmlNode trNode)
        {
            var galleryInfo = new GalleryInfo
            {
                Source = (Type == EhentaiType.Exhentai) ? Source.Exhentai : Source.Ehentai
            };

            var text        = trNode.InnerHtml;
            var previewNode = trNode.SelectSingleNode("td/div/div[@class=\"it2\"]/img");

            if (previewNode != null)
            {
                galleryInfo.PreviewUrl = previewNode.Attributes["src"].Value;
                galleryInfo.FullName   = previewNode.Attributes["alt"].Value;
            }
            else
            {
                previewNode = trNode.SelectSingleNode("td/div/div[@class=\"it2\"]");
                var initString = previewNode.InnerText;

                var initStringParts = initString.Split('~');
                galleryInfo.PreviewUrl = $"http{(initStringParts[0] == "inits" ? "s" : String.Empty)}://" +
                                         $"{initStringParts[1]}/{initStringParts[2]}";
                galleryInfo.FullName = initStringParts[3];
            }


            var url = trNode.SelectSingleNode("//div[@class=\"it5\"]/a").Attributes["href"].Value;

            galleryInfo.Url = url;

            var parts = url.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);

            galleryInfo.Id    = Int32.Parse(parts[parts.Length - 2]);
            galleryInfo.Token = parts[parts.Length - 1];

            return(galleryInfo);
        }
예제 #24
0
        public static byte[] GetFirstThumbnail(this GalleryInfo info, GalleryAgent agent)
        {
            foreach (var url in info.ThumbnailUrls)
            {
                if (string.IsNullOrWhiteSpace(url) == false)
                {
                    try
                    {
                        var bytes = agent.GetGalleryThumbnail(url);

                        using (var image = new MagickImage(bytes))
                        {
                            return(bytes);
                        }
                    }
                    catch
                    {
                    }
                }
            }

            return(null);
        }
예제 #25
0
 /// <summary>
 /// 获取监视器
 /// </summary>
 /// <returns></returns>
 public List <GalleryInfo> GetGalleryList(int regionId)
 {
     try
     {
         ServDeviceInfoDAL          deviceInfoDal  = new ServDeviceInfoDAL();
         List <GalleryInfo>         retGalleryList = new List <GalleryInfo>();
         GalleryInfo                gallery        = null;
         List <ServDeviceInfoModel> galleryList    = deviceInfoDal.GetAllDevice(5, regionId);//5代表监视器
         for (int i = 0; i < galleryList.Count; i++)
         {
             gallery               = new GalleryInfo();
             gallery.galleryCode   = galleryList[i].device_code;
             gallery.galleryName   = galleryList[i].device_name;
             gallery.galleryStatus = galleryList[i].device_status;
             gallery.id            = galleryList[i].id;
             retGalleryList.Add(gallery);
         }
         return(retGalleryList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// Gets the module depdendencies from the PowerShell Gallery
        /// </summary>
        /// <returns></returns>
        public static List <GalleryInfo> GetGalleryModuleDependencies(String moduleName, String Version)
        {
            List <GalleryInfo> dependencyList = new List <GalleryInfo>();
            Uri address = new Uri("https://www.powershellgallery.com/api/v2/FindPackagesById()?id='" + moduleName + "'");

            HttpWebRequest request        = WebRequest.Create(address) as HttpWebRequest;
            String         requestContent = null;

            // Get response
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());
                requestContent = reader.ReadToEnd();
            }

            // Load up the XML response
            XmlDocument doc = new XmlDocument();

            doc.XmlResolver = null;
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.XmlResolver = null;
            using (XmlReader reader = XmlReader.Create(new StringReader(requestContent), settings))
            {
                doc.Load(reader);
            }
            // Add the namespaces for the gallery xml content
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);

            nsmgr.AddNamespace("ps", "http://www.w3.org/2005/Atom");
            nsmgr.AddNamespace("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
            nsmgr.AddNamespace("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");

            // Find the version information
            XmlNode root  = doc.DocumentElement;
            var     props = root.SelectNodes("//m:properties/d:Version", nsmgr);

            // Find the dependencies
            foreach (XmlNode node in props)
            {
                if (String.Compare(node.FirstChild.Value, Version, StringComparison.CurrentCulture) == 0)
                {
                    // Get the dependency list
                    var dependencies = node.ParentNode.ChildNodes[4].InnerText;
                    if (!(String.IsNullOrEmpty(dependencies)))
                    {
                        var splitDependencies = dependencies.Split('|');
                        foreach (var dependent in splitDependencies)
                        {
                            var Parts = dependent.Split(':');
                            var DependentmoduleName = Parts[0];
                            var DependencyVersion   = Parts[1].Replace("[", "").Replace("]", "");
                            //       DependencyVersion = DependencyVersion.Replace("]", "");
                            address = new Uri("https://www.powershellgallery.com/api/v2/package/" + DependentmoduleName + "/" + DependencyVersion);

                            request = WebRequest.Create(address) as HttpWebRequest;
                            // Get response
                            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                            {
                                var dependency = response.ResponseUri.AbsoluteUri;
                                // Set gallery properties and add to dependency list
                                var galleryInfo = new GalleryInfo();
                                galleryInfo.URI           = dependency;
                                galleryInfo.moduleVersion = DependencyVersion;
                                galleryInfo.moduleName    = DependentmoduleName;
                                dependencyList.Add(galleryInfo);
                            }
                        }
                    }
                }
            }

            return(dependencyList);
        }
예제 #27
0
 public static IAsyncOperation <RenameInfo> FetchRenameInfoAsync(this GalleryInfo galleryInfo)
 => RenameInfo.FetchAsync(galleryInfo);
예제 #28
0
        /// <summary>
        /// 댓글을 반환하는 함수
        /// </summary>
        /// <param name="cmtSrc">댓글을 포함하는 HTML 소스</param>
        /// <param name="gall">갤러리 정보를 가진 GalleryInfo 객체</param>
        /// <param name="id">댓글이 달린 게시물의 ID</param>
        /// <returns></returns>
        public static Reply[] BuildReplies(string cmtSrc, GalleryInfo gall, int id)
        {
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(cmtSrc);

            List<Reply> replies = new List<Reply>();

            foreach(HtmlNode trow in doc.DocumentNode.Descendants("tr").Where(x=>x.GetAttributeValue("class", "") == "reply_line"))
            {
                UserInfo userInfo = null;
                string content = null;
                string date = null;
                string ip = null;

                foreach(HtmlNode td in trow.Descendants("td"))
                {
                    if(td.GetAttributeValue("class", "").Contains("user")) // 유저 정보
                    {
                        string userid = td.GetAttributeValue("user_id", "");
                        if (userid == "") //유동
                        {
                            string user_name = td.GetAttributeValue("user_name", "");
                            userInfo = new UserInfo(user_name);
                        }
                        else // 고닉
                        {
                            HtmlNode imgNode = td.SelectNodes(".//img")[0];
                            string src = imgNode.GetAttributeValue("src", "");
                            string user_name = td.GetAttributeValue("user_name", "");
                            string gallogLink = ExtractGallogURL(imgNode.GetAttributeValue("onClick", ""));
                            if (src.Contains("g_default")) // 유동고닉
                            {
                                userInfo = new UserInfo(user_name, userid, false, gallogLink);
                            }
                            else // 고정닉
                            {
                                userInfo = new UserInfo(user_name, userid, true, gallogLink);
                            }
                        }
                    }
                    else if(td.GetAttributeValue("class", "") == "reply")
                    {
                        IEnumerable<HtmlNode> ipNode = td.Descendants("span");
                        if(ipNode.Count()!= 0)
                        {
                            ip = ipNode.First().InnerText;
                            ipNode.First().Remove();
                        }

                        
                        content = td.InnerHtml.Replace("\n", "");
                    }
                    else if(td.GetAttributeValue("class", "") == "retime")
                    {
                        date = td.InnerText;
                    }
                }

                Reply rep = new Reply(gall, id, userInfo, content, ip, date);
                replies.Add(rep);
            }

            return replies.ToArray();
        }
예제 #29
0
        /// <summary>
        /// 현재 페이지의 글 목록을 반환합니다.
        /// </summary>
        /// <param name="parent">부모 DCInside 객체</param>
        /// <param name="doc">파싱된 HTML 소스를 가진 HtmlDocument 객체</param>
        /// <param name="gallInfo">현재 갤러리의 정보를 가진 GalleryInfo 객체</param>
        /// <returns></returns>
        private static List<Article> BuildArticleList(DCInside parent, HtmlDocument doc, GalleryInfo gallInfo)
        {
            List<Article> articles = new List<Article>();

            // 페이지 내부에 Table 요소는 하나뿐 이므로 하위의 TR만 가져온다. (tr중 class를 포함하지 않으면 테이블 헤더)
            foreach(HtmlNode trow in doc.DocumentNode.SelectNodes("//table//tr").Where(x => x.GetAttributeValue("class", "") == "tb"))
            {
                bool isNotice = false;  // 공지 여부
                int articleId = -1;     // 글 ID
                bool hasPic = false;    // 이미지 있는 글인지 여부
                bool isRec = false;     // 개념글 여부
                UserInfo userInfo = null;   // 사용자 정보 객체
                string title = "";      // 글 제목
                string date = "";       // 글 작성일
                int viewCnt = -1;       // 조회 수
                int commentCnt = 0;     // 댓글 수
                int recommendCnt = -1;  // 추천 수
                
                foreach(HtmlNode td in trow.Descendants("td"))
                {
                    if (isNotice)
                        continue;

                    switch(td.GetAttributeValue("class", "")){
                        case "t_notice":
                            if (td.InnerText != "공지")
                                articleId = int.Parse(td.InnerText);
                            else
                                isNotice = true;
                            break;
                        case "t_subject":
                            foreach(HtmlNode subjectNode in td.Descendants("a").Where(x=>x.GetAttributeValue("class", "") != ""))
                            {
                                title = HttpUtility.HtmlDecode(subjectNode.InnerText);

                                if(subjectNode.GetAttributeValue("class", "") == "icon_pic_n")
                                {
                                    hasPic = true;
                                    isRec = false;
                                }
                                else if(subjectNode.GetAttributeValue("class", "") == "icon_pic_b")
                                {
                                    hasPic = true;
                                    isRec = true;
                                }
                                else if (subjectNode.GetAttributeValue("class", "") == "icon_txt_n")
                                {
                                    hasPic = false;
                                    isRec = false;
                                }
                                else
                                {
                                    hasPic = true;
                                    isRec = true;
                                }
                            }
                            break;
                        case "t_date":
                            date = td.GetAttributeValue("title", "");
                            break;
                        case "t_hits":
                            if (viewCnt < 0)
                            {
                                viewCnt = int.Parse(td.InnerText);
                            }
                            else
                            {
                                recommendCnt = int.Parse(td.InnerText);
                            }
                            break; // 2016-02-12
                        case "t_writer user_layer":
                            string userid = td.GetAttributeValue("user_id", "");
                            if(userid == "") //유동
                            {
                                string user_name = td.GetAttributeValue("user_name", "");
                                userInfo = new UserInfo(user_name);
                            }
                            else // 고닉
                            {
                                HtmlNode imgNode = td.SelectNodes(".//img")[0];
                                string src = imgNode.GetAttributeValue("src", "");
                                string user_name = td.GetAttributeValue("user_name", "").Replace("\u8203", "");
                                string gallogLink = ExtractGallogURL(imgNode.GetAttributeValue("onClick", ""));
                                if (src.Contains("g_default")) // 유동고닉
                                {
                                    userInfo = new UserInfo(user_name, userid, false, gallogLink);
                                }
                                else // 고정닉
                                {
                                    userInfo = new UserInfo(user_name, userid, true, gallogLink);
                                }
                            }
                            break;
                    }
                }

                // 댓글 수를 가져오는 함수
                foreach(HtmlNode em in trow.Descendants("em"))
                {
                    var commentTxt = em.InnerText.Replace("[", "").Replace("]", "");
                    commentTxt = commentTxt.Substring(0, commentTxt.IndexOf("/") == -1 ? commentTxt.Length : commentTxt.IndexOf("/"));
                    commentCnt = int.Parse(commentTxt);
                }

                if (articleId == -1)
                    continue;

                // 새 글 객체를 생성한 후 배열에 넣는다
                Article art = new Article(parent, gallInfo, articleId, hasPic, isRec, title, commentCnt, userInfo, date, viewCnt, recommendCnt);

                articles.Add(art);
            }

            return articles;
        }
예제 #30
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <param name="keyValue">编号</param>
        /// <returns>GalleryInfo</returns>
        public GalleryInfo Get(int keyValue)
        {
            GalleryInfo model = null;
			using (DbCommand cmd = db.GetStoredProcCommand("SP_GetRecord"))
			{
				db.AddInParameter(cmd, "@TableName", DbType.String, "Gallery");
				db.AddInParameter(cmd, "@KeyName", DbType.String, "GalleryID");
				db.AddInParameter(cmd, "@KeyValue", DbType.Int32, keyValue);
				using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
				{
					if (dt.Rows.Count > 0)
					{
						model = new GalleryInfo();
						model.LoadFromDataRow(dt.Rows[0]);
					}
				}
				return model;
			}
        } 
예제 #31
0
 public ExpungeInfo(GalleryInfo galleryInfo) => this.GalleryInfo = galleryInfo;
예제 #32
0
 public static IAsyncOperation <ExpungeInfo> FetchExpungeInfoAsync(this GalleryInfo galleryInfo)
 => ExpungeInfo.FetchAsync(galleryInfo);
예제 #33
0
 public ExpungeInfo(GalleryInfo galleryInfo) => GalleryInfo = galleryInfo;
예제 #34
0
 public override IAsyncOperation <LaunchResult> HandleAsync(UriHandlerData data)
 {
     GalleryInfo.TryParseGallery(data, out var info);
     return(AsyncWrapper.CreateCompleted((LaunchResult) new GalleryLaunchResult(info, -1, GalleryLaunchStatus.Default)));
 }
예제 #35
0
 public override bool CanHandle(UriHandlerData data)
 {
     return(GalleryInfo.TryParseGallery(data, out var info));
 }
예제 #36
0
        /// <summary>
        /// 根据分页获得数据列表
        /// </summary>
        /// <param name="TbFields">返回字段</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="OrderField">排序字段</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页尺寸</param> 
        /// <param name="TotalCount">返回总记录数</param>
        /// <returns>IList<GalleryInfo></returns>
        public IList<GalleryInfo> Find(string tbFields, string strWhere, string orderField, int pageIndex, int pageSize, out int totalCount)
        {
			IList<GalleryInfo> list = new List<GalleryInfo>();
			using (DbCommand cmd = db.GetStoredProcCommand("SP_SqlPagenation"))
			{
				db.AddInParameter(cmd, "@TbName", DbType.String, "Gallery");
				db.AddInParameter(cmd, "@TbFields", DbType.String, tbFields);
				db.AddInParameter(cmd, "@StrWhere", DbType.String, strWhere);
				db.AddInParameter(cmd, "@OrderField", DbType.String, orderField);
				db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageIndex);
				db.AddInParameter(cmd, "@PageSize", DbType.Int32, pageSize);
				db.AddOutParameter(cmd, "@Total", DbType.Int32, int.MaxValue);
				using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
				{
					if (dt.Rows.Count > 0)
					{
						foreach (DataRow dr in dt.Rows)
						{
							GalleryInfo model = new GalleryInfo();
							model.LoadFromDataRow(dr);
							list.Add(model);
						}
					}
				}

				totalCount = (int)db.GetParameterValue(cmd, "@Total");
				return list;
			}
		} 
예제 #37
0
 private RenameInfo(GalleryInfo galleryInfo) => this.GalleryInfo = galleryInfo;
예제 #38
0
 /// <summary>
 /// 글을 초기화합니다.
 /// </summary>
 /// <param name="gall">글이 속한 갤러리의 정보입니다.</param>
 /// <param name="articleId">글의 ID입니다.</param>
 /// <param name="hasPicture">글에 사진이 있는가에 대한 여부입니다.</param>
 /// <param name="isRecommend">글이 개념글인지에 대한 여부입니다.</param>
 /// <param name="title">글의 제목입니다.</param>
 /// <param name="commentCnt">글의 댓글 수입니다.</param>
 /// <param name="writer">글을 작성한 글쓴이에 대한 정보입니다.</param>
 /// <param name="date">글을 작성한 시간입니다.</param>
 /// <param name="viewCnt">글의 조회수입니다.</param>
 /// <param name="recommendCnt">글의 추천수입니다.</param>
 public Article(DCInside parent, GalleryInfo gall, int articleId, bool hasPicture, bool isRecommend, string title, int commentCnt, UserInfo writer, string date, int viewCnt, int recommendCnt)
 {
     this.parent = parent;
     this.gallery = gall;
     this.articleId = articleId;
     this.hasPicture = hasPicture;
     this.isRecommend = isRecommend;
     this.title = title;
     this.commentCnt = commentCnt;
     this.writer = writer;
     this.date = DateTime.Parse(date);
     this.viewCnt = viewCnt;
     this.recommendCnt = recommendCnt;
 }