Вверх ↑
Ответов: 113
Рейтинг: 1
#1: 2020-08-06 18:01:45 ЛС | профиль | цитата
всем привет, подскажите как можно оптимизировать схему. Хочу сделать такой вариант работы с файлами: в папку добавляем фотографии, программа ищет файлы и записывает в базу данных, если добавились новые , то они также записываются в базу данных. В случае удаления файла ему присваивается значение - скрытый (Hide="1"), если вдруг его удалил в корзину и вернут обратно, то снова видимый (Hide="1").
сам процесс определения наличия файла и присвоения ему значения очень долгий - UPDATE file SET Hide = "1" WHERE Name = "%1" или UPDATE file SET Hide = "0" WHERE Name = "%1" . есть ли варианты как это оптимизировать ?

Add(FormatStr,2590690,1189,462)
{
Mask="UPDATE file SET Hide = "1" WHERE Name = "%1";"
link(onFString,14437340:doWork2,[])
link(Str1,5032413:Var2,[])
}
Add(MainForm,2953706,35,49)
{
Width=418
Height=506
BorderStyle=3
Position=1
Point(Handle)
Point(onClose)
link(onCreate,5558056:doEvent1,[])
link(onClose,1827425:In,[])
}
Add(Button,13228053,126,119)
{
Left=15
Top=10
link(onClick,1427945:doEvent1,[])
}
Add(MTStrTbl,3474883,1337,168)
{
Left=15
Top=45
Width=385
Height=420
Name="tbl"
Columns=#1:1|1:2|1:3|1:4|1:5|
}
Add(MST_RowAction,1415183,1281,168)
{
MSTControl="tbl"
}
Add(Ini,6101227,399,63)
{
FileName="Settings.ini"
Section="Section1"
Key="Startdir"
Type=1
link(onResult,3910624:doValue,[])
}
Add(Browse,1417443,301,133)
{
Edit=1
NewDirButton=1
Point(doDefaultFolder)
link(onBrowse,13505115:doEvent1,[])
}
Add(Hub,13505115,350,133)
{
OutCount=3
link(onEvent1,6101227:doWrite,[(382,139)(382,76)])
link(onEvent3,10359188:doSearch,[])
}
Add(Hub,1427945,252,119)
{
OutCount=3
link(onEvent1,10137780:doWork3,[(284,125)])
link(onEvent2,14731764:doClear,[(290,132)(290,97)])
link(onEvent3,1417443:doBrowse,[])
}
Add(HubEx,10137780,280,63)
{
link(onEvent,6101227:doRead,[])
}
Add(FileSearch,10359188,399,147)
{
link(onSearch,8916523:doEvent1,[(537,153)(537,69)])
link(onEndSearch,6239381:doTimer,[(536,160)(536,265)])
link(Dir,9381493:Var,[])
}
Add(GlobalVar,3910624,448,63)
{
Name="startdir"
}
Add(DoData,2820051,210,140)
{
link(onEventData,1417443:doDefaultFolder,[])
link(Data,6053331:Var,[])
}
Add(GlobalVar,6053331,210,98)
{
Name="startdir"
}
Add(Hub,5558056,140,63)
{
OutCount=3
link(onEvent1,10137780:doWork2,[])
link(onEvent2,2820051:doData,[(182,76)(182,146)])
link(onEvent3,5631628:doEvent1,[(168,83)(168,114)(65,114)(65,258)])
}
Add(GlobalVar,9381493,406,112)
{
Name="startdir"
}
Add(If_else,14635017,595,126)
{
Op2=String()
link(onFalse,8426976:doCompare,[])
link(Op1,3028391:Var2,[])
}
Add(StrMask,8426976,644,133)
{
Mask="*.jpg"
link(onTrue,8648575:doCompare,[])
link(Str,211618:Var2,[])
AddHint(-56,34,36,13,Mask)
}
Add(StrMask,8648575,693,140)
{
Mask="*.JPG"
link(onTrue,8164732:doString,[])
link(Str,947588:Var2,[])
AddHint(-49,31,42,13,Mask)
}
Add(FilePartElm,16044689,595,63)
{
Point(Part)
}
Add(Hub,8916523,560,63)
{
OutCount=5
link(onEvent1,16044689:doPart,[])
link(onEvent2,12436035:doReplace,[])
link(onEvent3,5269118:doRead,[])
link(onEvent4,14635017:doCompare,[(584,90)(584,132)])
}
Add(FilePartElm,9790652,700,70)
{
Mode=0
link(onPart,3559165:doTrim,[])
}
Add(Trim,3559165,749,70)
{
Char="\"
Point(Result)
}
Add(GetDataEx,3028391,595,105)
{
link(Data,16044689:Part,[])
}
Add(GetDataEx,211618,644,105)
{
Angle=3
link(Data,3028391:Var3,[])
}
Add(FormatStr,8164732,742,147)
{
DataCount=4
Mask="SELECT\r\ncase when count (*)=0 then 'NotFound'\r\n else max(Name) end\r\n||';'\r\n||'%1'\r\n||';'\r\n||'%2'\r\n||';'\r\n||'%3'\r\n||';'\r\n||'%4'\r\n||';'\r\n||'Stat'\r\n||';'\r\n||'Hide'\r\nFROM file\r\nWHERE Name =("%1");"
link(onFString,13892799:doQuery,[])
link(Str1,947588:Var3,[(748,110)])
link(Str2,3559165:Result,[])
link(Str3,5269118:DateModify,[(762,128)(832,128)])
link(Str4,5269118:FileSize,[(769,131)(839,131)])
}
Add(GetDataEx,947588,693,105)
{
Angle=3
link(Data,211618:Var3,[])
}
Add(FileAttributes,5269118,812,77)
{
Format="DMY_hm"
Point(FileSize)
}
Add(DS_SQLite,5372330,546,518)
{
Name="database"
Point(onError)
link(FileName,11246006:Var3,[(552,502)])
link(onError,2733831:doValue,[])
}
Add(FileTools,11216278,392,511)
{
link(onEnd,8852679:doEvent,[])
link(FileName,11246006:Var2,[])
}
Add(VisualStrings,15496986,399,399)
{
Lines=#12:Database.wdb|
Width=81
}
Add(DSC_Exec,10834091,546,462)
{
DSManager="database"
link(onError,2378110:doValue,[])
link(SQL,1747880:Text,[])
}
Add(IndexToChanel,8852679,448,511)
{
link(onEvent1,5617543:doEvent1,[(492,517)(492,461)])
link(onEvent2,16007518:doWork2,[])
}
Add(Hub,5617543,504,455)
{
OutCount=3
link(onEvent1,16007518:doWork1,[(529,461)])
link(onEvent2,10834091:doExec,[])
}
Add(Dir,15926344,315,231)
{
Point(MyDocumentDir)
}
Add(StrList,13928195,126,350)
{
Strings=#6:%3;Dir|20:%3\Database;Database|16:%3\Backup;Backup|16:%3\Export;Export|
}
Add(ArrayEnum,10030415,140,434)
{
link(onItem,15168602:doSplit,[(193,440)(193,321)])
link(onEndEnum,1763487:doEvent1,[])
link(Array,13928195:Array,[])
}
Add(DirTools,4196025,77,497)
{
Point(doExists)
link(onOK,14122577:doEvent,[])
}
Add(FormatStr,5566409,308,315)
{
DataCount=3
Mask="%2%1"
Point(FString)
link(onFString,4196025:doExists,[(353,321)(353,422)(65,422)(65,524)])
link(Str2,15926344:CurrentDir,[])
link(Str3,16166707:Part,[(328,299)(167,299)])
}
Add(IndexToChanel,14122577,140,497)
{
Point(Data)
link(onEvent1,9220000:doEvent1,[])
link(Data,14465055:Var1,[(146,474)])
}
Add(Registry,2432250,238,490)
{
HKey=1
Value="DataBase"
link(Data,14465055:Var2,[])
link(Key,5729389:Var2,[])
link(Value,15168602:RemaindStr,[])
}
Add(MultiStrData,15168602,252,315)
{
Count=1
link(onPart1,5566409:doString,[])
}
Add(Hub,9220000,196,497)
{
link(onEvent1,2432250:doWrite,[])
link(onEvent2,15926344:doDir,[(229,510)(229,237)])
}
Add(WinTools,10387803,154,203)
{
Point(FileName)
link(Handle,2953706:Handle,[(160,187)(41,187)])
}
Add(FilePartElm,16166707,161,252)
{
Mode=2
Point(Part)
link(onPart,818685:doString,[])
link(FileName,10387803:FileName,[])
}
Add(Hub,5631628,77,252)
{
InCount=2
OutCount=4
link(onEvent1,16166707:doPart,[])
link(onEvent2,10030415:doEnum,[(101,265)(101,440)])
}
Add(FormatStr,818685,245,252)
{
Mask="Software\%1"
Point(FString)
}
Add(Registry,2826727,329,441)
{
HKey=1
Value="DataBase"
link(onRead,5413130:doString,[])
link(Key,5729389:Var3,[(342,397)])
}
Add(FormatStr,5413130,392,441)
{
Mask="%1\%2"
Point(FString)
link(Str2,15496986:Text,[])
}
Add(Hub,1763487,196,441)
{
link(onEvent1,2826727:doRead,[])
link(onEvent2,11216278:doFileExists,[(295,454)(295,538)])
}
Add(HubEx,16007518,525,518)
{
link(onEvent,5372330:doOpen,[])
}
Add(StrList,1747880,546,392)
{
Strings=#19:CREATE TABLE file (|37:id INTEGER PRIMARY KEY AUTOINCREMENT,|17: Name TEXT NULL,|17: Path TEXT NULL,|18: Date1 TEXT NULL,|18: Size TEXT NULL,|17: Stat TEXT NULL,|19: Hide INTEGER NULL|2:);|
}
Add(LineBreak,8095610,448,553)
{
link(Out,5372330:doClose,[(512,559)(512,531)])
Primary=[1827425,-357,-483]
}
Add(Replace,12436035,644,70)
{
link(onReplace,9790652:doPart,[])
link(Sub_str,14427655:Var,[])
}
Add(GlobalVar,14427655,651,28)
{
Name="startdir"
}
Add(DSC_Query,13892799,805,147)
{
DSManager="database"
link(onQuery,15114553:doStr,[])
link(onError,5448304:doValue,[])
}
Add(MT_String,15114553,924,147)
{
link(onResult,9510237:doEvent1,[(966,153)(966,185)(548,185)(548,195)])
}
Add(GetDataEx,14465055,238,469)
{
link(Data,5566409:FString,[(244,363)(314,363)])
}
Add(GetDataEx,5729389,245,392)
{
link(Data,818685:FString,[])
}
Add(GetDataEx,11246006,392,497)
{
link(Data,5413130:FString,[])
}
Add(MultiStrPart,15390091,693,189)
{
Count=6
}
Add(Case,10146551,644,245)
{
Value=String(NotFound)
link(onTrue,5037257:doString,[])
}
Add(DoData,2093922,595,245)
{
link(onEventData,10146551:doCase,[])
link(Data,15390091:Part1,[(601,237)(699,237)])
}
Add(Hub,9510237,560,189)
{
OutCount=3
link(onEvent1,15390091:doSplit,[])
link(onEvent2,2093922:doData,[(584,202)(584,251)])
}
Add(FormatStr,5037257,700,252)
{
DataCount=5
Mask="('%1','%2','%3','%4','New','0'),"
Point(FString)
link(onFString,15360551:doWork2,[(756,258)(756,202)])
link(Str1,15390091:Part2,[])
link(Str2,15390091:Part3,[])
link(Str3,15390091:Part4,[])
link(Str4,15390091:Part5,[])
link(Str5,15390091:Part6,[])
}
Add(StrList,4191527,861,196)
{
}
Add(Replace,7717153,861,266)
{
SubStr="),\r\n;"
DestStr=");"
link(onReplace,16462616:doString,[])
link(Str,4191527:Text,[])
}
Add(FormatStr,5911929,777,259)
{
Mask="%1;"
link(onFString,15360551:doWork3,[(844,265)])
}
Add(Hub,8356559,749,259)
{
OutCount=10
link(onEvent1,5911929:doString,[])
link(onEvent2,7717153:doReplace,[])
link(onEvent3,13955723:doCompare,[(783,279)(783,314)])
link(onEvent10,11978024:doString,[(805,328)(805,398)])
}
Add(FormatStr,16462616,924,266)
{
Mask="INSERT INTO file (Name,Path,Date1,Size,Stat,Hide) VALUES %1;"
Point(FString)
}
Add(DSC_Exec,3130417,924,315)
{
DSManager="database"
link(onError,9210925:doValue,[])
link(SQL,16462616:FString,[])
}
Add(Timer,6239381,553,259)
{
Enable=1
AutoStop=1
link(onTimer,8356559:doEvent1,[])
}
Add(GlobalVar,9210925,994,322)
{
Name="error"
}
Add(GlobalVar,2378110,609,469)
{
Name="error"
}
Add(GlobalVar,2733831,602,525)
{
Name="error"
}
Add(If_else,13955723,812,308)
{
Op2=Integer(1)
link(onTrue,3822349:doWork3,[(851,314)])
link(onFalse,13322663:doEvent1,[])
link(Op1,4191527:Count,[(818,250)(874,250)])
}
Add(HubEx,15360551,840,196)
{
link(onEvent,4191527:doAdd,[])
}
Add(MT_String,2652565,952,637)
{
link(onResult,2531898:doFileExists,[])
}
Add(FileTools,2531898,994,616)
{
link(onEnd,13514935:doEvent,[])
}
Add(GlobalVar,15102907,840,602)
{
Name="startdir"
}
Add(FormatStr,8463911,833,637)
{
Mask="SELECT "%2\"||Path||"\"||Name FROM file \r\n--where Hide=1;"
Point(FString)
link(onFString,15462461:doQuery,[])
link(Str2,15102907:Var,[])
AddHint(-230,191,199,39,Mask)
}
Add(IndexToChanel,13514935,1043,616)
{
Point(Data)
link(onEvent1,1866408:doPart,[])
link(Data,2652565:Str,[(1049,604)(1003,604)(1003,681)(958,681)])
}
Add(DSC_Query,15462461,896,637)
{
DSManager="database"
link(onQuery,2652565:doStr,[])
link(onError,16687435:doValue,[(936,657)(936,699)])
}
Add(Hub,13322663,868,315)
{
link(onEvent1,3130417:doExec,[])
link(onEvent2,3822349:doWork1,[(911,328)(911,258)])
}
Add(HubEx,3822349,847,252)
{
Angle=3
link(onEvent,4191527:doClear,[(851,209)])
}
Add(FormatStr,10511622,1155,616)
{
Mask="UPDATE file SET Hide = "1" WHERE Name = "%1";"
link(onFString,10146195:doWork2,[])
}
Add(DSC_Exec,3298604,1288,616)
{
DSManager="database"
link(onError,696960:doValue,[])
}
Add(GlobalVar,696960,1358,623)
{
Name="error"
}
Add(FilePartElm,1866408,1099,616)
{
Point(Part)
link(onPart,10511622:doString,[])
}
Add(MST_Clear,14731764,301,91)
{
MSTControl="tbl"
}
Add(DSC_Query,10215262,1218,168)
{
DSManager="database"
link(onQuery,1415183:doRowAction,[])
}
Add(FormatStr,11471579,1148,168)
{
DataCount=4
Mask="SELECT\r\nid,Name\r\nFROM file\r\nWHERE Hide =0;"
link(onFString,10215262:doQuery,[])
}
Add(FormatStr,9422051,1155,679)
{
Mask="UPDATE file SET Hide = "0" WHERE Name = "%1";"
link(onFString,10146195:doWork3,[(1201,685)])
}
Add(FilePartElm,14948845,1099,679)
{
Point(Part)
link(onPart,9422051:doString,[])
}
Add(HubEx,10146195,1197,616)
{
link(onEvent,14522306:doEvent1,[])
}
Add(GlobalVar,16687435,945,693)
{
Name="error"
}
Add(StatusBar,11571795,609,609)
{
}
Add(GlobalVar,10321777,539,609)
{
Name="error"
link(onValue,11571795:doText,[])
}
Add(GlobalVar,5448304,861,161)
{
Name="error"
}
Add(FormatStr,12331231,847,728)
{
Mask="SELECT "%2\"||Path||"\"||Name FROM file where Hide=1;"
Point(FString)
link(onFString,4663461:doQuery,[])
link(Str2,1538008:Var,[])
AddHint(39,96,199,26,Mask)
}
Add(MT_String,16516159,952,728)
{
link(onResult,6276387:doFileExists,[])
}
Add(FileTools,6276387,994,707)
{
link(onEnd,717224:doEvent,[])
}
Add(IndexToChanel,717224,1043,707)
{
Point(Data)
link(onEvent2,14948845:doPart,[(1087,720)(1087,685)])
link(Data,16516159:Str,[(1049,695)(1003,695)(1003,772)(958,772)])
}
Add(DSC_Query,4663461,896,728)
{
DSManager="database"
link(onQuery,16516159:doStr,[])
link(onError,10323337:doValue,[(936,748)(936,790)])
}
Add(GlobalVar,10323337,945,784)
{
Name="error"
}
Add(GlobalVar,1538008,854,686)
{
Name="startdir"
}
Add(Hub,14522306,1232,616)
{
InCount=2
link(onEvent1,3298604:doExec,[])
}
Add(DoData,2983242,1001,266)
{
}
Add(IndexToChanel,13195485,1120,462)
{
Point(Data)
link(onEvent1,2590690:doString,[])
link(onEvent2,392218:doString,[(1167,475)(1167,510)])
link(Data,7057670:Var3,[(1126,439)])
}
Add(GlobalVar,12829000,854,357)
{
Name="startdir"
}
Add(FormatStr,11978024,847,392)
{
Mask="SELECT\r\n"%2\"\r\n||Path\r\n||"\"\r\n||Name\r\n||';'\r\n||Hide\r\nFROM file;"
Point(FString)
link(onFString,5692408:doQuery,[])
link(Str2,12829000:Var,[])
AddHint(-47,45,56,104,Mask)
}
Add(DSC_Query,5692408,910,392)
{
DSManager="database"
link(onQuery,414844:doStr,[])
}
Add(Button,4468557,1057,168)
{
Left=345
Top=15
link(onClick,11471579:doString,[])
}
Add(MT_String,414844,966,392)
{
link(onResult,5609116:doEvent1,[])
}
Add(FileTools,3032649,1064,462)
{
link(onEnd,13195485:doEvent,[])
link(FileName,7057670:Var2,[])
}
Add(StrPart,1626735,1064,392)
{
Char=";"
Point(Left)
Point(Right)
link(onPart,604350:doPart,[])
}
Add(Hub,5609116,1022,392)
{
link(onEvent1,1626735:doSplit,[])
link(onEvent2,3032649:doFileExists,[(1050,405)(1050,489)])
}
Add(GetDataEx,7057670,1064,434)
{
link(Data,1626735:Left,[])
}
Add(FormatStr,392218,1224,504)
{
Mask="UPDATE file SET Hide = "0" WHERE Name = "%1";"
link(onFString,14437340:doWork3,[(1271,510)])
link(Str1,5032413:Var3,[(1230,446)])
}
Add(FilePartElm,604350,1189,399)
{
Point(Part)
}
Add(GetDataEx,5032413,1189,441)
{
link(Data,604350:Part,[])
}
Add(DSC_Exec,15758952,1302,462)
{
DSManager="database"
link(onError,3275235:doValue,[])
}
Add(GlobalVar,3275235,1351,469)
{
Name="error"
}
Add(HubEx,14437340,1267,462)
{
link(onEvent,15758952:doExec,[])
}
Add(InfoTip,13719783,742,350)
{
Info=#28:файл существует / отсутсвует|
Width=638
Height=228
}
Add(InfoTip,15166246,742,588)
{
Info=#28:файл существует / отсутсвует|
Width=638
Height=228
}
Add(Hub,12261731,770,637)
{
link(onEvent1,8463911:doString,[])
link(onEvent2,12331231:doString,[(816,650)(816,734)])
}


https://forum.hiasm.com/getfile/39093

--- Добавлено в 2020-08-06 18:07:57


карма: 0
well done turner
0
файлы: 1Projects.zip [580.7KB] [397]
Редактировалось 5 раз(а), последний 2020-08-06 18:07:57