admin преди 2 години
родител
ревизия
45dd118f1d
променени са 1 файла, в които са добавени 26 реда и са изтрити 22 реда
  1. 26 22
      src/CallCenter.NewRock/DeviceManager.cs

+ 26 - 22
src/CallCenter.NewRock/DeviceManager.cs

@@ -400,8 +400,17 @@ namespace CallCenter.NewRock
             if (mId < 1 || mId > 50)
                 throw new UserFriendlyException("分机组只允许在1-50范围内");
 
-           
 
+            #region 清除分机组设置
+
+            await _newRockClient.ConfigExtGroup(
+                new AssginConfigGroupRequest() { Attribute = "Assign", Group = new Group() { Id = groupId }, },
+                _options.Value.ReceiveKey,
+                _options.Value.Expired,
+                cancellationToken
+                );
+
+            #endregion
 
             var list = await _telGroupRepository.QueryExtAsync(d =>d.No== groupId, d => d.Includes(x => x.Tels));
 
@@ -412,7 +421,11 @@ namespace CallCenter.NewRock
                 var iswork = await _userCacheManager.IsWorkingByTelAsync(ext.No, cancellationToken);
                 if (iswork)
                 {
-                    exts.Add(ext.No);
+                    var tel = _telCacheManager.GetTel(ext.No);
+                    if (tel.TelStatus == Tels.ETelStatus.Ready)
+                    {
+                        exts.Add(ext.No);
+                    }
                 }
             }
 
@@ -427,27 +440,18 @@ namespace CallCenter.NewRock
             }
 
             //优先加入空闲分机
-            List<string> groupExts = new List<string>();
-            foreach (var ext in exts)
-            {
-                var omExt = await _newRockClient.QueryExt(new QueryExtRequest() { Attribute = "Query", Ext = new Ext() { Id = ext } },_options.Value.ReceiveKey,_options.Value.Expired,cancellationToken);
-                if (omExt != null && omExt.Ext.State == "ready")
-                {
-                    groupExts.Add(ext);
-                }
-            }
+            //List<string> groupExts = new List<string>();
+            //foreach (var ext in exts)
+            //{
+            //    var omExt = await _newRockClient.QueryExt(new QueryExtRequest() { Attribute = "Query", Ext = new Ext() { Id = ext } },_options.Value.ReceiveKey,_options.Value.Expired,cancellationToken);
+            //    if (omExt != null && omExt.Ext.State == "ready")
+            //    {
+            //        groupExts.Add(ext);
+            //    }
+            //}
 
 
-            #region 清除分机组设置
-
-            await _newRockClient.ConfigExtGroup(
-                new AssginConfigGroupRequest() { Attribute = "Assign", Group = new Group() { Id = groupId }, },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
-                cancellationToken
-                );
-
-            #endregion
+            
 
             //更新
             var groupModel = new Group()
@@ -470,7 +474,7 @@ namespace CallCenter.NewRock
                     break;
             }
 
-            groupModel.Ext = groupExts;
+            groupModel.Ext = exts;
             await _newRockClient.ConfigExtGroup(
                 new AssginConfigGroupRequest() { Attribute = "Assign", Group = groupModel, },
                 _options.Value.ReceiveKey,