Example #1
0
        public async Task <IActionResult> PutLiveSession(int id, LiveSession liveSession)
        {
            if (id != liveSession.SId)
            {
                return(BadRequest());
            }

            _context.Entry(liveSession).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LiveSessionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #2
0
        public async Task <ActionResult <LiveSession> > PostLiveSession(LiveSession liveSession)
        {
            _context.liveSessions.Add(liveSession);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLiveSession", new { id = liveSession.SId }, liveSession));
        }
Example #3
0
        public async Task StopSOSOnly(string profileID, string sessionID, string ticks)
        {
            long   ProfileID  = Convert.ToInt64(profileID);
            string liveUserID = WebOperationContext.Current.IncomingRequest.Headers["LiveUserID"];

            bool isAuthorizedForSelf = await _authService.SelfAccess(liveUserID, ProfileID);

            if (isAuthorizedForSelf)
            {
                var tasks = new List <Task>();

                Task updateDatabaseTask = _locRepository.StopSOSOnly(ProfileID, sessionID);
                tasks.Add(updateDatabaseTask);

                LiveSession profileNotifyDetails =
                    await new LiveSessionRepository().GetNotificationDetails(ProfileID, sessionID);

                if (profileNotifyDetails != null)
                {
                    Task sendNotificationsTask = ServiceUtility.SendSafeNotificationAsync(profileNotifyDetails);
                    tasks.Add(sendNotificationsTask);
                }
                Task.WhenAll(tasks.ToArray()).Wait();
            }
        }
Example #4
0
 public void OnContinueGame()
 {
     if (CharacterSave.IsSavePresent())
     {
         LiveSession.SetPlayerData(CharacterSave.Load());
         GetComponent <SceneTransition>().DelayedSceneChange("ControlRoom");
     }
 }
Example #5
0
        public void OnNewGame()
        {
            LiveSession.SetPlayerData(new PlayerData());
            LiveSession.SetCaveData(NameGenerator.GenerateCaveName(), 3, new [] { Mineral.White });
            LiveSession.SetCurrentMission(new MapMission(3));

            GetComponent <SceneTransition>().DelayedSceneChange("CaveTutorial");
        }
        public async Task <IActionResult> ListAllSessions()
        {
            IList <LiveSessionViewModel> webinar = new List <LiveSessionViewModel>();

            if (ModelState.IsValid)
            {
                var details = userManager.GetUserAsync(User);

                var Test1 = userManager.GetUserId(User);
                //string emailId = TempData["LoggedUser"].ToString();
                bool        isLoggedIn     = signInManager.IsSignedIn(User);
                LiveSession objliveSession = new LiveSession();

                if (isLoggedIn)
                {
                    string _primarySkill = details.Result.primarySkill;
                    string email         = details.Result.Email;

                    IList <LiveSession> _result = await _liveSessionService.GetPrivateSession(_primarySkill);

                    if (_result.Count != 0)
                    {
                        foreach (var item in _result)
                        {
                            webinar.Add(new LiveSessionViewModel()
                            {
                                SId             = item.SId,
                                description     = item.description,
                                duration        = item.duration,
                                isPrivate       = item.isPrivate,
                                organiser       = item.organiser,
                                Url             = item.Url,
                                sessionCategory = item.sessionCategory
                            });
                        }

                        return(View(webinar));
                    }
                    else
                    {
                        TempData["NoSession"] = "You will soon see a private session here!";
                        return(View(webinar));
                    }
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                return(View(webinar));
            }
        }
Example #7
0
 private void OnTriggerEnter(Collider other)
 {
     if (!wasTriggered)
     {
         if (other.CompareTag(PlayerTag))
         {
             ExitCave();
             LiveSession.SavePlayer();
             wasTriggered = true;
         }
     }
 }
Example #8
0
        protected override void OnIntensiveSamplingStart()
        {
            int currentPid = Process.GetCurrentProcess().Id;
            var session    = new LiveSession(EventSpecification, new[] { currentPid }, includeKernelFrames: false);

            session.EventOccurred += OnEventOccurred;
            Task.Run(() => session.Start());
            Thread.Sleep(IntensiveSamplingDuration);
            session.Stop();

            WriteTraceLine($"Top {TopStacksToReport} stacks gathered during intensive sampling:");
            foreach (var stack in session.Stacks.TopStacks(TopStacksToReport, 0))
            {
                WriteTraceLine("");
                WriteTraceLine($"  {stack.Count,10}");
                foreach (var symbol in _resolver.Resolve(currentPid, stack.Addresses))
                {
                    WriteTraceLine("    " + symbol.ToString());
                }
            }
        }
Example #9
0
        /// <summary>
        ///     A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public Response FunctionHandler(Request input, ILambdaContext context)
        {
            var dba = new DBAccess();

            if (input.Body.IsPing)
            {
                return new Response {
                           StatusCode = 200, Message = dba.Test()
                }
            }
            ;

            try
            {
                var list = LiveSession.LoadOpenAll(dba.Connection);


                var r = new Response
                {
                    StatusCode = 200,
                    Message    = "ok",
                    Body       = new ResponseBody
                    {
                        LiveSessions = list.ToArray(),
                        Count        = list.Count
                    }
                };
                return(r);
            }
            catch (Exception e)
            {
                var r = new Response();
                r.SetError(400, e);
                return(r);
            }
        }
    }
Example #10
0
        /// <summary>
        ///     A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public Response FunctionHandler(Request input, ILambdaContext context)
        {
            var dba = new DBAccess();

            if (input.Body.IsPing)
            {
                return new Response {
                           StatusCode = 200, Message = dba.Test()
                }
            }
            ;

            try
            {
                //validate require role
                if (!input.SourceUser.HasRole("Model"))
                {
                    return new Response {
                               StatusCode = 401, Message = "Access denied, requires Model role"
                    }
                }
                ;


                //get user
                var user = User.LoadBySourceUser(input.SourceUser, dba.Connection);
                if (user == null) //does not exist
                {
                    return new Response {
                               StatusCode = 404, Message = "User is not registered, hence cannot be a model"
                    }
                }
                ;


                //get model
                var model = Model.LoadByUser(user.Id, true, dba.Connection);
                if (model == null)
                {
                    return new Response
                           {
                               StatusCode = 404,
                               Message    = "User is not registered as a model, so cannot create a live session"
                           }
                }
                ;


                var ls = LiveSession.LoadOpenForModel(model.Id, dba.Connection);
                if (ls == null)
                {
                    return new Response {
                               StatusCode = 404, Message = "The model is not host of an open live session"
                    }
                }
                ;

                //check if model is host of session
                if (ls.Id != input.Body.LiveSessionId)
                {
                    return new Response
                           {
                               StatusCode = 404,
                               Message    = "Inconsistance between provided live session id and one registered in the db"
                           }
                }
                ;

                //chekc if model is accepting product set for the goal
                Product usedProduct = null;
                foreach (var p in model.Products)
                {
                    if (p.Id == input.Body.ProductId)
                    {
                        usedProduct = p;
                        break;
                    }
                }

                if (usedProduct == null)
                {
                    return new Response {
                               StatusCode = 404, Message = $"The goal product is not accepted by this model"
                    }
                }
                ;

                var goal = new Goal
                {
                    LiveSessionId  = ls.Id,
                    Title          = input.Body.Title,
                    Description    = input.Body.Description,
                    Tags           = input.Body.Tags,
                    GoalAmount     = input.Body.GoalAmount,
                    GoalAmountLeft = input.Body.GoalAmount,
                    ProductId      = usedProduct.Id
                };
                goal.Save(dba.Connection);


                var r = new Response
                {
                    StatusCode = 200,
                    Message    = "ok",
                    Body       = new ResponseBody
                    {
                        HostModelId   = model.Id,
                        HostUserId    = user.Id,
                        LiveSessionId = ls.Id,
                        ProductId     = usedProduct.Id,
                        GoalId        = goal.Id
                    }
                };
                return(r);
            }
            catch (Exception e)
            {
                var r = new Response();
                r.SetError(400, e);
                return(r);
            }
        }
    }
