示例#1
0
        public PartialViewResult GiveALike(int postID)
        {
            int currentPersonID = ActiveSession.GetPersonID();

            Account.GiveALikeSL(postID, currentPersonID);
            return(PartialView("_InteractButtons", Account.GetInteractsCountSL(postID, currentPersonID)));
        }
        //public delegate void SetCursorDelegate(Cursor c);
        //public SetCursorDelegate SetCursorProperty { get; set; }
        #endregion

        #region Event Handlers
        private void Application_Exit(object sender, EventArgs e)
        {
            if (ActiveSession != null)
            {
                ActiveSession.ReleaseSession();
            }
        }
示例#3
0
        /// <summary>
        /// Save session to Database
        /// </summary>
        /// <param name="sessionToSave">Session needed to save</param>
        /// <param name="sessionSaveType">Session save type</param>
        /// <param name="sessionState">Session state</param>
        public void SaveSession(ActiveSession sessionToSave)
        {
            ActiveHours = sessionToSave.ActivityHours.ToString("0.0000", System.Globalization.CultureInfo.InvariantCulture);
            if (sessionToSave.SessionState == LogonTracerLib.LogonTracerWorker.SessionState.Disconnected || sessionToSave.SessionState == LogonTracerLib.LogonTracerWorker.SessionState.ServiceDown)
            {
                sessionToSave.SessionEnd = sessionToSave.SessionEnd ?? DateTime.Now;
            }

            if (sessionToSave.DbId.HasValue)
            {
                if (LogonTracerConfig.Instance.LogSaveSessionActivity)
                {
                    Utils.LoggingUtils.DefaultLogger.AddLogMessage(this, MessageType.Info,
                                                                   "Session UPDATE. USERNAME: {0}; MACHINE_NAME:{1} SESSION_BEGIN:{2}; ACTIVE_HOURS: {3}; " + (sessionToSave.SessionEnd.HasValue ? "SESSION_END: {4};" : "{4}") + "SESSION_STATE: {5}",
                                                                   sessionToSave.UserName, sessionToSave.MachineName, sessionToSave.SessionBegin, ActiveHours, sessionToSave.SessionEnd, sessionToSave.SessionState);
                }
            }
            else
            {
                if (LogonTracerConfig.Instance.LogSaveSessionActivity)
                {
                    Utils.LoggingUtils.DefaultLogger.AddLogMessage(this, MessageType.Info, "New Session. USERNAME: {0}; MACHINE_NAME:{1}; SESSION_BEGIN:{2}",
                                                                   sessionToSave.UserName, sessionToSave.MachineName, sessionToSave.SessionBegin);
                }
                if (sessionToSave.DbId.HasValue && sessionToSave.DbId != 0 && LogonTracerConfig.Instance.LogSessionHistory)
                {
                    UpdateSessionHistory(sessionToSave.DbId.Value, LogonTracerLib.LogonTracerWorker.SessionUpdateDetails.NewSession);
                }
            }


            OnSessionSave(sessionToSave);
        }
        public bool CheckSession(SessionId sessionId)
        {
            ArgumentValidator.IsNotNull("sessionId", sessionId);
            ActiveSession session = GetSession(sessionId);

            return(session != null);
        }
        public ActionResult Access(LoginViewModel model)
        {
            var dAO     = new LoginDAO();
            var session = new ActiveSession();

            if (ModelState.IsValid)
            {
                if (dAO.Login(model))
                {
                    session.Created = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
                    session.Name    = model.User;
                    session.Status  = true;
                    session.User    = model.User;

                    HttpContext.Session.Set("SESSION", Utils.ConvertToByteArray(JsonConvert.SerializeObject(session)));

                    return(RedirectToAction("Index", "Manager", new { area = "Admin" }));
                }
                else
                {
                    return(View("Index", new LoginViewModel()));
                }
            }
            else
            {
                return(View("Index", new LoginViewModel()));
            }
        }
 public bool ValidateSession(ActiveSession session)
 {
     using (var dbcontext = new DataAccess.MyCleanSolutionDatabaseEntities())
     {
         return(dbcontext.Sessions.FirstOrDefault(s => s.Id == session.Token) == null ? false : true);
     }
 }
