I do this workflow with bookmark
namespace wwwfff
{
public sealed class CodeActivity3 : NativeActivity
{
public InArgument<string> EventName1
{ get; set; }
public OutArgument<string> Data1
{ get; set; }
protected override void Execute(NativeActivityContext context)
{
context.CreateBookmark(EventName1.Get(context), new BookmarkCallback(HandleEvent));
Console.WriteLine("Pppppppppppp");
}
private void HandleEvent(NativeActivityContext context, Bookmark bookmark, object obj)
{
if (obj != null)
{
Data1.Set(context, obj.ToString());
}
}
}
}
and i write in program
class Program
{
static void Main(string[] args)
{
WorkflowApplication wf = new WorkflowApplication(new Workflow1());
wf.Run();
wf.ResumeBookmark("C1", "Hello word");
}
}
but it doesn't type "ppppppp"
the workflow is only start ->CodeActivity3->writline()
thanks
you need probably override property in CodeActivity3 class
protected override bool CanInduceIdle { get { return true; } }
Related
I am not sure why this error is coming. Below My code:
Context:
public partial class AdminLoginEntities : DbContext
{
public AdminLoginEntities() : base("name=AdminLoginEntities"){ }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
//throw new UnintentionalCodeFirstException();
modelBuilder.Entity<AdminLogin>().ToTable("AdminLogin");
}
public virtual DbSet<AdminLogin> AdminLogins { get; set; }
}
Controller Code:
AdminLoginEntities objadminE = new AdminLoginEntities();
[HttpPost]
[Route("AddAdmin")]
public IHttpActionResult InserNewAdmin(AdminLogin data)
{
if(!ModelState.IsValid)
{
return BadRequest(ModelState);
}
try
{
objadminE.AdminLogins.Add(data);
objadminE.SaveChanges();
}
catch(Exception)
{
throw;
}
return Ok(data);
}
I am having issues with binding context, after initialisation it doesn't update. so the button is not clickable and the name label doesn't update as its stated in ctor. This is the first and only page.
Page
<Label x:Name="NamesLabels" Text="{Binding Name}"/>
<Button HorizontalOptions="FillAndExpand" Text="Show scanner" Command="{Binding ShowScannerCommand}"/>
public MainPage()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
BindingContext = new MainPageViewModel();
}
//also tried
protected override void OnAppearing()
{
base.OnAppearing();
var context = new MainPageViewModel();
BindingContext = context;
name.Source = context.Name;
btn.Command = context.ShowScannerCommand;
}
ViewModel
public string Name
{
get => _name;
private set
{
_name = value;
NotifyPropertyChanged("Name");
}
}
public ICommand ShowScannerCommand { get; private set; }
public MainPageViewModel()
{
Name = "rwatag";
//have tried _name = "rwatag";
ShowScannerCommand = new Command(() => ShowScanner());
}
void ShowScanner()
{
System.Diagnostics.Debug.WriteLine("result");
}
this is what I get after clicking on button and when debugging the code doesn't get fired
[InputEventReceiver] Slow Input: took 118ms in dispatching, now at finishInputEvent (MotionEvent: event_seq=0, seq=78288, action=ACTION_DOWN)
Resolved pending breakpoint at '/Users/de/Projects/Demo/Demo/View/MainPage.xaml.cs:26,1' to void Demo.MainPage.OnAppearing () [0x00014].
[zygote] Do partial code cache collection, code=61KB, data=59KB
[zygote] After code cache collection, code=61KB, data=59KB
[zygote] Increasing code cache capacity to 256KB
I use your code and it works well on my side. I just add a string _name { get; set; } property and implement the INotifyPropertyChanged interface in MainPageViewModel.
Here is the code example:
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
BindingContext = new MainPageViewModel();
}
}
public class MainPageViewModel : INotifyPropertyChanged
{
string _name { get; set; }
public string Name
{
get => _name;
private set
{
_name = value;
OnPropertyChanged("Name");
}
}
public ICommand ShowScannerCommand { get; private set; }
public MainPageViewModel()
{
Name = "rwatag";
ShowScannerCommand = new Command(() => ShowScanner());
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
void ShowScanner()
{
System.Diagnostics.Debug.WriteLine("result");
}
}
I have a custon renderer entry
public class EntryPerson: Entry
{
public int TestInt { get; private set; }
public EntryPerson(int TestInt)
{
this.TestInt = TestInt;
}
}
and in xaml in have this
<local:EntryPerson >
but i want to use so:
<local:EntryPerson TextInt="0" >
how pass untill to my render?
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
Check the following code
public class EntryPerson
{
public int TestInt { get; set; }
public EntryPerson()
{
}
public EntryPerson(int test)
{
TestInt = test;
}
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if(Control!=null)
{
var element = Element as EntryPerson;
var test = element.TestInt;
//Element.TextChanged += Element_TextChanged;
}
}
I'm new to the forum and in the "world" of programming. I bumped into a problem while creating a game with SignalR Web technology and it is expressed in terms of access to the database (using EF) with multiple requests from UI-a. What is the best solution using the repository pattern? The decision to me at this stage is added Lock {} structure in each method, which accesses the database. How can I avoid blocking requests to a server?
public interface IRepository<T> where T : class
{
IQueryable<T> GetAll();
T GetById(object id);
void Add(T item);
void Update(T item);
void Delete(T item);
void Delete(object id);
}
public class DBRepository<T> : IRepository<T> where T : class
{
private DbContext DbContext;
private DbSet<T> Entities
{
get
{
return this.DbContext.Set<T>();
}
}
public DBRepository(DbContext context)
{
this.DbContext = context;
}
public IQueryable<T> GetAll()
{
return Entities.AsQueryable();
}
.....
public class TicTacToeContext : DbContext
{
public DbSet<Game> Games { get; set; }
public DbSet<Guess> Guesses { get; set; }
public DbSet<Message> Messages { get; set; }
public DbSet<MessageState> MessageStates { get; set; }
public DbSet<MessageType> MessageTypes { get; set; }
public DbSet<User> Users { get; set; }
public TicTacToeContext()
: base("TicTacToeDb")
{
}
public interface IGameService
{
void CreateGame(CreateGameModel gameModel);
void JoinGame(JoinGameModel gameModel);
...
public abstract class BaseService
{
public IRepository<User> UserRepository;
public IRepository<Game> GameRepository;
...
public class GameService : BaseService, IGameService
{
public GameService(IRepository<Game> gameRepositort, IRepository<User> userRepository, ISessionService sessionService)
{
this.UserRepository = userRepository;
this.GameRepository = gameRepositort;
}
public void CreateGame(CreateGameModel gameModel)
{
....
}
public class TicTacToeHub : Hub
{
IUserService UserServise;
IGameService GameServise;
private static object _syncRoot = new object();
public TicTacToeHub(IUserService userService, IGameService gameService)
{
this.UserServise = userService;
this.GameServise = gameService;
}
.....
public void ReturnOpenGamesToClient(string sessionKey)
{
IEnumerable<GameModel> openGames;
lock (_syncRoot)
{
openGames = GameServise.GetOpenGames(sessionKey).ToList();
}
Clients.Caller.updateOpenGamesList(openGames);
}
Why locks? You use a DB and only update one entity (No transaction scope needed).
Locks needs to be used for Inmemory types like IList or IDictionary otherwise it will crash when one request reads and another one writes. But SQL takes care of this for you
I am new in Fluent NHibernet and i am using Fluent NHibernet in my asp.net application
this is my Poco class
public virtual int CategoryId { get; set; }
public virtual string CategoryName { get; set; }
public virtual bool IsActive { get; set; }
public virtual bool IsDeleted { get; set; }
My Mapping Class
public class clsCategoryMap : ClassMap<clsCategory>
{
public clsCategoryMap()
{
Id(x => x.CategoryId).Column("CategoryId").GeneratedBy.Assigned().Not.Nullable();
Map(x => x.CategoryName).Column("CategoryName").Not.Nullable();
Map(x => x.IsActive).Column("IsActive").Not.Nullable();
Map(x => x.IsDeleted).Column("IsDeleted").Not.Nullable();
Table("tblCategory");
}
}
Poco class and Mapping class both saprated in class Liberar like: DAL for Poco class and BLL For Mapping class.
And i create helper class it's below:
public class FNHelper
{
private static ISessionFactory _sessionfactory;
private static ISessionFactory SessionFactory
{
get
{
if (_sessionfactory == null) { InitializationSessionFactory(); }
return _sessionfactory;
}
}
private static void InitializationSessionFactory()
{
_sessionfactory = Fluently.Configure()
.Database(
MsSqlConfiguration.MsSql2008
.ConnectionString(#"Server=test\SQLEXPRESS;Database=TestDB;User ID=sa;Password=root;")
.DefaultSchema("dbo")
.ShowSql()
)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<clsCategory>())
.ExposeConfiguration((cfg => new SchemaUpdate(cfg).Execute(true, true)))
.BuildSessionFactory();
}
public static ISession OpenSession()
{
return SessionFactory.OpenSession();
}
private static void BuildSchema(NHibernate.Cfg.Configuration configuration)
{
String SqliteRefFileName = #"D:\Projects\MeshpsDB.sql";
if (File.Exists(SqliteRefFileName))
File.Delete(SqliteRefFileName);
new SchemaExport(configuration)
.Create(true, true);
}
}
And finally i am doing in my form it's below:
protected void btnSave_Click(object sender, EventArgs e)
{
using (var session = FNHelper.OpenSession())
{
using (var tranction = session.Transaction)
{
var objCategory = new clsCategory
{
CategoryId = 0,
CategoryName = txtName.Text.Trim(),
IsActive = true,
IsDeleted = false
};
session.Save(objCategory);
tranction.Commit();
}
}
}
when i click on button then i am getting
so every one please tell me how can i solve this issue.
change m.FluentMappings.AddFromAssemblyOf<clsCategory>() to m.FluentMappings.AddFromAssemblyOf<clsCategoryMap>() because its the mappingss you want to add and these reside in another assembly.