Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }