コード例 #1
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;
            }


        }
コード例 #2
0
        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;
            }


        }
コード例 #3
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;
            }
        }
コード例 #4
0
        public ReturnError IsExisitAccount(string UserName, string Password)
        {
            DBConnection DBop = new DBConnection();
            ReturnError error = new ReturnError();

            /// check if this account avilable
            DataTable dataTable = new DataTable();
            dataTable = DBop.NewConectionDLL.SelectDataSet("Admins", " * ", "UserName like '" + UserName + "' AND Password like '" + Password + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                error.ErrorID = 2;
                error.AdminID = (int)dataTable.Rows[0]["UserID"];
                error.ErrorMessage = "Greate we find  record";
                return error;
            }


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


        }
コード例 #5
0
        public ReturnError ReturnLastLocationPN(string PhoneNumber)
        {
            DBConnection DBop = new DBConnection();
            ReturnError error = new ReturnError();

            string[] Phones = PhoneNumber.Split(':');
          
            for (int k = 0; k < Phones.Length - 1; k++)
            {
                /// check if this account avilable
                DataTable dataTable = new DataTable();
              
                dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " * ", "PhoneNumber like '%" + Phones[k] + "' and IsVisabale=1").Tables[0];
                if ((dataTable != null) && (dataTable.Rows.Count > 0))
                {
                    int PhoneID = (int)dataTable.Rows[0]["PhoneID"];

                    dataTable = DBop.NewConectionDLL.SelectDataSet("Tracking", " * ", "PhoneID=" + PhoneID + " and DateRecord=( select max(DateRecord) from Tracking where PhoneID=" + PhoneID + ")").Tables[0];
                    if ((dataTable != null) && (dataTable.Rows.Count > 0))
                    {
                          
                            error.ErrorMessage = error.ErrorMessage + ":" + Phones[k];
                          
                    }



                }

            } // for for
            if (error.ErrorMessage != null)
            {
               // error.myTrack = mytrack1;
                error.ErrorID = 2;
               // error.ErrorMessage = "Greate you find record";
                return error;
            }
            else
            {
                error.ErrorID = 1;
                error.ErrorMessage = "Error ,we cannot find any  friend for this phone";
                return error;
            }

        }
コード例 #6
0
        public ReturnError ReturnLastLocationPNOne(string PhoneNumber)
        {
            DBConnection DBop = new DBConnection();
            ReturnError error = new ReturnError();

            /// check if this account avilable
            DataTable dataTable = new DataTable();
            dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " * ", "PhoneNumber like '%" + PhoneNumber + "' and IsVisabale=1").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                int PhoneID = (int)dataTable.Rows[0]["PhoneID"];
                
                dataTable = DBop.NewConectionDLL.SelectDataSet("Tracking", " * ", "PhoneID=" + PhoneID + " and DateRecord=( select max(DateRecord) from Tracking where PhoneID=" + PhoneID + ")").Tables[0];
                if ((dataTable != null) && (dataTable.Rows.Count > 0))
                {

                    error.ErrorMessage = dataTable.Rows[0]["Latitude"].ToString() + ":" + dataTable.Rows[0]["longitude"].ToString() + ":" + dataTable.Rows[0]["DateRecord"].ToString();
                    error.ErrorID = 2;
                   // error.ErrorMessage = "Greate you find record";
                    return error;

                }
                else
                {
                    error.ErrorID = 1;
                    error.ErrorMessage = "Error , cannot Find Records in this date Range";
                    return error;
                }


            }
            else
            {
                error.ErrorID = 1;
                error.ErrorMessage = "You Cannot access to this person location. may be he dont allow you to see his location or he didnot install (my phone locations)";
                return error;
            }


        }
コード例 #7
0
        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;
                }
 

          


        }
コード例 #8
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];

              //  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;
            }


        }