protected override void ImplementBusinessLogic() { // var sqlDataCommand = new System.Data.SqlClient.SqlCommand(); sqlDataCommand.CommandText = "SELECT TOP 1 * from [SW_SYS_MSG] where [MSG_STATE]=@msgState and [MSG_USERID] = @userid order by [MSG_GENTIME] desc"; sqlDataCommand.Parameters.AddWithValue("@msgState", (int)Soway.Event.MsgState.Generate); sqlDataCommand.Parameters.AddWithValue("@userid", this.Info.User.UserId); var db = new Soway.Model.SqlServer.dbContext(this.Info.CurrentSqlCon, this); foreach (var msg in db.GetBySqlCommand(this.model, sqlDataCommand)) { this.msgResult.Messages.Add(new MessageInfo() { GernerationTime = msg.GenerateTime, IsTimeOut = false, IsRead = false, MessageContent = msg.MessageFmt, MessageID = msg.MessageId.ToString(), ResultKey = msg.ObjId, ResultView = (msg.View == null? 0:msg.View.ID) }); msg.State = MsgState.Push; msg.PushTime = DateTime.Now; db.Save(msg); } }
internal void CreateMessage(dynamic obj, dynamic defs) { var userModel = ModelFac.Models.First(p => p.ClassName == "SOWAY.ORM.AUTH.AuthorizedUser"); var items = new Soway.Model.SqlServer.dbContext(this.appcon, this.conFac).GetBySqlCommand(userModel, "Select * from [SW_APP_AUTH_USER]"); new MessageFactory(con).CreateMessage(MsgNotifyType.All, items, obj, defs); }
public View GetView(object id) { var proxy = new Soway.Model.SqlServer.dbContext(this.Con, this.ConFac).GetDetail(Global.ViewMode, id); var view = new ModelHelper(this.ConFac).GetFromProxy(proxy) as View;; view.Items = view.Items.OrderBy(p => p.ShowIndex).ToList(); return(view); }
protected override void ImplementBusinessLogic() { AutoViewFactory factory = new AutoViewFactory(this.Info.AppSqlCon, this); View view = factory.GetView(Option.ViewName); var sql = GetViewSql(view); var item = view.Items.FirstOrDefault(p => p.Name == this.Option.ViewItemId); if (item.SelectedView != null) { sql = GetViewSql(item.SelectedView); } var context = new Soway.Model.Context.InputContext(sql); List <Soway.Model.Context.InputQueryResult> list = null; Soway.Model.ModelBindingList source = null; var sourceExp = ""; sourceExp = item.ItemSourceExp; if (String.IsNullOrEmpty(sourceExp)) { sourceExp = item.Property.Source; } if (String.IsNullOrEmpty(sourceExp) == false) { if (Option.IsAdded && String.IsNullOrEmpty(Option.OwnerId) == false && view.Model.Owner != null) { var parentObj = new Soway.Model.SqlServer.dbContext(sql, this).GetDetail(view.Model.Owner, Option.OwnerId); var addedItem = new Soway.Model.ObjectProxy(item.Property.Model, this); addedItem.Owner = parentObj; source = addedItem[sourceExp] as Soway.Model.ModelBindingList; } else if (String.IsNullOrEmpty(this.Option.ObjID) == false) { var obj = new Soway.Model.SqlServer.dbContext(sql, this).GetDetail(view.Model, this.Option.ObjID); source = new Soway.Model.SqlServer.dbContext(sql, this).GetDetail(view.Model, this.Option.ObjID)[item.Property.Source] as Soway.Model.ModelBindingList; } } list = context.Query(item.Property.Model, Option.Text, source, null, 5); this.QueryResult.Items = new List <QueryItem>(); foreach (var dataitem in list) { this.QueryResult.Items.Add(new QueryItem() { Id = dataitem.id.ToString(), Text = dataitem.Text }); } }
private void saveMsgToDb(List <dynamic> items) { var dbContext = new Soway.Model.SqlServer.dbContext(this.con, this.conFac); foreach (var item in items) { dbContext.Create(item); } }
public T GetTheOne(object id, Soway.Model.SqlCon con = null) { var objectProxy = new Soway.Model.SqlServer.dbContext(GetCon(con), this.ConFac).GetDetail(Model, id, false); if (objectProxy.IsLoad == LoadType.NoObj) { return(default(T)); } return((T) new ModelHelper(this.ConFac).GetFromProxy(objectProxy)); }
public void Work() { //1 得到所有事件的定义 var appModel = ModelFac.Models.First(p => p.ClassName == "Soway.Model.App.Application");; isRun = true; while (isRun) { try { var apps = new Soway.Model.SqlServer.dbContext(this.conFac.GetCurrentContext().SysCon, this.conFac).GetBySqlCommand(appModel, "Select * from SW_APPLICATION"); var appfac = new Soway.Model.App.AppFac(this.conFac.GetCurrentContext().SysCon, this.conFac); foreach (dynamic app in apps) { // passed Soway.Model.SqlCon con = new Soway.Model.ModelHelper(this.conFac).GetFromProxy(app.SysCon) as Model.SqlCon; var fac = new EventDefFactory(con); List <Model.SqlCon> dbs = new List <Model.SqlCon>(); var evtFac = new EventFactory(conFac, con); foreach (dynamic db in app.DataBase) { Soway.Model.SqlCon dbSqlCon = new Soway.Model.ModelHelper(this.conFac).GetFromProxy(db.Conection) as Soway.Model.SqlCon; dbs.Add(dbSqlCon); } // to test //2 根据事件去检查 foreach (dynamic defs in fac.GetDefines()) { foreach (var db in dbs) { evtFac.CheckAndGenerate(defs, db, con); } } } }catch (Exception ex) { } System.Threading.Thread.Sleep(this.sleepMiliseconds); } //3生成时间 }
private dynamic MakeEvent(dynamic defs, dynamic obj, Soway.Model.SqlCon conStr) { dynamic item = new SqlDataProxy(this.model, this.conFac, LoadType.Null, conStr); if (defs.Operation != null) { item.DealOpertionText = defs.Operation.Name.ToString(); } item.Defination = defs; item.EventGenerationTime = DateTime.Now; item.ObjId = (obj.ID ?? "").ToString(); item.View = defs.View; item.EventMsg = defs.MsgFmt; var db = new Soway.Model.SqlServer.dbContext(conStr, this.conFac); if (db.IsExits(item)) { return(null); } db.Create(item); return(item); }