2
OpenERP, Open Source Business Applications
3
Copyright (c) 2011 OpenERP S.A. <http://openerp.com>
5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU Affero General Public License as
7
published by the Free Software Foundation, either version 3 of the
8
License, or (at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU Affero General Public License for more details.
15
You should have received a copy of the GNU Affero General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
21
using System.Collections;
23
using System.Drawing.Imaging;
25
using System.Windows.Forms;
26
using System.Text.RegularExpressions;
29
namespace OpenERPOutlookPlugin
31
public class ConfigManager
33
string openerp_config_file = "openerp_config.ini";
35
public void SaveConfigurationSetting()
37
string filepath = Tools.GetAppFolderPath();
38
OpenERPOutlookPlugin openerp_outlook = Cache.OpenERPOutlookPlugin;
39
OpenERPConnect openerp_connect = openerp_outlook.Connection;
40
filepath = Path.Combine(filepath, openerp_config_file);
41
string[] datas = { "url=" + openerp_connect.URL, "userid=" + openerp_connect.UserId, "dbname=" + openerp_connect.DBName,"rempwd="+openerp_connect.rempwd,"pswrd=" + openerp_connect.pswrd };
42
StreamWriter userfile = new StreamWriter(filepath, false);
44
foreach (string data in datas)
46
userfile.WriteLine(data);
51
public void LoadConfigurationSetting()
54
string filePath = Tools.GetAppFolderPath();
55
filePath = Path.Combine(filePath, this.openerp_config_file);
56
OpenERPConnect openerp_connect=null;
57
OpenERPOutlookPlugin openerp_outlook=null;
58
openerp_outlook = Cache.OpenERPOutlookPlugin;
59
if (openerp_outlook == null)
62
openerp_outlook = new OpenERPOutlookPlugin(openerp_connect);
64
openerp_connect = openerp_outlook.Connection;
65
if (openerp_connect == null)
67
openerp_connect = new OpenERPConnect();
70
if (File.Exists(filePath))
75
using (StreamReader file = new StreamReader(filePath))
77
while ((line = file.ReadLine()) != null)
79
char[] delimiters = new char[] { '=' };
80
string[] parts = line.Split(delimiters, 2);
82
for (int i = 0; i < parts.Length; i += 2)
84
if (parts[i] == "url")
85
openerp_connect.URL = parts[i + 1].Trim();
86
else if (parts[i] == "userid")
87
openerp_connect.UserId = parts[i + 1].Trim();
88
else if (parts[i] == "dbname")
89
openerp_connect.DBName = parts[i + 1].Trim();
90
else if (parts[i] == "pswrd")
91
openerp_connect.pswrd = parts[i + 1].Trim();
92
else if (parts[i] == "rempwd")
94
openerp_connect.rempwd = false;
95
if (parts[i + 1].Trim().ToLower() == "true")
96
openerp_connect.rempwd = true;
104
openerp_outlook.Connection = openerp_connect;
105
Cache.OpenERPOutlookPlugin = openerp_outlook;