public bool RestartSession(int sessionID) { Utils.Helper_Trace("MANAGER SERVICE", "Entering RestartSession"); XORCISMModel.XORCISMEntities model; model = new XORCISMModel.XORCISMEntities(); try { SESSION session; session = model.SESSION.SingleOrDefault(s => s.SessionID == sessionID); if (session.Status != XCommon.STATUS.ERROR.ToString() && session.Status != XCommon.STATUS.CANCELED.ToString()) { return false; } session.Status = XCommon.STATUS.IDLE.ToString(); model.SaveChanges(); } catch (Exception ex) { Utils.Helper_Trace("MANAGER SERVICE", "Exception = " + ex.Message); return false; } Utils.Helper_Trace("MANAGER SERVICE", "Leaving RestartSession"); // Finished return true; }
static public bool Helper_RightEnforcement(Guid userID, string securableType, RIGHT right) { XORCISMModel.XORCISMEntities model; model = new XORCISMModel.XORCISMEntities(); if (model.USERACCOUNT.FirstOrDefault(o => o.UserID == userID && o.UserAccountTypeID == 1) != null) //TODO Hardcoded "Administrator" { return(true); } List <string> listRACI; listRACI = new List <string>(); switch (right) { case RIGHT.CREATE: listRACI.Add("R"); break; case RIGHT.MODIFY: listRACI.Add("R"); listRACI.Add("A"); listRACI.Add("C"); break; case RIGHT.DELETE: listRACI.Add("R"); listRACI.Add("A"); break; case RIGHT.VIEW: listRACI.Add("R"); listRACI.Add("A"); listRACI.Add("C"); listRACI.Add("I"); break; } foreach (string raci in listRACI) { //RACISECURABLE raciSecurable; //raciSecurable = model.RACISECURABLE.FirstOrDefault(o => o.UserID == userID && o.SecurableType == securableType && o.RACIValue == raci); //if (raciSecurable != null) return(true); } return(false); }
public static string FindCPE(string rawString) { string myCPE = string.Empty; XORCISMModel.XORCISMEntities model; model = new XORCISMModel.XORCISMEntities(); // define which character is seperating fields char[] splitter = { ' ' }; string[] words = rawString.Split(splitter); for (int x = 0; x < words.Length; x++) { var possiblecpes = from c in model.CPE where SqlMethods.Like(c.CPEName, "%" + words[x].ToLower() + "%") select c; } return(myCPE); }
//static public void Helper_Notify(Guid userID, string securableType, string securableID, XCommon.RIGHT right) static public void Helper_Notify(int userID, string securableType, string securableID, XCommon.RIGHT right) { XORCISMModel.XORCISMEntities model; model = new XORCISMModel.XORCISMEntities(); string username = ""; //username = model.USERS.FirstOrDefault(o => o.UserId == userID).UserName; username = model.USER.FirstOrDefault(o => o.UserID == userID).UserName; USERACCOUNT uia = null; //uia = model.USERACCOUNT.FirstOrDefault(o => o.UserID == userID); //TODO review uniqueidentifier and uncomment int accountID; accountID = uia.ACCOUNT.AccountID; //List<RACISECURABLEINSTANCE> list; //list = model.RACISECURABLEINSTANCE.Where(o => o.SecurableType == securableType && o.SecurableID == securableID && o.AccountID == accountID && o.RACIValue == "I").ToList(); string verb = ""; switch (right) { case XCommon.RIGHT.CREATE: verb = "created"; break; case XCommon.RIGHT.DELETE: verb = "deleted"; break; case XCommon.RIGHT.MODIFY: verb = "modified"; break; case XCommon.RIGHT.UNLOCK: verb = "unlocked"; break; case XCommon.RIGHT.RELOAD: verb = "reloaded"; break; } /* * foreach (RACISECURABLEINSTANCE instance in list) * { * NOTIFICATION notification; * notification = new XORCISMModel.NOTIFICATION(); * notification.CreatedDate = DateTimeOffset.Now; * notification.UserID = instance.UserID; * * switch (securableType) * { * case "TASK_ASSET": * notification.NotificationMessage = string.Format("The asset #{0} has been {1} by user '{2}'", securableID, verb, username); * break; * case "TASK_USER": * notification.NotificationMessage = string.Format("The user #{0} has been {1} by user '{2}'", securableID, verb, username); * break; * case "TASK_JOB": * notification.NotificationMessage = string.Format("The user #{0} has been {1} by user '{2}'", securableID, verb, username); * break; * } * notification.timestamp = DateTimeOffset.Now; * model.NOTIFICATION.Add(notification); * } * * model.SaveChanges(); */ }
public static void Persist(Malware.MalwareScan malwareScan, int jobID, string providerName, XORCISMModel.XORCISMEntities m_model) { //TODO /* * //If the malware doesn't exist * MALWARESCAN newMalwareScan; * newMalwareScan = new MALWARESCAN(); * newMalwareScan.DomaineName = malwareScan.Domaine; * newMalwareScan.Date = DateTime.Now; * newMalwareScan.JobID = jobID; * foreach (Malware.MalwarePage malwarePage in malwareScan.MalwarePages) * { * MALWAREPAGE MalwarePage = new MALWAREPAGE(); * MalwarePage.PageUrl = malwarePage.Url; * * foreach (Malware.MalwareSnippet malwareSnippet in malwarePage.MalwareSnippets) * { * MALWARESNIPPET MalwareSnippet = new MALWARESNIPPET(); * MalwareSnippet.Snippet = malwareSnippet.Snippet; * MalwarePage.MALWARESNIPPET.Add(MalwareSnippet); * } * newMalwareScan.MALWAREPAGE.Add(MalwarePage); * } * m_model.AddToMALWARESCAN(newMalwareScan); * m_model.SaveChanges(); */ }