/// <summary>
 /// Raises the <see cref="E:EntityContextChanged"/> event.
 /// </summary>
 /// <param name="e">The <see cref="Sage.Platform.Application.EntityContextChangedEventArgs"/> instance containing the event data.</param>
 protected override void OnEntityContextChanged(EntityContextChangedEventArgs e)
 {
     //this should happen since the paging to a new entity does not have context of the old entity so this is not called.
     ContextService.RemoveContext("AddFilterStateInfo");
     ContextService.RemoveContext("CT_SELECTED_TARGETIDS");
     base.OnEntityContextChanged(e);
 }
Ejemplo n.º 2
0
        public void should_dispose_api_service()
        {
            // given
            var connectionService    = new Mock <IConnectionService>();
            var remoteServiceFactory = new Mock <IRemoteServiceFactory>();
            var service         = new ContextService(connectionService.Object, remoteServiceFactory.Object);
            var sedovCreds      = Credentials.GetConnectionCredentials("sedov", "passwrd1");
            var sedovHttpClient = new HttpPilotClient("");

            connectionService.Setup(cs => cs.Connect(sedovCreds)).Returns(sedovHttpClient);

            var sedovApi       = new Mock <IRemoteService>();
            var sedovServerApi = new Mock <IServerApiService>();

            sedovApi.Setup(sa => sa.IsActive).Returns(true);
            sedovApi.Setup(sa => sa.GetServerApi()).Returns(sedovServerApi.Object);
            remoteServiceFactory.Setup(rsf => rsf.CreateRemoteService(sedovHttpClient)).Returns(sedovApi.Object);
            service.CreateContext(sedovCreds);

            // when
            service.RemoveContext("sedov");

            // then
            sedovApi.Verify(sa => sa.Dispose(), Times.Once);
        }
 /// <summary>
 /// Handles the OnClick event of the cmdClearAll control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void cmdClearAll_OnClick(object sender, EventArgs e)
 {
     txtSelectedTargets.Value = string.Empty;
     txtSelectContext.Value   = "CLEAR_ALL";
     ContextService.RemoveContext("CT_SELECT_STATE");
 }
    /// <summary>
    /// Called when [form bound].
    /// </summary>
    protected override void OnFormBound()
    {
        ICampaign campaign = GetParentEntity() as ICampaign;

        if (campaign != null)
        {
            chkExternalList.Checked = false;
            if (campaign.UseExternalList.HasValue)
            {
                chkExternalList.Checked = campaign.UseExternalList.Value;
            }
            chkExternalList.Enabled = (campaign.ActualLaunchDate == null);
        }
        if (chkExternalList.Checked)
        {
            divDisplayGrid.Style.Add(HtmlTextWriterStyle.Display, "none");
            divExternal.Style.Add(HtmlTextWriterStyle.Display, "inline");
            lnkFilters.Style.Add(HtmlTextWriterStyle.Display, "none");
        }
        else
        {
            divDisplayGrid.Style.Add(HtmlTextWriterStyle.Display, "inline");
            divExternal.Style.Add(HtmlTextWriterStyle.Display, "none");
            lnkFilters.Style.Add(HtmlTextWriterStyle.Display, "inline");

            filterDiv.Style.Add(HtmlTextWriterStyle.Display, txtShowFilter.Value.Equals("true") ? "inline" : "none");
            chkDisplayOnOpen.Checked = Helpers.ShowTargetsOnOpen();

            if (_State.EntityID != EntityContext.EntityID.ToString())
            {
                ContextService.RemoveContext("AddFilterStateInfo");
                ContextService.RemoveContext("CT_SELECT_STATE");
                _State.EntityID = EntityContext.EntityID.ToString();
                _State.formOpen = false;
                AddDistinctGroupItemsToList();
                AddDistinctStageItemsToList();
                lbxPriority.SelectedIndex = _State.priorityFilter;
                lbxStatus.SelectedIndex   = _State.statusFilter;
            }

            grdTargets.EmptyTableRowText = GetLocalResourceObject("grdTargets.EmptyTableRowText").ToString();
            if (!_State.formOpen || (hfIsFormInit.Value == "False") || _State.manageViewOpen)
            {
                _State.formOpen          = true;
                hfIsFormInit.Value       = "True";
                txtSelectedTargets.Value = string.Empty;

                if (chkDisplayOnOpen.Checked)
                {
                    LoadGrid();
                }
                else
                {
                    grdTargets.EmptyTableRowText = GetLocalResourceObject("grdTargets.NoRecordsFoundText").ToString();
                    grdTargets.DataBind();
                }
            }
            else
            {
                LoadGrid();
            }
            ContextService.SetContext("AddFilterStateInfo", _State);
        }
        cmdSave.Visible       = chkExternalList.Checked;
        cmdUpdate.Visible     = !chkExternalList.Checked;
        cmdManageList.Visible = !chkExternalList.Checked;
        cmdDelete.Visible     = !chkExternalList.Checked;
    }