コード例 #1
0
        public ActionResult Download(FormCollection fc)
        {
            int status = CECRequest.StrToInt(fc["status"], 0);
            //会议ID
            int meetingId = CECRequest.StrToInt(CECRequest.GetQueryString("meetingid"), 0);



            switch (status)
            {
            case 1:
                //会前调查下载信息下载
            {
                #region ==
                var dtBeforeMeetingSurvey           = GetSurveyInfo(meetingId, "BeforeMeeting");
                var BeforeMeetingSurveyUserNameList = new List <string>();
                if (dtBeforeMeetingSurvey.Columns.Contains("UserName"))
                {
                    foreach (DataRow dr in dtBeforeMeetingSurvey.Rows)
                    {
                        BeforeMeetingSurveyUserNameList.Add(dr["UserName"].ToString());
                    }
                }
                if (dtBeforeMeetingSurvey != null && dtBeforeMeetingSurvey.Rows.Count > 0)
                {
                    StringBuilder strUserName = new StringBuilder();
                    foreach (string item in BeforeMeetingSurveyUserNameList)
                    {
                        if (!item.Equals("匿名"))
                        {
                            strUserName.Append("'" + item + "'");
                            strUserName.Append(",");
                        }
                    }
                    if (strUserName.Length > 0)
                    {
                        strUserName.Length -= 1;
                    }

                    DataTable dt;
                    if (dtBeforeMeetingSurvey.Columns.Contains("UserName"))
                    {
                        if (dtBeforeMeetingSurvey.Columns.Contains("Email"))
                        {
                            dtBeforeMeetingSurvey.Columns.Remove("Email");
                        }
                        if (dtBeforeMeetingSurvey.Columns.Contains("MobilePhone"))
                        {
                            dtBeforeMeetingSurvey.Columns.Remove("MobilePhone");
                        }
                        if (dtBeforeMeetingSurvey.Columns.Contains("RealName"))
                        {
                            dtBeforeMeetingSurvey.Columns.Remove("RealName");
                        }
                        dt = MergeDataTable(dtBeforeMeetingSurvey, DownLoadUserList(strUserName.ToString()), "UserName");
                    }
                    else
                    {
                        dt = dtBeforeMeetingSurvey;
                    }

                    if (dt != null)
                    {
                        if (dt.Columns.Contains("RealName"))
                        {
                            dt.Columns.Remove("RealName");
                        }
                        if (dt.Columns.Contains("地区"))
                        {
                            dt.Columns.Remove("地区");
                        }
                        if (dt.Columns.Contains("用户名"))
                        {
                            dt.Columns.Remove("用户名");
                        }
                        if (dt.Columns.Contains("邮编"))
                        {
                            dt.Columns.Remove("邮编");
                        }

                        if (dt.Columns.Contains("CreateTime"))
                        {
                            dt.Columns["CreateTime"].ColumnName = "timestamp";
                        }
                        if (dt.Columns.Contains("UserName"))
                        {
                            dt.Columns["UserName"].ColumnName = "User_id";
                        }

                        int indexColumn = dt.Columns.Count - 1;

                        if (dt.Columns.Contains("Name"))
                        {
                            dt.Columns["Name"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("User_id"))
                        {
                            dt.Columns["User_id"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Email"))
                        {
                            dt.Columns["Email"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Position"))
                        {
                            dt.Columns["Position"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Department"))
                        {
                            dt.Columns["Department"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Company"))
                        {
                            dt.Columns["Company"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Province"))
                        {
                            dt.Columns["Province"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("City"))
                        {
                            dt.Columns["City"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("District"))
                        {
                            dt.Columns["District"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Address"))
                        {
                            dt.Columns["Address"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Tele"))
                        {
                            dt.Columns["Tele"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("MobilePhone"))
                        {
                            dt.Columns["MobilePhone"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Postal_Code"))
                        {
                            dt.Columns["Postal_Code"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("timestamp"))
                        {
                            dt.Columns["timestamp"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("UserID"))
                        {
                            dt.Columns["UserID"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("FamilyName"))
                        {
                            dt.Columns["FamilyName"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("GivenName"))
                        {
                            dt.Columns["GivenName"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Guid"))
                        {
                            dt.Columns["Guid"].SetOrdinal(indexColumn);
                        }

                        DataTableToCSV(dt);
                    }
                }
                else
                {
                    ViewBag.Msg = "暂无任何信息可下载!";
                }
                #endregion
            }
            break;

            case 2:
                //会后调查下载信息下载
            {
                #region ==
                var dtAfterMeetingSurvey           = GetSurveyInfo(meetingId, "AfterMeeting");
                var AfterMeetingSurveyUserNameList = new List <string>();
                if (dtAfterMeetingSurvey.Columns.Contains("UserName"))
                {
                    foreach (DataRow dr in dtAfterMeetingSurvey.Rows)
                    {
                        AfterMeetingSurveyUserNameList.Add(dr["UserName"].ToString());
                    }
                }


                if (dtAfterMeetingSurvey != null && dtAfterMeetingSurvey.Rows.Count > 0)
                {
                    StringBuilder strUserName = new StringBuilder();
                    foreach (string item in AfterMeetingSurveyUserNameList)
                    {
                        if (!item.Equals("匿名"))
                        {
                            strUserName.Append("'" + item + "'");
                            strUserName.Append(",");
                        }
                    }
                    if (strUserName.Length > 0)
                    {
                        strUserName.Length -= 1;
                    }

                    DataTable dt;
                    if (dtAfterMeetingSurvey.Columns.Contains("UserName"))
                    {
                        if (dtAfterMeetingSurvey.Columns.Contains("Email"))
                        {
                            dtAfterMeetingSurvey.Columns.Remove("Email");
                        }
                        if (dtAfterMeetingSurvey.Columns.Contains("MobilePhone"))
                        {
                            dtAfterMeetingSurvey.Columns.Remove("MobilePhone");
                        }
                        if (dtAfterMeetingSurvey.Columns.Contains("RealName"))
                        {
                            dtAfterMeetingSurvey.Columns.Remove("RealName");
                        }
                        dt = MergeDataTable(dtAfterMeetingSurvey, DownLoadUserList(strUserName.ToString()), "UserName");
                    }
                    else
                    {
                        dt = dtAfterMeetingSurvey;
                    }

                    if (dt != null)
                    {
                        if (dt.Columns.Contains("RealName"))
                        {
                            dt.Columns.Remove("RealName");
                        }
                        if (dt.Columns.Contains("地区"))
                        {
                            dt.Columns.Remove("地区");
                        }
                        if (dt.Columns.Contains("用户名"))
                        {
                            dt.Columns.Remove("用户名");
                        }
                        if (dt.Columns.Contains("邮编"))
                        {
                            dt.Columns.Remove("邮编");
                        }

                        if (dt.Columns.Contains("CreateTime"))
                        {
                            dt.Columns["CreateTime"].ColumnName = "timestamp";
                        }
                        if (dt.Columns.Contains("UserName"))
                        {
                            dt.Columns["UserName"].ColumnName = "User_id";
                        }

                        int indexColumn = dt.Columns.Count - 1;

                        if (dt.Columns.Contains("Name"))
                        {
                            dt.Columns["Name"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("User_id"))
                        {
                            dt.Columns["User_id"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Email"))
                        {
                            dt.Columns["Email"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Position"))
                        {
                            dt.Columns["Position"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Department"))
                        {
                            dt.Columns["Department"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Company"))
                        {
                            dt.Columns["Company"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Province"))
                        {
                            dt.Columns["Province"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("City"))
                        {
                            dt.Columns["City"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("District"))
                        {
                            dt.Columns["District"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Address"))
                        {
                            dt.Columns["Address"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Tele"))
                        {
                            dt.Columns["Tele"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("MobilePhone"))
                        {
                            dt.Columns["MobilePhone"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Postal_Code"))
                        {
                            dt.Columns["Postal_Code"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("timestamp"))
                        {
                            dt.Columns["timestamp"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("UserID"))
                        {
                            dt.Columns["UserID"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("FamilyName"))
                        {
                            dt.Columns["FamilyName"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("GivenName"))
                        {
                            dt.Columns["GivenName"].SetOrdinal(indexColumn);
                        }
                        if (dt.Columns.Contains("Guid"))
                        {
                            dt.Columns["Guid"].SetOrdinal(indexColumn);
                        }

                        DataTableToCSV(dt);
                    }
                }
                else
                {
                    ViewBag.Msg = "暂无任何信息可下载!";
                }
                #endregion
            }
            break;

            case 3:
                //QA相关信息下载
            {
                #region ==
                var          dtQuestion = new DataTable();
                Action <int> fbQuestion = (mid) => {
                    DataSet      ds = new DataSet();
                    StringReader sr = new StringReader(
                        Goodspeed.Common.CharHelper.GetWebPage(
                            string.Format("http://webcast.planteng.cn/QuestionXmlList.aspx?MeetingID={0}", mid), false, Encoding.UTF8)
                        );
                    ds.ReadXml(sr);
                    if (ds.Tables.Count > 0)
                    {
                        dtQuestion = ds.Tables[0];
                    }
                };
                fbQuestion(meetingId);

                var QuestionUserNameList = new List <string>();
                if (dtQuestion.Columns.Contains("UserName"))
                {
                    foreach (DataRow dr in dtQuestion.Rows)
                    {
                        QuestionUserNameList.Add(dr["UserName"].ToString());
                    }
                }

                if (dtQuestion != null && dtQuestion.Rows.Count > 0)
                {
                    StringBuilder strUserName = new StringBuilder();
                    foreach (string item in QuestionUserNameList)
                    {
                        if (!item.Equals("匿名"))
                        {
                            strUserName.Append("'" + item + "'");
                            strUserName.Append(",");
                        }
                    }
                    if (strUserName.Length > 0)
                    {
                        strUserName.Length -= 1;
                    }

                    DataTable dt = new DataTable();
                    if (dtQuestion.Columns.Contains("UserName"))
                    {
                        if (dtQuestion.Columns.Contains("Email"))
                        {
                            dtQuestion.Columns.Remove("Email");
                        }
                        if (dtQuestion.Columns.Contains("MobilePhone"))
                        {
                            dtQuestion.Columns.Remove("MobilePhone");
                        }
                        if (dtQuestion.Columns.Contains("RealName"))
                        {
                            dtQuestion.Columns.Remove("RealName");
                        }
                        dt = MergeDataTable(dtQuestion, DownLoadUserList(strUserName.ToString()), "UserName");
                    }
                    else
                    {
                        dt = dtQuestion;
                    }

                    if (dt != null)
                    {
                        if (dt.Columns.Contains("RealName"))
                        {
                            dt.Columns.Remove("RealName");
                        }
                        if (dt.Columns.Contains("isDistillate"))
                        {
                            dt.Columns.Remove("isDistillate");
                        }
                        if (dt.Columns.Contains("OperationTime"))
                        {
                            dt.Columns.Remove("OperationTime");
                        }
                        if (dt.Columns.Contains("AnswerUserID"))
                        {
                            dt.Columns.Remove("AnswerUserID");
                        }
                        if (dt.Columns.Contains("StartTime"))
                        {
                            dt.Columns.Remove("StartTime");
                        }
                        if (dt.Columns.Contains("UserID"))
                        {
                            dt.Columns.Remove("UserID");
                        }
                        if (dt.Columns.Contains("IsInReply"))
                        {
                            dt.Columns.Remove("IsInReply");
                        }
                        if (dt.Columns.Contains("ReplyUserName"))
                        {
                            dt.Columns.Remove("ReplyUserName");
                        }

                        if (dt.Columns.Contains("UserName"))
                        {
                            dt.Columns["UserName"].ColumnName = "Webuser_ID";
                        }
                        if (dt.Columns.Contains("QuestionContent"))
                        {
                            dt.Columns["QuestionContent"].ColumnName = "Question_Details";
                        }
                        if (dt.Columns.Contains("QuestionTime"))
                        {
                            dt.Columns["QuestionTime"].ColumnName = "Question_Time";
                        }

                        if (dt.Columns.Contains("isReply"))
                        {
                            dt.Columns["isReply"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("isDirect"))
                        {
                            dt.Columns["isDirect"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("isEmcee"))
                        {
                            dt.Columns["isEmcee"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("isPublic"))
                        {
                            dt.Columns["isPublic"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("Question_Time"))
                        {
                            dt.Columns["Question_Time"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("Postal_Code"))
                        {
                            dt.Columns["Postal_Code"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("Address"))
                        {
                            dt.Columns["Address"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("Tele"))
                        {
                            dt.Columns["Tele"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("District"))
                        {
                            dt.Columns["District"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("City"))
                        {
                            dt.Columns["City"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("Province"))
                        {
                            dt.Columns["Province"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("Company"))
                        {
                            dt.Columns["Company"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("Department"))
                        {
                            dt.Columns["Department"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("Position"))
                        {
                            dt.Columns["Position"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("Question_Details"))
                        {
                            dt.Columns["Question_Details"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("Email"))
                        {
                            dt.Columns["Email"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("Name"))
                        {
                            dt.Columns["Name"].SetOrdinal(2);
                        }
                        if (dt.Columns.Contains("Webuser_ID"))
                        {
                            dt.Columns["Webuser_ID"].SetOrdinal(2);
                        }

                        DataTableToCSV(dt);
                    }
                }
                else
                {
                    ViewBag.Msg = "暂无任何信息可下载!";
                }
                #endregion
            }
            break;

            default:
            case 0:
                //会议相关人员信息下载
            {
                #region ==

                ///会议中的用户
                var          dtUserInMeeting = new DataTable();
                Action <int> fbUserInMeeting = (mid) =>
                {
                    DataSet      ds = new DataSet();
                    StringReader sr = new StringReader(
                        Goodspeed.Common.CharHelper.GetWebPage(
                            string.Format("http://webcast.planteng.cn/UserInMeetingXmlList.aspx?MeetingID={0}", mid),
                            false, Encoding.UTF8)
                        );
                    ds.ReadXml(sr);
                    if (ds.Tables.Count > 0)
                    {
                        dtUserInMeeting = ds.Tables[0];
                    }
                };
                fbUserInMeeting(meetingId);

                var UserInMeetingUserNameList = new List <string>();

                if (dtUserInMeeting.Columns.Contains("UserName"))
                {
                    foreach (DataRow dr in dtUserInMeeting.Rows)
                    {
                        UserInMeetingUserNameList.Add(dr["UserName"].ToString());
                    }
                }

                if (UserInMeetingUserNameList.Count > 0)
                {
                    StringBuilder strUserName = new StringBuilder();
                    foreach (string item in UserInMeetingUserNameList)
                    {
                        if (!item.Equals("匿名"))
                        {
                            strUserName.Append("'" + item + "'");
                            strUserName.Append(",");
                        }
                    }
                    if (strUserName.Length > 0)
                    {
                        strUserName.Length -= 1;
                    }

                    DataTable dt;
                    if (dtUserInMeeting.Columns.Contains("UserName"))
                    {
                        if (dtUserInMeeting.Columns.Contains("Email"))
                        {
                            dtUserInMeeting.Columns.Remove("Email");
                        }
                        if (dtUserInMeeting.Columns.Contains("MobilePhone"))
                        {
                            dtUserInMeeting.Columns.Remove("MobilePhone");
                        }
                        if (dtUserInMeeting.Columns.Contains("RealName"))
                        {
                            dtUserInMeeting.Columns.Remove("RealName");
                        }
                        dt = MergeDataTable(dtUserInMeeting, DownLoadUserList(strUserName.ToString()), "UserName");
                    }
                    else
                    {
                        dt = dtUserInMeeting;
                    }

                    if (dt != null)
                    {
                        //if (dt.Columns.Contains("RealName")) dt.Columns.Remove("RealName");
                        //if (dt.Columns.Contains("CompanyName")) dt.Columns.Remove("CompanyName");
                        if (dt.Columns.Contains("DepartmentName"))
                        {
                            dt.Columns.Remove("DepartmentName");
                        }
                        if (dt.Columns.Contains("LoginName"))
                        {
                            dt.Columns.Remove("LoginName");
                        }
                        //if (dt.Columns.Contains("Phone")) dt.Columns.Remove("Phone");
                        if (dt.Columns.Contains("PostNumber"))
                        {
                            dt.Columns.Remove("PostNumber");
                        }
                        if (dt.Columns.Contains("ProfessionalGrade"))
                        {
                            dt.Columns.Remove("ProfessionalGrade");
                        }
                        if (dt.Columns.Contains("Sex"))
                        {
                            dt.Columns.Remove("Sex");
                        }

                        if (dt.Columns.Contains("Name"))
                        {
                            dt.Columns["Name"].ColumnName = "Webuser_ID";
                        }
                        if (dt.Columns.Contains("UserName"))
                        {
                            dt.Columns["UserName"].ColumnName = "Name";
                        }
                        if (dt.Columns.Contains("SignUpTime"))
                        {
                            dt.Columns["SignUpTime"].ColumnName = "Register_Time";
                        }
                        if (dt.Columns.Contains("IsDirectOnline"))
                        {
                            dt.Columns["IsDirectOnline"].ColumnName = "直播时参会";
                        }
                        if (dt.Columns.Contains("IsSee"))
                        {
                            dt.Columns["IsSee"].ColumnName = "累计观看";
                        }
                        if (dt.Columns.Contains("hasQuestion"))
                        {
                            dt.Columns["hasQuestion"].ColumnName = "是否提问";
                        }

                        /*
                         * if (dt.Columns.Contains("GivenName")) dt.Columns["GivenName"].SetOrdinal(0);
                         * if (dt.Columns.Contains("FamilyName")) dt.Columns["FamilyName"].SetOrdinal(0);
                         * if (dt.Columns.Contains("Register_Time")) dt.Columns["Register_Time"].SetOrdinal(0);
                         * if (dt.Columns.Contains("Postal_Code")) dt.Columns["Postal_Code"].SetOrdinal(0);
                         * //if (dt.Columns.Contains("Address")) dt.Columns["Address"].SetOrdinal(0);
                         * if (dt.Columns.Contains("MobilePhone")) dt.Columns["MobilePhone"].SetOrdinal(0);
                         * if (dt.Columns.Contains("Tele")) dt.Columns["Tele"].SetOrdinal(0);
                         * if (dt.Columns.Contains("District")) dt.Columns["District"].SetOrdinal(0);
                         * //if (dt.Columns.Contains("City")) dt.Columns["City"].SetOrdinal(0);
                         * //if (dt.Columns.Contains("Province")) dt.Columns["Province"].SetOrdinal(0);
                         * if (dt.Columns.Contains("Company")) dt.Columns["Company"].SetOrdinal(0);
                         * if (dt.Columns.Contains("Department")) dt.Columns["Department"].SetOrdinal(0);
                         * //if (dt.Columns.Contains("Position")) dt.Columns["Position"].SetOrdinal(0);
                         * if (dt.Columns.Contains("是否提问")) dt.Columns["是否提问"].SetOrdinal(0);
                         * if (dt.Columns.Contains("累计观看")) dt.Columns["累计观看"].SetOrdinal(0);
                         * if (dt.Columns.Contains("直播时参会")) dt.Columns["直播时参会"].SetOrdinal(0);
                         * //if (dt.Columns.Contains("Email")) dt.Columns["Email"].SetOrdinal(0);
                         * if (dt.Columns.Contains("Name")) dt.Columns["Name"].SetOrdinal(0);
                         * if (dt.Columns.Contains("Webuser_ID")) dt.Columns["Webuser_ID"].SetOrdinal(0);
                         * if (dt.Columns.Contains("QuestionNum")) dt.Columns["QuestionNum"].SetOrdinal(0);
                         * if (dt.Columns.Contains("DirectOnlineTime")) dt.Columns["DirectOnlineTime"].SetOrdinal(0);
                         * if (dt.Columns.Contains("OnlineTime")) dt.Columns["OnlineTime"].SetOrdinal(0);
                         */
                        DataTableToCSV(dt);
                    }
                }
                else
                {
                    ViewBag.Msg = "暂无任何信息可下载!";
                }
                #endregion
            }
            break;
            }
            return(View());
        }