コード例 #1
0
    private void BindListbox(List <int> SubContentID)
    {
        #region Bind contents to checkbox list
        int contentid = Convert.ToInt32(Session["ContentID"]);
        using (CellEntities context = new CellEntities())
        {
            var contentlist = (from rs in context.Contents where rs.IsActive == true select rs).ToList();
            foreach (var contentitm in contentlist)
            {
                if (contentid != contentitm.ContentID)
                {
                    ListItem item = new ListItem();
                    item.Text  = contentitm.HeadingText;
                    item.Value = contentitm.ContentID.ToString();
                    if (SubContentID != null)
                    {
                        if (SubContentID.Contains(contentitm.ContentID))
                        {
                            item.Selected = true;
                        }
                    }
                    chkChoices.Items.Add(item);
                }
            }
        }

        #endregion
    }
コード例 #2
0
        private void SendNewlyVisibleEntities(Player player, AbsoluteEntityCell[] visibleCells)
        {
            List <Entity> newlyVisibleEntities = entityManager.GetVisibleEntities(visibleCells);

            if (newlyVisibleEntities.Count > 0)
            {
                CellEntities cellEntities = new CellEntities(newlyVisibleEntities);
                player.SendPacket(cellEntities);
            }
        }
コード例 #3
0
ファイル: Home.aspx.cs プロジェクト: ethannguyen1991/CellDamn
 public void SetDashboardForAdmin()
 {
     using (CellEntities context = new CellEntities())
     {
         var scenariocount = (from rs in context.Scenarios select rs.Name).ToList().Count();
         var contentcount  = (from rs in context.Contents select rs.HeadingID).ToList().Count();
         var studentcount  = (from rs in context.Accounts select rs.AccountId).ToList().Count();
         lblscenario.Text = @"Available no of scenario  " + scenariocount.ToString();
         lblcontent.Text  = @"Available no of conent  " + contentcount.ToString();
         lblstudetn.Text  = @"Available no of student  " + studentcount.ToString();
     };
 }
コード例 #4
0
    private List <int> GetContentDetails()
    {
        List <int> SubContentID = null;

        #region Bind data as per content ID
        if (Session["ContentID"] != null)
        {
            int contentid = Convert.ToInt32(Session["ContentID"]);
            using (CellEntities context = new CellEntities())
            {
                SubContentID = (from rs in context.SubContents where rs.ParentID == contentid select rs.ChildID).ToList();
                //SubContentID = new List<int> { 1 };
            }
            using (SqlConnection con = new SqlConnection())
            {
                con.ConnectionString = ConfigurationManager.ConnectionStrings["CPDBCS"].ConnectionString;
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "ShowContent";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Clear();
                cmd.Parameters.Add("@UserID", SqlDbType.Int).Value    = Convert.ToInt32(Session["UserID"]);
                cmd.Parameters.Add("@ContentID", SqlDbType.Int).Value = 1;//Convert.ToInt32(Session["ContentID"]);//TODO fix later
                cmd.Connection = con;
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    txtHeadingID.Text     = dr["HeadingID"].ToString();
                    txtHeadingText.Text   = dr["HeadingText"].ToString();
                    txtContent.Text       = dr["Contents"].ToString();
                    Link1Caption.Text     = dr["Link1Caption"].ToString();
                    Link2Caption.Text     = dr["Link2Caption"].ToString();
                    Link3Caption.Text     = dr["Link3Caption"].ToString();
                    Link4Caption.Text     = dr["Link4Caption"].ToString();
                    Link5Caption.Text     = dr["Link5Caption"].ToString();
                    Link6Caption.Text     = dr["Link6Caption"].ToString();
                    Link1Description.Text = dr["Link1Description"].ToString();
                    Link2Description.Text = dr["Link2Description"].ToString();
                    Link3Description.Text = dr["Link3Description"].ToString();
                    Link4Description.Text = dr["Link4Description"].ToString();
                    Link5Description.Text = dr["Link5Description"].ToString();
                    Link6Description.Text = dr["Link6Description"].ToString();
                }
            };
        }
        return(SubContentID);

        #endregion
    }
