public string Follow2Unfallow(int SubNesourceID, int UserID, int Tag)  ///Tag =0 devele 1 is add
        {
            JavaScriptSerializer ser = new JavaScriptSerializer();

            DBConnection DBop   = new DBConnection();
            int          Result = 0;

            if (Tag == 1)
            {  // addfollow
                ColoumnParam[] Coloumns = new ColoumnParam[3];
                Coloumns[0] = new ColoumnParam("UserID", ColoumnType.Int, UserID);
                Coloumns[1] = new ColoumnParam("SubNesourceID", ColoumnType.Int, SubNesourceID);
                Coloumns[2] = new ColoumnParam("DateRegister", ColoumnType.DateTime, DateTime.Now.ToString());
                if (DBop.cobject.InsertRow("UserFollowing", Coloumns))
                {
                    Result = 1;
                }
            }
            else  // delete follow
            {
                if (DBop.cobject.DeletedRow("UserFollowing", "UserID=" + UserID + " and SubNesourceID=" + SubNesourceID))
                {
                    Result = 1;
                }
            }


            var jsonData = new
            {
                Result = Result,
            };

            return(ser.Serialize(jsonData)); //products.ToString();
        }
Beispiel #2
0
        protected void BuSearche_Click(object sender, EventArgs e)
        {
            String password = "******";
            string imgPath;

            try
            {
                password = Convert.ToString(Session["adminID"]) + StringGeneration.getString(30);
                imgPath  = ("/attachments/"
                            + (password + Path.GetExtension(FileUpload1.PostedFile.FileName)));
                //  selct path before post back check nesa becose name file will dispose after poastback
                //   MsgBox(Server.MapPath(imgPath))
                FileUpload1.SaveAs(Server.MapPath(imgPath));
                ColoumnParam[] Coloumns1 = new ColoumnParam[5];
                Coloumns1[0] = new ColoumnParam("AttachmentTypeID", ColoumnType.Int, 2); // 1 for admin add news
                Coloumns1[1] = new ColoumnParam("AttachmentPath", ColoumnType.NVarChar, imgPath);
                Coloumns1[2] = new ColoumnParam("AttachmentDateIN", ColoumnType.DateTime, DateTime.Now.ToString());
                Coloumns1[3] = new ColoumnParam("AttachmentID", ColoumnType.Int, HiddenField1.Value);
                Coloumns1[4] = new ColoumnParam("AddedBy", ColoumnType.Int, Convert.ToString(Session["adminID"]));

                DBop.cobject.InsertRow("Attachments", Coloumns1);

                SqlDataSource1.DataBind();
                GridView2.DataBind();
            }
            catch (Exception ex)
            {
            }
        }
 protected void BuAddData_Click(object sender, EventArgs e)
 {
     if (IsAdminPasswordExists(txtOldPassword.Text))
     {
          string password =  txtAdminPassword.Text ;
         ColoumnParam[] Coloumns = new ColoumnParam[1];
         Coloumns[0] = new ColoumnParam("Password", ColoumnType.Char1, password);
         if (DBop.cobject.UpdateRow("MyStudents", Coloumns, ("StudentID=" + Session["adminID"])))
         {
             Response.Redirect("ChangePssword.aspx?S=T");
         }
         else
         {
             //  MsgBox(DBop.cobject.ErrorMessage)
             // statusLabel.Text = Resource1.AddNotComplte;
             LiMessage.Text = "<strong>Success!</strong>" + Resource1.AddNotComplte;
             ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalSucces();", true);
         }
     }
     else
     {
         //statusLabel.Text = Resource1.OldPasswordUncorrect;
         LiMessage.Text = "<strong>Warning!</strong> " + Resource1.OldPasswordUncorrect;
         ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
     }
 }
        protected void Buadd_Click(object sender, EventArgs e)
        {
            DateTime DateCreated = DateTime.Now;

            ColoumnParam[] Coloumns = new ColoumnParam[10];
            Coloumns[0] = new ColoumnParam("SubNesourceName", ColoumnType.NVarChar, txtSubNesourceName.Text);
            Coloumns[1] = new ColoumnParam("SubNesourceLink", ColoumnType.NVarChar, txtSubNesourceLink.Text);
            Coloumns[2] = new ColoumnParam("NesourceID", ColoumnType.Int, DDLNesourceID.SelectedValue);
            Coloumns[3] = new ColoumnParam("DateRegister", ColoumnType.DateTime, DateCreated);
            Coloumns[4] = new ColoumnParam("SubResourcesTypeID", ColoumnType.Int, SubResourcesNewType.SelectedValue);
            Coloumns[5] = new ColoumnParam("ChannelImage", ColoumnType.NVarChar, txtChannelImage.Text);
            Coloumns[6] = new ColoumnParam("BacugroundPicture", ColoumnType.NVarChar, txtBacugroundPicture.Text);
            Coloumns[7] = new ColoumnParam("ResourcesNewType", ColoumnType.Bit, DDLResourcesNewType.SelectedValue);
            Coloumns[8] = new ColoumnParam("DetailsConatinTag", ColoumnType.NVarChar, txtDetailsConatinTag.Text);
            Coloumns[9] = new ColoumnParam("ImageTag", ColoumnType.NVarChar, txtImageTag.Text);

            if (DBop.cobject.InsertRow("SubNesources", Coloumns))
            {
                Response.Redirect("ManageAccounts.aspx?S=T");
            }
            else
            {
                LiMessage.Text = "<strong>Warning!</strong> " + DBop.cobject.ErrorMessage;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
            }
        }
        public ReturnError InsertPhoneInfo(int UserID, string PhoneMac, string PhoneName, string PhoneNumber)
        {
            DBConnection DBop  = new DBConnection();
            ReturnError  error = new ReturnError();

            /// check if this account avilable
            DataTable dataTable = new DataTable();

            dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * ", "UserID=" + UserID).Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                Boolean isnulti = (Boolean)dataTable.Rows[0]["AccountType"];
                dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " * ", "PhoneMac like '" + PhoneMac + "' and PhoneNumber like '" + PhoneNumber + "'").Tables[0];
                if ((dataTable != null) && (dataTable.Rows.Count > 0))
                {
                    error.ErrorID      = 1;
                    error.ErrorMessage = "this phone is already registered in database";
                    return(error);
                }
                // check if this phone is not comercial

                if (isnulti == false)
                {
                    dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " * ", "UserID=" + UserID).Tables[0];
                    if ((dataTable != null) && (dataTable.Rows.Count > 0))
                    {
                        error.ErrorID      = 1;
                        error.ErrorMessage = "this type of account is for one device only";
                        return(error);
                    }
                }

                ColoumnParam[] Coloumns = new ColoumnParam[5];
                Coloumns[0] = new ColoumnParam("UserID", ColoumnType.Int, UserID);
                Coloumns[1] = new ColoumnParam("PhoneMac", ColoumnType.varchar50, PhoneMac);
                Coloumns[2] = new ColoumnParam("DateRegister", ColoumnType.DateTime, DateTime.Now);
                Coloumns[3] = new ColoumnParam("PhoneName", ColoumnType.varchar50, PhoneName);
                Coloumns[4] = new ColoumnParam("PhoneNumber", ColoumnType.varchar50, PhoneNumber);
                if (DBop.NewConectionDLL.InsertRow("AdminPhones", Coloumns))
                {
                    error.ErrorID      = 2;
                    error.ErrorMessage = "Greate you insert new record";
                    return(error);
                }
                else
                {
                    error.ErrorID      = 1;
                    error.ErrorMessage = "Error , cannot insert this record in the Database";
                    return(error);
                }
            }


            else
            {
                error.ErrorID      = 1;
                error.ErrorMessage = "Error , cannot find this record in the Database";
                return(error);
            }
        }
Beispiel #6
0
        private bool IsAdminExists(string userName, string password)
        {
            // Encryptions Myenc = new Encryptions();  // encript password
            DataTable dataTable = new DataTable();

            //password = Myenc.GetMD5Data(Encoding.Default.GetBytes(password));
            dataTable = DBop.cobject.SelectDataSet("MyStudents", "StudentID", "StudentEmail like '" + userName + "' AND Password like '" + password + "' and IsActive=1").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                Session["adminID"] = dataTable.Rows[0]["StudentID"];
                //  Session.Timeout = 10;  // set session time out
                /// save login information
                /// save access denial for this person
                ColoumnParam[] Coloumns = new ColoumnParam[7];
                Coloumns[0] = new ColoumnParam("TableID", ColoumnType.Int, 5);  // 1 is code for userlogin
                Coloumns[1] = new ColoumnParam("RecordID", ColoumnType.Int, dataTable.Rows[0]["StudentID"]);
                Coloumns[2] = new ColoumnParam("DateModify", ColoumnType.DateTime, DateTime.Now);
                Coloumns[3] = new ColoumnParam("PersonID", ColoumnType.Int, dataTable.Rows[0]["StudentID"]);
                Coloumns[4] = new ColoumnParam("AdminsOperationTypeID", ColoumnType.Int, 7);  // 6 is for login
                Coloumns[5] = new ColoumnParam("OldValue", ColoumnType.NVarChar, HFMAC.Value);
                Coloumns[6] = new ColoumnParam("NewValue", ColoumnType.NVarChar, Session.SessionID.ToString());
                DBop.cobject.InsertRow("AdminsTracking", Coloumns);



                return(true);
            }


            return(false);
        }
        protected void BuAddData_Click(object sender, EventArgs e)
        {
            DataTable dataTable = new DataTable();
            dataTable = DBop.cobject.SelectDataSet("MyStudents", "StudentID", "StudentEmail like '" + txtEmail.Text + "'  and IsActive=1").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                Encryptions Myenc = new Encryptions();  // encript password
                string PassCode = Myenc.GetMD5Data(Encoding.Default.GetBytes(Convert.ToString(dataTable.Rows[0]["StudentID"]) + StringGeneration.getString(30)));

                ColoumnParam[] Coloumns = new ColoumnParam[3];
                Coloumns[0] = new ColoumnParam("PersonID", ColoumnType.Int, Convert.ToString(dataTable.Rows[0]["StudentID"]));
                Coloumns[1] = new ColoumnParam("PassCode", ColoumnType.Char1, PassCode);
                Coloumns[2] = new ColoumnParam("DateIn", ColoumnType.DateTime, DateTime.Now.ToString());

                if (DBop.cobject.InsertRow("PeoplePassCode", Coloumns))
                {
                    Contacting sendwelcome = new Contacting();

                    string subject = "Ask for password";
                    string body = "Dear  ,";
                    body = body + "\n Recently you asked for your password please click the link bellow to complete your request";
                    body = body + "\n   please login here<a href=' http://www.alrubaye.com/ForgetPassWord.aspx?id=" + PassCode.Trim() + "'> Link </a> and change this password as soon as you login on \n";
                    sendwelcome.SendWelcome(txtEmail.Text, subject, body);
                   
                }
            }

            theDiv.Visible = true;
        }
Beispiel #8
0
        protected void BuAddData_Click(object sender, EventArgs e)
        {
            DataTable dataTable = new DataTable();

            dataTable = DBop.cobject.SelectDataSet("MyStudents", "StudentID", "StudentEmail like '" + txtEmail.Text + "'  and IsActive=1").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                Encryptions Myenc    = new Encryptions(); // encript password
                string      PassCode = Myenc.GetMD5Data(Encoding.Default.GetBytes(Convert.ToString(dataTable.Rows[0]["StudentID"]) + StringGeneration.getString(30)));

                ColoumnParam[] Coloumns = new ColoumnParam[3];
                Coloumns[0] = new ColoumnParam("PersonID", ColoumnType.Int, Convert.ToString(dataTable.Rows[0]["StudentID"]));
                Coloumns[1] = new ColoumnParam("PassCode", ColoumnType.Char1, PassCode);
                Coloumns[2] = new ColoumnParam("DateIn", ColoumnType.DateTime, DateTime.Now.ToString());

                if (DBop.cobject.InsertRow("PeoplePassCode", Coloumns))
                {
                    Contacting sendwelcome = new Contacting();

                    string subject = "Ask for password";
                    string body    = "Dear  ,";
                    body = body + "\n Recently you asked for your password please click the link bellow to complete your request";
                    body = body + "\n   please login here<a href=' http://www.alrubaye.com/ForgetPassWord.aspx?id=" + PassCode.Trim() + "'> Link </a> and change this password as soon as you login on \n";
                    sendwelcome.SendWelcome(txtEmail.Text, subject, body);
                }
            }

            theDiv.Visible = true;
        }
 protected void BuAddData_Click(object sender, EventArgs e)
 {
     if (IsAdminPasswordExists(txtOldPassword.Text))
     {
         string         password = txtAdminPassword.Text;
         ColoumnParam[] Coloumns = new ColoumnParam[1];
         Coloumns[0] = new ColoumnParam("Password", ColoumnType.Char1, password);
         if (DBop.cobject.UpdateRow("MyStudents", Coloumns, ("StudentID=" + Session["adminID"])))
         {
             Response.Redirect("ChangePssword.aspx?S=T");
         }
         else
         {
             //  MsgBox(DBop.cobject.ErrorMessage)
             // statusLabel.Text = Resource1.AddNotComplte;
             LiMessage.Text = "<strong>Success!</strong>" + Resource1.AddNotComplte;
             ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalSucces();", true);
         }
     }
     else
     {
         //statusLabel.Text = Resource1.OldPasswordUncorrect;
         LiMessage.Text = "<strong>Warning!</strong> " + Resource1.OldPasswordUncorrect;
         ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
     }
 }