示例#7
0
        /// <summary>
        /// Delete all damage extents of project in the database
        /// </summary>
        /// <param name="projectId"></param>
        public void deleteDamageExtentsFromDB(int projectId)
        {
            if (projectId < 1)
            {
                return;
            }

            string _deleteQueryString =
                $"delete " +
                $"from \"DamageExtent\" " +
                $"where \"DamageExtent\".\"MappedObjectId\" in " +
                $"(select damageextent.\"MappedObjectId\" " +
                $"from \"DamageExtent\" as damageextent, \"Intensity\" as intensity " +
                $"where intensity.\"Project_Id\" = {projectId} " +
                $"and damageextent.\"IntensityId\" = intensity.\"ID\") ";

            using (var transaction = DBManager.ActiveSession.BeginTransaction())
            {
                ISQLQuery query = ActiveSession.CreateSQLQuery(_deleteQueryString);
                query.ExecuteUpdate();
                DBManager.ActiveSession.Flush();
                transaction.Commit();
            }

            //Change the project to state "Started"
            var _resultController = new ResultController();

            _resultController.setProjectStatus(projectId, 1);
        }
示例#8
0
 private void SaveSessionToDatabase(SessionId sessionId, User user, ConnectionTicket ticket)
 {
     lock (_lockObj)
     {
         try
         {
             using (ServerDataContext context = new ServerDataContext())
             {
                 ActiveSession session = new ActiveSession
                 {
                     Id             = ObjectId.NewId(),
                     SessionId      = sessionId.ToString(),
                     UserId         = user.Id,
                     ClientComputer = ticket.ClientComputer,
                     Port           = ticket.Port
                 };
                 context.ActiveSessions.Add(session);
                 context.SaveChanges();
             }
         }
         catch (Exception e)
         {
             ApplicationContext.Log.Error(GetType(), e);
             throw;
         }
     }
 }
 protected override ActiveSession CheckSessionRepositoryExisting(ActiveSession activeSession)
 {
     try
     {
         dbu.ExecuteRead(string.Format(@"
                         SELECT id, ActiveHours, LastInputTime, ClientUtcOffset
                         FROM Logins 
                         WHERE UserName ='******' AND MachineName = '{1}' AND FORMAT(SessionBegin, 'yyyy-MM-dd HH:mm:ss') = '{2}'",
                                       activeSession.UserName, activeSession.MachineName, activeSession.SessionBegin.Value.ToString("yyyy-MM-dd HH:mm:ss")), null, delegate(SqlDataReader sdr)
         {
             activeSession.DbId           = sdr.GetInt32(0);
             activeSession.ActivityHours += sdr.GetDouble(1);
             if (sdr.IsDBNull(2))
             {
                 activeSession.LastInputTime = null;
             }
             else
             {
                 activeSession.LastInputTime = sdr.GetDateTime(2);
             }
         }, -1);
     }
     catch (Exception ex)
     {
         Utils.LoggingUtils.DefaultLogger.AddLogMessage(this, MessageType.Error, "Ошибка при попытке получить сессиию из БД. Message: {0}. Trace: {1}", ex.Message, ex.StackTrace);
     }
     return(activeSession);
 }
