public string GetXmlDataForUpdatingMeeting(SVCMMeetingDetail detail, string operationType, HandlerSession session)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?><updateConfer></updateConfer>");

            XmlNode root = xmlDoc.SelectSingleNode("updateConfer");

            this.AddChildrenNode(xmlDoc, root, "messageId", session.MessageId.ToString());
            this.AddChildrenNode(xmlDoc, root, "token", session.Token);
            this.AddChildrenNode(xmlDoc, root, "conferId", detail.Id);
            this.AddChildrenNode(xmlDoc, root, "conferName", detail.Name);
            this.AddChildrenNode(xmlDoc, root, "startTime", detail.StartTime.ToString("yyyy-MM-dd HH:mm:ss"));
            this.AddChildrenNode(xmlDoc, root, "durationHour", detail.DurantionHours.ToString());
            this.AddChildrenNode(xmlDoc, root, "durationMinute", detail.DurantionMinutes.ToString());
            this.AddChildrenNode(xmlDoc, root, "confPassword", detail.Password??string.Empty);
            this.AddChildrenNode(xmlDoc, root, "conferMemo", detail.Memo);
            this.AddChildrenNode(xmlDoc, root, "meetingRoom", detail.MainRoom == null ? string.Empty : detail.MainRoom.RoomId.Split(",".ToCharArray())[0]);
            this.AddChildrenNode(xmlDoc, root, "termIds", detail.RoomIds);
            this.AddChildrenNode(xmlDoc, root, "videoSet", ((int)detail.VideoSet).ToString());
            this.AddChildrenNode(xmlDoc, root, "participatorNumber", detail.ParticipatorNumber.ToString());
            this.AddChildrenNode(xmlDoc, root, "phone", detail.Phone);
            this.AddChildrenNode(xmlDoc, root, "ipdesc", detail.IPDesc);
            //点对点会议是否上MCU,0:不上MCU,1:上MCU,快乐平安新增字段,保留,默认填0
            this.AddChildrenNode(xmlDoc, root, "inMCU", "0");
            this.AddChildrenNode(xmlDoc, root, "leader", detail.LeaderListStr);
            this.AddChildrenNode(xmlDoc, root, "leaderRoom", detail.LeaderRoom);
            this.AddChildrenNode(xmlDoc, root, "conferType", ((int)detail.ConfType).ToString());
            this.AddChildrenNode(xmlDoc, root, "conferMideaType", ((int)detail.ConfMideaType).ToString());
            this.AddChildrenNode(xmlDoc, root, "operateType", operationType);

            //----会议操作对象,1:web端,2:outlook客户端,3:快乐平安客户端---
            this.AddChildrenNode(xmlDoc, root, "conf_operate_obj", "2");

            return xmlDoc.InnerXml;
        }
        public string GetXmlDataFromMeetingDetail(SVCMMeetingDetail detail, HandlerSession session)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?><startConfer></startConfer>");

            XmlNode root = xmlDoc.SelectSingleNode("startConfer");

            this.AddChildrenNode(xmlDoc, root, "messageId", session.MessageId.ToString());
            this.AddChildrenNode(xmlDoc, root, "token", session.Token);
            this.AddChildrenNode(xmlDoc, root, "conferName", detail.Name);
            this.AddChildrenNode(xmlDoc, root, "startTime", detail.StartTime.ToString("yyyy-MM-dd HH:mm:ss"));
            this.AddChildrenNode(xmlDoc, root, "durationHour", detail.DurantionHours.ToString());
            this.AddChildrenNode(xmlDoc, root, "durationMinute", detail.DurantionMinutes.ToString());
            this.AddChildrenNode(xmlDoc, root, "mcuTemplateId", "");
            this.AddChildrenNode(xmlDoc, root, "confPassword", detail.Password);
            this.AddChildrenNode(xmlDoc, root, "chairPassword", "");
            this.AddChildrenNode(xmlDoc, root, "caption", "");
            this.AddChildrenNode(xmlDoc, root, "conferMemo", detail.Memo);
            if(detail.MainRoom != null && detail.MainRoom.RoomId != null)
            this.AddChildrenNode(xmlDoc, root, "meetingRoom", detail.MainRoom.RoomId.Split(",".ToCharArray())[0]);
            else
                this.AddChildrenNode(xmlDoc, root, "meetingRoom", "");

            this.AddChildrenNode(xmlDoc, root, "termIds", detail.RoomIds);
            this.AddChildrenNode(xmlDoc, root, "videoSet", ((int)detail.VideoSet).ToString());
            //是否设定轮询 1 是 0 否,平安业务无此字段,保留
            this.AddChildrenNode(xmlDoc, root, "ifPolling", "1");
            //主席会场 0:表示无主席会场 ,平安业务无此字段,保留
            this.AddChildrenNode(xmlDoc, root, "chairRoom", "1");
            //与会人Ids,平安业务无此字段,保留
            this.AddChildrenNode(xmlDoc, root, "participateIds", "");
            //是否发送会议短信,平安业务无此字段,保留
            this.AddChildrenNode(xmlDoc, root, "sendmsgflag", "");
            //是否音视频分离,平安业务无此字段,保留
            this.AddChildrenNode(xmlDoc, root, "isSperate", "");
            this.AddChildrenNode(xmlDoc, root, "participatorNumber", detail.ParticipatorNumber.ToString());
            this.AddChildrenNode(xmlDoc, root, "phone", detail.Phone);
            this.AddChildrenNode(xmlDoc, root, "ipdesc", detail.IPDesc);
            //点对点会议是否上MCU,0:不上MCU,1:上MCU,快乐平安新增字段,保留,默认填0
            this.AddChildrenNode(xmlDoc, root, "inMCU", "0");
            this.AddChildrenNode(xmlDoc, root, "leader", detail.LeaderListStr);
            this.AddChildrenNode(xmlDoc, root, "leaderRoom", detail.LeaderRoom);
            this.AddChildrenNode(xmlDoc, root, "conferType", ((int)detail.ConfType).ToString());
            this.AddChildrenNode(xmlDoc, root, "conferMideaType", ((int)detail.ConfMideaType).ToString());
            this.AddChildrenNode(xmlDoc, root, "regularMeetingType", detail.RegularMeetingType.ToString());
            this.AddChildrenNode(xmlDoc, root, "regularMaxnum", detail.RegularMaxNum.ToString());
            this.AddChildrenNode(xmlDoc, root, "regularMeetingNum", detail.RegularMeetingNum.ToString());
            this.AddChildrenNode(xmlDoc, root, "multiExceptDay", detail.MultiExceptDay);
            this.AddChildrenNode(xmlDoc, root, "multiExceptWeek", detail.MultiExceptWeek);
            this.AddChildrenNode(xmlDoc, root, "everyFewMonths", ((int)detail.EveryFewMonths).ToString());
            this.AddChildrenNode(xmlDoc, root, "theFirstFew", ((int)detail.TheFirstFew).ToString());
            this.AddChildrenNode(xmlDoc, root, "week", detail.Week.ToString());

            //----会议操作对象,1:web端,2:outlook客户端,3:快乐平安客户端---
            this.AddChildrenNode(xmlDoc, root, "conf_operate_obj", "1");
            return xmlDoc.InnerXml;
        }
        public string BookMeeting(string name, string startDateTime, string endDateTime, string roomAlias, string memo)
        {
            string error = string.Empty;

            BookMeetingResponse response = new BookMeetingResponse();

            try
            {
                //Get rooms

                DateTime startTime;
                DateTime endTime;
                if (DateTime.TryParse(startDateTime, out startTime) && DateTime.TryParse(endDateTime, out endTime))
                {
                    if (!string.IsNullOrEmpty(roomAlias))
                    {
                        List<MeetingRoom> roomList = this.GetMeetingRooms(roomAlias);
                        if (roomList.Count > 0)
                        {
                            SVCMMeetingDetail detail = new SVCMMeetingDetail()
                            {
                                Name = name,
                                StartTime = DateTime.Parse(startDateTime),
                                EndTime = DateTime.Parse(endDateTime),
                                Memo = memo,
                                ConfMideaType = MideaType.Video,
                                ConfType = ConferenceType.Furture,
                                VideoSet = VideoSet.Audio,
                                Phone = "123",
                                ParticipatorNumber = 3,
                                IPDesc = "123456"
                            };

                            //detail.MobileTermList.Add(new MobileTerm() { RoomId = "13485", RoomName = "dfs" });
                            //detail.MobileTermList.Add(new MobileTerm() { RoomId = "13705", RoomName = "dfs" });

                            foreach (var item in roomList)
                            {
                                detail.Rooms.Add(item);
                            }

                            if (ClientServiceFactory.Create().BookingMeeting(detail, hSession, out error))
                            {
                                response.Result = true;
                                response.MeetingId = detail.Id;
                            }
                            else
                            {
                                response.Result = false;
                                response.MeetingId = "0";
                                response.Error = error;
                            }
                        }
                        else
                        {
                            response.Result = false;
                            response.MeetingId = "0";
                            response.Error = string.Format("不能通过短号 {0} 找到会议室,请重试!", roomAlias);
                        }
                    }
                    else
                    {
                        response.Result = false;
                        response.MeetingId = "0";
                        response.Error = "短号不能为空";// string.Format("不能通过短号 {0} 找到会议室,请重试!", roomAlias);
                    }

                }
                else
                {
                    response.Result = false;
                    response.MeetingId = "0";
                    response.Error = "开始时间或结束时间日期格式不对。";
                }

            }
            catch (Exception ex)
            {
                response.Result = false;
                response.MeetingId = "0";
                response.Error = ex.StackTrace;
            }

            return JsonConvert.SerializeObject(response);
        }
        public bool TryGetMeetingDetail(string meetingId, Model.HandlerSession session, out Model.SVCMMeetingDetail detail)
        {
            detail = new SVCMMeetingDetail();

               try
               {
               session.AddMessageId();
               string xmlData = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><confInfo><messageId>{0}</messageId><token>{1}</token><conferId>{2}</conferId></confInfo>", session.MessageId, session.Token, meetingId);
               //logger.Debug(string.Format("TryGetMeetingDetail, xmldata: {0}", xmlData));
               var response = this._client.DoHttpWebRequest(session.BaseUrl + "getConfInfo", xmlData);
               //logger.Debug(string.Format("TryGetMeetingDetail response, xmldata: {0}", response.OuterXml));
               XmlNode root = response.SelectSingleNode("confInfo");
               string status = root.SelectSingleNode("result").InnerText;

               if (status == "200")
               {
                   detail.Id = root.SelectSingleNode("conferId").InnerText;
                   detail.Name = root.SelectSingleNode("conferName").InnerText??string.Empty;
                   detail.StartTime = DateTime.Parse(root.SelectSingleNode("startTime").InnerText);
                   detail.EndTime = DateTime.Parse(root.SelectSingleNode("endTime").InnerText);
                   detail.Status = root.SelectSingleNode("status").InnerText;

                   string str = root.SelectSingleNode("mediaType").InnerText;
                   if (str == "4")
                       detail.ConfMideaType = MideaType.Local;
                   else
                       detail.ConfMideaType = MideaType.Video;

                   detail.ParticipatorNumber = int.Parse(root.SelectSingleNode("participatorNumber").InnerText);
                   detail.Series.Name = root.SelectSingleNode("seriesName").InnerText;
                   detail.AccountName = root.SelectSingleNode("accountName").InnerText;
                   detail.Phone = root.SelectSingleNode("telephone").InnerText.Replace("null", "");

                   var leaders = root.SelectSingleNode("leader").InnerText.Replace("null", "").Split(",".ToCharArray());

                   foreach (var item in leaders)
                   {
                       detail.LeaderList.Add(new MeetingLeader()
                       {
                           UserName = item
                       });
                   }

                   detail.LeaderNameListStr = root.SelectSingleNode("leaderName").InnerText;
                   detail.LeaderRoom = root.SelectSingleNode("leaderRoom").InnerText.Replace("null", "");
                   detail.IpTelephoneNumber = root.SelectSingleNode("ipTelephoneNumber").InnerText;
                   detail.Department = root.SelectSingleNode("department").InnerText;

                   detail.Memo = root.SelectSingleNode("confMemo").InnerText.Replace("null", "");
                   detail.Password = root.SelectSingleNode("confPassword").InnerText.Replace("null", "");

                   if (root.SelectSingleNode("videoSet") != null)
                       detail.VideoSet = (VideoSet)int.Parse(root.SelectSingleNode("videoSet").InnerText);

                   detail.IPDesc = root.SelectSingleNode("ipdesc").InnerText.Replace("null","");
                   XmlNode mobileTermlistNode = root.SelectSingleNode("mobileTermList");
                   if (mobileTermlistNode != null)
                   {
                       foreach (var item in root.SelectSingleNode("mobileTermList").SelectNodes("roomInfo"))
                       {
                           var node = item as XmlNode;

                           detail.MobileTermList.Add(new MobileTerm()
                           {
                               RoomId = node.SelectSingleNode("roomId").InnerText,
                               RoomName = node.SelectSingleNode("roomName").InnerText
                           });
                       }
                   }

                   XmlNode roomlistNode = root.SelectSingleNode("roomList");
                   if (roomlistNode != null)
                   {
                       foreach (var item in root.SelectSingleNode("roomList").SelectNodes("roomInfo"))
                       {
                           var node = item as XmlNode;
                           string termType = node.SelectSingleNode("termType").InnerText;

                           if (termType != "2")
                           {
                               detail.Rooms.Add(new MeetingRoom()
                               {
                                   RoomId = node.SelectSingleNode("roomId").InnerText,
                                   Name = node.SelectSingleNode("roomName").InnerText,
                                   Address = node.SelectSingleNode("address").InnerText

                               });

                               if (node.SelectSingleNode("roomType").InnerText == "1")
                               {
                                   detail.MainRoom = new MeetingRoom()
                                   {
                                       RoomId = node.SelectSingleNode("roomId").InnerText,
                                       Name = node.SelectSingleNode("roomName").InnerText
                                   };
                               }
                           }

                       }
                   }

                   //TermList

                   return true;
               }
               else
               {
                   //logger.Error(string.Format("TryGetMeetingDetail failed, status: {0}, error:{1}", status, response.InnerXml));
                   this.ReLogin(session, root.SelectSingleNode("result"));
                   return false;
               }
               }
               catch (Exception ex)
               {
               //logger.Error("TryGetMeetingDetail failed, error:" + ex.Message + "\n" + ex.StackTrace);
               this.Login(ref session);

               }

               return false;
        }