Beispiel #10
0
        public void UserTracking(string PhoneUID, string Latitude, string longitude, int BatteryLevel)
        {
            DBConnection DBop = new DBConnection();

            JavaScriptSerializer ser = new JavaScriptSerializer();

            ColoumnParam[] Coloumns = new ColoumnParam[4];
            Coloumns[0] = new ColoumnParam("Latitude", ColoumnType.Float, Latitude);
            Coloumns[1] = new ColoumnParam("longitude", ColoumnType.Float, longitude);
            Coloumns[2] = new ColoumnParam("BatteryLevel", ColoumnType.Int, BatteryLevel);
            Coloumns[3] = new ColoumnParam("PhoneUID", ColoumnType.uniqueidenifer, PhoneUID);
            if (DBop.NewConectionDLL.InsertRow("Tracking", Coloumns))
            {
                var jsonData = new
                {
                    IsDeliver = "Y"
                };
                HttpContext.Current.Response.Write(ser.Serialize(jsonData));
            }
            else
            {
                var jsonData = new
                {
                    IsDeliver = "N"
                };
                HttpContext.Current.Response.Write(ser.Serialize(jsonData));
            }
        }
        private bool IsAdminExists(string userName, string password)
        {
           // Encryptions Myenc = new Encryptions();  // encript password
            DataTable dataTable = new DataTable();
            //password = Myenc.GetMD5Data(Encoding.Default.GetBytes(password));
            dataTable = DBop.cobject.SelectDataSet("MyStudents", "StudentID", "StudentEmail like '" + userName + "' AND Password like '" + password + "' and IsActive=1").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                Session["adminID"] = dataTable.Rows[0]["StudentID"];
                //  Session.Timeout = 10;  // set session time out
                /// save login information
                /// save access denial for this person
                ColoumnParam[] Coloumns = new ColoumnParam[7];
                Coloumns[0] = new ColoumnParam("TableID", ColoumnType.Int, 5);  // 1 is code for userlogin
                Coloumns[1] = new ColoumnParam("RecordID", ColoumnType.Int, dataTable.Rows[0]["StudentID"]);
                Coloumns[2] = new ColoumnParam("DateModify", ColoumnType.DateTime, DateTime.Now);
                Coloumns[3] = new ColoumnParam("PersonID", ColoumnType.Int, dataTable.Rows[0]["StudentID"]);
                Coloumns[4] = new ColoumnParam("AdminsOperationTypeID", ColoumnType.Int, 7);  // 6 is for login
                Coloumns[5] = new ColoumnParam("OldValue", ColoumnType.NVarChar, HFMAC.Value);
                Coloumns[6] = new ColoumnParam("NewValue", ColoumnType.NVarChar, Session.SessionID.ToString());
                DBop.cobject.InsertRow("AdminsTracking", Coloumns);



                return true;
            }
 

            return false;
        }
Beispiel #12
0
        public void UserLogin(string EmailAdrress, string Password, string PhoneMac, string PhoneName)
        {
            DBConnection         DBop             = new DBConnection();
            MesseageResponseUser messeageResponse = new MesseageResponseUser();
            JavaScriptSerializer ser = new JavaScriptSerializer();

            /// check if the account is valid
            DataTable dataTable = new DataTable();

            dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " UserID,UserUID ", " EmailAdrress = '" + EmailAdrress + "' and Password = '******'").Tables[0];
            if ((dataTable == null) || (dataTable.Rows.Count == 0))
            {
                messeageResponse.ErrorID = (int)ErrorNumbers.NotFound;
                messeageResponse.Message = "Username or password is not correct";
                HttpContext.Current.Response.Write(ser.Serialize(messeageResponse));
                return;
            }

            int UserID = (int)dataTable.Rows[0]["UserID"];

            messeageResponse.UserUID = Convert.ToString(dataTable.Rows[0]["UserUID"]);
            // check if the user already resgitered with that account
            dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " PhoneUID ", "UserID=" + UserID + " and PhoneMac = '" + PhoneMac + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                messeageResponse.PhoneUID = Convert.ToString(dataTable.Rows[0]["PhoneUID"]);
                messeageResponse.ErrorID  = (int)ErrorNumbers.Found;
                messeageResponse.Message  = "you Already registered,  you will login now";
                HttpContext.Current.Response.Write(ser.Serialize(messeageResponse));
                return;
            }

            // register new user
            ColoumnParam[] Coloumns = new ColoumnParam[3];
            Coloumns[0] = new ColoumnParam("UserID", ColoumnType.Int, UserID);
            Coloumns[1] = new ColoumnParam("PhoneMac", ColoumnType.varchar50, PhoneMac);
            Coloumns[2] = new ColoumnParam("PhoneName", ColoumnType.varchar50, PhoneName);
            if (DBop.NewConectionDLL.InsertRow("AdminPhones", Coloumns))
            {
                dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " PhoneUID ", "UserID=" + UserID + " and PhoneMac = '" + PhoneMac + "'").Tables[0];
                if ((dataTable != null) && (dataTable.Rows.Count > 0))
                {
                    messeageResponse.PhoneUID = Convert.ToString(dataTable.Rows[0]["PhoneUID"]);
                    messeageResponse.ErrorID  = (int)ErrorNumbers.Found;
                    messeageResponse.Message  = "Great, you registered successfully";
                    HttpContext.Current.Response.Write(ser.Serialize(messeageResponse));
                    return;
                }
            }
            else
            {
                messeageResponse.ErrorID = (int)ErrorNumbers.NotFound;
                messeageResponse.Message = "Error , cannot add this account";
                HttpContext.Current.Response.Write(ser.Serialize(messeageResponse));
                return;
            }

            // check if the user already saved
        }
        protected void BuAddData_Click(object sender, EventArgs e)
        {
            string DatIN = DateTime.Now.ToString();

            ColoumnParam[] Coloumns = new ColoumnParam[8];
            Coloumns[0] = new ColoumnParam("HomeWorkTitle", ColoumnType.NVarChar, txtHomeWorkTitle.Text);
            Coloumns[1] = new ColoumnParam("HomeWorkDetails", ColoumnType.NVarChar, txtHomeWorkDetails.Text);
            Coloumns[2] = new ColoumnParam("Datein", ColoumnType.DateTime, DatIN);
            Coloumns[3] = new ColoumnParam("DeadLineDate", ColoumnType.DateTime, txtDeadLineDate.Text);
            Coloumns[4] = new ColoumnParam("AddedBy", ColoumnType.Int, Convert.ToString(Session["adminID"]));
            Coloumns[5] = new ColoumnParam("TutorialID", ColoumnType.Int, DDLAccounts.SelectedValue);
            Coloumns[6] = new ColoumnParam("Grade", ColoumnType.Float, txtGrade.Text);
            //string qul = Guid.NewGuid().ToString("N");
            Coloumns[7] = new ColoumnParam("HomeWorkUID", ColoumnType.uniqueidenifer, "Ignored");
            if (DBop.cobject.InsertRow("HomeWorks", Coloumns))
            {
                //===================  // uplaod file to attach folder
                DataTable dataTable = new DataTable();
                dataTable = DBop.cobject.SelectDataSet("HomeWorks", "HomeWorkID", "Datein =(select max(Datein) FROM HomeWorks where  AddedBy= " + Convert.ToString(Session["adminID"]) + ")  and AddedBy=" + Convert.ToString(Session["adminID"])).Tables[0];
                int    AttachmentID = Convert.ToInt32(dataTable.Rows[0]["HomeWorkID"]);
                string imgPath;
                String password = "******";
                if (FileUpload1.HasFile)
                {
                    try
                    {
                        password = Convert.ToString(Session["adminID"]) + StringGeneration.getString(30);
                        imgPath  = ("/attachments/"
                                    + (password + Path.GetExtension(FileUpload1.PostedFile.FileName)));
                        FileUpload1.SaveAs(Server.MapPath(imgPath));
                        ColoumnParam[] Coloumns1 = new ColoumnParam[5];
                        Coloumns1[0] = new ColoumnParam("AttachmentTypeID", ColoumnType.Int, 1);      // 1 for admin add home works
                        Coloumns1[1] = new ColoumnParam("AttachmentPath", ColoumnType.NVarChar, imgPath);
                        Coloumns1[2] = new ColoumnParam("AttachmentDateIN", ColoumnType.DateTime, DateTime.Now.ToString());
                        Coloumns1[3] = new ColoumnParam("AttachmentID", ColoumnType.Int, AttachmentID);
                        Coloumns1[4] = new ColoumnParam("AddedBy", ColoumnType.Int, Convert.ToString(Session["adminID"]));

                        //Grade
                        DBop.cobject.InsertRow("Attachments", Coloumns1);
                    }
                    catch (Exception ex)
                    {
                        //   MsgBox(ex.Message)
                        //imgPath = "/Images/AdminImage/defaultAdminImag.png";
                    }
                }



                Response.Redirect("ManageStudent.aspx?S=T");
            }
            else
            {
                LiMessage.Text = "<strong>" + DBop.NewConectionDLL.ErrorMessage + "</strong>  .";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
            }
        }
Beispiel #14
0
        public void OpenAccount(string EmailAdrress, string Password)
        {
            DBConnection         DBop             = new DBConnection();
            MesseageResponse     messeageResponse = new MesseageResponse();
            JavaScriptSerializer ser = new JavaScriptSerializer();

            /// check if the email already taken
            DataTable dataTable = new DataTable();

            dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * ", " EmailAdrress like '" + EmailAdrress + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                messeageResponse.ErrorID = (int)ErrorNumbers.NotFound;
                messeageResponse.Message = "email address already taken, try with different email";

                HttpContext.Current.Response.Write(ser.Serialize(messeageResponse));
                return;
            }

            /// save new account
            ///
            ColoumnParam[] Coloumns = new ColoumnParam[2];
            Coloumns[0] = new ColoumnParam("Password", ColoumnType.varchar50, Password);
            Coloumns[1] = new ColoumnParam("EmailAdrress", ColoumnType.varchar50, EmailAdrress);
            if (DBop.NewConectionDLL.InsertRow("Admins", Coloumns))
            {
                dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " UserUID ", "EmailAdrress like '" + EmailAdrress + "'").Tables[0];


                /////send email to new account=========================================================

                Messages send    = new Messages();
                string   subject = "My Phone Location Account is created successfully";
                string   body    = "Dear User,";
                body = body + "\n, Thank you for using My phones locations APP , now you could track your phone from any computer on real time \n";
                send.SendMessage(EmailAdrress, body, subject);

                ///send user info

                messeageResponse.ErrorID = (int)ErrorNumbers.Found;
                messeageResponse.UserUID = Convert.ToString(dataTable.Rows[0]["UserUID"]);
                messeageResponse.Message = "Great, your accound is created successfully";
                HttpContext.Current.Response.Write(ser.Serialize(messeageResponse));
                return;
            }
            else
            {
                messeageResponse.ErrorID = (int)ErrorNumbers.NotFound;
                messeageResponse.Message = "Error , cannot add this account";
                HttpContext.Current.Response.Write(ser.Serialize(messeageResponse));
                return;
            }
        }
        public string InitializeAccount(string MAC)  /// get list of notes
        {
            JavaScriptSerializer ser = new JavaScriptSerializer();

            DBConnection DBop = new DBConnection();

            // add acount
            DataTable dataTable         = new DataTable();
            Boolean   AlreadyRegistered = true;

            dataTable = DBop.cobject.SelectDataSet("Users", "PhoneMac", "PhoneMac='" + MAC + "'").Tables[0];
            if ((dataTable == null) || (dataTable.Rows.Count == 0))
            {   // if the phone is not already registered
                ColoumnParam[] Coloumns = new ColoumnParam[2];
                Coloumns[0] = new ColoumnParam("DateRegister", ColoumnType.DateTime, DateTime.Now.ToString());
                Coloumns[1] = new ColoumnParam("PhoneMac", ColoumnType.varchar50, MAC);
                DBop.cobject.InsertRow("Users", Coloumns);
                AlreadyRegistered = false;
            }

            string UserID = "";



            // get user info

            dataTable = DBop.cobject.SelectDataSet("Users", "UserID", "PhoneMac='" + MAC + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                UserID = Convert.ToString(dataTable.Rows[0]["UserID"]);
                if (AlreadyRegistered == false)
                {                                                                     // only for first time install we add him
                    ColProcedureParam[] Coloumns = new ColProcedureParam[1];
                    Coloumns[0] = new ColProcedureParam("UserID", UserID.ToString()); // Request.QueryString["id"]);// temp be 1

                    try
                    {
                        DBop.cobject.SelectDataSetProcedureTable("AddDefultChannels", Coloumns);
                    }
                    catch (Exception ex) { }
                }
            }
            var jsonData = new
            {
                IsAdded = AlreadyRegistered,
                UserID  = UserID
            };

            return(ser.Serialize(jsonData)); //products.ToString();
        }