コード例 #5
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int scenarioid = Convert.ToInt32(Session["ScenarioID"]);

        if (txtComment.Text == "")
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Please Post Your Comment')", true);
            return;
        }
        #region Save comment
        using (SqlConnection con = new SqlConnection())
        {
            con.ConnectionString = ConfigurationManager.ConnectionStrings["CPDBCS"].ConnectionString;
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "SaveComment";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Clear();
            cmd.Parameters.Add("@ScenarioID", SqlDbType.Int).Value = scenarioid;
            if (Session["ContentID"] != null)
            {
                cmd.Parameters.Add("@ContentID", SqlDbType.Int).Value = Session["ContentID"].ToString();
            }
            cmd.Parameters.Add("@StudentID", SqlDbType.Int).Value   = Session["UserID"].ToString();
            cmd.Parameters.Add("@Comment", SqlDbType.VarChar).Value = txtComment.Text;
            cmd.Connection = con;
            con.Open();
            cmd.ExecuteNonQuery();
            btnSave.Enabled = false;
            if (btnSave.Text == "Finish")
            {
                using (CellEntities context = new CellEntities())
                {
                    var getscanrio = (from rs in context.Scenarios where rs.ScenarioID == scenarioid select rs).FirstOrDefault();
                    if (getscanrio != null)
                    {
                        getscanrio.Rank = getscanrio.Rank + 1;
                        context.SaveChanges();
                    }
                }
                ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Game finish successfully');window.location ='Home.aspx';", true);
            }
        };
        #endregion
    }
コード例 #6
0
        public override void Process(EntitySpawnedByClient packet, Player playerWhoSpawned)
        {
            Entity entity = packet.Entity;

            entityManager.RegisterNewEntity(entity);

            SimulatedEntity simulatedEntity = entitySimulation.AssignNewEntityToPlayer(entity, playerWhoSpawned);

            SimulationOwnershipChange ownershipChangePacket = new SimulationOwnershipChange(simulatedEntity);

            playerManager.SendPacketToAllPlayers(ownershipChangePacket);

            foreach (Player player in playerManager.GetConnectedPlayers())
            {
                bool isOtherPlayer = player != playerWhoSpawned;
                if (isOtherPlayer && player.CanSee(entity))
                {
                    CellEntities cellEntities = new CellEntities(entity);
                    player.SendPacket(cellEntities);
                }
            }
        }
コード例 #7
0
        public override void Process(DroppedItem packet, Player droppingPlayer)
        {
            bool   existsInGlobalRoot = map.GlobalRootTechTypes.Contains(packet.TechType);
            Entity entity             = new Entity(packet.ItemPosition, packet.ItemRotation, NitroxVector3.One, packet.TechType, 0, null, true, packet.WaterParkId.OrElse(null), packet.Bytes, existsInGlobalRoot, packet.Id);

            entityManager.RegisterNewEntity(entity);

            SimulatedEntity simulatedEntity = entitySimulation.AssignNewEntityToPlayer(entity, droppingPlayer);

            SimulationOwnershipChange ownershipChangePacket = new SimulationOwnershipChange(simulatedEntity);

            playerManager.SendPacketToAllPlayers(ownershipChangePacket);

            foreach (Player player in playerManager.GetConnectedPlayers())
            {
                bool isOtherPlayer = player != droppingPlayer;
                if (isOtherPlayer && player.CanSee(entity))
                {
                    CellEntities cellEntities = new CellEntities(entity);
                    player.SendPacket(cellEntities);
                }
            }
        }
コード例 #8
0
        public override void Process(DroppedItem packet, Player droppingPlayer)
        {
            bool   existsInGlobalRoot = Map.GLOBAL_ROOT_TECH_TYPES.Contains(packet.TechType);
            Entity entity             = new Entity(packet.ItemPosition, packet.ItemRotation, new UnityEngine.Vector3(1, 1, 1), packet.TechType, 0, null, true, packet.WaterParkGuid.OrElse(null), packet.Bytes, existsInGlobalRoot, packet.Guid);

            entityManager.RegisterNewEntity(entity);

            SimulatedEntity simulatedEntity = entitySimulation.AssignNewEntityToPlayer(entity, droppingPlayer);

            SimulationOwnershipChange ownershipChangePacket = new SimulationOwnershipChange(simulatedEntity);

            playerManager.SendPacketToAllPlayers(ownershipChangePacket);

            foreach (Player player in playerManager.GetPlayers())
            {
                bool isOtherPlayer = (player != droppingPlayer);

                if (isOtherPlayer && player.CanSee(entity))
                {
                    CellEntities cellEntities = new CellEntities(entity);
                    player.SendPacket(cellEntities);
                }
            }
        }
