Browse Source

更新脚本生成程序

Yu.ding 4 years ago
parent
commit
24ea2b632f
2 changed files with 42 additions and 7 deletions
  1. 37 2
      usr/src/generate_context_conf.c
  2. 5 5
      usr/src/generate_trunk_conf.c

+ 37 - 2
usr/src/generate_context_conf.c

@@ -313,6 +313,7 @@ mytime()\
             printf("some feild is empty!\n");
             continue;
         }
+        int setout = 1;
         fprintf(conf_fp, "[DialRule_%s]\n",g_row[1]);
         memset(sql_tmp,0,sizeof(sql_tmp));
         sprintf(sql_tmp,"select exten from t_paging_deviceGroups JOIN t_paging_groups on t_paging_groups.id = t_paging_deviceGroups.GroupId where DeviceId = %s",g_row[0]);
@@ -328,6 +329,36 @@ mytime()\
             }
             fprintf(conf_fp, "include => extens-group-%s\n", d_row[0]);
         }
+        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]);
+        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;
+            }
+            int id = atoi(d_row[1]);
+            switch(id){
+                case 1:
+                    fprintf(conf_fp, "include => paging-group-%s\n", d_row[0]);
+                    break;
+                case 9:
+                    if(setout){
+                        fprintf(conf_fp, "include => CallingRule_OutCall\n");
+                        setout = 0;
+                    }
+                    break;
+            }
+        }
     }
 
     //IP话机根据所绑定的用户赋予所在group的权限。
@@ -343,6 +374,7 @@ mytime()\
             printf("some feild is empty!\n");
             continue;
         }
+        int setout = 1;
         fprintf(conf_fp, "[DialRule_%s]\n",g_row[0]);
         memset(sql_tmp,0,sizeof(sql_tmp));
         sprintf(sql_tmp,"select exten,t_paging_userServices.tPagingServiceId as service_id from t_paging_groups\
@@ -350,7 +382,7 @@ mytime()\
         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)",g_row[0]);
+        where t_paging_devices.exten=%s) order by t_paging_userServices.tPagingServiceId",g_row[0]);
         if (executesql(sql_tmp)){
             print_mysql_error(NULL);
             exit(1);
@@ -370,7 +402,10 @@ mytime()\
                     fprintf(conf_fp, "include => extens-group-%s\n", d_row[0]);
                     break;
                 case 9:
-                    fprintf(conf_fp, "include => CallingRule_OutCall\n");
+                    if(setout){
+                        fprintf(conf_fp, "include => CallingRule_OutCall\n");
+                        setout = 0;
+                    }
                     break;
             }
         }

+ 5 - 5
usr/src/generate_trunk_conf.c

@@ -865,16 +865,16 @@ trunkObject[i].allow\
                 if (strcmp(trunkObject[i].hassip, "") != 0 && strcmp(trunkObject[i].host, "") != 0 && strcmp(trunkObject[i].voipusername, "") != 0){
                     memset(registrationString, 0, sizeof(registrationString));
 
-                    if (strcmp(trunkObject[i].fromdomain, "") == 0 || strstr(trunkObject[i].voipusername, "@") != NULL){
+                    if (strcmp(trunkObject[i].fromdomain, "") == 0 || strstr(trunkObject[i].authuser, "@") != NULL){
                         // register="${USERNAME}@${FROMDOMAIN}:${SECRET}${AUTHUSER}@${HOST}:${PORT}"
-                        sprintf(registrationString, "%s:%s:%s@%s:%s", trunkObject[i].voipusername, trunkObject[i].voipsecret, \
-                                                                    trunkObject[i].authuser, trunkObject[i].host, \
+                        sprintf(registrationString, "%s:%s:%s@%s:%s", trunkObject[i].authuser, trunkObject[i].voipsecret, \
+                                                                    trunkObject[i].voipusername, trunkObject[i].host, \
                                                                     trunkObject[i].port);
                         // printf("%d\nregistrationString:%s\n", __LINE__, registrationString);
                     }else{
                         // register="${USERNAME}:${SECRET}${AUTHUSER}@${HOST}:${PORT}"
-                        sprintf(registrationString, "%s@%s:%s:%s@%s:%s", trunkObject[i].voipusername, trunkObject[i].fromdomain, \
-                                                                        trunkObject[i].voipsecret, trunkObject[i].authuser, \
+                        sprintf(registrationString, "%s@%s:%s:%s@%s:%s", trunkObject[i].authuser, trunkObject[i].fromdomain, \
+                                                                        trunkObject[i].voipsecret, trunkObject[i].voipusername, \
                                                                         trunkObject[i].host, trunkObject[i].port);
                     }