Beispiel #16
0
        protected void BuAddData_Click(object sender, EventArgs e)
        {
            // check if the email is active;
            DataTable dataTable = new DataTable();

            dataTable = DBop.NewConectionDLL.SelectDataSet("MyStudents", "StudentEmail", "StudentEmail like '" + txtEmail.Text + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                LiMessage.Text = "<strong>" + Resources.Resource1.Warning + "</strong> " + Resources.Resource1.emailalreadyregistered;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
                return;
            }
            ColoumnParam[] Coloumns = new ColoumnParam[7];
            Coloumns[0] = new ColoumnParam("StudentFirstName", ColoumnType.NVarChar, txtFirstName.Text);
            Coloumns[1] = new ColoumnParam("StudentLastName", ColoumnType.NVarChar, txtMiddleName.Text);
            Coloumns[2] = new ColoumnParam("StudentEmail", ColoumnType.NVarChar, txtEmail.Text);
            Coloumns[3] = new ColoumnParam("TutorialID", ColoumnType.Int, DDLAccounts.SelectedValue);
            Coloumns[4] = new ColoumnParam("DataRegister", ColoumnType.DateTime, DateTime.Now);
            Coloumns[5] = new ColoumnParam("StudentComment", ColoumnType.NVarChar, txtState.Text);
            Coloumns[6] = new ColoumnParam("SkypeID", ColoumnType.NVarChar, txtSkypeID.Text);
            if (DBop.NewConectionDLL.InsertRow("MyStudents", Coloumns))
            {
                // add tutorila to my list
                //password = Myenc.GetMD5Data(Encoding.Default.GetBytes(password));
                dataTable = DBop.cobject.SelectDataSet("MyStudents", "StudentID", "StudentEmail like '" + txtEmail.Text + "'").Tables[0];
                ColoumnParam[] Coloumns2 = new ColoumnParam[2];
                Coloumns2[0] = new ColoumnParam("TutorialID", ColoumnType.Int, DDLAccounts.SelectedValue);
                Coloumns2[1] = new ColoumnParam("StudentID", ColoumnType.Int, dataTable.Rows[0]["StudentID"]);
                if (DBop.NewConectionDLL.InsertRow("StudentTutorial", Coloumns2))
                {
                    Contacting sendwelcome = new Contacting();
                    string     message     = "عزيزي " + txtFirstName.Text + "\n   نحن نقدر جدا انظمامك للدورات وسوف نحاول قصارى جهدنا ان نوصل لك ماتسعى لتعلمه. لذالك سوف نرسل لك بريد يحتوي على معلومات الدخول الى الدورات قريبا لذالك قم بفحص صندوق الوراد والرسائل سبام بشكل دائم  ";
                    sendwelcome.SendWelcome(txtEmail.Text, "شكرا لتسجيلك في نظام الدورات", message);
                    Response.Redirect("Education.aspx?S=T");
                }
                else
                {
                    LiMessage.Text = "<strong>" + DBop.NewConectionDLL.ErrorMessage + "</strong>  .";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
                }
            }

            else
            {
                LiMessage.Text = "<strong>" + DBop.NewConectionDLL.ErrorMessage + "</strong>  ";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            DBop.cobject.DeletedRow("StudentAttendance", "TutorialScheduleID=" + DDLTimeID.SelectedValue); // delete all student register to update
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                DropDownList   ddlStatus = (DropDownList)GridView2.Rows[i].FindControl("DDLStatusID");
                Label          LaAdminID = (Label)GridView2.Rows[i].FindControl("LaPersonID");
                ColoumnParam[] Coloumns1 = new ColoumnParam[3];

                Coloumns1[0] = new ColoumnParam("StudentID", ColoumnType.Int, LaAdminID.Text); // 1 for admin add home works
                Coloumns1[1] = new ColoumnParam("TutorialScheduleID", ColoumnType.Int, DDLTimeID.SelectedValue);
                Coloumns1[2] = new ColoumnParam("AttendenceStutusID", ColoumnType.Bit, ddlStatus.SelectedValue);
                DBop.cobject.InsertRow("StudentAttendance", Coloumns1);
            }
            GridView1.DataBind();
        }
        protected void BuAddData_Click(object sender, EventArgs e)
        {
            // check if the email is active;
             DataTable dataTable = new DataTable();
            dataTable = DBop.NewConectionDLL.SelectDataSet("MyStudents", "StudentEmail", "StudentEmail like '" + txtEmail.Text  + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                LiMessage.Text = "<strong>" + Resources.Resource1.Warning +"</strong> " +Resources.Resource1.emailalreadyregistered;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
                return;
            }
             ColoumnParam[] Coloumns = new ColoumnParam[7];
            Coloumns[0] = new ColoumnParam("StudentFirstName", ColoumnType.NVarChar,txtFirstName.Text);
            Coloumns[1] = new ColoumnParam("StudentLastName", ColoumnType.NVarChar, txtMiddleName.Text);
            Coloumns[2] = new ColoumnParam("StudentEmail", ColoumnType.NVarChar, txtEmail.Text);
            Coloumns[3] = new ColoumnParam("TutorialID", ColoumnType.Int, DDLAccounts.SelectedValue);
            Coloumns[4] = new ColoumnParam("DataRegister", ColoumnType.DateTime, DateTime.Now);
            Coloumns[5] = new ColoumnParam("StudentComment", ColoumnType.NVarChar, txtState.Text);
            Coloumns[6] = new ColoumnParam("SkypeID", ColoumnType.NVarChar, txtSkypeID.Text);
            if (DBop.NewConectionDLL.InsertRow("MyStudents", Coloumns)){
                // add tutorila to my list
            //password = Myenc.GetMD5Data(Encoding.Default.GetBytes(password));
                dataTable = DBop.cobject.SelectDataSet("MyStudents", "StudentID", "StudentEmail like '" + txtEmail.Text + "'").Tables[0];
                ColoumnParam[] Coloumns2 = new ColoumnParam[2];
                Coloumns2[0] = new ColoumnParam("TutorialID", ColoumnType.Int, DDLAccounts.SelectedValue);
                Coloumns2[1] = new ColoumnParam("StudentID", ColoumnType.Int, dataTable.Rows[0]["StudentID"]);
                if (DBop.NewConectionDLL.InsertRow("StudentTutorial", Coloumns2))
                {
                    Contacting sendwelcome = new Contacting();
                    string message = "عزيزي " + txtFirstName.Text + "\n   نحن نقدر جدا انظمامك للدورات وسوف نحاول قصارى جهدنا ان نوصل لك ماتسعى لتعلمه. لذالك سوف نرسل لك بريد يحتوي على معلومات الدخول الى الدورات قريبا لذالك قم بفحص صندوق الوراد والرسائل سبام بشكل دائم  ";
                    sendwelcome.SendWelcome(txtEmail.Text, "شكرا لتسجيلك في نظام الدورات", message);
                    Response.Redirect("Education.aspx?S=T");
                }
                else
                {
                    LiMessage.Text = "<strong>" + DBop.NewConectionDLL.ErrorMessage + "</strong>  .";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
                }
            }
            
            else
            {
                LiMessage.Text = "<strong>" + DBop.NewConectionDLL.ErrorMessage + "</strong>  ";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
            }

        }
Beispiel #19
0
        public static void DeleteItem(string Tag, string UserID, string SubNesourceID)
        {
            DBConnection DBop = new DBConnection();

            if (Tag.Equals("1"))
            {  // addfollow
                ColoumnParam[] Coloumns = new ColoumnParam[3];
                Coloumns[0] = new ColoumnParam("UserID", ColoumnType.Int, UserID);
                Coloumns[1] = new ColoumnParam("SubNesourceID", ColoumnType.Int, SubNesourceID);
                Coloumns[2] = new ColoumnParam("DateRegister", ColoumnType.DateTime, DateTime.Now.ToString());
                DBop.cobject.InsertRow("UserFollowing", Coloumns);
            }
            else  // delete follow
            {
                DBop.cobject.DeletedRow("UserFollowing", "UserID=" + UserID + " and SubNesourceID=" + SubNesourceID);
            }
        }
        protected void GridView3_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "GradeIt")
            {
                GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);


                HiddenField HFStudentID        = (HiddenField)row.FindControl("HFStudentID");
                HiddenField HFSubmitHomeWorkID = (HiddenField)row.FindControl("HFSubmitHomeWorkID");
                TextBox     txtGrade           = (TextBox)row.FindControl("txtGrade");
                Label       LaStudentEmail     = (Label)row.FindControl("LaStudentEmail");
                TextBox     txtAdminComment    = (TextBox)row.FindControl("txtAdminComment");
                LinkButton  LinkButton1        = (LinkButton)row.FindControl("LinkButton1");
                //  DateTime dt=Convert.ToDateTime( LinkButton1.Text);
                // string s = dt .ToString("yyyy-MM-dd-HH:mm:ss"); // String.Format("{yyyy-MM-dd h:mm:ss tt}", dt);
                ColoumnParam[] Coloumns1 = new ColoumnParam[2];
                Coloumns1[0] = new ColoumnParam("Grade", ColoumnType.Float, txtGrade.Text); // 1 for admin add home works
                Coloumns1[1] = new ColoumnParam("AdminComment", ColoumnType.NVarChar, txtAdminComment.Text);
                DBop.cobject.UpdateRow("StudentHomeWorkSubmit", Coloumns1, "SubmitHomeWorkID=" + HFSubmitHomeWorkID.Value);

                GridView3.DataBind();

                // ntify student
                Contacting sendwelcome = new Contacting();
                string     message     = "عزيزي  </br>  تم تحديث درجتك  لواجب </br> ";
                message = message + DDLHomeWorkID.SelectedItem.Text;
                message = message + "</br>   الدرجة   " + txtGrade.Text + "</br>    التعليق  </br>  " + txtAdminComment.Text;
                sendwelcome.SendWelcome(LaStudentEmail.Text, "تنبيه بخصوص الواجب", message);
            }
            else if (e.CommandName == "DownloadIt")
            {
                GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);

                string filepath      = ((HiddenField)row.FindControl("HFAttachmentPath")).Value;
                string downloadsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");

                string   fileName = filepath.Substring(("/attachments/").Length, (filepath.Length - ("/attachments/").Length));
                String[] splitd   = fileName.Split('.');
                //byte[] fileBytes = System.IO.File.ReadAllBytes(splitd[1]);

                Response.ContentType = GetMimeTypeByFileName(splitd[1]);
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
                Response.TransmitFile(Server.MapPath("~" + filepath));
                Response.End();
            }
        }
Beispiel #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //if (!Request.QueryString["NID"]==null )
                SqlDataSource1.SelectParameters["NewsID"].DefaultValue = Request.QueryString["NID"];

                if (!(Request.QueryString["id"] == null))
                {
                    DBConnection   DBop     = new DBConnection();
                    ColoumnParam[] Coloumns = new ColoumnParam[3];
                    Coloumns[0] = new ColoumnParam("UserID", ColoumnType.Int, Request.QueryString["id"]);
                    Coloumns[1] = new ColoumnParam("NewsID", ColoumnType.Int, Request.QueryString["NID"]);
                    Coloumns[2] = new ColoumnParam("DateRead", ColoumnType.DateTime, DateTime.Now.ToString());
                    DBop.cobject.InsertRow("Readers", Coloumns);
                }
            }
        }
Beispiel #22
0
        protected void BuAddData_Click(object sender, EventArgs e)
        {
            // Encryptions Myenc = new Encryptions();  // encript password
            string password = txtPassword.Text;

            ColoumnParam[] Coloumns = new ColoumnParam[1];
            Coloumns[0] = new ColoumnParam("Password", ColoumnType.Char1, password);
            if (DBop.cobject.UpdateRow("MyStudents", Coloumns, ("StudentID=" + Session["adminID"])))
            {
                // LiMessage.Text = "<strong>Success!</strong> Password is changed successfully.";
                // ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalSucces();", true);
                Response.Redirect("MyDashoard.aspx");
            }
            else
            {
                //  MsgBox(DBop.cobject.ErrorMessage)
                // statusLabel.Text = Resource1.AddNotComplte;
                LiMessage.Text = "<strong>Success!</strong>" + Resource1.AddNotComplte;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalSucces();", true);
            }
        }
Beispiel #23
0
        protected void Buadd_Click(object sender, EventArgs e)
        {
            String password = "******";
            string imgPath  = "";

            try
            {
                if (FileUpload1.HasFile)
                {
                    password = StringGeneration.getString(30);
                    imgPath  = ("/attachments/"
                                + (password + Path.GetExtension(FileUpload1.PostedFile.FileName)));
                    //  selct path before post back check nesa becose name file will dispose after poastback
                    //   MsgBox(Server.MapPath(imgPath))
                    FileUpload1.SaveAs(Server.MapPath(imgPath));
                    imgPath = "http://www.news.alruabye.net/" + imgPath; //my host name
                }
            }
            catch (Exception ex) { imgPath = "~/Images/StylesImage/advestments.png"; }
            DateTime DateCreated = DateTime.Now;

            ColoumnParam[] Coloumns = new ColoumnParam[5];
            Coloumns[0] = new ColoumnParam("InvestmentTitle", ColoumnType.NVarChar, txtInvestmentTitle.Text);
            Coloumns[1] = new ColoumnParam("InvestmentImage", ColoumnType.NVarChar, imgPath);
            Coloumns[2] = new ColoumnParam("InvestmentLink", ColoumnType.NVarChar, txtInvestmentLink.Text);
            Coloumns[3] = new ColoumnParam("InvestmentDate", ColoumnType.DateTime, DateCreated);
            Coloumns[4] = new ColoumnParam("InverstmentPostion", ColoumnType.Int, txtInverstmentPostion.Text);


            if (DBop.cobject.InsertRow("Investments", Coloumns))
            {
                Response.Redirect("AddAdvestments.aspx?S=T");
            }
            else
            {
                LiMessage.Text = "<strong>Warning!</strong> " + DBop.cobject.ErrorMessage;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
            }
        }
Beispiel #24
0
        public ReturnError InsertTrackR(string PhoneMac, string Latitude, string longitude)
        {
            DBConnection DBop  = new DBConnection();
            ReturnError  error = new ReturnError();

            /// check if this account avilable
            DataTable dataTable = new DataTable();

            dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " * ", "PhoneMac like '" + PhoneMac + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                int PhoneID = (int)dataTable.Rows[0]["PhoneID"];

                ColoumnParam[] Coloumns = new ColoumnParam[4];
                Coloumns[0] = new ColoumnParam("Latitude", ColoumnType.Float, Latitude);
                Coloumns[1] = new ColoumnParam("longitude", ColoumnType.Float, longitude);
                Coloumns[2] = new ColoumnParam("PhoneID", ColoumnType.Int, PhoneID);
                Coloumns[3] = new ColoumnParam("DateRecord", ColoumnType.DateTime, DateTime.Now);
                if (DBop.NewConectionDLL.InsertRow("Tracking", Coloumns))
                {
                    error.ErrorID      = 2;
                    error.ErrorMessage = "Greate you insert new record";
                    return(error);
                }
                else
                {
                    error.ErrorID      = 1;
                    error.ErrorMessage = "Error , cannot insert this record in the Database";
                    return(error);
                }
            }
            else
            {
                error.ErrorID      = 1;
                error.ErrorMessage = "Error , this phone isnot register in your database";
                return(error);
            }
        }
        protected void BuAddData_Click(object sender, EventArgs e)
        {



           // Encryptions Myenc = new Encryptions();  // encript password
            string password =  txtPassword.Text ;
            ColoumnParam[] Coloumns = new ColoumnParam[1];
            Coloumns[0] = new ColoumnParam("Password", ColoumnType.Char1, password);
            if (DBop.cobject.UpdateRow("MyStudents", Coloumns, ("StudentID=" + Session["adminID"])))
            {
                // LiMessage.Text = "<strong>Success!</strong> Password is changed successfully.";
                // ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalSucces();", true);
                Response.Redirect("MyDashoard.aspx");
            }
            else
            {
                //  MsgBox(DBop.cobject.ErrorMessage)
                // statusLabel.Text = Resource1.AddNotComplte;
                LiMessage.Text = "<strong>Success!</strong>" + Resource1.AddNotComplte;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalSucces();", true);
            }
        }
        // save data
        void SendMessage(string reciveID)
        {
            ColoumnParam[] Coloumns = new ColoumnParam[5];
            Coloumns[0] = new ColoumnParam("NewsTitle", ColoumnType.NVarChar, txtMessageTitle.Text);
            Coloumns[1] = new ColoumnParam("NewsDetails", ColoumnType.NVarChar, txtMessageDetails.Text);
            Coloumns[2] = new ColoumnParam("NewsDate", ColoumnType.DateTime, DateTime.Now);
            Coloumns[3] = new ColoumnParam("SendAccountID", ColoumnType.Int, Convert.ToInt32(Session["adminID"]));
            Coloumns[4] = new ColoumnParam("AccountID", ColoumnType.Int, reciveID);
            if (DBop.cobject.InsertRow("News", Coloumns))
            {
                // get id othe the message to update the messages in atachments
                DataTable dataTable = new DataTable();
                dataTable = DBop.cobject.SelectDataSet("News", "NewsID", " (SendAccountID =" + Convert.ToString(Session["adminID"]) + " ) and NewsDate=(select max(NewsDate) from News where SendAccountID =" + Convert.ToString(Session["adminID"]) + ")").Tables[0];
                // we update all temp attach id
                ColoumnParam[] Coloumns1 = new ColoumnParam[1];
                Coloumns1[0] = new ColoumnParam("AttachID", ColoumnType.varchar50, dataTable.Rows[0]["NewsID"]);
                DBop.cobject.UpdateRow("Attachments", Coloumns1, "AttachmentID=" + HiddenField1.Value + "");
                Response.Redirect("AddNews.aspx?S=T");
            }
            else
                Label1info.Text = DBop.cobject.ErrorMessage;

        }
Beispiel #27
0
 // save data
 void SendMessage(string reciveID)
 {
     ColoumnParam[] Coloumns = new ColoumnParam[5];
     Coloumns[0] = new ColoumnParam("NewsTitle", ColoumnType.NVarChar, txtMessageTitle.Text);
     Coloumns[1] = new ColoumnParam("NewsDetails", ColoumnType.NVarChar, txtMessageDetails.Text);
     Coloumns[2] = new ColoumnParam("NewsDate", ColoumnType.DateTime, DateTime.Now);
     Coloumns[3] = new ColoumnParam("SendAccountID", ColoumnType.Int, Convert.ToInt32(Session["adminID"]));
     Coloumns[4] = new ColoumnParam("AccountID", ColoumnType.Int, reciveID);
     if (DBop.cobject.InsertRow("News", Coloumns))
     {
         // get id othe the message to update the messages in atachments
         DataTable dataTable = new DataTable();
         dataTable = DBop.cobject.SelectDataSet("News", "NewsID", " (SendAccountID =" + Convert.ToString(Session["adminID"]) + " ) and NewsDate=(select max(NewsDate) from News where SendAccountID =" + Convert.ToString(Session["adminID"]) + ")").Tables[0];
         // we update all temp attach id
         ColoumnParam[] Coloumns1 = new ColoumnParam[1];
         Coloumns1[0] = new ColoumnParam("AttachID", ColoumnType.varchar50, dataTable.Rows[0]["NewsID"]);
         DBop.cobject.UpdateRow("Attachments", Coloumns1, "AttachmentID=" + HiddenField1.Value + "");
         Response.Redirect("AddNews.aspx?S=T");
     }
     else
     {
         Label1info.Text = DBop.cobject.ErrorMessage;
     }
 }
        public ReturnError InsertPhoneNumberPrivicy(string PhoneMac, string PhoneNumber, Boolean IsVisabale)
        {
            DBConnection DBop  = new DBConnection();
            ReturnError  error = new ReturnError();

            /// check if this account avilable
            DataTable dataTable = new DataTable();


            dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " * ", "PhoneMac like '" + PhoneMac + "' and PhoneNumber like '" + PhoneNumber + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                ColoumnParam[] Coloumns = new ColoumnParam[1];

                Coloumns[0] = new ColoumnParam("IsVisabale", ColoumnType.Bit, IsVisabale);

                if (DBop.NewConectionDLL.UpdateRow("AdminPhones", Coloumns, "PhoneMac like '" + PhoneMac + "' and PhoneNumber like '" + PhoneNumber + "'"))
                {
                    error.ErrorID      = 2;
                    error.ErrorMessage = "Greate you update the record";
                    return(error);
                }
                else
                {
                    error.ErrorID      = 1;
                    error.ErrorMessage = "Error , cannot insert this record in the Database";
                    return(error);
                }
            }
            else
            {
                error.ErrorID      = 1;
                error.ErrorMessage = "Error , this phone is not registared in database";
                return(error);
            }
        }
        public ReturnError OpenAccount(string FullName, string UserName, String Password, Boolean AccountType, string EmailAdrress)
        {
            DBConnection DBop = new DBConnection();
            ReturnError error = new ReturnError();
            /// check if empty data
            if ((FullName.Length == 0) || (UserName.Length == 0) || (Password.Length == 0) || (EmailAdrress.Length == 0))
            {
                error.ErrorID = 1;
                error.ErrorMessage = "please fill all your information";
                return error;
            }

            /// check if this account avilable
            DataTable dataTable = new DataTable();
            dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * ", "UserName like '" + UserName + "' or EmailAdrress like '" + EmailAdrress + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                error.ErrorID = 1;
                error.ErrorMessage = "the user name or email address already used by other account try with different email or user name";
                return error;
            }

            /// save new account
            /// 
            ColoumnParam[] Coloumns = new ColoumnParam[6];
            Coloumns[0] = new ColoumnParam("FullName", ColoumnType.varchar50, FullName);
            Coloumns[1] = new ColoumnParam("UserName", ColoumnType.varchar50, UserName);
            Coloumns[2] = new ColoumnParam("Password", ColoumnType.varchar50, Password);
            Coloumns[3] = new ColoumnParam("AccountType", ColoumnType.Bit, AccountType);
            Coloumns[4] = new ColoumnParam("DateRegister", ColoumnType.DateTime, DateTime.Now);
            Coloumns[5] = new ColoumnParam("EmailAdrress", ColoumnType.varchar50, EmailAdrress);
            if (DBop.NewConectionDLL.InsertRow("Admins", Coloumns))
            {
               dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * ", "UserName like '" + UserName + "'").Tables[0];

              //  dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * " ).Tables[0];
                /////send email to new account=========================================================
                // System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                // mail.To.Add(EmailAdrress);
                // mail.From = new MailAddress( "*****@*****.**" , "Email head", System.Text.Encoding.UTF8);
                // mail.Subject = "Complete your final steps with  my phone locations";
                //mail.SubjectEncoding = System.Text.Encoding.UTF8;
              //  for (int i = 0; i < dataTable.Rows.Count; i++) { 
                    try
                    {

                        string smtpAddress = "mail.alrubaye.com";
                        int portNumber = 25;
                        bool enableSSL = false;

                        string emailFrom = "*****@*****.**";
                        string password = "******";
                        string emailTo =  EmailAdrress;
                        string subject = "Welcome in my phone location system";
                        string body = "Thank you for using my phone locations system \n" + "  \n Your account  now ready to be used.  please setup this app from google play on your phone \n" + "https://play.google.com/store/apps/details?id=phonelocation.example.asuss550c.phonelocation" + "\nThen from setting login with your user name and password." + "And enjoy." + "Best regards,";

                        using (MailMessage mail = new MailMessage())
                        {
                            mail.From = new MailAddress(emailFrom);
                            mail.To.Add(emailTo);
                            mail.Subject = subject;
                            mail.Body = body;
                            mail.IsBodyHtml = true;
                            // Can set to false, if you are sending pure text.

                            //  mail.Attachments.Add(new Attachment("C:\\SomeFile.txt"));
                            //  mail.Attachments.Add(new Attachment("C:\\SomeZip.zip"));

                            using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
                            {
                                smtp.Credentials = new NetworkCredential(emailFrom, password);
                                smtp.EnableSsl = enableSSL;
                                smtp.Send(mail);
                            }
                        }
                    }
                    catch (Exception ex) { }
                //} // for loop
                error.ErrorID = 2;
                error.AdminID = (int)dataTable.Rows[0]["UserID"];
                error.ErrorMessage = "Greate you insert new record";
                return error;
            }
            else
            {
                error.ErrorID = 1;
                error.ErrorMessage = "Error , cannot insert this record in the Database";
                return error;
            }


        }
