コード例 #1
0
        public object Post(CreateSession message)
        {
            using (var db = _connectionFactory.Open())
            {
                var session = new Session
                {
                    JournalId   = message.JournalId,
                    Name        = message.Name,
                    Description = message.Description,
                    CreatedAt   = DateTime.Now
                };

                try
                {
                    long sessionId = db.Insert(session, true);

                    return(new GeneralizedResponse {
                        Message = "New Session Created! Id: " + sessionId
                    });
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
コード例 #2
0
        private void CreateSession(CreateSession createSession)
        {
            // IActorRef sessionActor = Context.ActorOf(Context.DI().Props<SessionActor>(), $"session-{ createSession.SessionId }");
            IActorRef sessionActor = Context.ActorOf(Props.Create <SessionActor>(), $"session-{ createSession.SessionId }");

            sessionActor.Forward(createSession);
        }
コード例 #3
0
        public CreateSessionTest()
        {
            _readSessionRepository  = A.Fake <IReadSessionRepository>();
            _writeSessionRepository = A.Fake <IWriteSessionRepository>();

            _command = new CreateSession(_readSessionRepository, _writeSessionRepository);
        }
コード例 #4
0
        //<------------------------------------------------------------------------------------------------------>
        //<------------------------------------------------------------------------------------------------------>


        private async Task <OperationResult <int> > Post(CreateSession item)
        {
            using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                if (!item.ParameterValid())
                {
                    return new OperationResult <int>()
                           {
                               Success = false, Message = Messages.PARAMETERS_NOT_NULL
                           }
                }
                ;

                var EventRes = await eventService.GetByIdAsync(item.eventId);

                if (!EventRes.Success)
                {
                    return new OperationResult <int>()
                           {
                               Success = false, Message = EventRes.Message
                           }
                }
                ;
                if (!EventRes.Result.community.admins.Any(elem => elem.id == item.userId))
                {
                    return new OperationResult <int>()
                           {
                               Success = false, Message = Messages.USER_NO_PERMISSION
                           }
                }
                ;

                if (item.endDate.CompareTo(item.initialDate) <= 0)
                {
                    return new OperationResult <int>()
                           {
                               Success = false, Message = Messages.END_DATE_NOT_VALID
                           }
                }
                ;

                try
                {
                    var id = await sessionRepo.PostAsync(item);

                    scope.Complete();
                    return(new OperationResult <int>()
                    {
                        Success = true, Message = Messages.SESSION_CREATED, Result = id
                    });
                }
                catch (Exception ex)
                {
                    return(new OperationResult <int>()
                    {
                        Success = false, Message = ex.Message
                    });
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Create session for getty images api
        /// </summary>
        /// <returns>CreateSessionResult</returns>
        private static CreateSessionResult CreateSession()
        {
            var session = new CreateSession();
            var createSessionTokenResponse = session.GetCreateSessionResponse();

            return(createSessionTokenResponse != null ? createSessionTokenResponse.CreateSessionResult : null);
        }
コード例 #6
0
ファイル: SeminarSession.cs プロジェクト: xleza/FAS
 public SeminarSession(CreateSession cmd)
 {
     Id        = cmd.Id;
     SeminarId = cmd.SeminarId;
     Attendees = new List <SessionAttendee>();
     Status    = SessionStatus.NotStarted;
     StartTime = null;
     EndTime   = null;
 }
コード例 #7
0
        // GET: Session/Create
        public ActionResult Create()
        {
            CreateSession session = new CreateSession()
            {
                Films = _context.Films,
                Halls = _context.Halls
            };

            return(View(session));
        }
コード例 #8
0
        // GET: Session/Create
        public ActionResult Create()
        {
            CreateSession session = new CreateSession()
            {
                Films = _dao.Films.GetAll(),
                Halls = _dao.Halls.GetAll()
            };

            return(View(session));
        }
コード例 #9
0
        public async Task <Session <TSession, TUser> > CreateAsync <TSession, TUser>(CreateSession <TSession> session = null, string[] expand = null)
        {
            var additionalParams = new Dictionary <string, string>();

            if (expand != null)
            {
                additionalParams.Add(nameof(expand), string.Join(",", expand));
            }

            return(await HttpConnection.PostAsync <Session <TSession, TUser> >($"/sessions", session ?? new CreateSession <TSession>(), additionalParams));
        }
コード例 #10
0
ファイル: Session.cs プロジェクト: gvhung/SalesOrder
        private void CreateSession(CreateSession createSession)
        {
            logger.Info("Create session (Session Id: {0}, User Id: {1})", createSession.SessionId, createSession.UserId);
            // Console.WriteLine("Create session (Session Id: {0}, User Id: {1})", createSession.SessionId, createSession.UserId);

            sessionId = createSession.SessionId;
            userId    = createSession.UserId;

            var sessionCreated = new SessionCreated(createSession.SessionId, Self);

            Sender.Tell(sessionCreated);
        }
コード例 #11
0
        private async Task <OperationResult <int> > Put(CreateSession item)
        {
            using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var session = await sessionRepo.GetByIdAsync(item.id);

                if (session == null)
                {
                    return new OperationResult <int>()
                           {
                               Success = false, Message = Messages.SESSION_NOT_EXIST
                           }
                }
                ;
                if ([email protected](elem => elem.id == item.userId))
                {
                    return new OperationResult <int>()
                           {
                               Success = false, Message = Messages.USER_NO_PERMISSION
                           }
                }
                ;

                try
                {
                    session.title = item.title == null ? session.title : item.title;

                    session.description   = item.description == null ? session.description : item.description;
                    session.speakerName   = item.speakerName == null ? session.speakerName : item.speakerName;
                    session.lastName      = item.lastName == null ? session.lastName : item.lastName;
                    session.linkOfSpeaker = item.linkOfSpeaker == null ? session.linkOfSpeaker : item.linkOfSpeaker;
                    session.initialDate   = item.initialDate == default(DateTime) ? session.initialDate : item.initialDate;
                    session.endDate       = item.endDate == default(DateTime) ? session.endDate : item.endDate;

                    var id = await sessionRepo.PutAsync(session);

                    scope.Complete();
                    return(new OperationResult <int>()
                    {
                        Success = true, Message = Messages.SESSION_UPDATED, Result = id
                    });
                }
                catch (Exception ex)
                {
                    return(new OperationResult <int>()
                    {
                        Success = false, Message = ex.Message
                    });
                }
            }
        }
コード例 #12
0
        public async Task <CreateSessionResponse> CreateSession(string sessionName)
        {
            var createSessionData = new CreateSession()
            {
                Name               = sessionName,
                Notification       = true,
                Restricted         = false,
                SessionEndDate     = DateTime.Now.AddDays(30),
                DefaultPermissions = new List <DefaultSessionPermissions>()
                {
                    new DefaultSessionPermissions()
                    {
                        Type  = "SaveCopy",
                        Allow = "Allow"
                    },
                    new DefaultSessionPermissions()
                    {
                        Type  = "PrintCopy",
                        Allow = "Allow"
                    },
                    new DefaultSessionPermissions()
                    {
                        Type  = "Markup",
                        Allow = "Allow"
                    },
                    new DefaultSessionPermissions()
                    {
                        Type  = "MarkupAlert",
                        Allow = "Allow"
                    },
                    new DefaultSessionPermissions()
                    {
                        Type  = "AddDocuments",
                        Allow = "Allow"
                    }
                }
            };

            var json = JsonConvert.SerializeObject(createSessionData);

            var client     = new HttpAuthClient();
            var sessionUrl = "https://studioapi.bluebeam.com/publicapi/v1/sessions";
            var response   = await client.Post(sessionUrl, json, User, _userManager);

            var createSessionResponse = JsonConvert.DeserializeObject <CreateSessionResponse>(response);

            return(createSessionResponse);
        }
コード例 #13
0
ファイル: UsersClient.cs プロジェクト: deltaDirk/luno-dotnet
        public async Task <LoginResponse <TUser, TSession> > LoginAsync <TUser, TSession>(string login, string password, CreateSession <TSession> session = null, string[] expand = null)
        {
            var additionalParams = new Dictionary <string, string>();

            if (expand != null)
            {
                additionalParams.Add(nameof(expand), string.Join(",", expand));
            }

            if (session == null)
            {
                session = new CreateSession <TSession>();
            }

            return(await HttpConnection.PostAsync <LoginResponse <TUser, TSession> >("/users/login", new { login, password, session }, additionalParams));
        }
コード例 #14
0
ファイル: SessionsController.cs プロジェクト: Barsun/test
        public HttpResponseMessage Post(CreateSession model)
        {
            if(!ModelState.IsValid) {
                return Request.CreateErrorResponse(
                    HttpStatusCode.BadRequest,ModelState);
            }

            var success = signIn(
                model.Email.ToLowerInvariant(),
                model.Password,
                model.RememberMe.GetValueOrDefault());

            return Request.CreateResponse(success ?
                HttpStatusCode.NoContent :
                HttpStatusCode.BadRequest);
        }
コード例 #15
0
        public HttpResponseMessage Post(CreateSession model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(
                           HttpStatusCode.BadRequest, ModelState));
            }

            var success = signIn(
                model.Email.ToLowerInvariant(),
                model.Password,
                model.RememberMe.GetValueOrDefault());

            return(Request.CreateResponse(success ?
                                          HttpStatusCode.NoContent :
                                          HttpStatusCode.BadRequest));
        }
コード例 #16
0
        public Task <int> PostAsync(CreateSession item)
        {
            return(Task.Factory.StartNew(() =>
            {
                var result = new session()
                {
                    description = item.description,
                    eventId = item.eventId,
                    initialDate = item.initialDate,
                    endDate = item.endDate,
                    speakerName = item.speakerName,
                    linkOfSpeaker = item.linkOfSpeaker,
                    lastName = item.lastName,
                    title = item.title
                };

                context.session.Add(result);

                try
                {
                    context.SaveChanges();
                    return result.id;
                }

                /*catch (Exception e)
                 * {
                 *
                 *  throw new ArgumentException(e.Message);
                 * }*/

                catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                          eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                              ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    throw;
                }
            }));
        }
コード例 #17
0
        private async Task <OperationResult <int> > Delete(CreateSession item)
        {
            using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var session = await sessionRepo.GetByIdAsync(item.id);

                if (session == null)
                {
                    return new OperationResult <int>()
                           {
                               Success = false, Message = Messages.SESSION_NOT_EXIST
                           }
                }
                ;
                if ([email protected](elem => elem.id == item.userId))
                {
                    return new OperationResult <int>()
                           {
                               Success = false, Message = Messages.USER_NO_PERMISSION
                           }
                }
                ;

                try
                {
                    var id = await sessionRepo.DeleteAsync(session);

                    scope.Complete();
                    return(new OperationResult <int>()
                    {
                        Success = true, Message = Messages.SESSION_DELETED_SUCCESS, Result = id
                    });
                }
                catch (Exception ex)
                {
                    return(new OperationResult <int>()
                    {
                        Success = false, Message = ex.InnerException.Message
                    });
                }
            }
        }
    }
}
コード例 #18
0
        // PUT: api/Session/5
        public string Put(int id, [FromBody] CreateSession value)
        {
            SqlCommand cmd = new SqlCommand();

            conn.Connectdb("update Session set Id_user=@Id_user, Date_session=@Date_session, Duration_session=@Duration_session where Id_session='" + id + "'", cmd);
            cmd.Parameters.AddWithValue("@Id_user", value.Id_user);
            cmd.Parameters.AddWithValue("@Date_session", value.Date_session);
            cmd.Parameters.AddWithValue("@Duration_session", value.Duration_session);
            int result = cmd.ExecuteNonQuery();

            if (result > 0)
            {
                return("mise à jour réussie");
            }
            else
            {
                return("echec mise à jour");
            }
        }
