Unable to resolve error on Presentor

Topics: CAB & Smart Client Software Factory
Mar 28, 2007 at 11:25 AM
Hi,
I am unable to resolve compilation error which appears on presentor. My senario and code samples are as below.

I have Create A ShapeService


I can create a smart Webreference In My Project

ShapeController can contolled


using Matias.MasterModule.Constants;
using Matias.MasterModule;
using Matias.Infrastructure.Interface;

using Microsoft.Practices.CompositeUI;
using Microsoft.Practices.CompositeUI.Commands;
using System.Windows.Forms;


using Microsoft.Practices.CompositeUI.SmartParts;


namespace Matias.MasterModule
{
public class ShapeController : WorkItemController
{
private const string viewKey2 = "ViewKey2";

private OrderMode _orderMode;

public OrderMode OrderMode
{
get { return _orderMode; }
set { _orderMode = value; }
}
#region ExtendToolStrip

private void ExtendToolStrip()
{
UIExtensionSite mainToolbar = WorkItem.UIExtensionSitesUIExtensionSiteNames.MainToolbar;
AddSplashButton(mainToolbar);
}
private void AddSplashButton(UIExtensionSite pToolbar)
{
ToolStripButton newButton = new ToolStripButton("&New");
pToolbar.Add<ToolStripButton>(newButton);
//WorkItem.CommandsCommandNames.ShowAdd.AddInvoker(newButton, "Click");


ToolStripButton editButton = new ToolStripButton("&Edit");
pToolbar.Add<ToolStripButton>(editButton);

}

#endregion

public override void Run()
{
ExtendToolStrip();
IShapeView view2 = null;
SmartPartInfo Objshape = new SmartPartInfo();
Objshape.Title = "Shape Master";


if (this.WorkItem.SmartParts.Contains(viewKey2) == false)
{
view2 = WorkItem.SmartParts.AddNew<ShapeView>(viewKey2);
}
else
{
view2 = WorkItem.SmartParts.Get<ShapeView>(viewKey2);
}
this.WorkItem.WorkspacesWorkspaceNames.RightWorkspace.Show(view2, Objshape);
}
}
}


In userContoll i can write


using System;
using System.Windows.Forms;
using Microsoft.Practices.CompositeUI.SmartParts;
using Microsoft.Practices.ObjectBuilder;
using Matias.Infrastructure.Interface;

using Matias.Infrastructure.Interface.BusinessEntities;



namespace Matias.MasterModule
{
SmartPart
public partial class ShapeView : UserControl, IShapeView
{
UserLibrary.EntryMode dMode;
public ShapeView()
{
InitializeComponent();
}

CreateNew
public ShapeViewPresenter Presenter
{
set
{
_presenter = value;
_presenter.View = this;
}
}

protected override void OnLoad(EventArgs e)
{
_presenter.OnViewReady();

}

private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Trim() == "")
{
MessageBox.Show("Code cannot be empty");
textBox1.Focus();
return;
}
if (textBox2.Text.Trim() == "")
{
MessageBox.Show("Name cannot be empty");
textBox2.Focus();
return;
}
if (dMode == UserLibrary.EntryMode.New || dMode == UserLibrary.EntryMode.Existing)
{
if (dMode == UserLibrary.EntryMode.Existing)
dMode = UserLibrary.EntryMode.Edit;
_presenter.InsertShape(textBox1.Text, textBox2.Text);


}
dMode = UserLibrary.EntryMode.None;
_presenter.InsertShape(textBox1.Text, textBox2.Text);
_presenter.View.Clear();
textBox1.Show();

}
#region IShapeView Members

public void Clear()
{
textBox2.Text = "";
textBox1.Text = "";
}

#endregion


public void NewShape(ShapeSearchResult shape)
{
textBox1.Text = shape.ShapeId;
textBox2.Text = shape.ShapeName;
}

public void EditShape(ShapeSearchResult shape)
{

}


