///// <summary>
        ///// 取得口令回复一览
        ///// </summary>
        ///// <param name="autoReplyView"></param>
        ///// <returns></returns>
        //private List<AutoReplyContentView> GetAutoReplyList(AutoReplyView autoReplyView)
        //{
        //    // THIS IS NOT A GOOD WAY, SHOULD TRANSFER TO JSON OBJECT IN FRONT END
        //    var list = new List<AutoReplyContentView>();
        //    var replyTypes = Request.Form.GetValues("replyType");
        //    var textReply = Request.Form.Get("saytext");
        //    var newsTitle = Request.Form.Get("msgPictitle");
        //    var newsComment = Request.Form.Get("msgtips");
        //    var newsBody = Request.Form.Get("msgbody");
        //    //var isTextEncrypts = Request.Form.GetValues("isTextEncryptReplace");
        //    var replyNewsTypes = Request.Form.GetValues("replyNewsType");
        //    var replyNewsLatestCounts = Request.Form.GetValues("replyNewsLatestCount");
        //    var replyNewsLists = Request.Form.GetValues("replyNewsList");
        //    var textReplyFiles = Request.Form.GetValues("textReplyFiles");

        //    //if (replyTypes != null)
        //    //{
        //    //    var count = replyTypes.Length;
        //    //    for (int i = 0; i < count; i++)
        //    //    {
        //            var content = new AutoReplyContentView();
        //            content.AutoReplyId = autoReplyView.Id;
        //            content.PrimaryType = 2;//int.Parse(replyTypes[i]);
        //            NewsInfoView view = new NewsInfoView();
        //            switch (content.PrimaryType)
        //            {
        //                #region text
        //                case (int)AutoReplyContentEnum.TEXT:
        //                case (int)AutoReplyContentEnum.LINK:
        //                    {
        //                        content.Content = textReply;
        //                        //if (isTextEncrypts != null)
        //                        //{
        //                        //    content.IsEncrypt = isTextEncrypts[i] == "1";
        //                        //}
        //                        break;
        //                    }
        //                #endregion

        //                #region news
        //                case (int)AutoReplyContentEnum.PHOTO_TEXT:
        //                    {
        //                        view.NewsTitle = newsTitle;
        //                        view.NewsComment = newsComment;
        //                        view.NewsContent = newsBody;
        //                        //    //ImageContent = news
        //                        content.NewsID = Guid.NewGuid().ToString();
        //                        var configs = Infrastructure.Web.Domain.Service.CommonService.lstSysConfig;
        //                        var config = configs.Where(a => a.ConfigName.Equals("Content Server", StringComparison.CurrentCultureIgnoreCase)).First();
        //                        string host = config.ConfigValue;
        //                        if (host.EndsWith("/"))
        //                        {
        //                            host = host.Substring(0, host.Length - 1);
        //                        }
        //                        //var picUrl = host + item.ImageContent;
        //                        var url = host + "WechatMain/AutoReply/GetNews?id=" + content.NewsID;
        //                        content.Content = JsonConvert.SerializeObject(view);
        //                        //if (replyNewsTypes != null)
        //                        //{
        //                        //    content.SecondaryType = int.Parse(replyNewsTypes[i]);
        //                        //    if (content.SecondaryType == (int)AutoReplyNewsEnum.LATEST)
        //                        //    {
        //                        //        if (replyNewsLatestCounts != null) content.Content = replyNewsLatestCounts[i];
        //                        //    }
        //                        //    else if (content.SecondaryType == (int)AutoReplyNewsEnum.MANUAL)
        //                        //    {
        //                        //        if (replyNewsLists != null) content.NewsID = replyNewsLists[i];
        //                        //    }
        //                        //}

        //                        break;
        //                    }
        //                #endregion

        //                case (int)AutoReplyContentEnum.VIDEO:
        //                    view.NewsTitle = newsTitle;
        //                    break;
        //                case (int)AutoReplyContentEnum.FILE:
        //                    view.NewsTitle = newsTitle;
        //                    break;
        //                case (int)AutoReplyContentEnum.IMAGE:
        //                    view.NewsTitle = newsTitle;
        //                    break;
        //                case (int)AutoReplyContentEnum.AUDIO:
        //                    view.NewsTitle = newsTitle;
        //                    break;
        //                default:
        //                    {
        //                        //if (textReplyFiles != null) content.FileID = int.Parse(textReplyFiles[i]);
        //                        break;
        //                    }
        //            }

        //            list.Add(content);
        //    //    }

        //    //}

        //    return list;
        //}
        #endregion

        private List <AutoReplyContentView> GetAutoReplyList(AutoReplyNewView model)
        {
            var list    = new List <AutoReplyContentView>();
            var content = new AutoReplyContentView();

            content.AutoReplyId = model.Main.Id;
            var news = model.Send[0]; //保存多条内容。只有新闻存在多条情况

            content.IsEncrypt = news.isSecurityPost;
            var cate = (AutoReplyContentEnum)Enum.Parse(typeof(AutoReplyContentEnum), news.NewsCate, true);

            //选择资源文件
            if (news.materialId.HasValue && news.materialId.Value > 0)
            {
                var config = WeChatCommonService.GetWeChatConfigByID(model.Main.AppId);
                content.FileID       = news.materialId;
                content.IsNewContent = false;
                //更新MediaID
                //out 之后news.isSecurityPost 被清空
                Innocellence.WeChatMain.Common.WechatCommon.GetMediaIDByFileID(news.materialId, _attachmentsItemService, config.WeixinCorpId, out news);

                content.Content = JsonConvert.SerializeObject(new List <NewsInfoView> {
                    news
                });
            }
            else if (cate == AutoReplyContentEnum.NEWS)
            {                                          //图文消息特殊处理
                if (string.IsNullOrEmpty(news.NewsID)) //如果不是选择的素材
                {
                    var listArticle = GetArticleList(model.Send);

                    content.NewsID = string.Join(",", listArticle.Select(a => a.Id).ToArray());
                }
                else
                {
                    content.NewsID = news.NewsID;
                }
                content.IsNewContent = false;
                //content.SecondaryType = model.Main.Contents[0].SecondaryType;
                content.SecondaryType = (int)AutoReplyNewsEnum.MANUAL; //此处缺少功能,临时写死。画面应该增加返回最近的几条新闻
            }
            else
            {
                if (cate != AutoReplyContentEnum.TEXT && cate != AutoReplyContentEnum.LINK) //上传文件处理
                {
                    var mediaId = WechatCommon.GetMediaInfo(cate, news, model.Main.AppId);
                    content.MediaId = mediaId;
                }


                content.IsNewContent = true;
                //content.Content = JsonConvert.SerializeObject(model.Send);  //这个地方不应该存数组,todo
                content.Content = JsonConvert.SerializeObject(new List <NewsInfoView> {
                    news
                });
            }
            content.PrimaryType = (int)cate;
            list.Add(content);
            return(list);
        }