示例#10
0
        public async Task <IActionResult> Create([Bind("ExpenseId,Particulars,PartyName,EmployeeId,OnDate,PayMode,BankAccountId,PaymentDetails,Amount,Remarks,PartyId,LedgerEnteryId,IsCash,StoreId,UserId,EntryStatus")] Expense expense)
        {
            if (ModelState.IsValid)
            {
                if (expense.PayMode == PaymentMode.Cash)
                {
                    expense.BankAccountId = null;
                }
                _context.Add(expense);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BankAccountId"] = new SelectList(_context.BankAccounts, "BankAccountId", "Account", expense.BankAccountId);
            ViewData["EmployeeId"]    = new SelectList(_context.Employees, "EmployeeId", "StaffName", expense.EmployeeId);
            ViewData["PartyId"]       = new SelectList(_context.Parties.OrderBy(c => c.PartyName), "PartyId", "PartyName", expense.PartyId);
            ViewData["StoreId"]       = ActiveSession.GetActiveSession(HttpContext.Session, HttpContext.Response, _returnUrl);

            Console.WriteLine($"StoreId+{expense.StoreId}\tEnt {expense.EntryStatus},\t us {expense.UserId}, \taa=" + ModelState.IsValid);
            foreach (var modelState in ViewData.ModelState.Values)
            {
                foreach (ModelError error in modelState.Errors)
                {
                    Console.WriteLine(error.ErrorMessage);
                }
            }
            return(View(expense));
        }
示例#11
0
        public EndMenu()
        {
            session = Network.ActiveSession;

            quitBinding = new InputBinding();
            quitBinding.Add(Keys.Escape).Add(Buttons.Back).DefineGamePadIndex(0)
                .DefineInputType(InputType.Pressed);

            titleText = new Text(TestProject.Assets.GetFont("TitleFont"), "Game Over", new Vector2(Engine.Instance.Screen.Width / 2, 5), AlignX.Center, AlignY.Top);
            Add(titleText);

            subtitleText = new Text(TestProject.Assets.GetFont("MenuFont"), "Let's look at some results...", titleText.Position + new Vector2(0, titleText.Height + 5), AlignX.Center, AlignY.Top);
            Add(subtitleText);

            errorText = new Text(TestProject.Assets.GetFont("MenuFont"), "", subtitleText.Position + new Vector2(0, subtitleText.Height + 16), AlignX.Center, AlignY.Top);
            Add(errorText);
            errorText.Color = Color.Red;
            errorText.Alpha = 0;

            myGamer = Network.FirstLocalGamer;

            if (Network.ActiveSession.Winners.Count > 0)
                subtitleText.DrawText = String.Format(winString, Network.ActiveSession.Winners[0].GamerTag);
            else
                subtitleText.DrawText = tieString;
        }
示例#12
0
 // GET: Accountings/Payments/Create
 public IActionResult Create()
 {
     ViewData["BankAccountId"] = new SelectList(_context.BankAccounts, "BankAccountId", "Account");
     ViewData["PartyId"]       = new SelectList(_context.Parties, "PartyId", "PartyName");
     ViewData["StoreId"]       = ActiveSession.GetActiveSession(HttpContext.Session, HttpContext.Response, _returnUrl);
     return(PartialView());
 }
示例#13
0
 public string GetRelatedUserId(SessionId sessionId)
 {
     using (ServerDataContext context = new ServerDataContext())
     {
         ActiveSession session = context.GetSession(sessionId);
         return(session.User.Id.ToString().ToUpper());
     }
 }
示例#14
0
 public string GetRelatedUserName(SessionId sessionId)
 {
     using (ServerDataContext context = new ServerDataContext())
     {
         ActiveSession session = context.GetSession(sessionId);
         return(session.User.Name);
     }
 }
示例#15
0
 public UserData GetRelatedUserInfo(SessionId sessionId)
 {
     using (ServerDataContext context = new ServerDataContext())
     {
         ActiveSession session = context.GetSession(sessionId);
         return(context.CreateUserData(session.User));
     }
 }
 private XElement GetSessionFormRepository(ActiveSession session)
 {
     return(Repository.Root.Elements()
            .Where(e =>
                   (string)e.Attribute("UserName").Value == session.UserName &&
                   (string)e.Attribute("MachineName").Value == session.MachineName &&
                   Convert.ToDateTime(e.Attribute("SessionBegin").Value) == session.SessionBegin.Value).FirstOrDefault());
 }
示例#17
0
        public IActionResult Index()
        {
            // Setting Store Info Here
            ViewBag.StoreID = ActiveSession.GetActiveSession(HttpContext.Session, HttpContext.Response, "/Identity/Account/Login?ReturnUrl=/Home/Index");
            MasterViewReport mvr = DashboardWidget.GetMasterViewReport(_context);

            return(View(mvr));
        }
示例#18
0
        // GET: Accounts/CashPayments/Create
        public IActionResult Create()
        {
            ViewData["TranscationModeId"] = new SelectList(_context.TranscationModes, "TranscationModeId", "Transcation");
            // ViewData["StoreId"] = new SelectList(_context.Stores, "StoreId", "StoreId");
            ViewData["StoreId"] = ActiveSession.GetActiveSession(HttpContext.Session, HttpContext.Response, _returnUrl);

            return(PartialView());
        }
示例#19
0
        public ActiveSession Login(string username, string password)
        {
            ActiveSession fakeSession = new ActiveSession();

            fakeSession.Token             = Guid.NewGuid();
            fakeSession.DateTimeInitiated = DateTime.UtcNow;

            return(fakeSession);
        }
示例#20
0
        public ConnectionTicket CreateFakeTicket(ActiveSession session)
        {
            ConnectionTicket ticket = new ConnectionTicket();

            ticket.ClientComputer = session.ClientComputer;
            ticket.Username       = session.User.Name;
            ticket.Port           = session.Port;
            return(ticket);
        }
示例#21
0
        // GET: Tailoring/TalioringBookings/Create
        public IActionResult Create()
        {
            // Setting Store Info Here

            ViewBag.StoreID = ActiveSession.GetActiveSession(HttpContext.Session, HttpContext.Response, "/Identity/Account/Login?ReturnUrl=/Tailoring/TalioringBookings");

            ViewData["StoreId"] = new SelectList(_context.Stores, "StoreId", "StoreName");
            return(PartialView());
        }
示例#22
0
        public IActionResult Index()
        {
            int StoreId = ActiveSession.GetActiveSession(HttpContext.Session, HttpContext.Response, "/Identity/Account/Login?ReturnUrl=/Sales/DailySales");

            var vm = aprajitaContext.RegularInvoices.Include(c => c.Customer).Include(c => c.SaleItems).Include(c => c.PaymentDetail)
                     .Where(c => c.IsManualBill && c.StoreId == StoreId).OrderByDescending(c => c.OnDate).ThenByDescending(c => c.InvoiceNo).ToList();

            return(View(vm));
        }
示例#23
0
        // GET: DailySales/Create
        public IActionResult Create()
        {
            // Setting Store Info Here

            ViewBag.StoreID = ActiveSession.GetActiveSession(HttpContext.Session, HttpContext.Response, "/Identity/Account/Login?ReturnUrl=/Sales/DailySales");

            ViewData["SalesmanId"] = new SelectList(db.Salesmen, "SalesmanId", "SalesmanName");
            return(PartialView());
        }
示例#24
0
        public async Task <ActionResult <string> > PostTransaction([FromBody] float amount)
        {
            var sessionId = Guid.NewGuid();

            var url = appSettings.Server + $"sessions/{sessionId}/transaction?async=true";

            var request = new ApiRequest <EFTTransactionRequest>()
            {
                Request = new EFTTransactionRequest()
                {
                    TxnType     = "P",
                    TxnRef      = RandomStr.RandomString(TRX_RND_STR_LENGTH),
                    AmtPurchase = (int)(amount * DOLLAR_TO_CENT),
                    Merchant    = appSettings.Merchant,
                    Application = appSettings.Application,
                    PosName     = appSettings.PosName,
                    PosVersion  = appSettings.PosVersion
                },
                Notification = new Notification
                {
                    Uri = appSettings.NotificationUri
                }
            };

            if (string.IsNullOrEmpty(token))
            {
                token = GetToken().Result?.Token;
            }

            var apiClient = clients.GetAPIClient();

            apiClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            apiClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

            HttpContent content = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");

            try
            {
                var activeTxn = new ActiveSession()
                {
                    SessionId = sessionId.ToString(), Expire = DateTime.Now.AddMinutes(TRX_EXPIRATION_MINS).Ticks
                };
                await sessionRepository.AddSession(activeTxn);

                var response = await apiClient.PostAsync(url, content);

                if (response.IsSuccessStatusCode)
                {
                    return(Accepted(value: JsonConvert.SerializeObject(sessionId)));
                }
            }
            catch
            {
            }

            return(BadRequest());
        }
示例#25
0
 public bool TryGetSession(string sessionId, out ActiveSession session)
 {
     if (string.IsNullOrWhiteSpace(sessionId))
     {
         session = null;
         return(false);
     }
     return(_sessions.TryGetValue(sessionId, out session));
 }
示例#26
0
        public string ChangeAvatar()
        {
            if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any())
            {
                var avatarFile = System.Web.HttpContext.Current.Request.Files["ImageFile"];
                return(Account.ChangeAvatarSL(avatarFile, ActiveSession.GetPersonID()));
            }

            return("");
        }