private delegate void ShowShapeSearchResultsDelegate(ShapeSearchResult[] shapeSearchResult);
#region IShapeView Members

public void ShowShapeSearchResults(ShapeSearchResult[] shapeSearchResult)
{

}

public void ShowErrorMessage(string message)
{
MessageBox.Show(message, Properties.Resources.ErrorDialogTitle);
}

#endregion

#region ISmartPartInfoProvider Members

public ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)
{
return _presenter.GetSmartPartInfo(smartPartInfoType);
}

#endregion
}
}

In InterFace I can Write

using Matias.Infrastructure.Interface.BusinessEntities;

namespace Matias.MasterModule
{
public interface IShapeView
{
void Clear();
void NewShape(ShapeSearchResult shape);
void ShowErrorMessage(string message);
void EditShape(ShapeSearchResult shape);


}
}

In Presenter i can write


using System;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeUI;
using Matias.Infrastructure.Interface;
using Matias.Infrastructure.Interface.Constants;
using Microsoft.Practices.CompositeUI.EventBroker;

using Matias.Infrastructure.Interface.BusinessEntities;
using Matias.MasterModule.ShapeService;
using Matias.Infrastructure.Interface.Services;
using Matias.MasterModule.Constants;
using Microsoft.Practices.CompositeUI.SmartParts;


namespace Matias.MasterModule
{
public class ShapeViewPresenter : Presenter<IShapeView>
{
private IShapeServiceProxy _service = null;
private IEntityTranslatorService _translator;
private UserLibrary.EntryMode _entrymode;
private OrderMode _orderMode;

InjectionConstructor
public ShapeViewPresenter(OrderMode mode)
{
_orderMode = mode;
}


ServiceDependency
public IShapeServiceProxy IShapeServiceProxy
{
get { return _service; }
set { _service = value; }
}

ServiceDependency
public IEntityTranslatorService IEntityTranslatorService
{
get { return _translator; }
set { _translator = value; }
}

public void InsertShape(string shapeid, string shapename)
{

_service.InsertShape(3000, shapeid, shapename);


}

public void EditShape(string shapeid)
{
_service.EditShape(3000, shapeid);

}

private void ShowShape()
{
ShapeSearchResult shape;



switch (_orderMode)
{
case OrderMode.New:
shape = new ShapeSearchResult();
View.NewShape(shape);
break;

case OrderMode.Edit:

//shape = IShapeServiceProxy.DeleteShape(3000, shapeid);
//shape.ShapeId = IShapeServiceProxy.EditShape(3000, shape.ShapeId.ToString());
//View.EditShape(shape);
break;

default:
break;
}
}

public override void OnViewReady()
{
base.OnViewReady();
View.Clear();
ShowShape();
}

public void OnCloseView()
{
base.CloseView();
}
public void Exit()
{
CloseView();
}

internal ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)
{
ISmartPartInfo info = (ISmartPartInfo)Activator.CreateInstance(smartPartInfoType);

switch (_orderMode)
{
case OrderMode.New:
info.Title = Properties.Resources.NewOrderTitle;
info.Description = Properties.Resources.NewOrderDescription;
break;

case OrderMode.Edit:
info.Title = Properties.Resources.EditOrderTitle;
info.Description = Properties.Resources.EditOrderDescription;
break;

default:
break;
}

return info;
}

}
}
Can anyone tell me where I can see for resolving this issue.

Beena Desai


Developer
Mar 28, 2007 at 5:12 PM
Hi Beena Desai, I followed all your steps, and I didn’t get any compilation error. Could you please post the full compilation error description that you are getting? (please include the full stack trace).

Ezequiel Jadib
http://staff.southworks.net/blogs/ejadib
Apr 2, 2007 at 11:04 AM
Hi Ezequiel Jadib
Thabks for tour reply. Sorry for little delay in reply as I was away from my office. Anyway As u say I scan stack and find one of my class was not proper and some of declarations were missing. So as soon as I clear it everything works fine. Once again thanks for your response.

Beena Desai