public crmEditor(SageCRMBaseListBlock listcomponent, SageCRMBaseEntryBlock entrycomponent, SageCRMBaseFilterBlock filtercomponent, SageCRMTabGroup tabcomponent, SageCRMTopContent topcontentcomponent)
        {
            InitializeComponent();
            this._block = listcomponent;
            string entityname = "";

            if (entrycomponent != null)
            {
                _block             = entrycomponent;
                _sagecrmentryblock = entrycomponent;
                label1.Text        = "Active Screen: " + (_block as SageCRMBaseEntryBlock).EntryBlockName;
                entityname         = (_block as SageCRMBaseEntryBlock).EntityName;
            }
            else
            if (listcomponent != null)
            {
                _block            = listcomponent;
                _sagecrmlistblock = listcomponent;
                label1.Text       = "Active List: " + (_block as SageCRMBaseListBlock).ListBlock;
                entityname        = (_block as SageCRMBaseListBlock).EntityName;
            }
            else
            if (filtercomponent != null)
            {
                _block = filtercomponent;
                _sagecrmfilterblock = filtercomponent;
                label1.Text         = "Active Filter: " + (_block as SageCRMBaseFilterBlock).EntryBlockName;
                entityname          = (_block as SageCRMBaseFilterBlock).EntityName;
            }
            else if (tabcomponent != null)
            {
                _block           = tabcomponent;
                _sagecrmtabgroup = tabcomponent;
                label1.Text      = "Active Tab: " + (_block as SageCRMTabGroup).TabGroupName;
                entityname       = (_block as SageCRMTabGroup).EntityName;
            }
            else if (topcontentcomponent != null)
            {
                _block             = topcontentcomponent;
                _sagecrmtopcontent = topcontentcomponent;
                label1.Text        = "Active Tab: " + (_block as SageCRMTopContent).EntryBlockName;
                entityname         = (_block as SageCRMTopContent).EntityName;
            }
            string _url  = _block.editorURL.ToString();
            Uri    anUri = new Uri(_url);

            textBox1.Text = _url;

            //due to a persistance issue we must first set the context of the entity that we are working on
            string persistance_url   = _block.pathToCRM() + _block.CRMURL("1651") + "MenuName=&BC=Admin,Admin,AdminCustomization,Customization,," + entityname + "&Parent=" + entityname + "&Act2=830";
            Uri    persistance_anUri = new Uri(persistance_url);

            webBrowser1.Url = persistance_anUri;

            //sleep for a second before navigating to the correct entity
            System.Threading.Thread.Sleep(1000);
            webBrowser1.Url = anUri;

            string _url2  = "http://www.crmtogether.com/sage_crm_editor_bar/crmeditor.php";
            Uri    anUri2 = new Uri(_url2);
            // webBrowser2.Url = anUri2;
        }
Exemple #2
0
        public override bool EditComponent(ITypeDescriptorContext context, object component,
                                           IWin32Window owner)
        {
            SageCRMBaseListBlock block = component as SageCRMBaseListBlock;

            if (block == null)
            {
                throw new ArgumentException("Component must be a SageCRMListBlock or SageCRMPortalListBlock", "component");
            }
            IServiceProvider        site          = block.Site;
            IComponentChangeService changeservice = null;
            DesignerTransaction     transaction   = null;
            bool changed = false;

            try
            {
                if (site != null)
                {
                    IDesignerHost designerhost = (IDesignerHost)site.GetService(typeof(IDesignerHost));
                    transaction   = designerhost.CreateTransaction("Property Editor");
                    changeservice = (IComponentChangeService)site.GetService(typeof(IComponentChangeService));
                    if (changeservice != null)
                    {
                        try
                        {
                            changeservice.OnComponentChanging(block, null);
                        }
                        catch (CheckoutException ex)
                        {
                            if (ex == CheckoutException.Canceled)
                            {
                                return(false);
                            }
                            throw ex;
                        }
                    }
                }
                try
                {
                    block.SageCRMConnection.DesignRequest = true;
                    ListPropEditor form = new ListPropEditor(block);
                    form.ListBlock       = block.ListBlock;
                    form.EntityName      = block.EntityName;
                    form.BlockTitle      = block.BlockTitle;
                    form.SelectSQL       = block.SelectSQL;
                    form.WhereClause     = block.EntityWhere;
                    form.EntryBlockName  = block.EntryBlockName;
                    form.FilterBlockName = block.FilterBlockName;
                    if (block is SageCRMListBlock)
                    {
                        form.showWorkFlow();
                        form.WorkFlowTable          = (block as SageCRMListBlock).WorkflowTable;
                        form.ShowNewWorkflowButtons = (block as SageCRMListBlock).ShowNewWorkFlowButtons;
                        form.ShowWorkflowButtons    = (block as SageCRMListBlock).ShowWorkFlowButtons;
                    }
                    else //i assume its the portal
                    {
                        form.hideWorkFlow();
                    }
                    if (form.ShowDialog(owner) == DialogResult.OK)
                    {
                        changed = true;
                    }
                    block.SageCRMConnection.DesignRequest = false;
                }
                finally
                {
                    if (changed && changeservice != null)
                    {
                        changeservice.OnComponentChanged(block, null, null, null);
                    }
                }
            }
            finally
            {
                if (transaction != null)
                {
                    if (changed)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        transaction.Cancel();
                    }
                }
            }
            return(changed);
        }
 public ListPropEditor(SageCRMBaseListBlock _Block)
 {
     this.Block            = _Block;
     this.connectionObject = this.Block.SageCRMConnection;
     InitializeComponent();
 }
        public override bool EditComponent(ITypeDescriptorContext context, object component,
                                           IWin32Window owner)
        {
            SageCRMBaseListBlock block = component as SageCRMBaseListBlock;

            if (block == null)
            {
                throw new ArgumentException("Component must be a SageCRMListBlock or a SageCRMPortalListBlock", "component");
            }
            IServiceProvider        site          = block.Site;
            IComponentChangeService changeservice = null;
            DesignerTransaction     transaction   = null;
            bool changed = false;

            try
            {
                if (site != null)
                {
                    IDesignerHost designerhost = (IDesignerHost)site.GetService(typeof(IDesignerHost));
                    transaction   = designerhost.CreateTransaction("Sage CRM Administration");
                    changeservice = (IComponentChangeService)site.GetService(typeof(IComponentChangeService));
                    if (changeservice != null)
                    {
                        try
                        {
                            changeservice.OnComponentChanging(block, null);
                        }
                        catch (CheckoutException ex)
                        {
                            if (ex == CheckoutException.Canceled)
                            {
                                return(false);
                            }
                            throw ex;
                        }
                    }
                }
                try
                {
                    block.SageCRMConnection.DesignRequest = true;
                    crmEditor form = new crmEditor(block, null, null, null, null);
                    form.ShowDialog(owner);
                    changed = true;
                    block.SageCRMConnection.DesignRequest = false;
                }
                finally
                {
                    if (changed && changeservice != null)
                    {
                        changeservice.OnComponentChanged(block, null, null, null);
                    }
                }
            }
            finally
            {
                if (transaction != null)
                {
                    if (changed)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        transaction.Cancel();
                    }
                }
            }
            return(changed);
        }