Beispiel #30
0
        public async Task <string> GetTwitts(string userName, int count, DateTime LastGet, int SubNesourceID, string TagContent, string ImageTag)
        {
            //if (accessToken == null)
            //{
            //    accessToken = await GetAccessToken();
            //}
            try
            {
                var requestUserTimeline = new HttpRequestMessage(HttpMethod.Get, string.Format("https://api.twitter.com/1.1/statuses/user_timeline.json?count={0}&screen_name={1}", count, userName));//"https://api.twitter.com/1.1/search/tweets.json?q=%&count=10&geocode=37.781157,-122.398720,1mi"); //
                requestUserTimeline.Headers.Add("Authorization", "Bearer " + accessToken);
                var httpClient = new HttpClient();
                HttpResponseMessage responseUserTimeLine = await httpClient.SendAsync(requestUserTimeline);

                var     serializer       = new JavaScriptSerializer();
                dynamic json             = serializer.Deserialize <object>(await responseUserTimeLine.Content.ReadAsStringAsync());
                var     enumerableTwitts = (json as IEnumerable <dynamic>);

                if (enumerableTwitts == null)
                {
                    return(null);
                }
                // List<PostInfo> ls = new List<PostInfo>();
                List <string> listoflinks    = new List <string>();
                string        twitterlink    = "";
                string        Articlelink    = "";
                string        ArticleData    = "";
                string        SummaryContent = "";
                string        summary        = "";


                foreach (dynamic t in enumerableTwitts.Reverse())
                {
                    try
                    {
                        string Post_url       = "";
                        string host           = "";
                        string mytempImageURL = "";
                        try
                        {
                            dynamic media = t["entities"]["urls"];

                            Post_url = media[0]["url"].ToString();
                        }
                        catch (Exception ex) { }
                        ///


                        string dateStr = t["created_at"].ToString();
                        // DateTime PostDate = DateTime.ParseExact(dateStr, "dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                        DateTime PostDate = DateTime.ParseExact(dateStr, "ddd MMM dd HH:mm:ss zzzz yyyy", CultureInfo.InvariantCulture);
                        //  DateTime PostDate = Convert.ToDateTime(dateStr);
                        if ((PostDate > LastGet) && (PostDate <= DateTime.Now))
                        {
                            try // get news details
                            {
                                if (Post_url.Length > 0 && TagContent.Length > 0)
                                {
                                    // SummaryContent = await ReadTextFromUrl(Post_url, TagContent,2);
                                    //if (SummaryContent.Length > 0)
                                    //    summary = SummaryContent;
                                    String LoadURL = Post_url;
                                    if (Post_url.IndexOf("http") < 0)
                                    {
                                        LoadURL = "http://" + Post_url;
                                    }
                                    string PageContain = "";

                                    string PageFull;
                                    try
                                    {
                                        HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(LoadURL);
                                        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                                        if (response.StatusCode == HttpStatusCode.OK)
                                        {
                                            LoadURL = response.ResponseUri.ToString();
                                            host    = response.ResponseUri.Host.ToString();

                                            // get page content====================
                                            HtmlWeb web = new HtmlWeb();
                                            HtmlAgilityPack.HtmlDocument doc = web.Load(LoadURL);
                                            //doc.LoadHtml(PageContainhtml);
                                            HtmlNode rateNode = doc.DocumentNode.SelectSingleNode(TagContent);
                                            PageContain = rateNode.InnerHtml;
                                            PageFull    = "";
                                            foreach (HtmlAgilityPack.HtmlNode node2 in doc.DocumentNode.SelectNodes(TagContent))
                                            {
                                                PageFull = PageFull + "<p>" + node2.InnerHtml + "</p>";
                                            }
                                            if (PageFull.Length > 0)
                                            {
                                                PageContain = PageFull;
                                            }
                                            if (PageContain.Length > 0)
                                            {
                                                summary = PageContain;
                                            }

                                            // get image==============================
                                            // get image
                                            if (ImageTag.Length > 0)
                                            {
                                                if (host.IndexOf("http") < 0)
                                                {
                                                    host = "http://" + host;
                                                }
                                                HtmlNode rateNodeimage = doc.DocumentNode.SelectSingleNode(ImageTag);
                                                string   tempimageURL;
                                                foreach (Match m in Regex.Matches(rateNodeimage.InnerHtml, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase | RegexOptions.Multiline))
                                                {
                                                    tempimageURL = m.Groups[1].Value;
                                                    if (tempimageURL.IndexOf("http") < 0)
                                                    {
                                                        tempimageURL = host + m.Groups[1].Value;
                                                    }
                                                    // لget only the picture with  big size
                                                    try
                                                    {
                                                        System.Net.WebRequest  request1       = System.Net.WebRequest.Create(tempimageURL);
                                                        System.Net.WebResponse response1      = request1.GetResponse();
                                                        System.IO.Stream       responseStream = response1.GetResponseStream();
                                                        Bitmap bitmap2     = new Bitmap(responseStream);
                                                        var    imageHeight = bitmap2.Height;
                                                        var    imageWidth  = bitmap2.Width;
                                                        // string value = attribute.Value.ToLower();
                                                        if ((bitmap2.Width > 100) && (bitmap2.Height > 100) && (!tempimageURL.EndsWith(".gif")))
                                                        {
                                                            if ((mytempImageURL.Length == 0))
                                                            {
                                                                mytempImageURL = tempimageURL;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    catch (Exception ex) { }
                                                }
                                                //et viedos
                                                // get image in cause they cannot get in direct
                                                if (mytempImageURL.Length == 0)
                                                {
                                                    foreach (HtmlNode img in doc.DocumentNode.SelectNodes(ImageTag))
                                                    {
                                                        mytempImageURL = img.GetAttributeValue("src", null);
                                                        if (mytempImageURL.IndexOf("http") < 0)
                                                        {
                                                            mytempImageURL = host + mytempImageURL;
                                                        }
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    { }
                                }
                            }
                            catch (Exception ex) { }

                            // extract the links for text
                            ArticleData = t["text"].ToString();
                            try
                            {
                                Regex urlRx = new Regex(@"((https?|ftp|file)\://|www.)[A-Za-z0-9\.\-]+(/[A-Za-z0-9\?\&\=;\+!'\(\)\*\-\._~%]*)*", RegexOptions.IgnoreCase);

                                MatchCollection matches = urlRx.Matches(ArticleData);
                                foreach (Match match in matches)
                                {
                                    listoflinks.Add(match.Value);
                                    twitterlink = match.Value; // link in twitter will update
                                    if (listoflinks.Count > 1)
                                    {
                                        Articlelink = listoflinks.ElementAt(0);// het article link
                                    }
                                    ArticleData = ArticleData.Remove(ArticleData.IndexOf(twitterlink), twitterlink.Length);
                                }
                            }
                            catch (Exception ex) { }
                            ColoumnParam[] Coloumns = new ColoumnParam[6];
                            Coloumns[0] = new ColoumnParam("NewsTitle", ColoumnType.NVarChar, ArticleData);
                            Coloumns[1] = new ColoumnParam("NewsDate", ColoumnType.DateTime, PostDate);
                            Coloumns[2] = new ColoumnParam("ReadFromWebsiteLink", ColoumnType.NVarChar, Post_url);
                            Coloumns[3] = new ColoumnParam("SubNesourceID", ColoumnType.Int, SubNesourceID);
                            Coloumns[4] = new ColoumnParam("NewsDetails", ColoumnType.NVarChar, summary);
                            Coloumns[5] = new ColoumnParam("DateIN", ColoumnType.DateTime, DateTime.Now.ToString());
                            if (DBop.cobject.InsertRow("News", Coloumns))
                            {
                                DataTable dataTable = new DataTable();
                                dataTable = DBop.cobject.SelectDataSet("News", "NewsID", "SubNesourceID=" + SubNesourceID + "  and NewsDate ='" + PostDate + "'").Tables[0];
                                if ((dataTable != null) && (dataTable.Rows.Count > 0))
                                {
                                    string media_url = "";
                                    try
                                    {
                                        dynamic media = t["entities"]["media"];

                                        media_url = media[0]["media_url_https"].ToString();
                                    }
                                    catch (Exception ex) {
                                        media_url = "";
                                        if (mytempImageURL.Length > 0)// we looked for image
                                        {
                                            media_url = mytempImageURL;
                                        }
                                    }
                                    if (media_url.Length > 0)
                                    {
                                        ColoumnParam[] Coloumns1 = new ColoumnParam[2];
                                        Coloumns1[0] = new ColoumnParam("NewsID", ColoumnType.Int, Convert.ToString(dataTable.Rows[0]["NewsID"]));
                                        Coloumns1[1] = new ColoumnParam("NewsLink", ColoumnType.NVarChar, media_url);
                                        DBop.cobject.InsertRow("NewsImages", Coloumns1);
                                    }
                                    //
                                }
                            }
                            // Console.Clear();
                            twitterlink = "";
                            Articlelink = "";
                            ArticleData = "";
                            listoflinks.Clear();
                            // Console.WriteLine("Last New Readed was at :" + PostDate.ToString());
                        }
                    }
                    catch (Exception ex) { }
                    //ls.Add(new PostInfo(t["text"].ToString(), PostDate));
                }
            }catch (Exception ex8) {}
            return(null);
        }
Beispiel #31
0
        async Task <string> ReadRSS(string url, DateTime LastGet, int SubNesourceID, string TagContent, string ImageTag)
        {
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.DtdProcessing = DtdProcessing.Ignore;
            try
            {
                using (XmlReader reader = XmlReader.Create(url, settings))
                {
                    SyndicationFeed feed = SyndicationFeed.Load(reader);
                    string          link;
                    string          summary        = "";
                    string          SummaryContent = "";
                    foreach (SyndicationItem item in feed.Items.Reverse())
                    {
                        try
                        {
                            string dateStr = item.PublishDate.ToString("ddd MMM dd HH:mm:ss zzzz yyyy");
                            // // DateTime PostDate = DateTime.ParseExact(dateStr, "dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                            DateTime PostDate = DateTime.ParseExact(dateStr, "ddd MMM dd HH:mm:ss zzzz yyyy", CultureInfo.InvariantCulture);
                            // DateTime PostDate = Convert.ToDateTime(item.PublishDate.ToString());
                            if ((PostDate > LastGet))
                            {
                                link = item.Links[0].Uri.ToString();
                                string ImageURL = "";
                                try
                                { summary = item.Summary.Text;
                                  if (item.Links.Count > 1)
                                  {
                                      string value = item.Links[item.Links.Count - 1].Uri.ToString().ToLower();
                                      if (value.StartsWith("http://") && (value.EndsWith(".jpg") || value.EndsWith(".jpeg") || value.EndsWith(".png") || value.EndsWith(".gif")))
                                      {
                                          ImageURL = item.Links[item.Links.Count - 1].Uri.ToString();
                                      }
                                  }
                                  // read the attach images
                                  foreach (SyndicationElementExtension extension in item.ElementExtensions)
                                  {
                                      XElement element = extension.GetObject <XElement>();
                                      if (element.HasAttributes)
                                      {
                                          foreach (var attribute in element.Attributes())
                                          {
                                              string value = attribute.Value.ToLower();
                                              if (value.StartsWith("http://") && (value.EndsWith(".jpg") || value.EndsWith(".png") || value.EndsWith(".gif")))
                                              {
                                                  ImageURL = value; // Add here the image link to some array
                                                  break;            //get ne filesonly
                                              }
                                          }
                                      }
                                  }
                                }
                                catch (Exception ex) { summary = ""; }

                                try // get news details
                                {
                                    if (link.Length > 0)
                                    {
                                        //  SummaryContent = await ReadTextFromUrl(link, TagContent);
                                        // if (SummaryContent.Length > 0)
                                        //   summary = SummaryContent;
                                        try
                                        {
                                            string  PageContain = "";
                                            String  PageFull    = "";
                                            HtmlWeb web         = new HtmlWeb();
                                            HtmlAgilityPack.HtmlDocument doc = web.Load(link);
                                            //doc.LoadHtml(PageContainhtml);
                                            string host = web.ResponseUri.Host.ToString();
                                            if (host.IndexOf("http") < 0)
                                            {
                                                host = "http://" + host;
                                            }
                                            if (TagContent.Length > 0)
                                            { /// get one node data
                                                try
                                                {
                                                    HtmlNode rateNode = doc.DocumentNode.SelectSingleNode(TagContent);
                                                    PageContain = rateNode.InnerHtml;

                                                    //get all div content
                                                    //   var  query = doc.DocumentNode.SelectNodes(TagContent);
                                                    //   PageContain = query.ToString();
                                                    // get all nodes tags data
                                                    PageFull = "";
                                                    foreach (HtmlAgilityPack.HtmlNode node2 in doc.DocumentNode.SelectNodes(TagContent))
                                                    {
                                                        PageFull = PageFull + "<p>" + node2.InnerHtml + "</p>";
                                                    }
                                                    if (PageFull.Length > 0)
                                                    {
                                                        PageContain = PageFull;
                                                    }

                                                    if (PageContain.Length > 0)
                                                    {
                                                        summary = PageContain;
                                                    }
                                                }
                                                catch (Exception ex) { }
                                            }

                                            if (ImageTag.Length > 0)
                                            {
                                                HtmlNode rateNodeimage = doc.DocumentNode.SelectSingleNode(ImageTag);
                                                string   tempimageURL;
                                                foreach (Match m in Regex.Matches(rateNodeimage.InnerHtml, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase | RegexOptions.Multiline))
                                                {
                                                    tempimageURL = m.Groups[1].Value;
                                                    if (tempimageURL.IndexOf("http") < 0)
                                                    {
                                                        tempimageURL = host + m.Groups[1].Value;
                                                    }
                                                    // لget only the picture with  big size
                                                    System.Net.WebRequest  request        = System.Net.WebRequest.Create(tempimageURL);
                                                    System.Net.WebResponse response       = request.GetResponse();
                                                    System.IO.Stream       responseStream = response.GetResponseStream();
                                                    Bitmap bitmap2     = new Bitmap(responseStream);
                                                    var    imageHeight = bitmap2.Height;
                                                    var    imageWidth  = bitmap2.Width;
                                                    // string value = attribute.Value.ToLower();
                                                    if ((bitmap2.Width > 100) && (bitmap2.Height > 100) && (!tempimageURL.EndsWith(".gif")))
                                                    {
                                                        if ((ImageURL.Length == 0))
                                                        {
                                                            ImageURL = tempimageURL;
                                                            break;
                                                        }
                                                    }
                                                }

                                                // get image in cause they cannot get in direct
                                                if (ImageURL.Length == 0)
                                                {
                                                    foreach (HtmlNode img in doc.DocumentNode.SelectNodes(ImageTag))
                                                    {
                                                        ImageURL = img.GetAttributeValue("src", null);
                                                        if (ImageURL.IndexOf("http") < 0)
                                                        {
                                                            ImageURL = host + ImageURL;
                                                        }
                                                        break;
                                                    }
                                                }
                                                if (ImageURL.Length == 0)
                                                {
                                                    // get the viedos url
                                                    List <string>   list     = new List <string>();
                                                    Regex           urlRx    = new Regex(@"(http://youtu|https://youtu|https://www.youtu|http://www.youtu)[A-Za-z0-9\.\-]+(/[A-Za-z0-9\?\&\=;\+!'\(\)\*\-\._~%]*)*", RegexOptions.IgnoreCase);
                                                    string          ViedoURL = "";
                                                    MatchCollection matches  = urlRx.Matches(rateNodeimage.InnerHtml);
                                                    foreach (Match match in matches)
                                                    {
                                                        ViedoURL = match.Value;
                                                        try
                                                        {
                                                            string[] sp = ViedoURL.Split('&');
                                                            if (sp.Length > 1)
                                                            {
                                                                ViedoURL = sp[0];
                                                            }
                                                            string[] spid = ViedoURL.Split('/');
                                                            if (spid.Length > 1)
                                                            {
                                                                ViedoURL = "http://www.youtube.com/embed/" + spid[spid.Length - 1];
                                                            }
                                                            break;
                                                        }
                                                        catch (Exception ex) { }
                                                        list.Add(ViedoURL);
                                                    }
                                                    if (list.Count > 0)
                                                    {
                                                        ImageURL = list[0];
                                                    }


                                                    if (list.Count == 0)
                                                    {// get mp4
                                                        Regex urlRx1 = new Regex(@"(http://|https://)[A-Za-z0-9\.\-]+(/[A-Za-z0-9\?\&\=;\+!'\(\)\*\-\._~%]*)*(.mp4|.MP4)", RegexOptions.IgnoreCase);
                                                        ViedoURL = "";

                                                        MatchCollection matches1 = urlRx1.Matches(rateNodeimage.InnerHtml);
                                                        if (matches1.Count > 0)
                                                        {
                                                            list.Clear();
                                                            foreach (Match match in matches1)
                                                            {
                                                                ViedoURL = match.Value;

                                                                list.Add(ViedoURL);
                                                                break;
                                                            }
                                                            if (list.Count > 0)
                                                            {
                                                                ImageURL = list[0];
                                                            }
                                                        }
                                                    }

                                                    /////in cuase use video tag
                                                    tempimageURL = "";
                                                    if (list.Count == 0)
                                                    {
                                                        foreach (Match m in Regex.Matches(rateNodeimage.InnerHtml, "<iframe.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase | RegexOptions.Multiline))
                                                        {
                                                            tempimageURL = m.Groups[1].Value;
                                                            break;
                                                        }
                                                        if (tempimageURL.Length > 0)
                                                        {
                                                            ImageURL = tempimageURL;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        catch (Exception ex7) { }
                                    }
                                }
                                catch (Exception ex) { }

                                ColoumnParam[] Coloumns = new ColoumnParam[6];
                                Coloumns[0] = new ColoumnParam("NewsTitle", ColoumnType.NVarChar, item.Title.Text);
                                Coloumns[1] = new ColoumnParam("NewsDate", ColoumnType.DateTime, PostDate);
                                Coloumns[2] = new ColoumnParam("ReadFromWebsiteLink", ColoumnType.NVarChar, link);
                                Coloumns[3] = new ColoumnParam("SubNesourceID", ColoumnType.Int, SubNesourceID);
                                Coloumns[4] = new ColoumnParam("NewsDetails", ColoumnType.NVarChar, summary);
                                Coloumns[5] = new ColoumnParam("DateIN", ColoumnType.DateTime, DateTime.Now.ToString());
                                if (DBop.cobject.InsertRow("News", Coloumns))
                                {
                                    DataTable dataTable = new DataTable();
                                    dataTable = DBop.cobject.SelectDataSet("News", "NewsID", "SubNesourceID=" + SubNesourceID + "  and NewsDate ='" + PostDate + "'").Tables[0];
                                    if ((dataTable != null) && (dataTable.Rows.Count > 0))
                                    {
                                        if (ImageURL.Length > 0)// get image from content
                                        {
                                            ColoumnParam[] Coloumns1 = new ColoumnParam[2];
                                            Coloumns1[0] = new ColoumnParam("NewsID", ColoumnType.Int, Convert.ToString(dataTable.Rows[0]["NewsID"]));
                                            Coloumns1[1] = new ColoumnParam("NewsLink", ColoumnType.NVarChar, ImageURL);

                                            DBop.cobject.InsertRow("NewsImages", Coloumns1);
                                        }
                                    }
                                }
                                //Console.Clear();
                                // Console.WriteLine("Last New Readed was at :" + PostDate.ToString());
                            }
                        }
                        catch (Exception xexp)
                        {
                            // fix those datetime nodes with exceptions and read again.
                            try
                            {
                                /// old version of RSS
                                XmlDocument rssXmlDoc = new XmlDocument();

                                // Load the RSS file from the RSS URL
                                rssXmlDoc.Load(url);

                                // Parse the Items in the RSS file
                                XmlNodeList rssNodes = rssXmlDoc.SelectNodes("rss/channel/item");

                                StringBuilder rssContent = new StringBuilder();

                                string title;
                                string description;

                                string pubdate;
                                string ImageURL = "";
                                // Iterate through the items in the RSS file
                                foreach (XmlNode rssNode in rssNodes)
                                {
                                    XmlNode rssSubNode = rssNode.SelectSingleNode("title");
                                    title = rssSubNode != null ? rssSubNode.InnerText : "";

                                    rssSubNode = rssNode.SelectSingleNode("link");
                                    link       = rssSubNode != null ? rssSubNode.InnerText : "";

                                    rssSubNode  = rssNode.SelectSingleNode("description");
                                    description = rssSubNode != null ? rssSubNode.InnerText : "";
                                    rssSubNode  = rssNode.SelectSingleNode("pubDate");
                                    pubdate     = rssSubNode != null?rssSubNode.InnerText.ToString() : "";

                                    try
                                    {
                                        // string dateStr = rssSubNode.InnerText.ToString("ddd MMM dd HH:mm:ss zzzz yyyy");
                                        //DateTime PostDate = Convert.ToDateTime(pubdate);// DateTime.ParseExact(pubdate, "ddd MMM dd HH:mm:ss zzzz yyyy", null);
                                        // DateTime date = DateTime.ParseExact(pubdate, "dd/MM/yyyy", null);
                                        // string dateTime = parsedDateTime.ToString("ddd MMM dd HH:mm:ss zzzz yyyy");
                                        // DateTime dateStr = DateTime.ParseExact(pubdate, "ddd MMM dd HH:mm:ss zzzz yyyy", null );
                                        // DateTime PostDate = DateTime.ParseExact(pubdate, "ddd MMM dd HH:mm:ss zzzz yyyy", CultureInfo.InvariantCulture);
                                        // string dateStr = item.PublishDate.ToString("ddd MMM dd HH:mm:ss zzzz yyyy");
                                        // DateTime PostDate = DateTime.ParseExact(dateStr, "dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                                        DateTime PostDate = DateTime.ParseExact(pubdate, "ddd MMM dd HH:mm:ss zzzz yyyy", CultureInfo.InvariantCulture);

                                        if ((PostDate > LastGet))
                                        {
                                            ImageURL = "";
                                            summary  = description;
                                            if (link.Length > 0)
                                            {
                                                //  SummaryContent = await ReadTextFromUrl(link, TagContent);
                                                // if (SummaryContent.Length > 0)
                                                //   summary = SummaryContent;
                                                try
                                                {
                                                    string  PageContain = "";
                                                    String  PageFull    = "";
                                                    HtmlWeb web         = new HtmlWeb();
                                                    HtmlAgilityPack.HtmlDocument doc = web.Load(link);
                                                    //doc.LoadHtml(PageContainhtml);
                                                    string host = web.ResponseUri.Host.ToString();
                                                    if (host.IndexOf("http") < 0)
                                                    {
                                                        host = "http://" + host;
                                                    }
                                                    if (TagContent.Length > 0)
                                                    { /// get one node data
                                                        try
                                                        {
                                                            HtmlNode rateNode = doc.DocumentNode.SelectSingleNode(TagContent);
                                                            PageContain = rateNode.InnerHtml;

                                                            //get all div content
                                                            //   var  query = doc.DocumentNode.SelectNodes(TagContent);
                                                            //   PageContain = query.ToString();
                                                            // get all nodes tags data
                                                            PageFull = "";
                                                            foreach (HtmlAgilityPack.HtmlNode node2 in doc.DocumentNode.SelectNodes(TagContent))
                                                            {
                                                                PageFull = PageFull + "<p>" + node2.InnerHtml + "</p>";
                                                            }
                                                            ;
                                                            if (PageFull.Length > 0)
                                                            {
                                                                PageContain = PageFull;
                                                            }

                                                            if (PageContain.Length > 0)
                                                            {
                                                                summary = PageContain;
                                                            }
                                                        }
                                                        catch (Exception e34x) { }
                                                    }

                                                    if (ImageTag.Length > 0)
                                                    {
                                                        HtmlNode rateNodeimage = doc.DocumentNode.SelectSingleNode(ImageTag);
                                                        string   tempimageURL;
                                                        foreach (Match m in Regex.Matches(rateNodeimage.InnerHtml, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase | RegexOptions.Multiline))
                                                        {
                                                            tempimageURL = m.Groups[1].Value;
                                                            if (tempimageURL.IndexOf("http") < 0)
                                                            {
                                                                tempimageURL = host + m.Groups[1].Value;
                                                            }
                                                            // لget only the picture with  big size
                                                            System.Net.WebRequest  request        = System.Net.WebRequest.Create(tempimageURL);
                                                            System.Net.WebResponse response       = request.GetResponse();
                                                            System.IO.Stream       responseStream = response.GetResponseStream();
                                                            Bitmap bitmap2     = new Bitmap(responseStream);
                                                            var    imageHeight = bitmap2.Height;
                                                            var    imageWidth  = bitmap2.Width;
                                                            // string value = attribute.Value.ToLower();
                                                            if ((bitmap2.Width > 100) && (bitmap2.Height > 100) && (!tempimageURL.EndsWith(".gif")))
                                                            {
                                                                if ((ImageURL.Length == 0))
                                                                {
                                                                    ImageURL = tempimageURL;
                                                                    break;
                                                                }
                                                            }
                                                        }

                                                        // get image in cause they cannot get in direct
                                                        if (ImageURL.Length == 0)
                                                        {
                                                            foreach (HtmlNode img in doc.DocumentNode.SelectNodes(ImageTag))
                                                            {
                                                                ImageURL = img.GetAttributeValue("src", null);
                                                                if (ImageURL.IndexOf("http") < 0)
                                                                {
                                                                    ImageURL = host + ImageURL;
                                                                }
                                                                break;
                                                            }
                                                        }
                                                        //et viedos
                                                    }

                                                    ColoumnParam[] Coloumns = new ColoumnParam[6];
                                                    Coloumns[0] = new ColoumnParam("NewsTitle", ColoumnType.NVarChar, title);
                                                    Coloumns[1] = new ColoumnParam("NewsDate", ColoumnType.DateTime, PostDate);
                                                    Coloumns[2] = new ColoumnParam("ReadFromWebsiteLink", ColoumnType.NVarChar, link);
                                                    Coloumns[3] = new ColoumnParam("SubNesourceID", ColoumnType.Int, SubNesourceID);
                                                    Coloumns[4] = new ColoumnParam("NewsDetails", ColoumnType.NVarChar, summary);
                                                    Coloumns[5] = new ColoumnParam("DateIN", ColoumnType.DateTime, DateTime.Now.ToString());
                                                    if (DBop.cobject.InsertRow("News", Coloumns))
                                                    {
                                                        DataTable dataTable = new DataTable();
                                                        dataTable = DBop.cobject.SelectDataSet("News", "NewsID", "SubNesourceID=" + SubNesourceID + "  and NewsDate ='" + PostDate + "'").Tables[0];
                                                        if ((dataTable != null) && (dataTable.Rows.Count > 0))
                                                        {
                                                            if (ImageURL.Length > 0)// get image from content
                                                            {
                                                                ColoumnParam[] Coloumns1 = new ColoumnParam[2];
                                                                Coloumns1[0] = new ColoumnParam("NewsID", ColoumnType.Int, Convert.ToString(dataTable.Rows[0]["NewsID"]));
                                                                Coloumns1[1] = new ColoumnParam("NewsLink", ColoumnType.NVarChar, ImageURL);

                                                                DBop.cobject.InsertRow("NewsImages", Coloumns1);
                                                            }
                                                        }
                                                    }
                                                    //Console.Clear();
                                                    // Console.WriteLine("Last New Readed was at :" + PostDate.ToString());
                                                }
                                                catch (Exception xexssp)
                                                {
                                                    // fix those datetime nodes with exceptions and read again.
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception exerror) { }
                                }
                            }

                            catch (Exception exerror) { }
                        }
                    }
                }
            }
            catch (Exception ex) { }
            return(null);
        }
        public ReturnError OpenAccount(string FullName, string UserName, String Password, Boolean AccountType,string EmailAdrress)
        {
            DBConnection DBop = new DBConnection();
            ReturnError error = new ReturnError();
            /// check if empty data
            if (( FullName.Length==0)||(  UserName.Length==0)||(Password.Length==0)||( EmailAdrress.Length==0))
            {
                error.ErrorID = 1;
                error.ErrorMessage = "please fill all your information";
                return error;
            }

            /// check if this account avilable
            DataTable dataTable = new DataTable();
            dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * ", "UserName like '" + UserName + "' or EmailAdrress like '" + EmailAdrress + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                error.ErrorID = 1;
                error.ErrorMessage = "the user name or email address already used by other account try with different email or user name";
                return error;
            }

            /// save new account
            /// 
            ColoumnParam[] Coloumns = new ColoumnParam[6];
            Coloumns[0] = new ColoumnParam("FullName", ColoumnType.varchar50, FullName);
            Coloumns[1] = new ColoumnParam("UserName", ColoumnType.varchar50, UserName);
            Coloumns[2] = new ColoumnParam("Password", ColoumnType.varchar50, Password);
            Coloumns[3] = new ColoumnParam("AccountType", ColoumnType.Bit, AccountType);
            Coloumns[4] = new ColoumnParam("DateRegister", ColoumnType.DateTime, DateTime.Now);
            Coloumns[5] = new ColoumnParam("EmailAdrress", ColoumnType.varchar50, EmailAdrress);
            if (DBop.NewConectionDLL.InsertRow("Admins", Coloumns))
            {
                dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * ", "UserName like '" + UserName + "'").Tables[0];

                
                /////send email to new account=========================================================
                // System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                // mail.To.Add(EmailAdrress);
                // mail.From = new MailAddress( "*****@*****.**" , "Email head", System.Text.Encoding.UTF8);
                // mail.Subject = "Complete your final steps with  my phone locations";
                //mail.SubjectEncoding = System.Text.Encoding.UTF8;
                //mail.Body = "Thank you for using my phone locations system" + Environment.NewLine + "Your account  now ready to be used.  please setup this app from google play on your phone" + Environment.NewLine + "https://play.google.com/store/apps/details?id=phonelocation.example.asuss550c.phonelocation" + Environment.NewLine + "Then from setting login with your user name and password." + Environment.NewLine + "And enjoy." + Environment.NewLine + "Best regards,"; 
                //mail.BodyEncoding = System.Text.Encoding.UTF8;
                //mail.IsBodyHtml = true;
                //mail.Priority = MailPriority.High;
                //SmtpClient client = new SmtpClient();
                //client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "abc3551356");
                //client.Port = 25;
                //client.Host = "mail.alrubaye.com";
                //client.EnableSsl = true;
                //try
                //{
                //    client.Send(mail);
                //   // Page.RegisterStartupScript("UserMsg", "<script>alert('Successfully Send...');if(alert){ window.location='SendMail.aspx';}</script>");
                //}
                //catch (Exception ex)
                //{
                //    Exception ex2 = ex;
                //    string errorMessage = string.Empty;
                //    while (ex2 != null)
                //    {
                //        errorMessage += ex2.ToString();
                //        ex2 = ex2.InnerException;
                //    }
                //  //  Page.RegisterStartupScript("UserMsg", "<script>alert('Sending Failed...');if(alert){ window.location='SendMail.aspx';}</script>");
                //}
                error.ErrorID = 2;
                error.AdminID = (int)dataTable.Rows[0]["UserID"];
                error.ErrorMessage = "Greate you insert new record";
                return error;
            }
            else
            {
                error.ErrorID = 1;
                error.ErrorMessage = "Error , cannot insert this record in the Database";
                return error;
            }


        }
        public ReturnError InsertTrackR(string PhoneMac, string Latitude, string   longitude)
        {
            DBConnection DBop = new DBConnection();
            ReturnError error = new ReturnError();

            /// check if this account avilable
            DataTable dataTable = new DataTable();
            dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " * ", "PhoneMac like '" + PhoneMac + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                int PhoneID = (int)dataTable.Rows[0]["PhoneID"];

                ColoumnParam[] Coloumns = new ColoumnParam[4];
                Coloumns[0] = new ColoumnParam("Latitude", ColoumnType.Float, Latitude);
                Coloumns[1] = new ColoumnParam("longitude", ColoumnType.Float, longitude);
                Coloumns[2] = new ColoumnParam("PhoneID", ColoumnType.Int, PhoneID);
                Coloumns[3] = new ColoumnParam("DateRecord", ColoumnType.DateTime, DateTime.Now);
                if (DBop.NewConectionDLL.InsertRow("Tracking", Coloumns))
                {

                    error.ErrorID = 2;
                    error.ErrorMessage = "Greate you insert new record";
                    return error;

                }
                else
                {
                    error.ErrorID = 1;
                    error.ErrorMessage = "Error , cannot insert this record in the Database";
                    return error;
                }


            }
            else
            {
                error.ErrorID = 1;
                error.ErrorMessage = "Error , this phone isnot register in your database";
                return error;
            }
        }
        public ReturnError InsertPhoneInfo(int UserID, string PhoneMac, string PhoneName)
        {
            DBConnection DBop = new DBConnection();
            ReturnError error = new ReturnError();

            /// check if this account avilable
            DataTable dataTable = new DataTable();
            dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * ", "UserID=" + UserID).Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                Boolean isnulti = (Boolean)dataTable.Rows[0]["AccountType"];
                dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " * ", "PhoneMac like '" + PhoneMac + "'").Tables[0];
                if ((dataTable != null) && (dataTable.Rows.Count > 0))
                {
                    error.ErrorID = 1;
                    error.ErrorMessage = "this phone is already registered in database";
                    return error;
                }
                // check if this phone is not comercial
                
                if (isnulti == false)
                {
                    dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " * ", "UserID=" + UserID ).Tables[0];
                    if ((dataTable != null) && (dataTable.Rows.Count > 0))
                    {
                        error.ErrorID = 1;
                        error.ErrorMessage = "this type of account is for one device only";
                        return error;
                    }
                }
               
                ColoumnParam[] Coloumns = new ColoumnParam[4];
                Coloumns[0] = new ColoumnParam("UserID", ColoumnType.Int, UserID);
                Coloumns[1] = new ColoumnParam("PhoneMac", ColoumnType.varchar50, PhoneMac);
                Coloumns[2] = new ColoumnParam("DateRegister", ColoumnType.DateTime, DateTime.Now);
                Coloumns[3] = new ColoumnParam("PhoneName", ColoumnType.varchar50, PhoneName);
                if (DBop.NewConectionDLL.InsertRow("AdminPhones", Coloumns))
                {

                    error.ErrorID = 2;
                    error.ErrorMessage = "Greate you insert new record";
                    return error;

                }
                else
                {
                    error.ErrorID = 1;
                    error.ErrorMessage = "Error , cannot insert this record in the Database";
                    return error;
                }



            }


            else
            {
                error.ErrorID = 1;
                error.ErrorMessage = "Error , cannot find this record in the Database";
                return error;
            }


        }
        public void GetNewsDetials(int NewsIDvar, int UserID)
        {
            JavaScriptSerializer ser = new JavaScriptSerializer();

            DBConnection DBop                = new DBConnection();
            DataTable    dataTable           = new DataTable();
            string       Row                 = null;
            string       SubNesourceID       = null;
            string       NewsTitle           = null;
            string       PicturLink          = null;
            string       InvestmentLink      = null;
            string       NewsDateN           = null;
            string       NewsID              = null;
            string       SubNesourceName     = null;
            string       ChannelImage        = null;
            string       NewsDetails         = null;
            int          HasNewNews          = 0;
            string       ReadFromWebsiteLink = null;


            // get last news
            ColProcedureParam[] Coloumns1 = new ColProcedureParam[1];
            Coloumns1[0] = new ColProcedureParam("NewsID", Convert.ToString(NewsIDvar));

            dataTable = DBop.cobject.SelectDataSetProcedureTable("GetNewsDetials", Coloumns1).Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            { //
                //SaveNews is readed by person
                ColoumnParam[] Coloumns = new ColoumnParam[3];
                Coloumns[0] = new ColoumnParam("NewsID", ColoumnType.Int, NewsIDvar);
                Coloumns[1] = new ColoumnParam("UserID", ColoumnType.Int, UserID);
                Coloumns[2] = new ColoumnParam("DateRead", ColoumnType.DateTime, DateTime.Now.ToString());
                DBop.cobject.InsertRow("Readers", Coloumns);

                Row           = Convert.ToString(dataTable.Rows[0]["Row"]);
                SubNesourceID = Convert.ToString(dataTable.Rows[0]["SubNesourceID"]);
                NewsTitle     = Convert.ToString(dataTable.Rows[0]["NewsTitle"]);
                PicturLink    = Convert.ToString(dataTable.Rows[0]["PicturLink"]);
                //InvestmentLink[i] = Convert.ToString(dataTable.Rows[i]["InvestmentLink"]); ;
                NewsDateN           = Convert.ToString(dataTable.Rows[0]["NewsDateN"]);
                NewsID              = Convert.ToString(dataTable.Rows[0]["NewsID"]);
                SubNesourceName     = Convert.ToString(dataTable.Rows[0]["SubNesourceName"]);
                ChannelImage        = Convert.ToString(dataTable.Rows[0]["ChannelImage"]);
                NewsDetails         = Convert.ToString(dataTable.Rows[0]["NewsDetails"]);
                ReadFromWebsiteLink = Convert.ToString(dataTable.Rows[0]["ReadFromWebsiteLink"]);
                HasNewNews          = 1;
            }
            var jsonData = new
            { HasNew              = HasNewNews,
              Row                 = Row,
              SubNesourceID       = SubNesourceID,
              NewsTitle           = NewsTitle,
              PicturLink          = PicturLink,
              InvestmentLink      = InvestmentLink,
              NewsDateN           = NewsDateN,
              NewsID              = NewsID,
              SubNesourceName     = SubNesourceName,
              ChannelImage        = ChannelImage,
              NewsDetails         = NewsDetails,
              ReadFromWebsiteLink = ReadFromWebsiteLink };

            //return ser.Serialize(jsonData); //products.ToString();
            HttpContext.Current.Response.Write(ser.Serialize(jsonData));
        }
Beispiel #36
0
        public ReturnError OpenAccount(string FullName, string UserName, String Password, Boolean AccountType, string EmailAdrress)
        {
            DBConnection DBop  = new DBConnection();
            ReturnError  error = new ReturnError();

            /// check if empty data
            if ((FullName.Length == 0) || (UserName.Length == 0) || (Password.Length == 0) || (EmailAdrress.Length == 0))
            {
                error.ErrorID      = 1;
                error.ErrorMessage = "please fill all your information";
                return(error);
            }

            /// check if this account avilable
            DataTable dataTable = new DataTable();

            dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * ", "UserName like '" + UserName + "' or EmailAdrress like '" + EmailAdrress + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                error.ErrorID      = 1;
                error.ErrorMessage = "the user name or email address already used by other account try with different email or user name";
                return(error);
            }

            /// save new account
            ///
            ColoumnParam[] Coloumns = new ColoumnParam[6];
            Coloumns[0] = new ColoumnParam("FullName", ColoumnType.varchar50, FullName);
            Coloumns[1] = new ColoumnParam("UserName", ColoumnType.varchar50, UserName);
            Coloumns[2] = new ColoumnParam("Password", ColoumnType.varchar50, Password);
            Coloumns[3] = new ColoumnParam("AccountType", ColoumnType.Bit, AccountType);
            Coloumns[4] = new ColoumnParam("DateRegister", ColoumnType.DateTime, DateTime.Now);
            Coloumns[5] = new ColoumnParam("EmailAdrress", ColoumnType.varchar50, EmailAdrress);
            if (DBop.NewConectionDLL.InsertRow("Admins", Coloumns))
            {
                dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * ", "UserName like '" + UserName + "'").Tables[0];


                /////send email to new account=========================================================
                // System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                // mail.To.Add(EmailAdrress);
                // mail.From = new MailAddress( "*****@*****.**" , "Email head", System.Text.Encoding.UTF8);
                // mail.Subject = "Complete your final steps with  my phone locations";
                //mail.SubjectEncoding = System.Text.Encoding.UTF8;
                //mail.Body = "Thank you for using my phone locations system" + Environment.NewLine + "Your account  now ready to be used.  please setup this app from google play on your phone" + Environment.NewLine + "https://play.google.com/store/apps/details?id=phonelocation.example.asuss550c.phonelocation" + Environment.NewLine + "Then from setting login with your user name and password." + Environment.NewLine + "And enjoy." + Environment.NewLine + "Best regards,";
                //mail.BodyEncoding = System.Text.Encoding.UTF8;
                //mail.IsBodyHtml = true;
                //mail.Priority = MailPriority.High;
                //SmtpClient client = new SmtpClient();
                //client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "abc3551356");
                //client.Port = 25;
                //client.Host = "mail.alrubaye.com";
                //client.EnableSsl = true;
                //try
                //{
                //    client.Send(mail);
                //   // Page.RegisterStartupScript("UserMsg", "<script>alert('Successfully Send...');if(alert){ window.location='SendMail.aspx';}</script>");
                //}
                //catch (Exception ex)
                //{
                //    Exception ex2 = ex;
                //    string errorMessage = string.Empty;
                //    while (ex2 != null)
                //    {
                //        errorMessage += ex2.ToString();
                //        ex2 = ex2.InnerException;
                //    }
                //  //  Page.RegisterStartupScript("UserMsg", "<script>alert('Sending Failed...');if(alert){ window.location='SendMail.aspx';}</script>");
                //}
                error.ErrorID      = 2;
                error.AdminID      = (int)dataTable.Rows[0]["UserID"];
                error.ErrorMessage = "Greate you insert new record";
                return(error);
            }
            else
            {
                error.ErrorID      = 1;
                error.ErrorMessage = "Error , cannot insert this record in the Database";
                return(error);
            }
        }
 protected void Button1_Click(object sender, EventArgs e)
 {
     DBop.cobject.DeletedRow("StudentAttendance", "TutorialScheduleID=" + DDLTimeID.SelectedValue); // delete all student register to update
     for (int i = 0; i < GridView1.Rows.Count; i++)
     {
         DropDownList ddlStatus = (DropDownList)GridView2.Rows[i].FindControl("DDLStatusID");
         Label LaAdminID = (Label)GridView2.Rows[i].FindControl("LaPersonID");
         ColoumnParam[] Coloumns1 = new ColoumnParam[3];
       
         Coloumns1[0] = new ColoumnParam("StudentID", ColoumnType.Int, LaAdminID.Text); // 1 for admin add home works
         Coloumns1[1] = new ColoumnParam("TutorialScheduleID", ColoumnType.Int,DDLTimeID.SelectedValue);
         Coloumns1[2] = new ColoumnParam("AttendenceStutusID", ColoumnType.Bit, ddlStatus.SelectedValue);
         DBop.cobject.InsertRow("StudentAttendance", Coloumns1);
     }
     GridView1.DataBind();
 }
        protected void BuAddData_Click(object sender, EventArgs e)
        {
            // check the expire date
 
            DataTable dataTable = new DataTable();
            dataTable = DBop.cobject.SelectDataSet("HomeWorks", "HomeWorkID,DeadLineDate", "HomeWorkUID like '" + HFid.Value + "'").Tables[0];
            DateTime Deadline = Convert.ToDateTime(dataTable.Rows[0]["DeadLineDate"]); ;
            if ((DateTime.Now - Deadline).TotalMinutes > 0)
            {
                BuAddData0.Enabled = false;
                LiMessage.Text = "<strong>The Time of upload file is expired</strong>  .";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
                return;
            }

            string timesumit = DateTime.Now.ToString();
            ColoumnParam[] Coloumns = new ColoumnParam[4];
            Coloumns[0] = new ColoumnParam("HomeWorkID", ColoumnType.Int,Convert.ToInt32( dataTable.Rows[0]["HomeWorkID"]));
            Coloumns[1] = new ColoumnParam("StudentNote", ColoumnType.NVarChar, txtMessageTitle.Text);
            Coloumns[2] = new ColoumnParam("SubmitDatein", ColoumnType.DateTime, DateTime.Now);
            Coloumns[3] = new ColoumnParam("StudentID", ColoumnType.Int, Convert.ToInt32(Session["adminID"]));
            if (DBop.cobject.InsertRow("StudentHomeWorkSubmit", Coloumns))
            {

                dataTable = DBop.cobject.SelectDataSet("StudentHomeWorkSubmit", "SubmitHomeWorkID", "SubmitDatein=(SELECT  max([SubmitDatein]) FROM [StudentHomeWorkSubmit] where StudentID=" + Convert.ToInt32(Session["adminID"]) + ") and StudentID=" + Convert.ToInt32(Session["adminID"])).Tables[0];
                
                // get id othe the message to update the messages in atachments
               // we update all temp attach id
                String password = "******";
                string imgPath;
                try
                {
                    if (FileUpload1.HasFile) { 
                    password = Convert.ToString(Session["adminID"]) + StringGeneration.getString(30);
                    imgPath = ("/attachments/"
                                + (password + Path.GetExtension(FileUpload1.PostedFile.FileName)));
                    //  selct path before post back check nesa becose name file will dispose after poastback
                    //   MsgBox(Server.MapPath(imgPath))
                    FileUpload1.SaveAs(Server.MapPath(imgPath));
                    ColoumnParam[] Coloumns1 = new ColoumnParam[5];
                    Coloumns1[0] = new ColoumnParam("AttachmentTypeID", ColoumnType.Int, 3); // 1 for admin add news
                    Coloumns1[1] = new ColoumnParam("AttachmentPath", ColoumnType.NVarChar, imgPath);
                    Coloumns1[2] = new ColoumnParam("AttachmentDateIN", ColoumnType.DateTime, DateTime.Now.ToString());
                    Coloumns1[3] = new ColoumnParam("AttachmentID", ColoumnType.Int, Convert.ToInt32(dataTable.Rows[0]["SubmitHomeWorkID"]));
                    Coloumns1[4] = new ColoumnParam("AddedBy", ColoumnType.Int, Convert.ToString(Session["adminID"]));

                    DBop.cobject.InsertRow("Attachments", Coloumns1);

                    SqlDataSource1.DataBind();
                    GridView2.DataBind();}
                 
                }
                catch (Exception ex)
                {


                }
                Response.Redirect("MyHomeWorksdetails.aspx?id=" + HFid.Value + "&S=T");
            }
            else
            {
                LiMessage.Text = "<strong>" + DBop.NewConectionDLL.ErrorMessage + "</strong>  .";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
            }
                
        }
        protected void BuAddData_Click(object sender, EventArgs e)
        {
            // check the expire date

            DataTable dataTable = new DataTable();

            dataTable = DBop.cobject.SelectDataSet("HomeWorks", "HomeWorkID,DeadLineDate", "HomeWorkUID like '" + HFid.Value + "'").Tables[0];
            DateTime Deadline = Convert.ToDateTime(dataTable.Rows[0]["DeadLineDate"]);;

            if ((DateTime.Now - Deadline).TotalMinutes > 0)
            {
                BuAddData0.Enabled = false;
                LiMessage.Text     = "<strong>The Time of upload file is expired</strong>  .";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
                return;
            }

            string timesumit = DateTime.Now.ToString();

            ColoumnParam[] Coloumns = new ColoumnParam[4];
            Coloumns[0] = new ColoumnParam("HomeWorkID", ColoumnType.Int, Convert.ToInt32(dataTable.Rows[0]["HomeWorkID"]));
            Coloumns[1] = new ColoumnParam("StudentNote", ColoumnType.NVarChar, txtMessageTitle.Text);
            Coloumns[2] = new ColoumnParam("SubmitDatein", ColoumnType.DateTime, DateTime.Now);
            Coloumns[3] = new ColoumnParam("StudentID", ColoumnType.Int, Convert.ToInt32(Session["adminID"]));
            if (DBop.cobject.InsertRow("StudentHomeWorkSubmit", Coloumns))
            {
                dataTable = DBop.cobject.SelectDataSet("StudentHomeWorkSubmit", "SubmitHomeWorkID", "SubmitDatein=(SELECT  max([SubmitDatein]) FROM [StudentHomeWorkSubmit] where StudentID=" + Convert.ToInt32(Session["adminID"]) + ") and StudentID=" + Convert.ToInt32(Session["adminID"])).Tables[0];

                // get id othe the message to update the messages in atachments
                // we update all temp attach id
                String password = "******";
                string imgPath;
                try
                {
                    if (FileUpload1.HasFile)
                    {
                        password = Convert.ToString(Session["adminID"]) + StringGeneration.getString(30);
                        imgPath  = ("/attachments/"
                                    + (password + Path.GetExtension(FileUpload1.PostedFile.FileName)));
                        //  selct path before post back check nesa becose name file will dispose after poastback
                        //   MsgBox(Server.MapPath(imgPath))
                        FileUpload1.SaveAs(Server.MapPath(imgPath));
                        ColoumnParam[] Coloumns1 = new ColoumnParam[5];
                        Coloumns1[0] = new ColoumnParam("AttachmentTypeID", ColoumnType.Int, 3); // 1 for admin add news
                        Coloumns1[1] = new ColoumnParam("AttachmentPath", ColoumnType.NVarChar, imgPath);
                        Coloumns1[2] = new ColoumnParam("AttachmentDateIN", ColoumnType.DateTime, DateTime.Now.ToString());
                        Coloumns1[3] = new ColoumnParam("AttachmentID", ColoumnType.Int, Convert.ToInt32(dataTable.Rows[0]["SubmitHomeWorkID"]));
                        Coloumns1[4] = new ColoumnParam("AddedBy", ColoumnType.Int, Convert.ToString(Session["adminID"]));

                        DBop.cobject.InsertRow("Attachments", Coloumns1);

                        SqlDataSource1.DataBind();
                        GridView2.DataBind();
                    }
                }
                catch (Exception ex)
                {
                }
                Response.Redirect("MyHomeWorksdetails.aspx?id=" + HFid.Value + "&S=T");
            }
            else
            {
                LiMessage.Text = "<strong>" + DBop.NewConectionDLL.ErrorMessage + "</strong>  .";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
            }
        }
        protected void BuSearche_Click(object sender, EventArgs e)
        {

            String password = "******";
            string imgPath;
            try
            {
                password = Convert.ToString(Session["adminID"]) + StringGeneration.getString(30);
                imgPath = ("/attachments/"
                            + (password + Path.GetExtension(FileUpload1.PostedFile.FileName)));
                //  selct path before post back check nesa becose name file will dispose after poastback
                //   MsgBox(Server.MapPath(imgPath))
                FileUpload1.SaveAs(Server.MapPath(imgPath));
                ColoumnParam[] Coloumns1 = new ColoumnParam[5];
                Coloumns1[0] = new ColoumnParam("AttachmentTypeID", ColoumnType.Int, 2); // 1 for admin add news
                Coloumns1[1] = new ColoumnParam("AttachmentPath", ColoumnType.NVarChar, imgPath);
                Coloumns1[2] = new ColoumnParam("AttachmentDateIN", ColoumnType.DateTime, DateTime.Now.ToString());
                Coloumns1[3] = new ColoumnParam("AttachmentID", ColoumnType.Int, HiddenField1.Value);
                Coloumns1[4] = new ColoumnParam("AddedBy", ColoumnType.Int, Convert.ToString(Session["adminID"]));

                DBop.cobject.InsertRow("Attachments", Coloumns1);

                SqlDataSource1.DataBind();
                GridView2.DataBind();
            }
            catch (Exception ex)
            {

             
            }

 

            
        }
        protected void GridView3_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "GradeIt")
            {
                GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);


                HiddenField HFStudentID = (HiddenField)row.FindControl("HFStudentID");
                HiddenField HFSubmitHomeWorkID = (HiddenField)row.FindControl("HFSubmitHomeWorkID");
                TextBox txtGrade = (TextBox)row.FindControl("txtGrade");
                Label LaStudentEmail=(Label)row.FindControl("LaStudentEmail");
                TextBox txtAdminComment = (TextBox)row.FindControl("txtAdminComment");
                LinkButton LinkButton1 = (LinkButton)row.FindControl("LinkButton1");
              //  DateTime dt=Convert.ToDateTime( LinkButton1.Text);
               // string s = dt .ToString("yyyy-MM-dd-HH:mm:ss"); // String.Format("{yyyy-MM-dd h:mm:ss tt}", dt);
                ColoumnParam[] Coloumns1 = new ColoumnParam[2];
                Coloumns1[0] = new ColoumnParam("Grade", ColoumnType.Float, txtGrade.Text); // 1 for admin add home works
                Coloumns1[1] = new ColoumnParam("AdminComment", ColoumnType.NVarChar, txtAdminComment.Text);
                DBop.cobject.UpdateRow("StudentHomeWorkSubmit", Coloumns1, "SubmitHomeWorkID=" + HFSubmitHomeWorkID.Value  );

                GridView3.DataBind();

               // ntify student
                     Contacting sendwelcome = new Contacting();
                    string message = "عزيزي  </br>  تم تحديث درجتك  لواجب </br> ";
                    message = message + DDLHomeWorkID.SelectedItem.Text;
                    message = message + "</br>   الدرجة   " + txtGrade.Text + "</br>    التعليق  </br>  " + txtAdminComment.Text;
                    sendwelcome.SendWelcome(LaStudentEmail.Text, "تنبيه بخصوص الواجب", message);
                   
            }
            else if (e.CommandName == "DownloadIt")
            {
                
             GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);

                string filepath = ((HiddenField)row.FindControl("HFAttachmentPath")).Value;
                string downloadsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),"Downloads");
                 
                string fileName = filepath.Substring(("/attachments/").Length, (filepath.Length - ("/attachments/").Length));
                String[] splitd=fileName.Split('.');
                //byte[] fileBytes = System.IO.File.ReadAllBytes(splitd[1]);

                Response.ContentType = GetMimeTypeByFileName(splitd[1]);
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
                Response.TransmitFile(Server.MapPath("~"+filepath));
                Response.End();
            }
        }
        public ReturnError OpenAccount(string FullName, string UserName, String Password, Boolean AccountType, string EmailAdrress)
        {
            DBConnection DBop  = new DBConnection();
            ReturnError  error = new ReturnError();

            /// check if empty data
            if ((FullName.Length == 0) || (UserName.Length == 0) || (Password.Length == 0) || (EmailAdrress.Length == 0))
            {
                error.ErrorID      = 1;
                error.ErrorMessage = "please fill all your information";
                return(error);
            }

            /// check if this account avilable
            DataTable dataTable = new DataTable();

            dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * ", "UserName like '" + UserName + "' or EmailAdrress like '" + EmailAdrress + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                error.ErrorID      = 1;
                error.ErrorMessage = "the user name or email address already used by other account try with different email or user name";
                return(error);
            }

            /// save new account
            ///
            ColoumnParam[] Coloumns = new ColoumnParam[6];
            Coloumns[0] = new ColoumnParam("FullName", ColoumnType.varchar50, FullName);
            Coloumns[1] = new ColoumnParam("UserName", ColoumnType.varchar50, UserName);
            Coloumns[2] = new ColoumnParam("Password", ColoumnType.varchar50, Password);
            Coloumns[3] = new ColoumnParam("AccountType", ColoumnType.Bit, AccountType);
            Coloumns[4] = new ColoumnParam("DateRegister", ColoumnType.DateTime, DateTime.Now);
            Coloumns[5] = new ColoumnParam("EmailAdrress", ColoumnType.varchar50, EmailAdrress);
            if (DBop.NewConectionDLL.InsertRow("Admins", Coloumns))
            {
                dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * ", "UserName like '" + UserName + "'").Tables[0];

                //  dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * " ).Tables[0];
                /////send email to new account=========================================================
                // System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                // mail.To.Add(EmailAdrress);
                // mail.From = new MailAddress( "*****@*****.**" , "Email head", System.Text.Encoding.UTF8);
                // mail.Subject = "Complete your final steps with  my phone locations";
                //mail.SubjectEncoding = System.Text.Encoding.UTF8;
                //  for (int i = 0; i < dataTable.Rows.Count; i++) {
                try
                {
                    string smtpAddress = "mail.alrubaye.com";
                    int    portNumber  = 25;
                    bool   enableSSL   = false;

                    string emailFrom = "*****@*****.**";
                    string password  = "******";
                    string emailTo   = EmailAdrress;
                    string subject   = "Welcome in my phone location system";
                    string body      = "Thank you for using my phone locations system \n" + "  \n Your account  now ready to be used.  please setup this app from google play on your phone \n" + "https://play.google.com/store/apps/details?id=phonelocation.example.asuss550c.phonelocation" + "\nThen from setting login with your user name and password." + "And enjoy." + "Best regards,";

                    using (MailMessage mail = new MailMessage())
                    {
                        mail.From = new MailAddress(emailFrom);
                        mail.To.Add(emailTo);
                        mail.Subject    = subject;
                        mail.Body       = body;
                        mail.IsBodyHtml = true;
                        // Can set to false, if you are sending pure text.

                        //  mail.Attachments.Add(new Attachment("C:\\SomeFile.txt"));
                        //  mail.Attachments.Add(new Attachment("C:\\SomeZip.zip"));

                        using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
                        {
                            smtp.Credentials = new NetworkCredential(emailFrom, password);
                            smtp.EnableSsl   = enableSSL;
                            smtp.Send(mail);
                        }
                    }
                }
                catch (Exception ex) { }
                //} // for loop
                error.ErrorID      = 2;
                error.AdminID      = (int)dataTable.Rows[0]["UserID"];
                error.ErrorMessage = "Greate you insert new record";
                return(error);
            }
            else
            {
                error.ErrorID      = 1;
                error.ErrorMessage = "Error , cannot insert this record in the Database";
                return(error);
            }
        }
        protected void BuAddData_Click(object sender, EventArgs e)
        {
           
           
            string DatIN=DateTime.Now.ToString();
             
                ColoumnParam[] Coloumns = new ColoumnParam[8];
                Coloumns[0] = new ColoumnParam("HomeWorkTitle", ColoumnType.NVarChar, txtHomeWorkTitle.Text);
                Coloumns[1] = new ColoumnParam("HomeWorkDetails", ColoumnType.NVarChar, txtHomeWorkDetails.Text);
                Coloumns[2] = new ColoumnParam("Datein", ColoumnType.DateTime,DatIN);
                Coloumns[3] = new ColoumnParam("DeadLineDate", ColoumnType.DateTime, txtDeadLineDate.Text);
                Coloumns[4] = new ColoumnParam("AddedBy", ColoumnType.Int, Convert.ToString(Session["adminID"]));
                Coloumns[5] = new ColoumnParam("TutorialID", ColoumnType.Int, DDLAccounts.SelectedValue);
                Coloumns[6] = new ColoumnParam("Grade", ColoumnType.Float, txtGrade.Text);
                //string qul = Guid.NewGuid().ToString("N");
                Coloumns[7] = new ColoumnParam("HomeWorkUID", ColoumnType.uniqueidenifer, "Ignored");
                if (DBop.cobject.InsertRow("HomeWorks", Coloumns))
                {
                    //===================  // uplaod file to attach folder
                    DataTable dataTable = new DataTable();
                    dataTable = DBop.cobject.SelectDataSet("HomeWorks", "HomeWorkID", "Datein =(select max(Datein) FROM HomeWorks where  AddedBy= "  + Convert.ToString(Session["adminID"])+  ")  and AddedBy=" + Convert.ToString(Session["adminID"])).Tables[0];
                    int AttachmentID = Convert.ToInt32(dataTable.Rows[0]["HomeWorkID"]);
                    string imgPath;
                    String password = "******";
                    if (FileUpload1.HasFile) 
                    {
                        try
                        {

                            password = Convert.ToString(Session["adminID"]) + StringGeneration.getString(30);
                            imgPath = ("/attachments/"
                                        + (password + Path.GetExtension(FileUpload1.PostedFile.FileName)));
                            FileUpload1.SaveAs(Server.MapPath(imgPath));
                             ColoumnParam[] Coloumns1 = new ColoumnParam[5];
                             Coloumns1[0] = new ColoumnParam("AttachmentTypeID", ColoumnType.Int, 1); // 1 for admin add home works
                             Coloumns1[1] = new ColoumnParam("AttachmentPath", ColoumnType.NVarChar, imgPath);
                             Coloumns1[2] = new ColoumnParam("AttachmentDateIN", ColoumnType.DateTime, DateTime.Now.ToString());
                             Coloumns1[3] = new ColoumnParam("AttachmentID", ColoumnType.Int, AttachmentID);
                Coloumns1[4] = new ColoumnParam("AddedBy", ColoumnType.Int, Convert.ToString(Session["adminID"]));
                
                //Grade
                DBop.cobject.InsertRow("Attachments", Coloumns1);
                        }
                        catch (Exception ex)
                        {
                            //   MsgBox(ex.Message)
                            //imgPath = "/Images/AdminImage/defaultAdminImag.png";
                        }
                    }



                    Response.Redirect("ManageStudent.aspx?S=T");
                }
                else
                {
                    LiMessage.Text = "<strong>" + DBop.NewConectionDLL.ErrorMessage + "</strong>  .";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "ShowModalError();", true);
                }
                  
        }
        public ReturnError InsertPhoneNumberPrivicy( string PhoneMac, string PhoneNumber, Boolean IsVisabale)
        {
            DBConnection DBop = new DBConnection();
            ReturnError error = new ReturnError();

            /// check if this account avilable
            DataTable dataTable = new DataTable();
             
              
                dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " * ", "PhoneMac like '" + PhoneMac + "' and PhoneNumber like '" + PhoneNumber +"'").Tables[0];
                if ((dataTable != null) && (dataTable.Rows.Count > 0))
                {

                    ColoumnParam[] Coloumns = new ColoumnParam[1];
                    
                     Coloumns[0] = new ColoumnParam("IsVisabale", ColoumnType.Bit, IsVisabale);

                     if (DBop.NewConectionDLL.UpdateRow("AdminPhones", Coloumns, "PhoneMac like '" + PhoneMac + "' and PhoneNumber like '" + PhoneNumber + "'"))
                    {

                        error.ErrorID = 2;
                        error.ErrorMessage = "Greate you update the record";
                        return error;

                    }
                    else
                    {
                        error.ErrorID = 1;
                        error.ErrorMessage = "Error , cannot insert this record in the Database";
                        return error;
                    }

                }
                else
                {
                    error.ErrorID = 1;
                    error.ErrorMessage = "Error , this phone is not registared in database";
                    return error;
                }
 

          


        }