public async void GetTopicArticles(int topicid)
        {
            var vault          = new Windows.Security.Credentials.PasswordVault();
            var credentialList = vault.FindAllByResource(resourceName);

            credentialList[0].RetrievePassword();
            if (credentialList[0] != null)
            {
                try
                {
                    List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >();
                    paramList.Add(new KeyValuePair <string, string>("stuNum", credentialList[0].UserName));
                    paramList.Add(new KeyValuePair <string, string>("topic_id", topicid.ToString()));
                    string Topictemp = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/Topic/listTopicArticle", paramList);

                    JObject Tobj = JObject.Parse(Topictemp);
                    if (Int32.Parse(Tobj["status"].ToString()) == 200)
                    {
                        string       content = Tobj["data"].ToString();
                        JObject      _tobj   = JObject.Parse(content);
                        TopicContent item    = new TopicContent();
                        item.GetAttribute(_tobj);
                        foreach (var _item in item.articles)
                        {
                            al.Add(_item);
                        }
                    }
                }
                catch
                {
                    NotifyPopup notifyPopup = new NotifyPopup("网络异常 无法读取话题详情~");
                    notifyPopup.Show();
                }
            }
        }
 private void InitialCateContentModel(IEnumerable <TopicInfo> topicList, TopicAjaxModel model)
 {
     foreach (TopicInfo info in topicList)
     {
         TopicContent item = new TopicContent
         {
             create_time = "",
             item_id     = info.Id,
             link        = "/m-wap/topic/detail/" + info.Id,
             pic         = "",
             title       = info.Name,
             tag         = info.Tags
         };
         model.list.Add(item);
     }
 }
Example #3
0
        /// <summary>
        /// 获取帖子内容块列表
        /// </summary>
        /// <param name="sourceTopicContent"></param>
        /// <returns></returns>
        private static List <TopicContent> GetTopicContentList(this string sourceTopicContent)
        {
            List <TopicContent> contentList = new List <TopicContent>(0);

            if (!string.IsNullOrEmpty(sourceTopicContent) && sourceTopicContent.StartsWith("<TopicContent>") && sourceTopicContent.EndsWith("</TopicContent>"))
            {
                try
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(sourceTopicContent.Trim());
                    XmlNode rootNode = xmlDoc.SelectSingleNode("TopicContent");
                    if (null != rootNode && rootNode.HasChildNodes)
                    {
                        foreach (XmlNode node in rootNode.ChildNodes)
                        {
                            if (node.NodeType == XmlNodeType.Element)
                            {
                                //ContentType ct = (ContentType)Enum.Parse(typeof(ContentType), node.Name, true);
                                ContentType ct   = GetTopicContentType(node.Name);
                                byte[]      data = null;
                                switch (ct)
                                {
                                case ContentType.Image:
                                    ImageContent imageContent = node.GetImageContent();
                                    if (null != imageContent)
                                    {
                                        data = imageContent.ProtoBufSerialize <ImageContent>();
                                    }
                                    break;

                                case ContentType.Voice:
                                    VoiceContent voiceContent = node.GetVoiceContent();
                                    if (null != voiceContent)
                                    {
                                        data = voiceContent.ProtoBufSerialize <VoiceContent>();
                                    }
                                    break;

                                case ContentType.Video:
                                    VideoContent videoContent = node.GetVideoContent();
                                    if (null != videoContent)
                                    {
                                        data = videoContent.ProtoBufSerialize <VideoContent>();
                                    }
                                    break;

                                case ContentType.Address:
                                    AddressContent addressContent = node.GetAddressContent();
                                    if (null != addressContent)
                                    {
                                        data = addressContent.ProtoBufSerialize <AddressContent>();
                                    }
                                    break;

                                case ContentType.Telphone:
                                    TelphoneContent telphoneContent = node.GetTelphoneContent();
                                    if (null != telphoneContent)
                                    {
                                        data = telphoneContent.ProtoBufSerialize <TelphoneContent>();
                                    }
                                    break;

                                case ContentType.Contact:
                                    ContactContent contactContent = node.GetContactContent();
                                    if (null != contactContent)
                                    {
                                        data = contactContent.ProtoBufSerialize <ContactContent>();
                                    }
                                    break;

                                case ContentType.Text:
                                default:
                                    TextContent textContent = node.GetTextContent();
                                    if (null != textContent)
                                    {
                                        data = textContent.ProtoBufSerialize <TextContent>();
                                    }
                                    break;
                                }

                                TopicContent content = new TopicContent {
                                    ContentType = ct, Data = data
                                };
                                contentList.Add(content);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    ex.Error();
                }
            }
            return(contentList);
        }