Sanjay Gohel (Open ERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-outlook.net-jam-configrw-sgo into
lp:~openerp-dev/openobject-addons/trunk-outlook.net-jam.
Requested reviews:
Jigar Amin (OpenERP) (jam-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-outlook.net-jam-configrw-sgo/+merge/74717
Hello sir,
i have created file for userpref. and from file load data and save data.
thank you
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-outlook.net-jam-configrw-sgo/+merge/74717
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-outlook.net-jam.
=== modified file 'outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/ConfigManager.cs'
--- outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/ConfigManager.cs 2011-09-07 09:54:00 +0000
+++ outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/ConfigManager.cs 2011-09-09 05:24:17 +0000
@@ -2,11 +2,15 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.IO;
+using System.Windows.Forms;
+
namespace OpenERPOutlookPlugin
{
public class ConfigManager
{
+
private string[] combodb_val;
public string[] GetDB()
{
@@ -18,7 +22,7 @@
combodb_val = dbval;
}
- private string server;
+ private string server = "localhost";
public string Getserver()
{
return server;
@@ -29,7 +33,7 @@
server = Server;
}
- private int port;
+ private int port = 8069;
public int Getport()
{
return port;
@@ -40,7 +44,7 @@
port = Port;
}
- private string protocol;
+ private string protocol = "http://";
public string Getprotocol()
{
return protocol;
@@ -62,7 +66,7 @@
weburl = WebUrl;
}
- private string user_name;
+ private string user_name = "admin";
public string GetUname()
{
return user_name;
@@ -73,7 +77,7 @@
user_name = uname;
}
- private string pwd;
+ private string pwd = "a";
public string GetPwd()
{
return pwd;
@@ -84,7 +88,19 @@
pwd = Password;
}
- private string webserver;
+
+ private string databse = "";
+ public string GetDataBase()
+ {
+ return databse;
+ }
+
+ public void SetDataBase(string Db)
+ {
+ databse = Db;
+ }
+
+ private string webserver = "localhost";
public string GetWebserver()
{
return webserver;
@@ -95,7 +111,7 @@
webserver = WebServer;
}
- private int webport;
+ private int webport = 8080;
public int GetWebport()
{
return webport;
@@ -106,7 +122,7 @@
webport = WebPort;
}
- private string webprotocol;
+ private string webprotocol = "http:\\\\";
public string GetWebprotocol()
{
return webprotocol;
@@ -116,7 +132,78 @@
{
webprotocol = WebProtocol;
}
-
+ public void loadConfig()
+ {
+
+ string filePath = Tools.getAppFolderPath();
+ filePath = System.IO.Path.Combine(filePath, "OpenErpOutlook");
+
+ if (Directory.Exists(filePath))
+ {
+ filePath = Path.Combine(filePath, "openerp.ini");
+ if (File.Exists(filePath))
+ {
+ StreamReader sr = new StreamReader(filePath);
+ string line;
+ using (StreamReader file = new StreamReader(filePath))
+ {
+ while ((line = file.ReadLine()) != null)
+ {
+ char[] delimiters = new char[] { '=' };
+ string[] parts = line.Split(delimiters, 2);
+ for (int i = 0; i < parts.Length; i += 2)
+ {
+ if (parts[i] == "server")
+ this.server = parts[i + 1].Trim();
+ else if (parts[i] == "port")
+ this.port = Int32.Parse(parts[i + 1].Trim());
+ else if (parts[i] == "protocol")
+ this.protocol = parts[i + 1].Trim();
+
+ else if (parts[i] == "username")
+ this.user_name = parts[i + 1].Trim();
+
+ else if (parts[i] == "webserver")
+ this.webserver = parts[i + 1].Trim();
+
+ else if (parts[i] == "webport")
+ this.webport = Int32.Parse(parts[i + 1].Trim());
+
+ else if (parts[i] == "webprotocol")
+ this.webprotocol = parts[i + 1].Trim();
+
+ else if (parts[i] == "lastdb")
+ this.databse = parts[i + 1].Trim();
+
+ }
+ }
+ sr.Close();
+ }
+
+ }
+
+ else
+ this.saveConfig();
+ }
+ else
+ this.saveConfig();
+
+
+ }
+
+ public void saveConfig()
+ {
+ string filepath = Tools.getAppFolderPath();
+ filepath = System.IO.Path.Combine(filepath, "OpenErpOutlook");
+ char[] splt = { '=' };
+ if (!Directory.Exists(filepath))
+ {
+ Directory.CreateDirectory(filepath);
+ }
+ filepath = Path.Combine(filepath, "openerp.ini");
+ string[] data = {"server="+this.server,"port="+ this.port.ToString(),"protocol="+ this.protocol, "username="+ this.user_name,"webserver="+this.webserver,"webport="+this.webport.ToString(),"webprotocol="+this.webprotocol,"lastdb="+this.databse };
+ File.WriteAllLines(filepath, data);
+ }
}
-}
+}
\ No newline at end of file
=== modified file 'outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/Tools.cs'
--- outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/Tools.cs 2011-09-07 06:07:59 +0000
+++ outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/Tools.cs 2011-09-09 05:24:17 +0000
@@ -11,7 +11,11 @@
{
static public class Tools
{
-
+ static public string getAppFolderPath()
+ {
+ string filePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+ return filePath;
+ }
static public string Getmessage_id(outlook.MailItem mail)
{
var propertyAccessor = mail.PropertyAccessor;
=== modified file 'outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/frm_openerp_configuration.Designer.cs'
--- outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/frm_openerp_configuration.Designer.cs 2011-09-08 08:41:13 +0000
+++ outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/frm_openerp_configuration.Designer.cs 2011-09-09 05:24:17 +0000
@@ -40,6 +40,7 @@
this.label2 = new System.Windows.Forms.Label();
this.pnconfig = new System.Windows.Forms.Panel();
this.grpconfig = new System.Windows.Forms.GroupBox();
+ this.txt_dbname = new System.Windows.Forms.TextBox();
this.combo_config_database = new System.Windows.Forms.ComboBox();
this.btn_openerp_connect = new System.Windows.Forms.Button();
this.txt_password = new System.Windows.Forms.TextBox();
@@ -72,7 +73,6 @@
this.imageListSmall = new System.Windows.Forms.ImageList(this.components);
this.btn_main_close = new System.Windows.Forms.Button();
this.opendialog_image = new System.Windows.Forms.OpenFileDialog();
- this.txt_dbname = new System.Windows.Forms.TextBox();
this.tb1.SuspendLayout();
this.tbconfigsetting.SuspendLayout();
this.pnwebparam.SuspendLayout();
@@ -199,6 +199,14 @@
this.grpconfig.TabStop = false;
this.grpconfig.Text = "Application Server Parameters";
//
+ // txt_dbname
+ //
+ this.txt_dbname.Location = new System.Drawing.Point(88, 74);
+ this.txt_dbname.Name = "txt_dbname";
+ this.txt_dbname.Size = new System.Drawing.Size(269, 20);
+ this.txt_dbname.TabIndex = 2;
+ this.txt_dbname.Visible = false;
+ //
// combo_config_database
//
this.combo_config_database.AllowDrop = true;
@@ -503,14 +511,6 @@
//
this.opendialog_image.FileName = "openimagedialog";
//
- // txt_dbname
- //
- this.txt_dbname.Location = new System.Drawing.Point(88, 74);
- this.txt_dbname.Name = "txt_dbname";
- this.txt_dbname.Size = new System.Drawing.Size(269, 20);
- this.txt_dbname.TabIndex = 2;
- this.txt_dbname.Visible = false;
- //
// frm_openerp_configuration
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
=== modified file 'outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/frm_openerp_configuration.cs'
--- outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/frm_openerp_configuration.cs 2011-09-08 08:41:13 +0000
+++ outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/frm_openerp_configuration.cs 2011-09-09 05:24:17 +0000
@@ -33,31 +33,27 @@
public frm_openerp_configuration()
{
InitializeComponent();
-
+ cm.loadConfig();
}
- public frm_openerp_configuration(string strparam, string strparam2)
+ public frm_openerp_configuration(ConfigManager cm)
{
InitializeComponent();
- this.txt_server_config.Text = strparam + strparam2;
+ this.cm = cm;
+ this.txt_server_config.Text = cm.Getprotocol() + cm.Getserver() + ":" + cm.Getport();
+ this.txt_webserver_parameter.Text = cm.GetWebprotocol() + cm.GetWebserver() + ":" + cm.GetWebport();
}
- public frm_openerp_configuration(string weburl)
- {
- InitializeComponent();
- this.txt_webserver_parameter.Text = weburl;
- }
private void frm_openerp_configuration_Load(object sender, EventArgs e)
- {
- this.getname();
- }
- public ListView getname()
- {
- string url = txt_server_config.Text;
+ {
+
+ this.txt_server_config.Text = cm.Getprotocol() + cm.Getserver() + ":" + cm.Getport();
+ this.txt_username.Text = cm.GetUname();
+ this.txt_webserver_parameter.Text = cm.GetWebprotocol() + cm.GetWebserver() + ":" +cm.GetWebport();
try
{
- XMLRPCConnect rpcclient_dblist = new XMLRPCConnect(url + "/xmlrpc/db");
+ XMLRPCConnect rpcclient_dblist = new XMLRPCConnect(this.txt_server_config.Text + "/xmlrpc/db");
Object[] res_dblist = rpcclient_dblist.list();
foreach (var selection in res_dblist)
{
@@ -67,10 +63,13 @@
catch
{
txt_dbname.Visible = true;
+ MessageBox.Show("visible");
combo_config_database.Visible = false;
-
}
- //ImageList imageSmallList = new ImageList();
+ this.getname();
+ }
+ public ListView getname()
+ {
lstviewdoc.SmallImageList = imageListSmall;
@@ -107,9 +106,9 @@
{
throw new NotImplementedException();
}
-
+
private void btn_main_close_Click(object sender, EventArgs e)
- {
+ {
this.Close();
}
@@ -132,6 +131,7 @@
if (openerp_connect.Login() != 0)
{
System.Windows.Forms.MessageBox.Show("Successfully Login to OpenERP..");
+ cm.saveConfig();
this.Close();
}
@@ -140,7 +140,7 @@
private void btn_open_server_url_form_Click(object sender, EventArgs e)
{
- frm_openerp_connection openerp_connection = new frm_openerp_connection();
+ frm_openerp_connection openerp_connection = new frm_openerp_connection(cm);
openerp_connection.Show();
this.Close();
}
@@ -203,25 +203,13 @@
}
- private void btnloadimage_Click(object sender, EventArgs e)
- {
- opendialog_image.Filter = "Icon Files .ico|*.ico";
- opendialog_image.ShowDialog();
-
-
- if (opendialog_image.FileName != "")
- {
- txtimage_path.Text = opendialog_image.FileName;
-
- }
-
-
- }
+
private void btn_webserver_parameter_change_Click(object sender, EventArgs e)
{
-
- frm_openerp_connection_webserver connect_webserver = new frm_openerp_connection_webserver();
+
+ frm_openerp_connection_webserver connect_webserver = new frm_openerp_connection_webserver(cm);
connect_webserver.Show();
+ cm.saveConfig();
this.Close();
}
@@ -230,5 +218,9 @@
}
- }
+
+
+ }
+
+
}
=== modified file 'outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/frm_openerp_connection.cs'
--- outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/frm_openerp_connection.cs 2011-09-07 06:07:59 +0000
+++ outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/frm_openerp_connection.cs 2011-09-09 05:24:17 +0000
@@ -11,10 +11,20 @@
{
public partial class frm_openerp_connection : Form
{
+ public ConfigManager configman = new ConfigManager();
+
public frm_openerp_connection()
{
InitializeComponent();
}
+ public frm_openerp_connection(ConfigManager cm)
+ {
+ InitializeComponent();
+ this.configman = cm;
+ this.txt_server_connect.Text = cm.Getserver();
+ this.txt_port.Text = cm.Getport().ToString();
+ }
+
private void btn_change_server_url_Click(object sender, EventArgs e)
{
@@ -25,7 +35,9 @@
else
{
- frm_openerp_configuration config = new frm_openerp_configuration("http://" + this.txt_server_connect.Text, ":" + this.txt_port.Text);
+ this.configman.Setserver(this.txt_server_connect.Text.Trim());
+ this.configman.Setport(Int32.Parse(this.txt_port.Text.Trim()));
+ frm_openerp_configuration config = new frm_openerp_configuration(this.configman);
config.Show();
this.Close();
}
=== modified file 'outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/frm_openerp_connection_webserver.cs'
--- outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/frm_openerp_connection_webserver.cs 2011-09-07 06:07:59 +0000
+++ outlook/plugin/openerp-outlook-plugin_v2.0/OpenERPOutlookPlugin/frm_openerp_connection_webserver.cs 2011-09-09 05:24:17 +0000
@@ -11,59 +11,39 @@
{
public partial class frm_openerp_connection_webserver : Form
{
- public frm_openerp_connection_webserver()
- {
+ public ConfigManager configmanager = new ConfigManager();
+ public frm_openerp_connection_webserver(ConfigManager cm)
+ {
InitializeComponent();
+ this.configmanager = cm;
+
}
private frm_openerp_configuration frm_config = new frm_openerp_configuration();
private void frm_openerp_connection_webserver_Load(object sender, EventArgs e)
{
-
- }
-
- public string txt_web_server
- {
- get
- {
- return this.txt_webserver_server_change.Text;
- }
-
- set
- {
- this.txt_webserver_server_change.Text = value;
- }
-
- }
-
- public string txt_web_port
- {
- get
- {
- return this.txt_webserver_port_change.Text;
- }
-
- set
- {
- this.txt_webserver_port_change.Text = value;
- }
- }
+ this.txt_webserver_port_change.Text = configmanager.GetWebport().ToString();
+ this.txt_webserver_server_change.Text = configmanager.GetWebserver();
+ if (configmanager.GetWebprotocol() == "https:\\\\")
+ this.chkssl.Checked = true;
+ else
+ this.chkssl.Checked = false;
+ }
+
private void btn_webserver_change_ok_Click(object sender, EventArgs e)
{
- string weburl = "";
- string url = "";
+ string url = "http:\\\\";
if (chkssl.Checked)
{
- url = "https://";
- }
- else
- {
- url = "http://";
- }
- weburl = url + txt_web_server.ToString() + ":" + txt_web_port.ToString();
- frm_openerp_configuration frm_web_config = new frm_openerp_configuration(weburl);
+ url = "https:\\\\";
+ }
+ this.configmanager.SetWebserver(this.txt_webserver_server_change.Text.Trim());
+ this.configmanager.SetWebport(Int32.Parse(this.txt_webserver_port_change.Text.Trim()));
+ this.configmanager.SetWebprotocol(url);
+ this.configmanager.saveConfig();
+ frm_openerp_configuration frm_web_config = new frm_openerp_configuration(this.configmanager);
frm_web_config.Show();
this.Close();
}
@@ -74,14 +54,6 @@
this.Close();
}
- private void chkssl_CheckedChanged(object sender, EventArgs e)
- {
-
- }
-
-
-
-
}
}
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp