|
@@ -36,7 +36,7 @@ MYSQL_ROW d_row; // 字符串数组,mysql 记录行
|
|
#define VERSION "V1.0.1"
|
|
#define VERSION "V1.0.1"
|
|
|
|
|
|
#define QUERY_INTERCOM_SQL "select id,exten from t_paging_devices where type_id in('2','5')"
|
|
#define QUERY_INTERCOM_SQL "select id,exten from t_paging_devices where type_id in('2','5')"
|
|
-#define QUERY_IPPHONE_SQL "select exten from t_paging_devices where type_id = '3'"
|
|
|
|
|
|
+#define QUERY_IPPHONE_SQL "select id,exten,user_id from t_paging_devices where type_id = '3'"
|
|
|
|
|
|
char g_host_name[MINI_SIZE];
|
|
char g_host_name[MINI_SIZE];
|
|
char g_user_name[MINI_SIZE];
|
|
char g_user_name[MINI_SIZE];
|
|
@@ -315,7 +315,9 @@ mytime()\
|
|
}
|
|
}
|
|
int setout = 1;
|
|
int setout = 1;
|
|
fprintf(conf_fp, "[DialRule_%s]\n",g_row[1]);
|
|
fprintf(conf_fp, "[DialRule_%s]\n",g_row[1]);
|
|
|
|
+ fprintf(conf_fp, "include => call-trigger\n");
|
|
memset(sql_tmp,0,sizeof(sql_tmp));
|
|
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]);
|
|
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]);
|
|
if (executesql(sql_tmp)){
|
|
if (executesql(sql_tmp)){
|
|
print_mysql_error(NULL);
|
|
print_mysql_error(NULL);
|
|
@@ -330,6 +332,23 @@ mytime()\
|
|
fprintf(conf_fp, "include => extens-group-%s\n", d_row[0]);
|
|
fprintf(conf_fp, "include => extens-group-%s\n", d_row[0]);
|
|
}
|
|
}
|
|
memset(sql_tmp,0,sizeof(sql_tmp));
|
|
memset(sql_tmp,0,sizeof(sql_tmp));
|
|
|
|
+ //获取对讲终端所在队列的管理员ID
|
|
|
|
+ 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]);
|
|
|
|
+ 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){
|
|
|
|
+ printf("some feild is empty!\n");
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ int q = 100000 + atoi(d_row[0]);
|
|
|
|
+ fprintf(conf_fp, "include => manager-queue-%d\n", q);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ memset(sql_tmp,0,sizeof(sql_tmp));
|
|
sprintf(sql_tmp,"select exten,t_paging_userServices.tPagingServiceId as service_id from t_paging_groups\
|
|
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_userGroups on t_paging_groups.id = t_paging_userGroups.GroupId\
|
|
JOIN t_paging_userServices on t_paging_userServices.UserId = t_paging_userGroups.UserId\
|
|
JOIN t_paging_userServices on t_paging_userServices.UserId = t_paging_userGroups.UserId\
|
|
@@ -359,6 +378,7 @@ mytime()\
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
//IP话机根据所绑定的用户赋予所在group的权限。
|
|
//IP话机根据所绑定的用户赋予所在group的权限。
|
|
@@ -370,64 +390,84 @@ mytime()\
|
|
g_res = mysql_store_result(g_conn); // 从服务器传送结果集至本地,mysql_use_result直接使用服务器上的记录集
|
|
g_res = mysql_store_result(g_conn); // 从服务器传送结果集至本地,mysql_use_result直接使用服务器上的记录集
|
|
|
|
|
|
while ((g_row=mysql_fetch_row(g_res))){ // 打印结果集
|
|
while ((g_row=mysql_fetch_row(g_res))){ // 打印结果集
|
|
- if (g_row[0] == NULL){
|
|
|
|
|
|
+ if (g_row[0] == NULL || g_row[1] == NULL){
|
|
printf("some feild is empty!\n");
|
|
printf("some feild is empty!\n");
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
int setout = 1;
|
|
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\
|
|
|
|
- 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[0]);
|
|
|
|
- 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, "[DialRule_%s]\n",g_row[1]);
|
|
|
|
+ fprintf(conf_fp, "include => call-trigger\n");
|
|
|
|
+ if(g_row[2]){
|
|
|
|
+ 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);
|
|
}
|
|
}
|
|
- int id = atoi(d_row[1]);
|
|
|
|
- switch(id){
|
|
|
|
- case 1:
|
|
|
|
- fprintf(conf_fp, "include => paging-group-%s\n", d_row[0]);
|
|
|
|
- break;
|
|
|
|
- case 4:
|
|
|
|
- fprintf(conf_fp, "include => extens-group-%s\n", d_row[0]);
|
|
|
|
- break;
|
|
|
|
- case 9:
|
|
|
|
- if(setout){
|
|
|
|
- fprintf(conf_fp, "include => CallingRule_OutCall\n");
|
|
|
|
- setout = 0;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
|
|
+ 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 4:
|
|
|
|
+ fprintf(conf_fp, "include => extens-group-%s\n", d_row[0]);
|
|
|
|
+ break;
|
|
|
|
+ case 9:
|
|
|
|
+ if(setout){
|
|
|
|
+ fprintf(conf_fp, "include => CallingRule_OutCall\n");
|
|
|
|
+ setout = 0;
|
|
|
|
+ }
|
|
|
|
+ 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[0]);
|
|
|
|
- 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;
|
|
|
|
|
|
+ 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_fp, "include => featurecodes\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]);
|
|
|
|
+ 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){
|
|
|
|
+ printf("some feild is empty!\n");
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ int q = 100000 + atoi(d_row[0]);
|
|
|
|
+ fprintf(conf_fp, "include => manager-queue-%d\n", q);
|
|
}
|
|
}
|
|
- fprintf(conf_fp, "include => DialRule_users\n");
|
|
|
|
- fprintf(conf_fp, "include => featurecodes\n");
|
|
|
|
- fprintf(conf_users_fp, "exten => %s,1,Macro(stdexten,%s,SIP/%s)\n",g_row[0],g_row[0],g_row[0]);
|
|
|
|
- fprintf(global_fp, "USER_ID_%s = %s\n",g_row[0],d_row[0]);
|
|
|
|
- fprintf(global_fp, "USER_LEVEL_%s = %s\n",g_row[0],d_row[1]);
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
fclose(conf_fp);
|
|
fclose(conf_fp);
|
|
fclose(conf_users_fp);
|
|
fclose(conf_users_fp);
|