Example #11
0
        /// <summary>
        ///     A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public Response FunctionHandler(Request input, ILambdaContext context)
        {
            var dba = new DBAccess();

            if (input.Body.IsPing)
            {
                return new Response {
                           StatusCode = 200, Message = dba.Test()
                }
            }
            ;

            try
            {
                //validate require role
                if (!input.SourceUser.HasRole("Model"))
                {
                    return new Response {
                               StatusCode = 401, Message = "Access denied, requires Model role"
                    }
                }
                ;


                //get user
                var user = User.LoadBySourceUser(input.SourceUser, dba.Connection);
                if (user == null) //does not exist
                {
                    return new Response {
                               StatusCode = 404, Message = "User is not registered, hence cannot be a model"
                    }
                }
                ;


                //get model
                var model = Model.LoadByUser(user.Id, false, dba.Connection);
                if (model == null)
                {
                    return new Response
                           {
                               StatusCode = 404,
                               Message    = "User is not registered as a model, so cannot create a live session"
                           }
                }
                ;


                //validate that we received the correct live session id.
                //the calling model must also be the host of the livesession and the live session must not be closed/have ended
                var lsModel = LiveSession.LoadOpenForModel(model.Id, dba.Connection);
                if (lsModel == null)
                {
                    return new Response
                           {
                               StatusCode = 400,
                               Message    = "the calling model does not have any open live session"
                           }
                }
                ;

                var lsReq = LiveSession.LoadOpenById(input.Body.LiveSessionId, dba.Connection);
                if (lsReq == null)
                {
                    return new Response
                           {
                               StatusCode = 400,
                               Message    = "the requested live session does not exists or is already closed"
                           }
                }
                ;

                if (lsModel.Id != lsReq.Id)
                {
                    return new Response {
                               StatusCode = 400, Message = "invalid live session id"
                    }
                }
                ;

                lsReq.EndedRating = input.Body.Rating;
                lsReq.EndedRemark = input.Body.Remarks;
                lsReq.EndSession(dba.Connection);


                var r = new Response
                {
                    StatusCode = 200,
                    Message    = "ok"
                };
                return(r);
            }
            catch (Exception e)
            {
                var r = new Response();
                r.SetError(400, e);
                return(r);
            }
        }
    }
