首页 > 代码库 > UE-行文-js-20141125
UE-行文-js-20141125
function Trim(str)
{
//把str首尾的空格去掉
var temp1 = str.replace(/(^\s*)|(\s*$)/g, "");
//把str首尾的单引号去掉
var temp2 = temp1.replace(/(^‘*)|(‘*$)/g, "");
//把str首尾的双引号去掉
var temp3 = temp2.replace(/(^"*)|("*$)/g, "");
return temp3;
}
//数组分组
function count_str(text_all,str_f)
{
var result = "";
result = text_all.split(str_f);
//return result.length - 1;
return result;
}
UltraEdit.activeDocument.findReplace.regExp = true;
var str_f = "^db";
var str_s = "^select";
//UltraEdit.activeDocument.bottom(); //跳转到文件结尾。
//==mongo.find==
UltraEdit.document[0].write("\n===========\n")
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.find(str_f); //查找字符串 str_f
while (UltraEdit.activeDocument.isFound()) //如果找到要查询的字符串,则执行下面程序
{
UltraEdit.activeDocument.selectLine();
line = UltraEdit.activeDocument.selection;
//UltraEdit.messageBox("find: "+line);
//var array = line.split(":"); //分成数组
var array = count_str(line,":");
var arr2 = array[0].split("{");
var arr3 = array[1].split("}");
var arr4 = arr2[0].split(".");
//UltraEdit.messageBox(arr4[1]+","+arr2[1]+","+arr3[0]);
var tab_name = arr4[1];
var key_name2 = arr2[1];
var key_name = Trim(key_name2)
var key_value2 = arr3[0];
var key_value = http://www.mamicode.com/Trim(key_value2)
var Filed_0 = ‘db.‘+tab_name+‘.find({"‘+key_name+‘":"‘+key_value+‘"},{"logicalDel":1}).pretty()‘;
//var Filed_1 = ‘db.‘+db_name+‘.remove({"‘+key_name+‘":"‘+key_value+‘"})‘;
//var Filed_2 = ‘db.‘+tab_name+‘.update({"‘+key_name+‘":"‘+key_value+‘"},{$set:{"logicalDel":NumberInt(1)}})‘;
//UltraEdit.messageBox(Filed_0+"\n"+Filed_1);
//UltraEdit.messageBox(Filed_2);
UltraEdit.document[0].write(Filed_0+"\n");
//UltraEdit.document[0].write(Filed_2+"\n")
UltraEdit.activeDocument.findReplace.find(str_f);
}
UltraEdit.document[0].write("\n===========\n")
//==mongo.update==
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.find(str_f); //查找字符串 str_f
while (UltraEdit.activeDocument.isFound()) //如果找到要查询的字符串,则执行下面程序
{
UltraEdit.activeDocument.selectLine();
line = UltraEdit.activeDocument.selection;
//UltraEdit.messageBox("find: "+line);
//var array = line.split(":"); //分成数组
var array = count_str(line,":");
var arr2 = array[0].split("{");
var arr3 = array[1].split("}");
var arr4 = arr2[0].split(".");
//UltraEdit.messageBox(arr4[1]+","+arr2[1]+","+arr3[0]);
var tab_name = arr4[1];
var key_name2 = arr2[1];
var key_name = Trim(key_name2)
var key_value2 = arr3[0];
var key_value = http://www.mamicode.com/Trim(key_value2)
//var Filed_0 = ‘db.‘+tab_name+‘.find({"‘+key_name+‘":"‘+key_value+‘"},{"logicalDel":1}).pretty()‘;
//var Filed_1 = ‘db.‘+db_name+‘.remove({"‘+key_name+‘":"‘+key_value+‘"})‘;
var Filed_2 = ‘db.‘+tab_name+‘.update({"‘+key_name+‘":"‘+key_value+‘"},{$set:{"logicalDel":NumberInt(1)}})‘;
//UltraEdit.messageBox(Filed_0+"\n"+Filed_1);
//UltraEdit.messageBox(Filed_2);
//UltraEdit.document[1].write(Filed_0+"\n");
UltraEdit.document[0].write(Filed_2+"\n")
UltraEdit.activeDocument.findReplace.find(str_f);
}
//==mysql.select==
UltraEdit.document[0].write("\n===========\n")
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.find(str_s); //查找字符串 str_f
while (UltraEdit.activeDocument.isFound()) //如果找到要查询的字符串,则执行下面程序
{
UltraEdit.activeDocument.selectLine();
line = UltraEdit.activeDocument.selection;
//UltraEdit.messageBox("find: "+line);
var arr = count_str(line," ");
//UltraEdit.messageBox(arr[3]+","+arr[5]);
var table_name=Trim(arr[3]);
var arr2 = count_str(arr[5],"=");
//UltraEdit.messageBox(arr2[0]+","+arr2[1]);
var Column_name =Trim(arr2[0]);
var Column_value2 =Trim(arr2[1]);
var Column_value =http://www.mamicode.com/count_str(Column_value2,"/"")
var Filed_4 = ‘select * from ‘+table_name+‘ where ‘+Column_name+‘="‘+Column_value[0]+‘"\\G‘;
//UltraEdit.messageBox(Filed_4);
UltraEdit.document[0].write(Filed_4+"\n")
UltraEdit.activeDocument.findReplace.find(str_s);
}
//==mysql.update==
UltraEdit.document[0].write("\n===========\n")
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.find(str_s); //查找字符串 str_f
while (UltraEdit.activeDocument.isFound()) //如果找到要查询的字符串,则执行下面程序
{
UltraEdit.activeDocument.selectLine();
line = UltraEdit.activeDocument.selection;
//UltraEdit.messageBox("find: "+line);
var arr = count_str(line," ");
//UltraEdit.messageBox(arr[3]+","+arr[5]);
var table_name=Trim(arr[3]);
var arr2 = count_str(arr[5],"=");
//UltraEdit.messageBox(arr2[0]+","+arr2[1]);
var Column_name =Trim(arr2[0]);
var Column_value2 =Trim(arr2[1]);
var Column_value =http://www.mamicode.com/count_str(Column_value2,"/"")
var Filed_4 = ‘update ‘+table_name+‘ set LogicalDel=1 where ‘+Column_name+‘="‘+Column_value[0]+‘";‘;
//UltraEdit.messageBox(Filed_4);
UltraEdit.document[0].write(Filed_4+"\n")
UltraEdit.activeDocument.findReplace.find(str_s);
}
UltraEdit.document[0].write("commit;\n")
{
//把str首尾的空格去掉
var temp1 = str.replace(/(^\s*)|(\s*$)/g, "");
//把str首尾的单引号去掉
var temp2 = temp1.replace(/(^‘*)|(‘*$)/g, "");
//把str首尾的双引号去掉
var temp3 = temp2.replace(/(^"*)|("*$)/g, "");
return temp3;
}
//数组分组
function count_str(text_all,str_f)
{
var result = "";
result = text_all.split(str_f);
//return result.length - 1;
return result;
}
UltraEdit.activeDocument.findReplace.regExp = true;
var str_f = "^db";
var str_s = "^select";
//UltraEdit.activeDocument.bottom(); //跳转到文件结尾。
//==mongo.find==
UltraEdit.document[0].write("\n===========\n")
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.find(str_f); //查找字符串 str_f
while (UltraEdit.activeDocument.isFound()) //如果找到要查询的字符串,则执行下面程序
{
UltraEdit.activeDocument.selectLine();
line = UltraEdit.activeDocument.selection;
//UltraEdit.messageBox("find: "+line);
//var array = line.split(":"); //分成数组
var array = count_str(line,":");
var arr2 = array[0].split("{");
var arr3 = array[1].split("}");
var arr4 = arr2[0].split(".");
//UltraEdit.messageBox(arr4[1]+","+arr2[1]+","+arr3[0]);
var tab_name = arr4[1];
var key_name2 = arr2[1];
var key_name = Trim(key_name2)
var key_value2 = arr3[0];
var key_value = http://www.mamicode.com/Trim(key_value2)
var Filed_0 = ‘db.‘+tab_name+‘.find({"‘+key_name+‘":"‘+key_value+‘"},{"logicalDel":1}).pretty()‘;
//var Filed_1 = ‘db.‘+db_name+‘.remove({"‘+key_name+‘":"‘+key_value+‘"})‘;
//var Filed_2 = ‘db.‘+tab_name+‘.update({"‘+key_name+‘":"‘+key_value+‘"},{$set:{"logicalDel":NumberInt(1)}})‘;
//UltraEdit.messageBox(Filed_0+"\n"+Filed_1);
//UltraEdit.messageBox(Filed_2);
UltraEdit.document[0].write(Filed_0+"\n");
//UltraEdit.document[0].write(Filed_2+"\n")
UltraEdit.activeDocument.findReplace.find(str_f);
}
UltraEdit.document[0].write("\n===========\n")
//==mongo.update==
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.find(str_f); //查找字符串 str_f
while (UltraEdit.activeDocument.isFound()) //如果找到要查询的字符串,则执行下面程序
{
UltraEdit.activeDocument.selectLine();
line = UltraEdit.activeDocument.selection;
//UltraEdit.messageBox("find: "+line);
//var array = line.split(":"); //分成数组
var array = count_str(line,":");
var arr2 = array[0].split("{");
var arr3 = array[1].split("}");
var arr4 = arr2[0].split(".");
//UltraEdit.messageBox(arr4[1]+","+arr2[1]+","+arr3[0]);
var tab_name = arr4[1];
var key_name2 = arr2[1];
var key_name = Trim(key_name2)
var key_value2 = arr3[0];
var key_value = http://www.mamicode.com/Trim(key_value2)
//var Filed_0 = ‘db.‘+tab_name+‘.find({"‘+key_name+‘":"‘+key_value+‘"},{"logicalDel":1}).pretty()‘;
//var Filed_1 = ‘db.‘+db_name+‘.remove({"‘+key_name+‘":"‘+key_value+‘"})‘;
var Filed_2 = ‘db.‘+tab_name+‘.update({"‘+key_name+‘":"‘+key_value+‘"},{$set:{"logicalDel":NumberInt(1)}})‘;
//UltraEdit.messageBox(Filed_0+"\n"+Filed_1);
//UltraEdit.messageBox(Filed_2);
//UltraEdit.document[1].write(Filed_0+"\n");
UltraEdit.document[0].write(Filed_2+"\n")
UltraEdit.activeDocument.findReplace.find(str_f);
}
//==mysql.select==
UltraEdit.document[0].write("\n===========\n")
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.find(str_s); //查找字符串 str_f
while (UltraEdit.activeDocument.isFound()) //如果找到要查询的字符串,则执行下面程序
{
UltraEdit.activeDocument.selectLine();
line = UltraEdit.activeDocument.selection;
//UltraEdit.messageBox("find: "+line);
var arr = count_str(line," ");
//UltraEdit.messageBox(arr[3]+","+arr[5]);
var table_name=Trim(arr[3]);
var arr2 = count_str(arr[5],"=");
//UltraEdit.messageBox(arr2[0]+","+arr2[1]);
var Column_name =Trim(arr2[0]);
var Column_value2 =Trim(arr2[1]);
var Column_value =http://www.mamicode.com/count_str(Column_value2,"/"")
var Filed_4 = ‘select * from ‘+table_name+‘ where ‘+Column_name+‘="‘+Column_value[0]+‘"\\G‘;
//UltraEdit.messageBox(Filed_4);
UltraEdit.document[0].write(Filed_4+"\n")
UltraEdit.activeDocument.findReplace.find(str_s);
}
//==mysql.update==
UltraEdit.document[0].write("\n===========\n")
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.find(str_s); //查找字符串 str_f
while (UltraEdit.activeDocument.isFound()) //如果找到要查询的字符串,则执行下面程序
{
UltraEdit.activeDocument.selectLine();
line = UltraEdit.activeDocument.selection;
//UltraEdit.messageBox("find: "+line);
var arr = count_str(line," ");
//UltraEdit.messageBox(arr[3]+","+arr[5]);
var table_name=Trim(arr[3]);
var arr2 = count_str(arr[5],"=");
//UltraEdit.messageBox(arr2[0]+","+arr2[1]);
var Column_name =Trim(arr2[0]);
var Column_value2 =Trim(arr2[1]);
var Column_value =http://www.mamicode.com/count_str(Column_value2,"/"")
var Filed_4 = ‘update ‘+table_name+‘ set LogicalDel=1 where ‘+Column_name+‘="‘+Column_value[0]+‘";‘;
//UltraEdit.messageBox(Filed_4);
UltraEdit.document[0].write(Filed_4+"\n")
UltraEdit.activeDocument.findReplace.find(str_s);
}
UltraEdit.document[0].write("commit;\n")
UE-行文-js-20141125
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。