Esempio n. 1
0
 public void Dispose()
 {
     if (_callList.Count > 0)
     {
         #region 结束呼叫
         //保存通话记录
         foreach (var call in _callList)
         {
             if (!call.IsActive())
             {
                 PlcmProxy.TerminateCall(call.CallHandle);
                 call.StopTime  = DateTime.Now;
                 call.CallState = CallState.SIP_CALL_CLOSED;
                 call.Reason    = "关闭程序,结束通话";
             }
         }
         #endregion
         #region 保存呼叫
         GetHistoryCalls((calls) =>
         {
             var dicPath = Path.Combine(Application.StartupPath, "History");
             if (!Directory.Exists(dicPath))
             {
                 Directory.CreateDirectory(dicPath);
             }
             var filePath = Path.Combine(dicPath, string.Format("history_{0}.log", qlConfig.GetProperty(PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_UserName)));
             using (var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write))
             {
                 using (var sw = new StreamWriter(fs))
                 {
                     var str = SerializerUtil.SerializeJson(calls);
                     sw.Write(str);
                 }
             }
         });
         #endregion
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 渲染视图
        /// </summary>
        internal void ViewRender()
        {
            if (null == _currentCall || channelViews.Count <= 0)
            {
                return;
            }
            var layoutType = qlConfig.GetProperty(PropertyKey.LayoutType);

            var viewWidth   = this.Width;
            var viewHeight  = this.Height;
            var ratioWidth  = 320;
            var ratioHeight = 240;
            var cellWidth   = ratioWidth;
            var cellHeight  = ratioHeight;

            var cols = viewWidth / cellWidth;
            var rows = viewHeight / cellHeight;

            #region ActiveChannel
            var activeChannel = contentChannel;
            if (null == activeChannel && null != _currentCall.CurrentChannel)
            {
                activeChannel = _currentCall.CurrentChannel;
            }
            if (null == activeChannel)
            {
                activeChannel = _currentCall.Channels.FirstOrDefault();
            }
            if (null == activeChannel)
            {
                return;
            }
            #endregion

            switch (layoutType)
            {
            case "VAS":
            {
                #region VAS
                var activeView = channelViews.Where(cv => cv.Key == activeChannel).Select(cv => cv.Value).FirstOrDefault();
                if (null != activeView)
                {
                    activeView.Location  = new Point(0, 0);
                    activeView.Size      = new Size(viewWidth, viewHeight);
                    activeView.IsShowBar = false;
                    activeView.SendToBack();
                }

                LocateChannel(rows, cols, viewWidth, viewHeight, cellWidth, cellHeight
                              , channelViews.Where(cv => cv.Key != activeChannel).Select(cv => cv.Value).ToList());
                #endregion
            }
            break;

            case "ContinuousPresence":
            {
                #region ContinuousPresence
                var cRows = 0;
                var cCols = 0;
                if (rows <= cols)
                {
                    switch (channelViews.Count)
                    {
                    case 0: cRows = 0; cCols = 0; break;

                    case 1: cRows = 1; cCols = 1; break;

                    case 2: cRows = 1; cCols = 2; break;

                    case 3: cRows = 2; cCols = 2; break;

                    case 4: cRows = 2; cCols = 2; break;

                    case 5: cRows = 2; cCols = 3; break;

                    case 6: cRows = 2; cCols = 3; break;

                    case 7: cRows = 3; cCols = 3; break;

                    case 8: cRows = 3; cCols = 3; break;

                    case 9: cRows = 3; cCols = 3; break;

                    case 10: cRows = 3; cCols = 4; break;

                    case 11: cRows = 3; cCols = 4; break;

                    case 12: cRows = 3; cCols = 4; break;

                    case 13: cRows = 4; cCols = 4; break;

                    case 14: cRows = 4; cCols = 4; break;

                    case 15: cRows = 4; cCols = 4; break;

                    case 16: cRows = 4; cCols = 4; break;
                    }
                }
                else
                {
                    switch (channelViews.Count)
                    {
                    case 0: cRows = 0; cCols = 0; break;

                    case 1: cRows = 1; cCols = 1; break;

                    case 2: cRows = 2; cCols = 1; break;

                    case 3: cRows = 2; cCols = 2; break;

                    case 4: cRows = 2; cCols = 2; break;

                    case 5: cRows = 3; cCols = 2; break;

                    case 6: cRows = 3; cCols = 2; break;

                    case 7: cRows = 3; cCols = 3; break;

                    case 8: cRows = 3; cCols = 3; break;

                    case 9: cRows = 3; cCols = 3; break;

                    case 10: cRows = 4; cCols = 3; break;

                    case 11: cRows = 4; cCols = 3; break;

                    case 12: cRows = 4; cCols = 3; break;

                    case 13: cRows = 4; cCols = 4; break;

                    case 14: cRows = 4; cCols = 4; break;

                    case 15: cRows = 4; cCols = 4; break;

                    case 16: cRows = 4; cCols = 4; break;
                    }
                }
                var x       = 0;
                int y       = 0;
                var i       = 0;
                var cWidth  = viewWidth / cCols;
                var cHeight = viewHeight / cRows;
                foreach (var view in channelViews.Values)
                {
                    view.Location  = new Point(x, y);
                    view.Size      = new Size(cWidth, cHeight);
                    view.IsShowBar = true;
                    view.BringToFront();
                    x = x + cWidth;
                    i++;
                    if (i % cCols == 0)
                    {
                        x = 0;
                        y = y + cHeight;
                    }
                }
                #endregion
            }
            break;

            case "Presentation":
            {
                #region ContinuousPresence
                var locate = LocateChannel(rows, cols, viewWidth, viewHeight, cellWidth, cellHeight
                                           , channelViews.Where(cv => cv.Key != activeChannel).Select(cv => cv.Value).ToList());
                var activeView = channelViews.Where(cv => cv.Key == activeChannel).Select(cv => cv.Value).FirstOrDefault();
                if (null != activeView)
                {
                    activeView.Location  = new Point(0, 0);
                    activeView.Size      = new Size(locate.X, locate.Y);
                    activeView.IsShowBar = false;
                    activeView.BringToFront();
                }
                #endregion
            }
            break;

            case "Single":
            {
                #region Single
                var activeView = channelViews.Where(cv => cv.Key == activeChannel).Select(cv => cv.Value).FirstOrDefault();
                if (null != activeView)
                {
                    activeView.Location  = new Point(0, 0);
                    activeView.Size      = new Size(viewWidth, viewHeight);
                    activeView.IsShowBar = false;
                    activeView.SendToBack();
                }
                foreach (var view in  channelViews.Where(cv => cv.Key != activeChannel))
                {
                    view.Value.Size = new Size(0, 0);
                }
                #endregion
            }
            break;
            }
            var maskPnl = ownerContainer.Controls.Find("msgPnl", true).FirstOrDefault();
            if (null != maskPnl)
            {
                maskPnl.BringToFront();
                if (maskPnl.Controls.Count > 0)
                {
                    maskPnl.Controls[0].BringToFront();
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 获取当前的regId
 /// </summary>
 /// <returns>当前的regId</returns>
 public string GetRegID()
 {
     return(qlConfig.GetProperty(PropertyKey.PLCM_MFW_KVLIST_KEY_REG_ID));
 }