private void IMSessionStarted(GroupInstantMessage im) { if (!m_GroupsService.Members.ContainsKey(im.FromAgent, im.ToGroup, im.FromAgent)) { throw new Exception("Not a member"); } GroupSession session = m_ActiveChats.GetOrAddIfNotExists(im.ToGroup.ID, () => new GroupSession(im.ToGroup)); im.IMSessionID = session.SessionID; im.FromGroup = im.ToGroup; try { foreach (GroupMember gm in m_GroupsService.Members[im.FromAgent, im.ToGroup]) { session.Participants.AddIfNotExists(gm.Principal); } } finally { m_ActiveSessions.RemoveIf(im.IMSessionID, (entry) => entry.Participants.Count == 0); m_ActiveChats.RemoveIf(im.ToGroup.ID, (entry) => entry.Participants.Count == 0); } DistributeMessage(session, im); }
public GroupSession UpdateGroupSession(GroupSession GroupSession, List <Person> persons) { try { var groupSession = _groupSessionRepository.Get(GroupSession.Id); _groupSesionPersonRepository.Remove(GroupSession.GroupSesionPersons?.ToList()); GroupSession.GroupSesionPersons = new List <GroupSesionPerson>(); if (persons != null) { foreach (var person in persons) { GroupSession.GroupSesionPersons.Add(new GroupSesionPerson() { IsDelete = false, GroupSessionId = GroupSession.Id, PersonId = person.Id, }); } } return(_groupSessionRepository.Update(GroupSession)); } catch (Exception e) { return(null); } }
internal static bool IsTodayActiveGroupSession(string exchangeID, string groupID) { lock (_lockObj) { GroupSession session = m_todayActiveSessions.Single(b => b.ExchangeID == exchangeID && b.GroupID == groupID); return(session.SessionStartTime.TimeOfDay < DateTime.Now.TimeOfDay && session.SessionEndTime.TimeOfDay > DateTime.Now.TimeOfDay && !_marketsOff.Contains(exchangeID)); } }
public GroupSession InsertGroupSession(GroupSession GroupSession) { try { return(_groupSessionRepository.Insert(GroupSession)); } catch (Exception e) { return(null); } }
private void DistributeMessage(GroupSession session, GroupInstantMessage im) { try { foreach (UGUI target in session.Participants) { m_IMRouter.SendWithResultDelegate(im.GetAgentIM(target)); } } catch { /* do not pass any from here since we cannot reliably say so which failed */ } }
public ActionResult Create([Bind(Include = "sessionSubject,sessionDesc,endDate")] GroupSession groupSessionToCreate, string GId, string filesToUpload) { NullChecker.NullCheck(new object[] { GId }); if (ModelState.IsValid) { var gid = EncryptionHelper.Unprotect(GId); var group = unitOfWork.GroupRepository.GetByID(gid); if (group.Admins.Any(a => AuthorizationHelper.isRelevant(a.UserId))) { var fileUploadResult = UploadHelper.UpdateUploadedFiles(filesToUpload, null, "GSession"); groupSessionToCreate.image = fileUploadResult.ImagesToUpload; groupSessionToCreate.document = fileUploadResult.DocsToUpload; groupSessionToCreate.groupId = (int)gid; groupSessionToCreate.startDate = DateTime.UtcNow; unitOfWork.GroupSessionRepository.Insert(groupSessionToCreate); unitOfWork.Save(); return(Json(new { Success = true, Url = Url.Action("Detail", new { SsId = groupSessionToCreate.sessionId, GSName = StringHelper.URLName(groupSessionToCreate.sessionSubject) }) })); } throw new JsonCustomException(ControllerError.ajaxError); } throw new ModelStateException(this.ModelState); }
public FixExchange[] GetFixExchangeInfo() { List <FixExchange> exchanges = new List <FixExchange>(); string query = "select * from exchanges"; DBManager db = new DBManager(DataProvider.SqlServer, SystemConfigurations.GetConnectionString("BasicDataDBConnectionString")); db.Open(); DataSet ds = db.ExecuteDataSet(System.Data.CommandType.Text, query); //string today = DateTime.Today.DayOfWeek.ToString(); foreach (DataRow rowExchange in ds.Tables[0].Rows) { FixExchange exchange = new FixExchange(); exchange.ExchangeID = rowExchange["ExchangeID"].ToString(); exchange.NameAr = rowExchange["NameAr"].ToString(); exchange.NameEn = rowExchange["NameEn"].ToString(); List <ExchangeMarket> markets = new List <ExchangeMarket>(); string queryMarkets = string.Format("select * from Exchanges_Markets where exchangeid = '{0}'", exchange.ExchangeID); DataTable dtMarkets = db.ExecuteDataSet(System.Data.CommandType.Text, queryMarkets).Tables[0]; foreach (DataRow rowMarket in dtMarkets.Rows) { ExchangeMarket market = new ExchangeMarket(); market.ExchangeID = exchange.ExchangeID; market.MarketID = rowMarket["MarketID"].ToString(); market.NameAr = rowMarket["NameAr"].ToString(); market.NameEn = rowMarket["NameEn"].ToString(); string queryGroups = string.Format("select * from Markets_Groups where exchangeid = '{0}' and marketid = '{1}';", exchange.ExchangeID, market.MarketID); DataTable dtGroups = db.ExecuteDataSet(System.Data.CommandType.Text, queryGroups).Tables[0]; List <MarketGroup> groups = new List <MarketGroup>(); foreach (DataRow rowGroup in dtGroups.Rows) { MarketGroup group = new MarketGroup(); group.ExchangeID = exchange.ExchangeID; group.MarketID = market.MarketID; group.GroupID = rowGroup["GroupID"].ToString(); List <GroupSession> sessions = new List <GroupSession>(); string querySessions = string.Format("select * from Markets_Groups_Sessions where exchangeid = '{0}' and marketid = '{1}' and groupid = '{2}';", exchange.ExchangeID, market.MarketID, group.GroupID); DataTable dtSessions = db.ExecuteDataSet(System.Data.CommandType.Text, querySessions).Tables[0]; foreach (DataRow rowSessions in dtSessions.Rows) { GroupSession session = new GroupSession(); session.ExchangeID = exchange.ExchangeID; session.GroupID = group.GroupID; session.MarketID = market.MarketID; session.SessionStartTime = (DateTime)rowSessions["SessionStartTime"]; session.SessionEndTime = (DateTime)rowSessions["SessionEndTime"]; session.WorkingDays = rowSessions["WorkingDays"].ToString(); sessions.Add(session); } group.Sessions = sessions.ToArray(); groups.Add(group); } market.Groups = groups.ToArray(); markets.Add(market); } exchange.Markets = markets.ToArray(); exchanges.Add(exchange); } db.Close(); db = null; return(exchanges.ToArray()); }