Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Synchronize phonebook by network (Read 6553 times)
AgentSmith
YaBB Newbies
*
Offline


Phoner is great!

Posts: 5
Joined: 12. Dec 2016
Synchronize phonebook by network
12. Dec 2016 at 14:26
Print Post  
Is there a way to synchronize phonebooks between PnonerLite softphones, installed on different computers on my network? I can make PhonerLite to use phonebook.csv, stored on network share (by creating a symlink to it in folder, where phonebook is stored), but i have noticed, that when i close program? it saves phonebook, and when i close 4 clients on 4 PCs, only changes, that were made in LAST closed PhonerLite, are in file. Other are simply rewritten. As far i see now only one way  - give only one user read/write permissions to share with phonebook and make all changes on it. Is there any option to change the behavior of program: 1) make it to just add a string into phonebook in realtime (and read it on othe PC without restart); 2) or make it store contacts in some database (SQL etc), as an option?
  
Back to top
 
IP Logged
 
Phoner Admin
YaBB Administrator
*****
Offline



Posts: 11406
Location: Germany
Joined: 12. Oct 2003
Gender: Male
Re: Synchronize phonebook by network
Reply #1 - 12. Dec 2016 at 14:39
Print Post  
Keep in mind that PhonerLite is just a hobby project of mine for my personal use. I never had the need for sharing phone books.
The only thing I needed for my own was the possibility to import my Google Contacts - that is implemented therefore  Wink

If you need a softphone with some centralized data, you have to look for a different solution. PhonerLite is NOT the right solution for you. Sorry.
« Last Edit: 13. Dec 2016 at 08:51 by Phoner Admin »  
Back to top
WWW  
IP Logged
 
AgentSmith
YaBB Newbies
*
Offline


Phoner is great!

Posts: 5
Joined: 12. Dec 2016
Re: Synchronize phonebook by network
Reply #2 - 12. Dec 2016 at 17:52
Print Post  
So... If anyone needs it, i found solution:

1) Make a network share on your server and make sure all client PCs have R\W access to it;
2) Copy your phonebook.csv file to network share with names for each client - client1.csv, client2.csv, client3,csv etc.;
3) On each PC make a symlink to phonebook.csv file in network folder -DELETE file phonebook.txt in your program or AppData folder, then open CMD and execute a command - mklink /H "c:\PhonerLite\phonebook.csv" "\\SERVER\RealPhonebook\client1.csv" (replace paths with correct for your case);
4) Make sure your client reads phonebook file correctly;
5) Create on server in folder, where your phonebooks are stored batch and vbs files for merge, deduplicate merged results and make all phonebooks equal:

sync.bat: (merges all files)
@echo off
type nul > temp.csv
type nul > sync.csv,
copy *.csv temp.csv
for /f "delims=" %%I in (temp.csv) do findstr /X /C:"%%I" sync.csv >NUL ||(echo;%%I)>>sync.csv
del temp.csv
exit

cleanfile.vbs (Removes SUB simbol at the end of merged file, i am ukrainian, maybe it appears because of ukrainian names in phonebook)

Dim objFS, objFile, strPath, arrTemp
strPath = "sync.csv"
Set objFS = CreateObject("Scripting.FileSystemObject")
If objFS.FileExists(strPath) Then
    Set objFile = objFS.OpenTextFile(strPath, 1)
    arrTemp = Split(objFile.ReadAll, vbNewLine)
    objFile.Close
    For i = 0 To UBound(arrTemp)
        If InStr(1, arrTemp(i), "
", vbTextCompare) > 0 Then arrTemp(i) = Replace(arrTemp(i), "
", "")
    Next
    Set objFile = objFS.CreateTextFile(strPath, True)
    objFile.Write Join(arrTemp, vbNewLine)
    objFile.Close
    Set objFile = Nothing
End If
Set objFS = Nothing
WScript.Quit 0

deduplicate.bat (removes duplicate lines from merged file)

@echo off
setlocal disableDelayedExpansion
set "file=sync.csv"
set "line=%file%.line"
set "deduped=result.csv"
:Cheesyefine a variable containing a linefeed character
set LF=^


::The 2 blank lines above are critical, do not remove
>"%deduped%" (
  for /f usebackq^ eol^=^%LF%%LF%^ delims^= %%A in ("sync.csv") do (
    set "ln=%%A"
    setlocal enableDelayedExpansion
    >"%line%" (echo !ln:\=\\!)
    >nul findstr /xlg:"%line%" "%deduped%" || (echo !ln!)
    endlocal
  )
)
>nul move /y "%deduped%" "ready.csv"
2>nul del "%line%"
exit

clean.bat (removes temp files and replaces all your phonebooks witn deduplicated merged file, i made also a backup option to folder backup)

@echo off
copy client*.csv D:\mergetest\csv\backup
copy ready.csv client1.csv
copy ready.csv client2.csv
copy ready.csv client3.csv
del sync.csv
copy ready.csv D:\mergetest\csv\backup
del ready.csv
exit

makephonebook.bat (main bat file, that launches all processes)

@ECHO OFF
START "" sync.bat
ping 127.0.0.1 -n 10 >nul
start /w wscript.exe  "cleanfile.vbs"
ping 127.0.0.1 -n 10 >nul
START "" deduplicate.bat
ping 127.0.0.1 -n 10 >nul
START "" clean.bat
exit

6) On server add makephonebook.bat to tasks list WHEN ALL YOUR CLIENTS ARE NOT ONLINE, for example in 2:00 AM, or run it manually after closing all PhonerLite copies on PCs in your network

7) Have fun! Smiley
  
Back to top
 
IP Logged
 
Phoner Admin
YaBB Administrator
*****
Offline



Posts: 11406
Location: Germany
Joined: 12. Oct 2003
Gender: Male
Re: Synchronize phonebook by network
Reply #3 - 13. Dec 2016 at 08:52
Print Post  
Thanks for your shown solution. Hopefully this helps people with the same needs.
  
Back to top
WWW  
IP Logged
 
AgentSmith
YaBB Newbies
*
Offline


Phoner is great!

Posts: 5
Joined: 12. Dec 2016
Re: Synchronize phonebook by network
Reply #4 - 13. Dec 2016 at 17:04
Print Post  
If you want to run sync process as a Windows task, just add to each .bat (NOT .vbs) file path to your working directory, for example:
@ECHO OFF
D:
cd D:\mergetest\csv

And create a task to run makephonebook.bat on your server or PC, where client phonebooks are stored, at 02.00 AM (or any time you want) everyday.
Tested and working without any problems.
  
Back to top
 
IP Logged
 
federicososa1
YaBB Newbies
*
Offline


Phoner is great!

Posts: 4
Joined: 31. Jul 2017
Re: Synchronize phonebook by network
Reply #5 - 01. Sep 2017 at 14:34
Print Post  
Hi AgentSmith:

I know the thread is a Little bit old, but i was looking for this but i got an Error when using the mklink when using cmd as normal user "there must be NTFS something else" - difficult to translate to englisch..
When using it as Admin " Username or Password is wrong" 
My Shared Folder is on a Windows Server 2008 share everybody has right to write and read. - Clients are Windows 10 Pro.

do you have any idea?

Thanks!
  
Back to top
 
IP Logged
 
Phoner Admin
YaBB Administrator
*****
Offline



Posts: 11406
Location: Germany
Joined: 12. Oct 2003
Gender: Male
Re: Synchronize phonebook by network
Reply #6 - 07. Sep 2017 at 11:10
Print Post  
Creating links in Windows and the need for a special file system (NTFS) is out of scope of PhonerLite. I can't help with this here. Sorry.
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint