private void checkProblemAccount() { try { List <FaceBook> listFBToDelete = new List <FaceBook>(); for (int iIndex = 0; iIndex < gridData.Rows.Count; iIndex++) { //Check account die FaceBook fb = gridData.Rows[iIndex].DataBoundItem as FaceBook; if (fb != null && fb.Status != null && fb.Status != 1) { //FaceBookController fbController = gridData[GridConst.Controller, iIndex].Value as FaceBookController; //if (fbController.CheckLogin()) //{ // fb.Cookies = Serializer.ConvertObjectToBlob(fbController.WebClient.CookieContainer); // fb.Status = 1; // DataProvider.DB.Entry(fb).State = System.Data.Entity.EntityState.Modified; // DataProvider.DB.SaveChanges(); //} //else //{ // if (fbController.WebClient.Error != null) // { // } // else if (fbController.WebClient.ResponseText.Contains("If this account reflects your real name and personal information, please help us verify it")) // { listFBToDelete.Add(fb); //} //} } } if (listFBToDelete.Count > 0 && TMessage.ShowQuestion("Are you sure want to delete problem account", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { DataProvider.DB.FaceBook.RemoveRange(listFBToDelete); DataProvider.DB.SaveChanges(); } } catch (Exception ex) { TMessage.ShowException(ex); } finally { } }
private void loadWorkingSession() { try { var ss = DataProvider.DB.Session.OrderByDescending(mbox => mbox.ID).Take(1).ToList(); if (ss.Count > 0) { workingSession = ss[0]; } else { workingSession = new Session(); workingSession.Date = DateTime.Now; DataProvider.DB.Session.Add(workingSession); DataProvider.DB.SaveChanges(); } this.txtSession.Text = workingSession.ID.ToString(); this.txtDateStart.Text = workingSession.Date == null ? string.Empty : ((DateTime)workingSession.Date).ToString("yyyy-MM-dd"); } catch (Exception ex) { TMessage.ShowException(ex); } }
private void loadAllData() { try { //var dtFB = DataProvider.Provider.GetData("SELECT * FROM M_FaceBook", ""); //if (dtFB != null && dtFB.Rows.Count > 0) //{ // foreach (DataRow rowFB in dtFB.Rows) // { // FaceBook model = new FaceBook(); // model.Cookies = (byte[])rowFB["Cookie"]; // model.Login = rowFB["Login"].ToString(); // model.Pass = rowFB["Pass"].ToString(); // model.Status = 1; // model.UserID = rowFB["UserID"].ToString(); // db.FaceBook.Add(model); // } //} //db.SaveChanges(); //var listInactive = (from fb in DataProvider.DB.FaceBook // join post in DataProvider.DB.PostStatus on fb.ID equals post.FaceBookID into fbpost // from fp in fbpost.DefaultIfEmpty() // where fp.FaceBookID == null // select fb).ToList(); //if (listInactive.Count > 0) //{ // listInactive.ForEach(m => m.Status = 2); // DataProvider.DB.SaveChanges(); //} List <FaceBook> listFB = (from m in DataProvider.DB.FaceBook select m).ToList(); if (gridData.Columns.Count == 0) { gridData.AutoGenerateColumns = false; DataGridViewTextBoxColumn colStt = new DataGridViewTextBoxColumn(); colStt.Name = GridConst.STT; colStt.HeaderText = GridConst.STT; colStt.Width = 50; colStt.SortMode = DataGridViewColumnSortMode.NotSortable; gridData.Columns.Add(colStt); DataGridViewTextBoxColumn colAccount = new DataGridViewTextBoxColumn(); colAccount.Name = GridConst.Login; colAccount.HeaderText = GridConst.Login; colAccount.Width = 200; colAccount.DataPropertyName = GridConst.Login; colAccount.SortMode = DataGridViewColumnSortMode.NotSortable; gridData.Columns.Add(colAccount); DataGridViewTextBoxColumn colStatus = new DataGridViewTextBoxColumn(); colStatus.Name = GridConst.GridStatus; colStatus.HeaderText = GridConst.GridStatus; colStatus.Width = 500; colStatus.SortMode = DataGridViewColumnSortMode.NotSortable; gridData.Columns.Add(colStatus); DataGridViewTextBoxColumn colController = new DataGridViewTextBoxColumn(); colController.Name = GridConst.Controller; colController.Visible = false; gridData.Columns.Add(colController); } BindingSource bs = new BindingSource(); bs.DataSource = listFB; gridData.DataSource = bs; for (int iIndex = 0; iIndex < gridData.Rows.Count; iIndex++) { gridData[GridConst.STT, iIndex].Value = iIndex + 1; FaceBookController fbController = new FaceBookController { Models = gridData.Rows[iIndex].DataBoundItem as FaceBook , SessionID = workingSession.ID , GridIndex = iIndex }; gridData[GridConst.Controller, iIndex].Value = fbController; gridData.Rows[iIndex].Tag = fbController; fbController.StatusChanged += (objs, obje) => { gridData.Invoke((Action)(() => { gridData[GridConst.GridStatus, (objs as FaceBookController).GridIndex].Value = obje.Status; })); }; } } catch (Exception ex) { TMessage.ShowException(ex); } }