public void Create(User user) { using (OOCEntities db = new OOCEntities()) { try { db.User.AddObject(user); db.SaveChanges(); } catch { throw new FaultException("TRANSACTION_FAILED"); } } }
//string guid, string elementSet?,string quantity?,string parameterValue,string creation //根据task的计算结果创建outputParameter表项 public void Create(string taskGuid, string compositionGuid, string compositionModelGuid, string elementSet, string quantity, string parameterValue, DateTime creation) { using (OOCEntities db = new OOCEntities()) { OutputParameter outputParameter = new OutputParameter(){ guid = GuidUtil.newGuid(), taskGuid = taskGuid, compositionGuid = compositionGuid, compositionModelGuid = compositionModelGuid, elementSet = elementSet, quantity = quantity, parameterValue = parameterValue, creation = creation }; db.OutputParameter.AddObject(outputParameter); db.SaveChanges(); } }
public void AddTaskFileMapping(string guid, string fileName, string relativePath, TaskFileType type, bool isDownloadable) { using (OOCEntities db = new OOCEntities()) { TaskFileMapping taskFileMapping = new TaskFileMapping() { taskGuid = guid, fileName = fileName, relativePath = relativePath, type = (sbyte)type, isDownloadable = isDownloadable }; try { db.TaskFileMapping.AddObject(taskFileMapping); db.SaveChanges(); } catch { } } }
public TaskAssignResponse AssignPendingTask(string instanceName) { lock (assigningLock) { using (OOCEntities db = new OOCEntities()) { IQueryable<Task> result = from o in db.Task where o.state == (sbyte)TaskState.Ready select o; if (!result.Any()) { throw new FaultException("NO_TASK_AVAILABLE"); } Task task = result.First(); task.state = (sbyte)TaskState.Assigned; task.instanceName = instanceName; db.SaveChanges(); return new TaskAssignResponse(task, QueryTaskFileMapping(task.guid, TaskFileType.Input), task.triggerInvokeTime); } } }
public void AddOne(ResultLogs ModelResultLog) { /*strSql.Append("insert into ResultLogs (ID,ModelID,UserID,CalTime,FileFolder)"); strSql.Append(" values(@ID,@ModelID,@UserID,@CalTime,@FileFolder);"); SqlParameter[] parameters ={ new SqlParameter("@ID", SqlDbType.NVarChar,50), new SqlParameter("@ModelID",SqlDbType.NVarChar,50), new SqlParameter("@UserID",SqlDbType.NVarChar,50), new SqlParameter("@CalTime",SqlDbType.DateTime), new SqlParameter("@FileFolder",SqlDbType.NVarChar,200), }; parameters[0].Value = ModelResultLog.ID; parameters[1].Value = ModelResultLog.ModelID; parameters[2].Value = ModelResultLog.UserID; parameters[3].Value = ModelResultLog.CalTime; parameters[4].Value = ModelResultLog.FileFolder; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);*/ using (OOCEntities db = new OOCEntities()) { db.ResultLogs.AddObject(ModelResultLog); db.SaveChanges(); } }
public void AddAclEntry(int id, string entry) { using (OOCEntities db = new OOCEntities()) { IQueryable<User> result = from o in db.User where o.id == id select o; if (!result.Any()) { throw new FaultException("USER_NOT_EXISTS"); } User user = result.First(); List<string> entries = SerializationUtil.Deserialize<List<string>>(user.acl); if (entries == null) entries = new List<string>(); if (entries.Contains(entry)) { throw new FaultException("ENTRY_ALREADY_EXISTED"); } entries.Add(entry); user.acl = SerializationUtil.Serialize(entries); db.SaveChanges(); } }
public string Create(string compositionGuid, int userId, string triggerInvokeTime) { using (OOCEntities db = new OOCEntities()) { IQueryable<Composition> result = from o in db.Composition where o.guid == compositionGuid select o; if (!result.Any()) { throw new FaultException("COMPOSITION_NOT_EXISTS"); } Composition composition = result.First(); CompositionData compositionData = new CompositionData(composition); Task task = new Task() { guid = GuidUtil.newGuid(), compositionGuid = compositionGuid, compositionData = compositionData.Serialized, state = (sbyte)TaskState.Created, userId = userId, triggerInvokeTime = triggerInvokeTime, modelProgress = new ModelProgress().Serialized }; db.Task.AddObject(task); db.SaveChanges(); SyncCompositionInputFiles(task.guid); return task.guid; } }
public void UpdateState(string guid, TaskState state) { using (OOCEntities db = new OOCEntities()) { IQueryable<Task> result = from o in db.Task where o.guid == guid select o; if (!result.Any()) { throw new FaultException("TASK_NOT_EXISTS"); } Task task = result.First(); task.state = (sbyte)state; if (state == TaskState.Running) { task.timeStarted = System.DateTime.Now; } if (state == TaskState.Completed) { task.timeFinished = System.DateTime.Now; } db.SaveChanges(); } }
public void UpdateModelProgress(string guid, ModelProgress modelProgress) { using (OOCEntities db = new OOCEntities()) { IQueryable<Task> result = from o in db.Task where o.guid == guid select o; if (!result.Any()) { throw new FaultException("TASK_NOT_EXISTS"); } Task task = result.First(); task.modelProgress = modelProgress.Serialized; db.SaveChanges(); } }
public void SyncComposition(string guid) { using (OOCEntities db = new OOCEntities()) { IQueryable<Task> result = from o in db.Task where o.guid == guid select o; if (!result.Any()) { throw new FaultException("TASK_NOT_EXISTS"); } Task task = result.First(); CompositionData compositionData = new CompositionData(task.Composition); task.compositionData = compositionData.Serialized; db.SaveChanges(); SyncCompositionInputFiles(guid); } }
public void ReportInstanceFault(string instanceName) { using (OOCEntities db = new OOCEntities()) { IQueryable<Task> result = from o in db.Task where o.instanceName == instanceName && o.state >= (sbyte)TaskState.Assigned && o.state <= (sbyte)TaskState.Finishing select o; foreach (Task task in result) { task.state = (sbyte)TaskState.Aborted; } db.SaveChanges(); } }
public void UpdatePassword(int id, string password) { using (OOCEntities db = new OOCEntities()) { IQueryable<User> result = from o in db.User where o.id == id select o; if (!result.Any()) { throw new FaultException("USER_NOT_EXISTS"); } User user = result.First(); user.passhash = Hash(password); db.SaveChanges(); } }
public void UpdateMobile(int id, string mobile) { using (OOCEntities db = new OOCEntities()) { IQueryable<User> result = from o in db.User where o.id == id select o; if (!result.Any()) { throw new FaultException("USER_NOT_EXISTS"); } User user = result.First(); user.mobile = mobile; db.SaveChanges(); } }