示例#27
0
        public string CreateNewSession(SessionDto session)
        {
            var guid = Guid.NewGuid().ToString();

            session.Id = guid;
            var activeSession = new ActiveSession(session);

            _sessions.Set(guid, activeSession, CreateEntryOptions());
            return(guid);
        }
示例#28
0
        public JsonResult EditDetailsForm(ProfileDetailsDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { message = "Fallaron las validaciones" }));
            }

            ProfileDetailsDTO newDetails = Account.ChangeProfileDetailsSL(model, ActiveSession.GetPersonID());

            return(Json(new { personalDescription = newDetails.PersonalDescription, websiteURL = newDetails.WebSiteURL, birthDate = newDetails.Birthdate }));
        }
示例#29
0
        public ActionResult Search(SearchDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model.MatchesFound = home.FindMatchesSL(model.WordToSearch, ActiveSession.GetPersonID());

            return(View(model));
        }
示例#30
0
 public JsonResult FollowUser(int follow)
 {
     if (Account.FollowUserSL(ActiveSession.GetPersonID(), follow))
     {
         return(Json(new { buttonText = "Dejar de seguir", className = "btn-danger" }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(new { buttonText = "Seguir", className = "btn-success" }, JsonRequestBehavior.AllowGet));
     }
 }
示例#31
0
        public ActionResult NewList(ListDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Account.NewListSL(model, ActiveSession.GetPersonID());

            return(RedirectToAction("ProfileScreen", "Account", new { id = ActiveSession.GetPersonID(), v = "lists" }));
        }
示例#32
0
        public LobbyMenu()
        {
            session = Network.ActiveSession;

            quitBinding = new InputBinding();
            quitBinding.Add(Keys.Escape).Add(Buttons.Back).DefineGamePadIndex(0)
                .DefineInputType(InputType.Pressed);

            upBinding = new InputBinding();
            upBinding.Add(Keys.Up, Keys.W).Add(Buttons.DPadUp, Buttons.LeftThumbstickUp)
                .DefineGamePadIndex(0).DefineInputType(InputType.Pressed);

            downBinding = new InputBinding();
            downBinding.Add(Keys.Down, Keys.S).Add(Buttons.DPadDown, Buttons.LeftThumbstickDown)
                .DefineGamePadIndex(0).DefineInputType(InputType.Pressed);

            selectBinding = new InputBinding();
            selectBinding.Add(Keys.Enter, Keys.Space).Add(Buttons.A).DefineGamePadIndex(0)
                .DefineInputType(InputType.Pressed);

            titleText = new Text(TestProject.Assets.GetFont("TitleFont"), "Game Lobby", new Vector2(Engine.Instance.Screen.Width / 2, 5), AlignX.Center, AlignY.Top);
            Add(titleText);

            subtitleText = new Text(TestProject.Assets.GetFont("MenuFont"), "Join with others and play a multiplayer game.", titleText.Position + new Vector2(0, titleText.Height + 5), AlignX.Center, AlignY.Top);
            Add(subtitleText);

            errorText = new Text(TestProject.Assets.GetFont("MenuFont"), "", subtitleText.Position + new Vector2(0, subtitleText.Height + 16), AlignX.Center, AlignY.Top);
            Add(errorText);
            errorText.Color = Color.Red;
            errorText.Alpha = 0;

            var instructionsText = new Text(TestProject.Assets.GetFont("MenuFont"), "[Arrow Keys] Choose\n[Space] Select\n[Escape] Back", new Vector2(Engine.Instance.Screen.Width - 5, 120), AlignX.Right);
            Add(instructionsText);

            speed = session.SessionProperties[0].Value;
            map = session.SessionProperties[1].Value;
        }
		private async Task<ActionResult> ProcessTopics(ActiveSession session, SessionReport report)
		{
			List<Topic> topics = db.Topics
				.Include(t => t.SessionType)
				.Include(t => t.Lock)
				.Include(t => t.Assignments)
				.Where(t => t.Lock.Session.ID == session.ID)
				.ToList();

			var mailer = new UserMailer();

			try
			{
				mailer.SendSessionReport(topics, report);
			}
			catch (Exception ex)
			{
				// return HTTPStatus(HttpStatusCode.InternalServerError, "Fehler beim Versenden der E-Mails: " + ex.Message);
			}

			foreach (var t in topics)
			{
				switch (t.Lock.Action)
				{
					case TopicAction.None:
						t.IsReadOnly = false;
						break;
					case TopicAction.Decide:
						t.Decision = new Decision
						{
							OriginTopic = t,
							Report = report,
							Text = t.Proposal,
							Type = DecisionType.Resolution
						};
						// Inaktive Aufgaben löschen
						db.Assignments.RemoveRange(db.Assignments.Where(a => a.TopicID == t.ID && !a.IsActive));

						// Für aktive Umsetzungaufgaben E-Mails verschicken
						var tasks = new List<Task>();
						foreach (var duty in t.Assignments.Where(a => a.Type == AssignmentType.Duty && a.IsActive))
							tasks.Add(mailer.SendNewAssignment(duty));
						await Task.WhenAll(tasks);

						break;
					case TopicAction.Close:
						t.Decision = new Decision
						{
							OriginTopic = t,
							Report = report,
							Text = t.Proposal,
							Type = DecisionType.Closed
						};
						break;
					case TopicAction.Delete:
						db.DeleteTopic(t.ID);
						break;
					default:
						throw new ArgumentOutOfRangeException();
				}
				if (t.Lock != null) // Wenn gelöscht wird, ist t.Lock hier bereits null
					db.TopicLocks.Remove(t.Lock);
			}

			return null;
		}
示例#34
0
        /// <summary>
        /// Creates a session with the given parameters asynchronously.
        /// </summary>
        /// <param name="maxGamers">Maximum number of gamers allowed.</param>
        /// <param name="allowHostMigration">If host migration is allowed.</param>
        /// <param name="properties">Properties to initialize the session with.</param>
        /// <param name="initializeFunction">The optional function to call to initialize the session.</param>
        public static void CreateSessionAsync(int maxGamers, bool allowHostMigration, NetworkSessionProperties properties, ActiveSession.ActiveSessionDelegate initializeFunction, Action<bool> callback)
        {
            if (IsLocked)
            {
                if (callback != null)
                    callback(false);
                return;
            }
            #if DEBUG
            Log.Trace("Creating session...", 2.0f);
            #endif
            createAsyncAllowHostMigration = allowHostMigration;
            createAsyncFunction = initializeFunction;
            createAsyncCallback = callback;

            try
            {
                createAsync = NetworkSession.BeginCreate(NetworkSessionType.SystemLink, MaxLocalGamers, maxGamers, 0, properties, CreateAsyncFinished, null);
            }
            catch (Exception e)
            {
                ReportError(e.Message);
                if ( createAsyncCallback != null )
                    createAsyncCallback(false);
                CreateAsyncClear();
            }
        }
示例#35
0
 /// <summary>
 /// Creates a session with the given parameters.
 /// </summary>
 /// <param name="maxGamers">Maximum number of gamers allowed.</param>
 /// <param name="allowHostMigration">If host migration is allowed.</param>
 /// <param name="properties">Properties to initialize the session with.</param>
 /// <param name="initializeFunction">The optional function to call to initialize the session.</param>
 public static bool CreateSession(int maxGamers, bool allowHostMigration, NetworkSessionProperties properties, ActiveSession.ActiveSessionDelegate initializeFunction )
 {
     if (IsLocked)
         return false;
     #if DEBUG
     Log.Trace("Creating session...", 2.0f);
     #endif
     try
     {
         NetworkSession session = NetworkSession.Create(NetworkSessionType.SystemLink, MaxLocalGamers, maxGamers, 0, properties);
         session.AllowHostMigration = allowHostMigration;
         ActiveSession = new ActiveSession(session, initializeFunction);
         return true;
     }
     catch( Exception e)
     {
         ReportError(e.Message);
         ActiveSession.EndSession();
         return false;
     }
 }
示例#36
0
        /// <summary>
        /// Attempts to join a session asynchronously.
        /// </summary>
        /// <param name="session">The AvailableSession to join.</param>
        /// <param name="initializeFunction">The optional function to call to initialize the session.</param>
        public static void JoinSessionAsync(AvailableSession session, ActiveSession.ActiveSessionDelegate initializeFunction, Action<bool> callback)
        {
            if (IsLocked)
            {
                if (callback != null)
                    callback(false);
                return;
            }
            #if DEBUG
            Log.Trace(String.Format("Joining session hosted by {0}...", session.HostName), 2.0f);
            #endif
            joinAsyncFunction = initializeFunction;
            joinAsyncCallback = callback;

            try
            {
                joinAsync = NetworkSession.BeginJoin(session.NativeSession, JoinAsyncFinished, null);
            }
            catch (Exception e)
            {
                ReportError(e.Message);
                if (joinAsyncCallback != null)
                    joinAsyncCallback(false);
                JoinAsyncClear();
            }
        }
示例#37
0
 /// <summary>
 /// Attempts to join a session.
 /// </summary>
 /// <param name="session">The AvailableSession to join.</param>
 /// <param name="initializeFunction">The optional function to call to initialize the session.</param>
 public static bool JoinSession(AvailableSession session, ActiveSession.ActiveSessionDelegate initializeFunction)
 {
     if (IsLocked)
         return false;
     #if DEBUG
     Log.Trace(String.Format("Joining session hosted by {0}...", session.HostName), 2.0f);
     #endif
     try
     {
         NetworkSession newSession = NetworkSession.Join(session.NativeSession);
         ActiveSession = new ActiveSession(newSession, initializeFunction);
         return true;
     }
     catch (Exception e)
     {
         ReportError(e.Message);
         ActiveSession.EndSession();
         return false;
     }
 }
 private ActiveSession DefaultValues(ActiveSession row)
 {
     return row;
 }
示例#39
0
        private static void CreateAsyncFinished(IAsyncResult result)
        {
            if (createAsync == null || HasActiveSession)
            {
                if ( createAsyncCallback != null )
                    createAsyncCallback(false);
                CreateAsyncClear();
                return;
            }

            try
            {
                NetworkSession session = NetworkSession.EndCreate(result);
                session.AllowHostMigration = createAsyncAllowHostMigration;
                ActiveSession = new ActiveSession(session, createAsyncFunction);
                if (createAsyncCallback != null)
                    createAsyncCallback(true);
            }
            catch (Exception e)
            {
                ReportError(e.Message);
                EndSessionNow();
                if (createAsyncCallback != null)
                    createAsyncCallback(false);
            }

            CreateAsyncClear();
        }
        private void PrepareTopics(FilteredTopics filter, ActiveSession session)
        {
            // Zwecks Performance wäre hier eigentlich eine Query-Projektion angebracht
            IQueryable<Topic> query = db.Topics
                .Include(t => t.SessionType)
                .Include(t => t.TargetSessionType)
                .Include(t => t.Owner)
                .Include(t => t.Comments)
                .Include(t => t.Lock)
                .Include(t => t.Tags)
                .Include(t => t.Votes)
                .Include(t => t.UnreadBy)
                .Include(t => t.Assignments)
                .Where(t => t.Decision == null && !t.IsReadOnly)
                .Where(t =>
                    t.Lock.Session.ID == session.ID ||
                    (t.SessionTypeID == session.SessionType.ID && t.Created < session.Start && !(t.ResubmissionDate >= session.Start)));

            if (filter.ShowPriority >= 0)
                query = query.Where(t => t.Priority == (Priority)filter.ShowPriority);

            if (filter.Timespan != 0)
            {
                if (filter.Timespan > 0) // Nur die letzten x Tage anzeigen
                {
                    var cutoff = DateTime.Today.AddDays(-filter.Timespan);
                    query = query.Where(t => t.Created >= cutoff);
                }
                else // Alles VOR den letzten x Tagen anzeigen
                {
                    var cutoff = DateTime.Today.AddDays(filter.Timespan);
                    query = query.Where(t => t.Created < cutoff);
                }
            }

            if (filter.OwnerID != 0)
                query = query.Where(a => a.OwnerID == filter.OwnerID);

            filter.UserList = CreateUserSelectList();
            filter.PriorityList = TopicsController.PriorityChoices(filter.ShowPriority);
            filter.SessionTypeList = new SelectList(db.GetActiveSessionTypes(), "ID", "Name");

            filter.TimespanList = TopicsController.TimespanChoices(filter.Timespan);

            using (MiniProfiler.Current.Step("Sortierung der Themen"))
            {
                filter.Topics = query.ToList().OrderByDescending(t => t.IsUnreadBy(GetCurrentUserID())).ThenBy(t =>
                {
                    TimeSpan time;
                    return TimeSpan.TryParse(t.Time, out time) ? time : new TimeSpan(24, 0, 0);
                }).ThenByDescending(t => t.Priority).ThenBy(t => t.Created).ToList();
            }

            foreach (var topic in filter.Topics)
                topic.IsLocked = topic.Lock != null;
        }
示例#41
0
 public static SessionReport FromActiveSession(ActiveSession a)
 {
     return new SessionReport
     {
         Manager = a.Manager,
         SessionType = a.SessionType,
         PresentUsers = a.PresentUsers,
         AdditionalAttendees = a.AdditionalAttendees,
         Notes = a.Notes,
         Start = a.Start,
         End = a.End,
         Decisions = new List<Decision>()
     };
 }
示例#42
0
        private static void JoinAsyncFinished(IAsyncResult result)
        {
            if (joinAsync == null || HasActiveSession)
            {
                if (joinAsyncCallback != null)
                    joinAsyncCallback(false);
                JoinAsyncClear();
                return;
            }

            try
            {
                NetworkSession session = NetworkSession.EndJoin(result);
                ActiveSession = new ActiveSession(session, joinAsyncFunction);
                if ( joinAsyncCallback != null )
                    joinAsyncCallback(true);
            }
            catch (Exception e)
            {
                ReportError(e.Message);
                EndSessionNow();
                if ( joinAsyncCallback != null )
                    joinAsyncCallback(false);
            }

            JoinAsyncClear();
        }