Example #12
0
 public void ReturnToMenu()
 {
     LiveSession.SavePlayer();
     GetComponent <SceneTransition>().DelayedSceneChange("MainMenu");
 }
Example #13
0
        /// <summary>
        ///     A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public Response FunctionHandler(Request input, ILambdaContext context)
        {
            var dba = new DBAccess();

            if (input.Body.IsPing)
            {
                return new Response {
                           StatusCode = 200, Message = dba.Test()
                }
            }
            ;

            try
            {
                //validate require role
                if (!input.SourceUser.HasRole("Model"))
                {
                    return new Response {
                               StatusCode = 401, Message = "Access denied, requires Model role"
                    }
                }
                ;


                //get user
                var user = User.LoadBySourceUser(input.SourceUser, dba.Connection);
                if (user == null) //does not exist
                {
                    return new Response {
                               StatusCode = 404, Message = "User is not registered, hence cannot be a model"
                    }
                }
                ;


                //get model
                var model = Model.LoadByUser(user.Id, false, dba.Connection);
                if (model == null)
                {
                    return new Response
                           {
                               StatusCode = 404,
                               Message    = "User is not registered as a model, so cannot create a live session"
                           }
                }
                ;


                //cleanup old sessions for model and create a new
                var ls = new LiveSession
                {
                    HostModelId       = model.Id,
                    Title             = input.Body.Title,
                    Description       = input.Body.Description,
                    RequiredUserScore = input.Body.RequiredUserScore,
                    Tags = input.Body.Tags,
                    AllowPayPerMinute    = input.Body.AllowPayPerMinute,
                    PpmProductId         = input.Body.PpmProductId,
                    PpmAmount            = input.Body.PpmAmount,
                    PpmMinimumJoinAmount = input.Body.PpmMinimumJoinAmount
                };
                ls.Save(dba.Connection);


                var r = new Response
                {
                    StatusCode = 200,
                    Message    = "ok",
                    Body       = new ResponseBody
                    {
                        HostModelId   = model.Id,
                        HostUserId    = user.Id,
                        LiveSessionId = ls.Id
                    }
                };
                return(r);
            }
            catch (Exception e)
            {
                var r = new Response();
                r.SetError(400, e);
                return(r);
            }
        }
    }
