private void txt_server_config_TextChanged(object sender, EventArgs e) { try { PengERPOutlookPlugin openerp_outlook = Cache.PengERPOutlookPlugin; PengERPConnect openerp_connect = openerp_outlook.Connection; openerp_connect.URL = txt_server_config.Text; this.combo_config_database.Text = ""; this.txt_dbname.Text = ""; try { openerp_connect.DBList(); this.load_dbname_list(); if (txt_dbname.Visible) { txt_dbname.Visible = false; } combo_config_database.Visible = true; } catch { if (combo_config_database.Visible) { combo_config_database.Visible = false; } this.txt_dbname.Visible = true; } this.txt_username.Text = ""; this.txt_password.Text = ""; } catch (Exception ex) { Connect.handleException(ex); } }
public Boolean PushMail(outlook.MailItem mail, string model, int thread_id) { /* * * This will push the mail as per the selected items from the list. * :Param outlook.MailItem mail: selected mail from the outlook. * :Param string model : Model name to push. * :Param int thread_id : Thread id of the mail. * If mail pushed successfully then it returns true. * return False if mail Already Exist. * */ PengERPOutlookPlugin openerp_outlook = Cache.PengERPOutlookPlugin; PengERPConnect openerp_connect = openerp_outlook.Connection; ArrayList args = new ArrayList(); Hashtable vals = new Hashtable(); string email; if (Tools.GetHeader(mail) != null) { email = Tools.GetHeader(mail); //TODO: Outlook.MailItem Should be Converted into MIME Message } else { email = ""; } args.Add(model); args.Add(email.ToString()); args.Add(thread_id); Hashtable attachments = Tools.GetAttachments(mail); args.Add(mail.Body); args.Add(mail.HTMLBody); args.Add(attachments); object push_mail = this.Connection.Execute("plugin.handler", "push_message_outlook", args.ToArray()); object[] push = (object[])push_mail; if (Convert.ToInt32(push[1]) == 0) { MessageBox.Show(push[3].ToString()); } else { this.RedirectWeb(push[2].ToString()); } return(true); }
private void btn_server_ok_Click(object sender, EventArgs e) { try { PengERPOutlookPlugin openerp_outlook = Cache.PengERPOutlookPlugin; PengERPConnect openerp_connect = openerp_outlook.Connection; string url = Tools.JoinURL(this.txt_server_host.Text, this.txt_server_port.Text, this.chkSSL.Checked); this.txtServerURL.Text = url; openerp_connect.check_connectivity(); this.Close(); } catch (Exception ex) { Connect.handleException(ex); } }
public void SaveConfigurationSetting() { string filepath = Tools.GetAppFolderPath(); PengERPOutlookPlugin openerp_outlook = Cache.PengERPOutlookPlugin; PengERPConnect openerp_connect = openerp_outlook.Connection; filepath = Path.Combine(filepath, openerp_config_file); string[] datas = { "url=" + openerp_connect.URL, "userid=" + openerp_connect.UserId, "dbname=" + openerp_connect.DBName, "rempwd=" + openerp_connect.rempwd, "pswrd=" + openerp_connect.pswrd }; StreamWriter userfile = new StreamWriter(filepath, false); foreach (string data in datas) { userfile.WriteLine(data); } userfile.Close(); }
private void frm_openerp_configuration_Load(object sender, EventArgs e) { try { this.config_manager = new ConfigManager(); this.config_manager.LoadConfigurationSetting(); PengERPOutlookPlugin openerp_outlook = Cache.PengERPOutlookPlugin; PengERPConnect openerp_connect = openerp_outlook.Connection; if (this.txt_server_config.Text != "") { openerp_connect.URL = this.txt_server_config.Text; } if (openerp_connect.rempwd == true) { this.txt_password.Text = Tools.DecryptB64Pwd(openerp_connect.pswrd); this.chkpwd.Checked = true; } if (openerp_connect.URL != null) { this.txt_server_config.Text = openerp_connect.URL; this.txt_username.Text = openerp_connect.UserId; try { object[] res_dblist = openerp_connect.DBList(); foreach (string selection in res_dblist) { if (openerp_connect.DBName != "" && selection == openerp_connect.DBName) { this.combo_config_database.SelectedText = openerp_connect.DBName; } } this.load_dbname_list(); } catch { this.setdblist(openerp_connect.DBName); } } } catch (Exception ex) { Connect.handleException(ex); } }
private void btn_openerp_connect_Click(object sender, EventArgs e) { try { url = txt_server_config.Text; string dbname; if (txt_dbname.Visible == true) { dbname = txt_dbname.Text; } else { dbname = combo_config_database.Text; } PengERPOutlookPlugin openerp_outlook = Cache.PengERPOutlookPlugin; PengERPConnect openerp_connect = openerp_outlook.Connection; openerp_connect.URL = url; openerp_connect.DBName = dbname; openerp_connect.UserId = txt_username.Text; openerp_connect.rempwd = chkpwd.Checked; if (chkpwd.Checked) { openerp_connect.pswrd = Tools.EncryptB64Pwd(txt_password.Text); } else { openerp_connect.pswrd = ""; } if (openerp_connect.Login(openerp_connect.DBName, openerp_connect.UserId, txt_password.Text) != 0) { openerp_outlook.Connection = openerp_connect; Cache.PengERPOutlookPlugin = openerp_outlook; this.config_manager.SaveConfigurationSetting(); Connect.displayMessage("Successfully login to PengERP."); this.Close(); } } catch (Exception) { MessageBox.Show("Authentication Error!\nInvalid Database.", Form.ActiveForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void frm_push_mail_Load(object sender, EventArgs e) { try { Model[] document_models = Cache.PengERPOutlookPlugin.GetMailModels(); PengERPOutlookPlugin openerp_outlook = Cache.PengERPOutlookPlugin; PengERPConnect openerp_connect = openerp_outlook.Connection; foreach (Model model in document_models) { ListViewItem item = new ListViewItem(); item.Name = model.model; item.Text = model.name; cmboboxcreate.Items.Add(model); } } catch (Exception ex) { Connect.handleException(ex); } }
void load_dbname_list() { combo_config_database.Items.Clear(); PengERPOutlookPlugin openerp_outlook = Cache.PengERPOutlookPlugin; PengERPConnect openerp_connect = openerp_outlook.Connection; try { if (openerp_connect.URL != null && openerp_connect.URL != "") { object[] res_dblist = openerp_connect.DBList(); foreach (var selection in res_dblist) { combo_config_database.Items.Add(selection); } } } catch { this.setdblist(openerp_connect.DBName); } }
public void OnStartupComplete(ref System.Array custom) { /* * * When outlook is opened it loads a Menu if Outlook plugin is installed. * PengERP - > Push, Partner ,Documents, Configuration * */ Microsoft.Office.Interop.Outlook.Application app = null; try { app = new Microsoft.Office.Interop.Outlook.Application(); object omissing = System.Reflection.Missing.Value; menuBar = app.ActiveExplorer().CommandBars.ActiveMenuBar; ConfigManager config = new ConfigManager(); config.LoadConfigurationSetting(); PengERPOutlookPlugin openerp_outlook = Cache.PengERPOutlookPlugin; PengERPConnect openerp_connect = openerp_outlook.Connection; try { if (openerp_connect.URL != null && openerp_connect.DBName != null && openerp_connect.UserId != null && openerp_connect.pswrd != "") { string decodpwd = Tools.DecryptB64Pwd(openerp_connect.pswrd); openerp_connect.Login(openerp_connect.DBName, openerp_connect.UserId, decodpwd); } } catch (Exception) { MessageBox.Show("Unable to connect remote Server ' " + openerp_connect.URL + " '.", "PengERP Connection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } newMenuBar = (office.CommandBarPopup)menuBar.Controls.Add(office.MsoControlType.msoControlPopup, omissing, omissing, omissing, true); if (newMenuBar != null) { newMenuBar.Caption = "PengERP"; newMenuBar.Tag = "My"; btn_open_partner = (office.CommandBarButton)newMenuBar.Controls.Add(office.MsoControlType.msoControlButton, omissing, omissing, 1, true); btn_open_partner.Style = office.MsoButtonStyle.msoButtonIconAndCaption; btn_open_partner.Caption = "Contact"; //Face ID will use to show the ICON in the left side of the menu. btn_open_partner.FaceId = 3710; newMenuBar.Visible = true; btn_open_partner.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.btn_open_partner_Click); btn_open_document = (office.CommandBarButton)newMenuBar.Controls.Add(office.MsoControlType.msoControlButton, omissing, omissing, 2, true); btn_open_document.Style = office.MsoButtonStyle.msoButtonIconAndCaption; btn_open_document.Caption = "Documents"; //Face ID will use to show the ICON in the left side of the menu. btn_open_document.FaceId = 258; newMenuBar.Visible = true; btn_open_document.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.btn_open_document_Click); btn_open_configuration_form = (office.CommandBarButton)newMenuBar.Controls.Add(office.MsoControlType.msoControlButton, omissing, omissing, 3, true); btn_open_configuration_form.Style = office.MsoButtonStyle.msoButtonIconAndCaption; btn_open_configuration_form.Caption = "Configuration"; //Face ID will use to show the ICON in the left side of the menu. btn_open_configuration_form.FaceId = 5644; newMenuBar.Visible = true; btn_open_configuration_form.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.btn_open_configuration_form_Click); } } catch (Exception) { object oActiveExplorer; oActiveExplorer = applicationObject.GetType().InvokeMember("ActiveExplorer", BindingFlags.GetProperty, null, applicationObject, null); oCommandBars = (office.CommandBars)oActiveExplorer.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, oActiveExplorer, null); } }
public void LoadConfigurationSetting() { string filePath = Tools.GetAppFolderPath(); filePath = Path.Combine(filePath, this.openerp_config_file); PengERPConnect openerp_connect = null; PengERPOutlookPlugin openerp_outlook = null; openerp_outlook = Cache.PengERPOutlookPlugin; if (openerp_outlook == null) { openerp_outlook = new PengERPOutlookPlugin(openerp_connect); } openerp_connect = openerp_outlook.Connection; if (openerp_connect == null) { openerp_connect = new PengERPConnect(); } if (File.Exists(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] == "url") { openerp_connect.URL = parts[i + 1].Trim(); } else if (parts[i] == "userid") { openerp_connect.UserId = parts[i + 1].Trim(); } else if (parts[i] == "dbname") { openerp_connect.DBName = parts[i + 1].Trim(); } else if (parts[i] == "pswrd") { openerp_connect.pswrd = parts[i + 1].Trim(); } else if (parts[i] == "rempwd") { openerp_connect.rempwd = false; if (parts[i + 1].Trim().ToLower() == "true") { openerp_connect.rempwd = true; } } } } file.Close(); } } openerp_outlook.Connection = openerp_connect; Cache.PengERPOutlookPlugin = openerp_outlook; }