Example #1
0
 public EntryPropEditor(SageCRMBaseEntryBlock _Block)
 {
     this.Block            = _Block;
     this.connectionObject = this.Block.SageCRMConnection;
     if ((this.Block is SageCRMEntryBlock) == false)
     {
         lbl_checklocks.Visible   = false;
         cbCheckLocks.Visible     = false;
         lbl_showflowbtns.Visible = false;
         cb_showflowbtns.Visible  = false;
         lbl_state.Visible        = false;
         tb_state.Visible         = false;
     }
     InitializeComponent();
 }
        public override bool EditComponent(ITypeDescriptorContext context, object component,
                                           IWin32Window owner)
        {
            SageCRMBaseEntryBlock block = component as SageCRMBaseEntryBlock;

            if (block == null)
            {
                throw new ArgumentException("Component must be a SageCRMEntryBlock or SageCRMPortalEntryBlock", "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 Builder");
                    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(null, block, 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);
        }
        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;
        }
        public override bool EditComponent(ITypeDescriptorContext context, object component,
                                           IWin32Window owner)
        {
            SageCRMBaseEntryBlock block = component as SageCRMBaseEntryBlock;

            if (block == null)
            {
                throw new ArgumentException("Component must be a SageCRMEntryBlock or SageCRMPortalEntryBlock", "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;
                    EntryPropEditor form = new EntryPropEditor(block);
                    form.EntityName     = block.EntityName;
                    form.BlockTitle     = block.BlockTitle;
                    form.CreateMode     = block.CreateMode;
                    form.WhereClause    = block.EntityWhere;
                    form.EntryBlockName = block.EntryBlockName;
                    form.ListBlock      = block.ListBlockName;
                    form.SearchMode     = block.SearchMode;
                    form.ShowSearchList = block.ShowSearchList;
                    form.AfterSavePage  = block.AfterSavePage;
                    form.AjaxSearchMode = block.AjaxSearchMode;
                    if (block is SageCRMEntryBlock)
                    {
                        form.ShowWorkflowButtons = (block as SageCRMEntryBlock).ShowWorkFlowButtons;
                        form.CheckLocks          = (block as SageCRMEntryBlock).CheckLocks;
                        form.WorkFlowName        = (block as SageCRMEntryBlock).WorkFlowName;
                        form.WFState             = (block as SageCRMEntryBlock).WFState;
                    }
                    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);
        }