コード例 #9
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        using (SqlConnection con = new SqlConnection())
        {
            con.ConnectionString = ConfigurationManager.ConnectionStrings["CPDBCS"].ConnectionString;
            try
            {
                #region Declaration
                int hasCommentBox = 0;
                if (chkCommentBox.Checked)
                {
                    hasCommentBox = 1;
                }
                int hasButtons = 1;

                int    isStudent = Convert.ToInt32(Session["IsStudent"]);
                string userID    = Session["UserID"].ToString();

                string image = null;
                if (fileImage.HasFile)
                {
                    image = DateTime.Now.ToString("yyyyMMddHHmmssfff").ToString() + ".jpg";
                    string filePath = "ContentImages/" + image;
                    fileImage.SaveAs(Server.MapPath(filePath));
                }

                int contentID = -1;
                if (Session["ContentID"] != null)
                {
                    contentID = Convert.ToInt32(Session["ContentID"]);

                    SqlCommand cmdd = new SqlCommand();
                    cmdd.CommandText = "DeleteSubContent";
                    cmdd.CommandType = CommandType.StoredProcedure;
                    cmdd.Parameters.Clear();
                    cmdd.Parameters.Add("@ParentId", SqlDbType.Int).Value = contentID;
                    cmdd.Connection = con;
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    cmdd.ExecuteNonQuery();
                }
                #endregion

                #region Saving parent content
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "SaveContent";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Clear();
                cmd.Parameters.Add("@ContentID", SqlDbType.Int).Value       = contentID;
                cmd.Parameters.Add("@HeadingID", SqlDbType.VarChar).Value   = txtHeadingID.Text;
                cmd.Parameters.Add("@HeadingText", SqlDbType.VarChar).Value = txtHeadingText.Text;
                cmd.Parameters.Add("@Contents", SqlDbType.VarChar).Value    = txtContent.Text;
                if (!string.IsNullOrEmpty(image))
                {
                    cmd.Parameters.Add("@Image", SqlDbType.VarChar).Value = image;
                }
                cmd.Parameters.Add("@Link1Caption", SqlDbType.VarChar).Value     = Link1Caption.Text;
                cmd.Parameters.Add("@Link1Description", SqlDbType.VarChar).Value = Link1Description.Text;
                cmd.Parameters.Add("@Link2Caption", SqlDbType.VarChar).Value     = Link2Caption.Text;
                cmd.Parameters.Add("@Link2Description", SqlDbType.VarChar).Value = Link2Description.Text;
                cmd.Parameters.Add("@Link3Caption", SqlDbType.VarChar).Value     = Link3Caption.Text;
                cmd.Parameters.Add("@Link3Description", SqlDbType.VarChar).Value = Link3Description.Text;

                cmd.Parameters.Add("@Link4Caption", SqlDbType.VarChar).Value     = Link4Caption.Text;
                cmd.Parameters.Add("@Link4Description", SqlDbType.VarChar).Value = Link4Description.Text;
                cmd.Parameters.Add("@Link5Caption", SqlDbType.VarChar).Value     = Link5Caption.Text;
                cmd.Parameters.Add("@Link5Description", SqlDbType.VarChar).Value = Link5Description.Text;
                cmd.Parameters.Add("@Link6Caption", SqlDbType.VarChar).Value     = Link6Caption.Text;
                cmd.Parameters.Add("@Link6Description", SqlDbType.VarChar).Value = Link6Description.Text;

                cmd.Parameters.Add("@HasCommentBox", SqlDbType.Bit).Value      = hasCommentBox;
                cmd.Parameters.Add("@HasButtons", SqlDbType.Bit).Value         = hasButtons;
                cmd.Parameters.Add("@IsCreatedByStudent", SqlDbType.Int).Value = isStudent;
                cmd.Parameters.Add("@CreatedBy", SqlDbType.Int).Value          = userID;
                cmd.Parameters.Add("@NewContentID", SqlDbType.VarChar, 50);
                cmd.Parameters["@NewContentID"].Direction = ParameterDirection.Output;
                cmd.Connection = con;
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                cmd.ExecuteNonQuery();
                string newContentID = cmd.Parameters["@NewContentID"].Value.ToString();
                #endregion
                Session["ContentID"] = newContentID;
                #region Saving child content
                CellEntities context = new CellEntities();

                foreach (ListItem childSubContentID in chkChoices.Items)
                {
                    int isDel = 0;
                    if (!childSubContentID.Selected)
                    {
                        isDel = 1;
                    }
                    if (childSubContentID.Selected)
                    {
                        int childID = Convert.ToInt32(childSubContentID.Value);
                        cmd.CommandText = "SaveSubContent";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@ParentID", SqlDbType.Int).Value  = newContentID;
                        cmd.Parameters.Add("@ChildID", SqlDbType.Int).Value   = childID;
                        cmd.Parameters.Add("@IsDeleted", SqlDbType.Int).Value = isDel;
                        cmd.Connection = con;
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }
                        cmd.ExecuteNonQuery();
                    }
                }
                #endregion
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "alert", "alert('Content saved successfully')", true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        };
        Response.Redirect("ShowContents.aspx", false);
        ApplicationInstance.CompleteRequest();
    }