public ActionResult ScheduledTask(string EntityName, long BizId) { var user = new InternalUser(); var MainBiz = new BusinessRule(); List <BusinessRule> businessrules = new List <BusinessRule>(); using (var br = new BusinessRuleContext()) { var rolebr = br.BusinessRules.Where(p => p.Roles != null && p.Roles.Length > 0 && !p.Disable).ToList(); MainBiz = rolebr.FirstOrDefault(p => p.Id == BizId); foreach (var rules in rolebr) { if (rules.Roles.Split(",".ToCharArray()).Contains("All")) { businessrules.Add(rules); } } } if (MainBiz != null) { (user).businessrules = businessrules.ToList(); var database = new ApplicationContext(user, 0); var myType = Type.GetType("GeneratorBase.MVC.Models." + EntityName + ""); //var data = GetGenericData(database, myType).ToListAsync(); //foreach (var item in data.Result) var data = GetTableObject(database, EntityName); var dataList = (IQueryable <object>)data; foreach (var item in dataList.ToList()) { if (ApplyRule.CheckRule <object>(item, MainBiz, MainBiz.EntityName)) { database.Entry(item).State = EntityState.Modified; database.SaveChanges(); } } ScheduledTaskHistoryContext sthcontext = new ScheduledTaskHistoryContext(); var itemhistory = sthcontext.ScheduledTaskHistorys.FirstOrDefault(p => p.BusinessRuleId == MainBiz.Id); itemhistory.Status = "Processed"; sthcontext.Entry(itemhistory).State = EntityState.Modified; sthcontext.SaveChanges(); RegisterScheduledTask nexttask = new RegisterScheduledTask(); nexttask.RegisterTask(MainBiz.EntityName, MainBiz.Id); } return(Json("Success", "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet)); }
private UIObject[] GetObjects( Plugin plugin, XDataHolder input, ValueInfo valueInfo ) { ///Create UI elements for each input var uiObjects = new List <UIObject>(); foreach (var data in input.ReadAll()) { switch (data.Type) { case "Single": uiObjects.Add(new UIObject(data.Key)); uiObjects.Add( new UIObject( data.RawValue, null, (single) => { input.Write(data.Key, (float)single); valueInfo.ValueChanged = true; }, true ) ); break; case "Integer": uiObjects.Add(new UIObject(data.Key)); uiObjects.Add( new UIObject( (float)(int)data.RawValue, null, (single) => { input.Write(data.Key, (int)(float)single); valueInfo.ValueChanged = true; }, true ) ); break; case "Vector3": void Put(object single, int i) { var v3 = input.ReadVector3(data.Key); v3[i] = (float)single; input.Write(data.Key, v3); valueInfo.ValueChanged = true; } uiObjects.Add(new UIObject(data.Key)); uiObjects.Add( new UIObject( ((Vector3)data.RawValue).x, null, f => Put(f, 0) ) ); uiObjects.Add( new UIObject( ((Vector3)data.RawValue).y, null, f => Put(f, 1) ) ); uiObjects.Add( new UIObject( ((Vector3)data.RawValue).z, null, f => Put(f, 2), true ) ); break; case "Boolean": uiObjects.Add(new UIObject(data.Key)); uiObjects.Add( new UIObject( data.RawValue, null, (boolean) => { input.Write(data.Key, (bool)boolean); valueInfo.ValueChanged = true; }, true ) ); break; } } if (uiObjects.Count > 0) { var lastObj = uiObjects[uiObjects.Count - 1]; lastObj.NewLine = true; uiObjects[uiObjects.Count - 1] = lastObj; } ///Create global UI elements ApplyRule applyRule = (ApplyRule)((int)plugin.ApplyRule % (int)ApplyRule.NoEnable); if (applyRule == ApplyRule.OnApply) { uiObjects.Add( new UIObject( null, "Apply", (b) => { valueInfo.WasApplied |= b is bool?(bool)b: false; } ) ); } if ((plugin.ApplyRule & ApplyRule.NoEnable) == ApplyRule.Disabled) { uiObjects.Add( new UIObject( "Enabled:" ) ); uiObjects.Add( new UIObject( plugin.Enabled, null, (b) => { plugin.Enabled = b is bool ?(bool)b : plugin.Enabled; valueInfo.ValueChanged = true; valueInfo.WasApplied = true; }, true ) ); } return(uiObjects.ToArray()); }