public void Create(CreateRestrictedIPDto dto)
        {
            var restrictedIP = new RestrictedIP
            {
                IP = dto.IP
            };

            _restrictedIPsRepository.Insert(restrictedIP);
        }
Exemplo n.º 2
0
    private DataView CreateDataView(RestrictedIP[] aRI)
    {
        DataView dv = new DataView();
        System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn();

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "IPMask";
        colBound.HeaderText = this.GetMessage("lbl block ip");
        dgRestricted.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "ID";
        colBound.HeaderText = this.GetMessage("generic id");
        dgRestricted.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "RestrictedSince";
        colBound.HeaderText = this.GetMessage("lbl since");
        dgRestricted.Columns.Add(colBound);

        if (m_iBoardID == 0)
        {
            colBound = new System.Web.UI.WebControls.BoundColumn();
            colBound.DataField = "AppliesTo";
            colBound.HeaderText = this.GetMessage("lbl applies to");
            dgRestricted.Columns.Add(colBound);
        }

        DataTable dt = new DataTable();
        DataRow dr;

        dt.Columns.Add(new DataColumn("IPMask", typeof(string)));
        dt.Columns.Add(new DataColumn("ID", typeof(string)));
        dt.Columns.Add(new DataColumn("RestrictedSince", typeof(string)));
        dt.Columns.Add(new DataColumn("AppliesTo", typeof(string)));

        for (int i = 0; i <= (aRI.Length - 1); i++)
        {
            dr = dt.NewRow();
            dr[0] = "<a href=\"restrictIP.aspx?action=view&boardid=" + this.m_iBoardID.ToString() + "&id=" + aRI[i].RestrictedID.ToString() + "\">" + aRI[i].IPMask + "</a>";
            dr[1] = "<a href=\"restrictIP.aspx?action=view&boardid=" + this.m_iBoardID.ToString() + "&id=" + aRI[i].RestrictedID.ToString() + "\">" + aRI[i].RestrictedID.ToString() + "</a>";
            dr[2] = aRI[i].RestrictedSince.ToLongDateString() + " " + aRI[i].RestrictedSince.ToShortTimeString();
            if (m_iBoardID == 0)
            {
                for (int j = 0; j <= (aRI[i].AppliesTo.Length - 1); j++)
                {
                    dr[3] += "<img valign=\'center\' src=\'" + m_refContentApi.AppImgPath + "menu/users2.gif" + "\' />&nbsp;<a href=\"../content.aspx?action=ViewContentByCategory&id=" + aRI[i].AppliesTo[j].Id.ToString() + "\">" + aRI[i].AppliesTo[j].Name + "</a>";
                    if (j < aRI[i].AppliesTo.Length)
                    {
                        dr[3] += "<br/>";
                    }
                }
            }
            dt.Rows.Add(dr);
        }
        dv = new DataView(dt);
        return dv;
    }
Exemplo n.º 3
0
 public void Process_AddEdit()
 {
     ArrayList alTmp = new ArrayList();
     FolderData fdTmp;
     if (this.m_iID > 0)
     {
         aRestricted = cContent.SelectRestrictedIP(this.m_iID);
         riRestrict = aRestricted[0];
     }
     else
     {
         riRestrict = new RestrictedIP();
     }
     riRestrict.IPMask = Request.Form[txt_mask.UniqueID];
     if (m_iBoardID > 0)
     {
         riRestrict.AppliesTo = (FolderData[])Array.CreateInstance(typeof(FolderData), 1);
         riRestrict.AppliesTo[0] = new FolderData();
         riRestrict.AppliesTo[0].Id = this.m_iBoardID;
     }
     else
     {
         for (int i = 0; i <= (cl_boards.Items.Count - 1); i++)
         {
             if (cl_boards.Items[i].Selected == true)
             {
                 fdTmp = new FolderData();
                 fdTmp.Id = Convert.ToInt64(cl_boards.Items[i].Value);
                 alTmp.Add(fdTmp);
             }
         }
         riRestrict.AppliesTo = (FolderData[])alTmp.ToArray(typeof(FolderData));
     }
     if (this.m_iID > 0) // edit
     {
         if (m_iBoardID > 0)
         {
             riRestrict = cContent.UpdateRestrictedIP(riRestrict, this.m_iBoardID);
         }
         else
         {
             riRestrict = cContent.AddEditRestrictedIP(riRestrict);
         }
         Response.Redirect((string)("restrictIP.aspx?boardid=" + this.m_iBoardID.ToString() + "&action=view&id=" + this.m_iID.ToString()), false);
     }
     else // add
     {
         riRestrict = cContent.AddEditRestrictedIP(riRestrict);
         Response.Redirect((string)("restrictIP.aspx?boardid=" + this.m_iBoardID.ToString()), false);
     }
 }