コード例 #19
0
ファイル: Terminal.cs プロジェクト: vaness666vad/reposit
        public void Session(DataCover128kb data)
        {
            CreateSession si = Protocol.BufferToObject <CreateSession>(data.Data);
            RemoteDevice  rd = ClientsControl.GetDevices().FirstOrDefault(x => x.Id.Value == si.RemDevId);

            if (rd != null)
            {
                string text = $"Запрос создания сессии id{Id.Value}:{Name} id{rd.Id.Value}:{rd.Name}";
                LogWriter.SendLog(text);
                ClientsControl.SendGlobalChat(text);

                byte[]   ip      = new byte[4];
                int      port    = si.CustomPort;
                string[] ipstrar = null;
                if (port > -1)
                {
                    ipstrar = Program.GLOBALIP.Split('.');
                }
                else
                {
                    IPEndPoint ipep = (IPEndPoint)Client.RemoteEndPoint;
                    ipstrar = ipep.Address.ToString().Split('.');
                    port    = ipep.Port;
                }
                for (int i = 0; i < ip.Length; i += 1)
                {
                    ip[i] = byte.Parse(ipstrar[i]);
                }

                byte[] pass = Guid.NewGuid().ToByteArray();

                rd.Write(new DataCover128kb(new ConnectedInfo(ip, port, pass).Pack(), DataType.createSessionIpPort).Pack());
                Write(new DataCover128kb(new ConnectedInfo(((IPEndPoint)rd.Client.RemoteEndPoint).Address.GetAddressBytes(), ((IPEndPoint)rd.Client.RemoteEndPoint).Port, pass).Pack(), DataType.createSessionIpPort).Pack());
            }
            else
            {
                string text = $"В запросе создания сессии для {Id.Value}:{Name} отказано, удаленное устройство id:{si.RemDevId} не подключено";
                LogWriter.SendLog(text);
                ClientsControl.SendGlobalChat(text);
            }
        }
