Exemplo n.º 1
0
        public void SetData(StreamReader reader, StreamReader reader_2 = null)
        {
            reader.DiscardBufferedData();
            reader.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                int      Sign;
                double[] Vector      = new double[68];
                string[] splitstring = line.Split();
                if (splitstring.First().First() == '+')
                {
                    Sign = +1;
                }
                else
                {
                    Sign = -1;
                }
                foreach (var item in splitstring)
                {
                    if (item.Contains(":"))
                    {
                        string[] s = item.Split(':');
                        Vector[Convert.ToInt32(s[0]) - 1] = Convert.ToDouble(s[1]);
                    }
                }
                Training_Data.Add(new Entry(Sign, Vector));
            }
            if (reader_2 != null)
            {
                reader_2.DiscardBufferedData();
                reader_2.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
                string line2;
                while ((line2 = reader_2.ReadLine()) != null)
                {
                    int      Sign;
                    double[] Vector      = new double[68];
                    string[] splitstring = line2.Split();
                    if (splitstring.First().First() == '+')
                    {
                        Sign = +1;
                    }
                    else
                    {
                        Sign = -1;
                    }
                    foreach (var item in splitstring)
                    {
                        if (item.Contains(":"))
                        {
                            string[] s = item.Split(':');
                            Vector[Convert.ToInt32(s[0]) - 1] = Convert.ToDouble(s[1]);
                        }
                    }
                    Test_Data.Add(new Entry(Sign, Vector));
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SessionUserLogin nUserLogin = (SessionUserLogin)Session["UserLogin"];

            if (nUserLogin != null)
            {
                nUserLogin.CheckRole("CU0009");
                DataTable dt = Training_Data.GetJobList();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Job += "\"" + dt.Rows[i]["Job"].ToString() + "\",";
                }
                dt = Training_Data.GetTrainingContentList();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    TrainingContent += "\"" + dt.Rows[i]["TrainingContent"].ToString() + "\",";
                }
                dt = Training_Data.GetTrainerList();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Trainer += "\"" + dt.Rows[i]["Trainer"].ToString() + "\",";
                }
                string nKey = this.Request["key"];
                txtKey.Text = "0";
                int _nKey = 0;
                if (nKey != null)
                {
                    if (int.TryParse(nKey, out _nKey))
                    {
                        txtKey.Text = nKey;
                    }
                    if (!IsPostBack)
                    {
                        LoadInfo(_nKey);
                        if (!nUserLogin.Role.Edit && nKey != "0")
                        {
                            cmdSave.Visible            = false;
                            txtDatetime.Enabled        = false;
                            txtJob.Enabled             = false;
                            txtTrainer.Enabled         = false;
                            txtTrainingContent.Enabled = false;
                            txtTrainingTime.Enabled    = false;
                        }
                        else if (!nUserLogin.Role.Add && nKey == "0")
                        {
                            cmdSave.Visible            = false;
                            txtDatetime.Enabled        = false;
                            txtJob.Enabled             = false;
                            txtTrainer.Enabled         = false;
                            txtTrainingContent.Enabled = false;
                            txtTrainingTime.Enabled    = false;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void SetTrainingData()
 {
     foreach (var item in data_1)
     {
         Training_Data.Add(new TrainingData(ScreenNameLength(item.Vector[0]), DescriptionLength(item.Vector[1]), Days(item.Vector[2]), Hours(item.Vector[3]),
                                            MinSec(item.Vector[4]), MinSec(item.Vector[5]), Follow(item.Vector[6]), Follow(item.Vector[7]), Ratio(item.Vector[8]), Tweets(item.Vector[9]),
                                            TweetsPerDay(item.Vector[10]), AverageLinks(item.Vector[11]), AverageLinks(item.Vector[12]), AverageUsername(item.Vector[13]),
                                            AverageUsername(item.Vector[14]), ChangeRate(item.Vector[15]), item.Sign));
     }
     foreach (var item in data_2)
     {
         Test_Data.Add(new TrainingData(ScreenNameLength(item.Vector[0]), DescriptionLength(item.Vector[1]), Days(item.Vector[2]), Hours(item.Vector[3]),
                                        MinSec(item.Vector[4]), MinSec(item.Vector[5]), Follow(item.Vector[6]), Follow(item.Vector[7]), Ratio(item.Vector[8]), Tweets(item.Vector[9]),
                                        TweetsPerDay(item.Vector[10]), AverageLinks(item.Vector[11]), AverageLinks(item.Vector[12]), AverageUsername(item.Vector[13]),
                                        AverageUsername(item.Vector[14]), ChangeRate(item.Vector[15]), item.Sign));
     }
 }
Exemplo n.º 4
0
        protected void cmdView_Click1(object sender, ImageClickEventArgs e)
        {
            txtPageNumber.Text = "1";
            int nPageNumber             = int.Parse(txtPageNumber.Text);
            int nPageSize               = int.Parse(txtPageSize.Text);
            SessionUserLogin nUserLogin = (SessionUserLogin)Session["UserLogin"];
            DateTime         dtfrom     = DateTime.ParseExact(txtfromDatetime.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            DateTime         dtto       = DateTime.ParseExact(txttoDatetime.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            DataTable        nTable     = Training_Data.GetList(dtfrom, dtto, Convert.ToInt16(Session["EmployeeKey"]), nPageSize, nPageNumber);

            if (nTable.Rows.Count == 0)
            {
                nTable.Rows.Add("", 0, 0, null, 0, 0, "", "", null, "");
            }
            GV_Training.DataSource = nTable;
            GV_Training.DataBind();
            LoadPages();
        }
Exemplo n.º 5
0
        public void LoadData()
        {
            int nPageNumber             = int.Parse(txtPageNumber.Text);
            int nPageSize               = int.Parse(txtPageSize.Text);
            SessionUserLogin nUserLogin = (SessionUserLogin)Session["UserLogin"];
            DataTable        nTable     = Training_Data.GetList(Convert.ToInt16(Session["EmployeeKey"]), nPageSize, nPageNumber);

            if (nTable.Rows.Count == 0)
            {
                nTable.Rows.Add("", 0, 0, null, 0, 0, "", "", null, "");
            }
            GV_Training.DataSource = nTable;
            GV_Training.DataBind();
            DateTime dt = DateTime.Now;

            txtfromDatetime.Text = "01/01/2013";
            txttoDatetime.Text   = DateTime.Now.ToString("dd/MM/yyyy");
            LoadPages();
        }
Exemplo n.º 6
0
        protected void LoadPages()
        {
            int nPageNumber = int.Parse(txtPageNumber.Text);
            int nPageSize   = int.Parse(txtPageSize.Text);

            int nTotalRecord = Training_Data.Count(Session["EmployeeKey"].ToInt());

            if (nTotalRecord > nPageSize)
            {
                PageNumbers.Visible = true;
                DataTable nTable = TNLibrary.WEB.LoadDataToToolboxWeb.LoadPageSize(nPageSize, nTotalRecord, nPageNumber);

                PageNumbers.SelectedIndex = (nPageNumber - 1) - (int.Parse(nTable.Rows[0][0].ToString()) - 1);
                PageNumbers.DataSource    = nTable;
                PageNumbers.DataBind();
            }
            else
            {
                PageNumbers.Visible = false;
            }
        }
Exemplo n.º 7
0
        protected void GrDelete(object sender, CommandEventArgs e)
        {
            int nPageNumber             = int.Parse(txtPageNumber.Text);
            int nPageSize               = int.Parse(txtPageSize.Text);
            SessionUserLogin nUserLogin = (SessionUserLogin)Session["UserLogin"];

            nUserLogin.CheckRole("CU0009");
            if (!nUserLogin.Role.Del)
            {
                Response.Write("<script >alert('Bạn không có quyền xóa danh mục này!')</script>");
            }
            else
            {
                try
                {
                    int          mKey = int.Parse(e.CommandArgument.ToString());
                    Harvest_Info info = new Harvest_Info(mKey);
                    if ((DateTime.Now - info.DateOn).TotalDays > 7)
                    {
                        Response.Write("<script >alert('Dữ liệu đã quá 7 ngày, không được phép xóa!')</script>");
                    }
                    else
                    {
                        info.Delete();
                        DataTable nTable = Training_Data.GetList(Convert.ToInt16(Session["EmployeeKey"]), nPageSize, nPageNumber);
                        GV_Training.DataSource = nTable;
                        GV_Training.DataBind();
                        LoadPages();
                    }
                }
                catch
                {
                    Response.Write("<script >alert('Có lỗi gì đó vui lòng thử lại!')</script>");
                }
            }
        }
Exemplo n.º 8
0
 public void ShuffleTraining_Data(Random rSeed)
 {
     Training_Data = Training_Data.OrderBy(i => rSeed.Next()).ToList();
 }