private bool GetChannel(string LockIDStr) { //ConnectionStringSettings CloudLockConnectString = ConfigurationManager.ConnectionStrings["CloudLockConnectString"]; //LockManager MyLockManager = new LockManager(CloudLockConnectString.ConnectionString); LockManager MyLockManager = new LockManager(); Lock MyLock = null; Channel MyChannel = null; //MyLock = MyLockManager.FindLock(LockIDStr); MyLock = MyLockManager.FindLock(LockIDStr); if (MyLock == null) { return(false); } else { if (MyLock.Status == 3) { //ChannelManager MyChannelManager = new ChannelManager(CloudLockConnectString.ConnectionString); //MyChannel = MyChannelManager.FindChannel(LockIDStr); ChannelManager MyChannelManager = new ChannelManager(); MyChannel = MyChannelManager.FindChannel(LockIDStr); if (MyChannel == null) { return(false); } else { MyFindMobileIDStr = MyChannel.MobileID; return(true); } } else { return(false); } } //---------------------------------------------------------- }
protected void CustomerCreateManagerment(string CustomerInforStr, SocketServiceReadWriteChannel InputSocketServiceReadWriteChannel) { string ReplyCommandMessageStr = "customercreate"; //----1------------------------------------------------------------------------------------------------ string ActionID = CustomerInforStr.Substring(0, CustomerInforStr.IndexOf(":")); if (ActionID == "authenlockid") { int IndexStart = CustomerInforStr.IndexOf(":") + 1; string LockID = CustomerInforStr.Substring(IndexStart, CustomerInforStr.IndexOf("-") - IndexStart); LockManager MyLockManager = new LockManager(); Lock MyLock = MyLockManager.FindLock(LockID); if (MyLock == null) { //MessageBox.Show("此锁ID号不存在!"); ReplyCommandMessageStr = string.Format(ReplyCommandMessageStr + "#false[110]!"); } if (MyLock.Status != 2) { //MessageBox.Show("此锁ID号不没有出售或授权!"); ReplyCommandMessageStr = string.Format(ReplyCommandMessageStr + "#false[120]!"); } else { string TempStr = CustomerInforStr.Substring(CustomerInforStr.IndexOf("-") + 1); string RegsisterCode = TempStr;//循环截取 RegisterCodeCRUD MyRegisterCodeCRUD = new RegisterCodeCRUD(); RegisterCode MyRegisterCode = MyRegisterCodeCRUD.FindRegisterCode(LockID); if (MyRegisterCode == null) { //MessageBox.Show("此注册号码不存在!"); ReplyCommandMessageStr = string.Format(ReplyCommandMessageStr + "#false[130]!"); } if (MyRegisterCode.RegisterCodeStr != RegsisterCode) { //MessageBox.Show("此注册号码有错误!"); ReplyCommandMessageStr = string.Format(ReplyCommandMessageStr + "#false[140]!"); } else { ReplyCommandMessageStr = string.Format(ReplyCommandMessageStr + "#true[0]!"); } } } if (ActionID == "authenloginid") { int IndexStart = CustomerInforStr.IndexOf(":") + 1; string LockID = CustomerInforStr.Substring(IndexStart, CustomerInforStr.IndexOf("-") - IndexStart); string TempStr = CustomerInforStr.Substring(CustomerInforStr.IndexOf("-") + 1); string CustomerLoginID = TempStr;//循环截取 CustomerManager MyCustomerManager = new CustomerManager(); Customer MyCustomer = MyCustomerManager.FindCustomer(CustomerLoginID); if (MyCustomer != null) { //已经注册; ReplyCommandMessageStr = string.Format(ReplyCommandMessageStr + "#false[210]!"); } else { //还没有注册; ReplyCommandMessageStr = string.Format(ReplyCommandMessageStr + "#true[0]!"); } } if (ActionID == "createcustomer") { int IndexStart = CustomerInforStr.IndexOf(":") + 1; string LockID = CustomerInforStr.Substring(IndexStart, CustomerInforStr.IndexOf(",") - IndexStart); IndexStart = CustomerInforStr.IndexOf(",") + 1; string TempStr = CustomerInforStr.Substring(IndexStart); string RegsisterCode = TempStr.Substring(0, TempStr.IndexOf(",")); //循环截取 IndexStart = TempStr.IndexOf(",") + 1; TempStr = TempStr.Substring(IndexStart); string CustomerName = TempStr.Substring(0, TempStr.IndexOf(",")); //循环截取 IndexStart = TempStr.IndexOf(",") + 1; TempStr = TempStr.Substring(IndexStart); string LoginName = TempStr.Substring(0, TempStr.IndexOf(",")); //循环截取 IndexStart = TempStr.IndexOf(",") + 1; TempStr = TempStr.Substring(IndexStart); string PassWord = TempStr.Substring(0, TempStr.IndexOf(",")); //循环截取 IndexStart = TempStr.IndexOf(",") + 1; TempStr = TempStr.Substring(IndexStart); string PersonID = TempStr.Substring(0, TempStr.IndexOf(",")); //循环截取 IndexStart = TempStr.IndexOf(",") + 1; TempStr = TempStr.Substring(IndexStart); string TeleCode = TempStr.Substring(0, TempStr.IndexOf(",")); //循环截取 IndexStart = TempStr.IndexOf(",") + 1; TempStr = TempStr.Substring(IndexStart); string EMail = TempStr.Substring(0, TempStr.IndexOf(",")); //循环截取 IndexStart = TempStr.IndexOf(",") + 1; TempStr = TempStr.Substring(IndexStart); string Address = TempStr; //最后截取 Channel MyChannel; MyChannel = new Channel(); MyChannel.LockID = LockID; MyChannel.RegisterCodeStr = RegsisterCode; Customer MyNewCustomer = new Customer();; MyNewCustomer.CustomerName = CustomerName; MyNewCustomer.LoginName = LoginName; MyNewCustomer.PersonID = PersonID; MyNewCustomer.TeleCode = TeleCode; MyNewCustomer.Password = PassWord; MyNewCustomer.EMail = EMail; MyNewCustomer.Address = Address; CustomerManager MyCustomerManager = new CustomerManager(); string MobileID = MyCustomerManager.InsertCustomerExxx(MyNewCustomer, MyChannel); if (MobileID != null) { Customer MyCustomer; MyCustomer = MyCustomerManager.FindCustomerEx(MobileID); if (MyCustomer != null) { // 注册操作成功,客户ID:" + MyCustomer.CustomerID + " ,云锁ID:" + MyChannel.LockID + ", 移动端ID:" + MobileID + "\r\n"); ReplyCommandMessageStr = string.Format(ReplyCommandMessageStr + "#true[{0}]!", MyCustomer.CustomerID + "," + MyChannel.LockID + "," + MobileID); } else { //注册操作失败!; ReplyCommandMessageStr = string.Format(ReplyCommandMessageStr + "#false[310]!"); } } else { //注册操作失败!; ReplyCommandMessageStr = string.Format(ReplyCommandMessageStr + "#false[320]!"); } } //----2.Reply----------------------------------------------------------------------------- ResponseToSynchClient(InputSocketServiceReadWriteChannel, ReplyCommandMessageStr); }