コード例 #20
0
        // POST: api/Session
        public string Post([FromBody] CreateSession value)
        {
            SqlCommand cmd = new SqlCommand();

            conn.Connectdb("insert into Session(Id_session, Id_user, Date_session, Duration_session)values(@Id_session, @Id_user, @Date_session, @Duration_session)", cmd);
            cmd.Parameters.AddWithValue("@Id_session", value.Id_session);   //auto-incrementé
            cmd.Parameters.AddWithValue("@Id_user", value.Id_user);
            cmd.Parameters.AddWithValue("@Date_session", value.Date_session);
            cmd.Parameters.AddWithValue("@Duration_session", value.Duration_session);
            conn.Con.Open();
            int result = cmd.ExecuteNonQuery();

            if (result > 0)
            {
                return("insertion réussie");
            }
            else
            {
                return("echec insertion");
            }
        }
コード例 #21
0
ファイル: SessionsCommandService.cs プロジェクト: xleza/FAS
        public async Task CreateAsync(CreateSession cmd)
        {
            cmd.Validate();

            if (await _sessionsDao.ExistsByIdAsync(cmd.Id))
            {
                throw new ObjectAlreadyExitsException(cmd.Id, typeof(SeminarSession));
            }

            if (await _sessionsDao.ExistsByWhereAsync($"SeminarId = '{cmd.SeminarId}' AND Status != '{SessionStatus.Finished}'"))
            {
                throw new DomainException($"Can't create a seminar: {cmd.SeminarId} session until all sessions have finished");
            }

            if (await _seminarDao.ExistsAsync(cmd.Id))
            {
                throw new ObjectNotFoundException(cmd.SeminarId, typeof(Seminar));
            }

            await _sessionsDao.AddAsync(new SeminarSession(cmd));
        }