Example #14
0
 public void LaunchMission()
 {
     LiveSession.SetCaveData(caveMission.CaveName, caveMission.CaveRooms, caveMission.CaveMinerals);
     LiveSession.SetCurrentMission(caveMission.Mission);
     GetComponent <SceneTransition>().DelayedSceneChange("Cave");
 }
Example #15
0
        public static async Task SendSafeNotificationAsync(LiveSession session)
        {
            if (!string.IsNullOrEmpty(session.SMSRecipientsList) || !string.IsNullOrEmpty(session.EmailRecipientsList) ||
                !string.IsNullOrEmpty(session.FBGroupID) || !string.IsNullOrEmpty(session.FBAuthID))
            {
                string decryptedBuddyNumbers = string.Empty, mobileNumber = string.Empty;
                mobileNumber = Utility.Security.Decrypt(session.MobileNumber);
                try
                {
                    //Send Safe SMS to Buddies
                    if (Config.SendSms && string.IsNullOrEmpty(session.SMSRecipientsList))
                    {
                        try
                        {
                            if (!session.SMSRecipientsList.StartsWith("DM"))
                            {
                                decryptedBuddyNumbers = "DM" + DecryptMobileNumbers(session.SMSRecipientsList);
                            }

                            SMS.SendSMS(decryptedBuddyNumbers.Substring(2), GetSafeSMSBody(session.Name));
                        }
                        catch (Exception ex)
                        {
                            Trace.TraceError(
                                String.Format(
                                    "Error while sending Safe SMS for user with Mobile Number : {0}, ErrorMessage: {1}",
                                    mobileNumber, ex.Message));
                        }
                    }

                    //Send Email to buddies
                    if (!string.IsNullOrEmpty(session.EmailRecipientsList))
                    {
                        try
                        {
                            Email.SendEmail(session.EmailRecipientsList.Split(',').ToList(),
                                            GetSafeEmailBody(session.Name, mobileNumber),
                                            GetSafeEmailSubject(session.Name));
                        }
                        catch (Exception ex)
                        {
                            Trace.TraceError(
                                String.Format("Error while sending email for Profile: {0}, ErrorMessage: {1}",
                                              session.ProfileID, ex.Message));
                        }
                    }

                    //Post on FB account
                    if (!String.IsNullOrEmpty(session.FBGroupID) && !String.IsNullOrEmpty(session.FBAuthID) &&
                        session.LastFacebookPostTime.Value.AddMinutes(Config.FacebookPostGap) <= DateTime.UtcNow)
                    {
                        try
                        {
                            FaceBookPosting.FBPosting(session.FBAuthID,
                                                      GetSafeFacebookMessage(session.Name),
                                                      GetSafeFacebookCaption(session.Name), null, session.FBGroupID);
                        }
                        catch (Exception ex)
                        {
                            Trace.TraceError(
                                String.Format(
                                    "Error while posting on FB Group for the Profile: {0}, ErrorMessage: {1}",
                                    session.ProfileID, ex.Message));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Trace.TraceError(
                        String.Format(
                            "Error while posting to friends for GeoTag with Identifier: {0}, ErrorMessage: {1}",
                            session.SessionID, ex.Message));
                }
                finally
                {
                }
            }
        }
Example #16
0
 void ExitCave()
 {
     LiveSession.ExitCave();
     GetComponent <SceneTransition>().DelayedSceneChange("ControlRoom");
 }