Yu.ding 4 years ago
parent
commit
a4efb9bf8d
3 changed files with 27 additions and 24 deletions
  1. 19 19
      usr/src/generate_context_conf.c
  2. 6 3
      usr/src/generate_extension_conf.c
  3. 2 2
      usr/src/generate_trunk_conf.c

+ 19 - 19
usr/src/generate_context_conf.c

@@ -387,12 +387,30 @@ mytime()\
         fprintf(conf_fp, "include => featurecodes\n");
         if(g_row[2]){
             memset(sql_tmp,0,sizeof(sql_tmp));
+            sprintf(sql_tmp,"select t_paging_users.id,t_paging_users.level from t_paging_users join t_paging_devices on t_paging_users.id = t_paging_devices.user_id\
+            where t_paging_devices.exten=%s",g_row[1]);     //查询分机号所属的用户ID和等级
+            if (executesql(sql_tmp)){
+                print_mysql_error(NULL);
+                exit(1);
+            }
+            d_res = mysql_store_result(g_conn); // 从服务器传送结果集至本地,mysql_use_result直接使用服务器上的记录集
+            while((d_row=mysql_fetch_row(d_res))){
+                if (d_row[0] == NULL || d_row[1] == NULL){
+                    printf("some feild is empty!\n");
+                    continue;
+                }
+                fprintf(conf_fp, "include => DialRule_users\n");
+                fprintf(conf_users_fp, "exten => %s,1,Macro(stdexten,%s,SIP/%s)\n",g_row[1],g_row[1],g_row[1]);
+                fprintf(global_fp, "USER_ID_%s = %s\n",g_row[1],d_row[0]);
+                fprintf(global_fp, "USER_LEVEL_%s = %s\n",g_row[1],d_row[1]);
+            }
+            memset(sql_tmp,0,sizeof(sql_tmp));
             sprintf(sql_tmp,"select exten,t_paging_userServices.tPagingServiceId as service_id from t_paging_groups\
             JOIN t_paging_userGroups on t_paging_groups.id = t_paging_userGroups.GroupId\
             JOIN t_paging_userServices on t_paging_userServices.UserId = t_paging_userGroups.UserId\
             where t_paging_userServices.tPagingServiceId in(1,4,9) and t_paging_userGroups.UserId\
             in(select t_paging_users.id from t_paging_users join t_paging_devices on t_paging_users.id = t_paging_devices.user_id\
-            where t_paging_devices.exten=%s) order by t_paging_userServices.tPagingServiceId",g_row[1]);
+            where t_paging_devices.exten=%s) order by t_paging_userServices.tPagingServiceId",g_row[1]);        //查询分机所属管理员的权限以及所管理的组
             if (executesql(sql_tmp)){
                 print_mysql_error(NULL);
                 exit(1);
@@ -419,24 +437,6 @@ mytime()\
                         break;
                 }
             }
-            memset(sql_tmp,0,sizeof(sql_tmp));
-            sprintf(sql_tmp,"select t_paging_users.id,t_paging_users.level from t_paging_users join t_paging_devices on t_paging_users.id = t_paging_devices.user_id\
-            where t_paging_devices.exten=%s",g_row[1]);
-            if (executesql(sql_tmp)){
-                print_mysql_error(NULL);
-                exit(1);
-            }
-            d_res = mysql_store_result(g_conn); // 从服务器传送结果集至本地,mysql_use_result直接使用服务器上的记录集
-            while((d_row=mysql_fetch_row(d_res))){
-                if (d_row[0] == NULL || d_row[1] == NULL){
-                    printf("some feild is empty!\n");
-                    continue;
-                }
-                fprintf(conf_fp, "include => DialRule_users\n");
-                fprintf(conf_users_fp, "exten => %s,1,Macro(stdexten,%s,SIP/%s)\n",g_row[1],g_row[1],g_row[1]);
-                fprintf(global_fp, "USER_ID_%s = %s\n",g_row[1],d_row[0]);
-                fprintf(global_fp, "USER_LEVEL_%s = %s\n",g_row[1],d_row[1]);
-            }
         }else{
             memset(sql_tmp,0,sizeof(sql_tmp));
             sprintf(sql_tmp,"select UserId from t_paging_deviceGroups JOIN t_paging_userGroups on t_paging_deviceGroups.GroupId = t_paging_userGroups.GroupId where DeviceId = %s group by UserId",g_row[0]);

+ 6 - 3
usr/src/generate_extension_conf.c

@@ -47,6 +47,7 @@ const unsigned int g_db_port = 3306;
 char dialrule[MIDLE_SIZE];
 char ivrstr[MAX_SIZE];
 char inboundstr[MIDLE_SIZE];
+char prompt[MINI_SIZE];
 
 //读取配置文件函数----功能:删除左边空格
 char *l_trim(char *szOutput, const char *szInput)
@@ -290,11 +291,13 @@ g_row[0]\
     if(g_row[5] != NULL){
         sprintf(ivrstr,"%s\nsame => n,Set(CHANNEL(language)=%s)",ivrstr,g_row[5]);
     }
+    memset(prompt, 0, sizeof(prompt));
+    strncpy(prompt,g_row[2],strlen(g_row[2])-4);
     sprintf(ivrstr,"%s\n\
 same => n,Set(COUNT=%s)\n\
 same => n(loop),Background(%s)",ivrstr,\
 g_row[3],\
-g_row[2]
+prompt
     );
     if(strcmp(g_row[4], "0") != 0 && g_row[4] != NULL){
         sprintf(ivrstr,"%s\nsame => n,WaitExten(%s)",ivrstr,g_row[4]);
@@ -387,7 +390,7 @@ fputs("[CallingRule_OutCall]\n",conf_dialrule_fp);
         }
         strcat(dialrule,"}");
         if(g_row[4] != NULL){
-            strcat(dialrule,g_row[2]);
+            strcat(dialrule,g_row[4]);
         }
         strcat(dialrule,")\n");
         fputs(dialrule,conf_dialrule_fp);
@@ -532,7 +535,7 @@ exten => _%s.,1,Macro(calltrigger,${EXTEN})\n\
 exten => _%s.,1,Macro(calltrigger,${EXTEN})\n\
 ",\
 cJSON_GetObjectItem(pJson, "start")->valuestring,\
-cJSON_GetObjectItem(pJson, "end")->valuestring\
+cJSON_GetObjectItem(pJson, "stop")->valuestring\
 );
         }
         else if(strcmp(g_row[1],"paging.featurecodes.config") == 0){

+ 2 - 2
usr/src/generate_trunk_conf.c

@@ -14,6 +14,7 @@ Description : Generate trunk info from mysql to turnk conf file
 #include <errno.h>
 #include <assert.h>
 #include <time.h>
+#include <ctype.h>
 
 #include <mysql/mysql.h>
 
@@ -773,7 +774,7 @@ hassip = %s\n\
 registersip = %s\n\
 hasiax = %s\n\
 registeriax = %s\n\
-context = %s\n\
+context = from-voip\n\
 hasexten = %s\n\
 nat = %s\n\
 directmedia = %s\n\
@@ -802,7 +803,6 @@ trunkObject[i].hassip,\
 trunkObject[i].registersip,\
 trunkObject[i].hasiax,\
 trunkObject[i].registeriax,\
-trunkObject[i].context,\
 trunkObject[i].hasexten,\
 trunkObject[i].nat,\
 trunkObject[i].directmedia,\