コード例 #22
0
        public async Task<HttpResponseMessage> Post(CreateSession model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(
                    HttpStatusCode.BadRequest, ModelState);
            }

            var success = await membershipService.InternalSignIn(
                model.Email.ToLower(CultureInfo.CurrentCulture),
                model.Password,
                model.RememberMe.GetValueOrDefault());

            return Request.CreateResponse(success ?
                HttpStatusCode.NoContent :
                HttpStatusCode.BadRequest);
        }
コード例 #23
0
        public async Task <HttpResponseMessage> Post(CreateSession model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(
                           HttpStatusCode.BadRequest, ModelState));
            }

            var success = await membershipService.InternalSignIn(
                model.Email.ToLower(CultureInfo.CurrentCulture),
                model.Password,
                model.RememberMe.GetValueOrDefault());

            return(Request.CreateResponse(success ?
                                          HttpStatusCode.NoContent :
                                          HttpStatusCode.BadRequest));
        }
コード例 #24
0
        public async Task <CreateSessionResult> CreateSession(string username, string password, string deviceId)
        {
            var client = Client;

            var data = new CreateSession()
            {
                Username = username,
                Password = password,
                DeviceId = deviceId
            };

            var resp = await client.PostAsJsonAsync("api/sessions", data);

            if (!resp.IsSuccessStatusCode)
            {
                throw ApiClientException.FromResponse(resp);
            }

            var result = await resp.Content.ReadAsAsync <CreateSessionResult>();

            return(result);
        }
コード例 #25
0
        public async Task <ActionResult> CreateSession(Session session)
        {
            if (ModelState.IsValid)
            {
                SessionService service = SessionService.GetInstance();

                CreateSession newSession = new CreateSession()
                {
                    title         = session.Title,
                    description   = session.Description,
                    eventId       = session.EventId,
                    initialDate   = DateTime.Parse(session.StartDate),
                    endDate       = DateTime.Parse(session.EndDate),
                    speakerName   = session.SpeakerName,
                    lastName      = session.LastName,
                    linkOfSpeaker = session.LinkOfSpeaker,
                    userId        = User.Identity.GetUserId()
                };
                var res = await service.PostSessionAsync(newSession);// retorna o id da sessão que foi criado se quiser fazer redirect falta o nome da comunidade

                if (res.Success)
                {
                    //Falta meter o redirect como deve ser
                    //return Json(new { url = Constants.WebAPPAddress + "/Home/"  });
                    return(Redirect(Request.UrlReferrer.PathAndQuery));
                }

                else
                {
                    //tratar do erro que ainda falta pode dar um erro na inserção

                    ViewBag.Message = res.Message;
                }
            }

            return(PartialView("_CreateSession", session));
        }
コード例 #26
0
        public object Post(CreateSession message)
        {
            using (var db = _connectionFactory.Open())
            {
                var session = new Session
                {
                    JournalId = message.JournalId,
                    Name = message.Name,
                    Description = message.Description,
                    CreatedAt = DateTime.Now
                };

                try
                {
                    long sessionId = db.Insert(session, true);
                    return new GeneralizedResponse {Message = "New Session Created! Id: " + sessionId};
                }
                catch (Exception)
                {

                    throw;
                }
            }
        }
コード例 #27
0
 public async Task <OperationResult <int> > PostSessionAsync(CreateSession item)
 {
     return(await Post(item));
 }
コード例 #28
0
 public async Task <OperationResult <int> > UpdateSession(CreateSession item)
 {
     return(await Put(item));
 }
コード例 #29
0
 public async Task <OperationResult <int> > DeleteSession(CreateSession item)
 {
     return(await Delete(item));
 }
コード例 #30
0
        private void CreateSession(CreateSession createSession)
        {
            IActorRef sessionActor = Context.ActorSelection(SalesOrderActorRefs.SessionCollection).ResolveOne(TimeSpan.FromSeconds(10)).Result;

            sessionActor.Tell(createSession);
        }
コード例 #31
0
 public async Task Post([FromBody] CreateSession command)
 => await _commandDispatcher.DispatchAsync(command);
コード例 #32
0
 public NetAcceptor(CreateSession dlgtCreateSession, NetCmdQueue refCmdQueue)
 {
     m_dlgtCreateSession = dlgtCreateSession;
     m_refCmdQueue       = refCmdQueue;
 }
コード例 #33
0
        public void CreateSession()
        {
            CreateSession createSession = new CreateSession(Context.ConnectionId, Context.User.Identity.Name);

            SalesOrderActorSystem.SalesOrderBridgeActor.Tell(createSession);
        }