public void initManager() { MysqlUtil mysql = new MysqlUtil(); mysql.GetConnection(); var rdr = mysql.ReadData("SELECT * FROM manager;"); managerLinkLists = new LinkList <ManagerAccount>(); if (rdr.HasRows) { //managerLists = new List<ManagerAccount>(); while (rdr.Read()) { Console.WriteLine("{0} {1} {2} {3}", rdr.GetInt32(0), rdr.GetString(1), rdr.GetString(2), rdr.GetString(3)); ManagerAccount manager = new ManagerAccount(); manager.ID = rdr.GetInt32(0); manager.Username = rdr.GetString(1); manager.Password = rdr.GetString(2); manager.Level = rdr.GetInt32(3); //managerLists.Add(manager); managerLinkLists.Add(manager); } } mysql.Close(); }
/// <summary> /// 根据名称获取负责人 /// </summary> /// <param name="managerName"></param> /// <returns></returns> public ManagerAccount GetManagerByName(string managerName) { if (ManagerNameExists(managerName)) { Manager entity = ManagerRepository.GetManagerByName(managerName); var model = new ManagerAccount { ManagerId = entity.ManagerId, ManagerName = entity.ManagerName, ManagerEmail = entity.ManagerEmail, MobilePhone = entity.MobilePhone, IdCardNo = entity.IdCardNo, ChannelId = entity.ChannelId, ChannelName = entity.Channel.ChannelName, CityId = entity.CId, City = entity.City.Name, ProvinceId = entity.City.PId, CreatedTime = entity.CreatedTime, ModifiedTime = entity.ModifiedTime, IsActive = entity.IsActive }; return(model); } return(new ManagerAccount()); }
public ActionResult ProfileVendorOwner() { if (Session["vendorID"] == null) { return(RedirectToAction("Index", "Manager")); } int id = (int)Session["vendorID"]; List <ManagerAccount> vendors = new List <ManagerAccount>(); try { vendors = DatabaseService.DBGetList <ManagerAccount>("Account/VendorOwner"); vendors.RemoveAll(x => x == null); } catch (Exception e) { Console.WriteLine("Execute fail: " + e.Message.ToString()); } ManagerAccount f = null; for (int i = 0; i < vendors.Count; ++i) { ManagerAccount account = vendors.ElementAt(i); if (account.id == id) { f = account; } } ViewData["vendor"] = f; return(View()); }
/// <summary> /// Executes the plug-in. /// </summary> /// <param name="localContext">The <see cref="LocalPluginContext"/> which contains the /// <see cref="IPluginExecutionContext"/>, /// <see cref="IOrganizationService"/> /// and <see cref="ITracingService"/> /// </param> /// <remarks> /// For improved performance, Microsoft Dynamics CRM caches plug-in instances. /// The plug-in's Execute method should be written to be stateless as the constructor /// is not called for every invocation of the plug-in. Also, multiple system threads /// could execute the plug-in at the same time. All per invocation state information /// is stored in the context. This means that you should not use global variables in plug-ins. /// </remarks> protected void ExecuteAccountPostPlugin(LocalPluginContext localContext) { if (localContext == null) { throw new ArgumentNullException("localContext"); } var isUpdate = MatchesEventOperation(localContext, EventOperation.Update); var accountManager = new ManagerAccount( localContext.TracingService, localContext.PluginExecutionContext, localContext.OrganizationService, localContext.OrganizationAdminService); try { accountManager.FooPlugin(localContext.PluginExecutionContext.PrimaryEntityId, isUpdate); } catch (Exception ex) { throw new InvalidPluginExecutionException( HU.ErrorMessageWrapper(ex)); } }
protected override IModel CreateModel(SqlDataReader dr) { ManagerAccount managerAccount = new ManagerAccount(); int indexManagerId = dr.GetOrdinal("ManagerId"); managerAccount.ManagerId = Convert.ToInt32(dr[indexManagerId]); int indexManAccount = dr.GetOrdinal("ManAccount"); if (dr[indexManAccount] != DBNull.Value) { managerAccount.ManAccount = Convert.ToString(dr[indexManAccount]); } int indexManPassWord = dr.GetOrdinal("ManPassWord"); if (dr[indexManPassWord] != DBNull.Value) { managerAccount.ManPassWord = Convert.ToString(dr[indexManPassWord]); } int indexUserName = dr.GetOrdinal("UserName"); if (dr[indexUserName] != DBNull.Value) { managerAccount.UserName = Convert.ToString(dr[indexUserName]); } return(managerAccount); }
protected override void Execute(CodeActivityContext executionContext) { var traceService = executionContext.GetExtension <ITracingService>() as ITracingService; var workflowExecutionContext = executionContext.GetExtension <IWorkflowContext>() as IWorkflowContext; var factory = executionContext.GetExtension <IOrganizationServiceFactory>() as IOrganizationServiceFactory; var orgService = factory.CreateOrganizationService(workflowExecutionContext.UserId) as IOrganizationService; var orgAdminService = factory.CreateOrganizationService(null) as IOrganizationService; // Retrieve the id var accountId = this.inputEntity.Get(executionContext).Id; // Create a task entity var taskId = new ManagerAccount( traceService, workflowExecutionContext, orgService, orgAdminService).BarWorkflow(accountId); this.taskCreated.Set(executionContext, new EntityReference(Task.EntityLogicalName, taskId)); }
/// <summary> /// 修改负责人 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool EditManager(ManagerAccount model) { try { Manager entity = ManagerRepository.GetManagerById(model.ManagerId); if (entity == null) { return(false); } entity.ManagerName = model.ManagerName; entity.ManagerEmail = model.ManagerEmail; entity.MobilePhone = model.MobilePhone; entity.IdCardNo = model.IdCardNo; entity.ChannelId = model.ChannelId; entity.CId = model.CityId; entity.ModifiedTime = DateTime.Now; entity.IsActive = Convert.ToInt32(Enum.Parse(typeof(Status), model.IsActiveStr)); if (ManagerRepository.EditManager(entity) == 1) { return(true); } return(false); } catch (Exception) { return(false); } }
/// <summary> /// 根据用户ID获取负责人 /// </summary> /// <param name="managerId"></param> /// <returns></returns> public ManagerAccount GetManagerById(Int64 managerId) { if (ManagerIdExists(managerId)) { Manager entity = ManagerRepository.GetManagerById(managerId); var model = new ManagerAccount { ManagerId = entity.ManagerId, ManagerName = entity.ManagerName, ManagerEmail = entity.ManagerEmail, MobilePhone = entity.MobilePhone, IdCardNo = entity.IdCardNo, ChannelId = entity.ChannelId, ChannelName = entity.Channel.ChannelName, ChannelType = entity.Channel.ChannelType, ChannelTypeDesc = EnumHelper.GetDescription((ChannelType)(entity.Channel.ChannelType)), ChannelRank = entity.Channel.Rank, ChannelRankDesc = EnumHelper.GetDescription((ChannelRank)(entity.Channel.Rank)), CityId = entity.CId, City = entity.City.Name, ProvinceId = entity.City.PId, Province = RegionProvinceCityRepository.GetProvinceById(entity.City.PId).Name, CreatedTime = entity.CreatedTime, ModifiedTime = entity.ModifiedTime, IsActive = entity.IsActive, IsActiveDesc = EnumHelper.GetDescription((Status)(entity.IsActive)) }; return(model); } return(new ManagerAccount()); }
public void CreateAccount(ManagerAccount account) { using (var db = new LiteDatabase(CurrentDb)) { var col = db.GetCollection <ManagerAccount>("ManagerAccounts"); col.Insert(account); } }
public ActionResult EditManager(Int64 managerId) { ManagerAccount entity = ManagerAccountBll.GetManagerById(managerId); var typeSelectItems = new List <SelectListItem>(); typeSelectItems.AddRange(from object value in Enum.GetValues(typeof(ChannelType)) select new SelectListItem { Text = EnumHelper.GetDescription((ChannelType)(value)), Value = value.ToString(), Selected = false }); ViewData["ChannelType"] = typeSelectItems; var statusSelectItems = new List <SelectListItem>(); statusSelectItems.AddRange(from object value in Enum.GetValues(typeof(Status)) select new SelectListItem { Text = EnumHelper.GetDescription((Status)(value)), Value = value.ToString(), Selected = false }); ViewData["Status"] = statusSelectItems; var provinceList = RegionProvinceCityRepository.GetProvinceList(); var provSelectItems = new List <SelectListItem>(); provSelectItems.AddRange(from prov in provinceList select new SelectListItem { Text = prov.Name, Value = prov.PId.ToString(CultureInfo.InvariantCulture), Selected = false }); ViewData["ProvList"] = provSelectItems; var cityList = RegionProvinceCityRepository.GetCityListByProvId(entity.ProvinceId); var citySelectItems = new List <SelectListItem>(); citySelectItems.AddRange(from city in cityList select new SelectListItem { Text = city.Name, Value = city.CId.ToString(CultureInfo.InvariantCulture), Selected = false }); ViewData["CityList"] = citySelectItems; entity.ChannelTypeStr = Enum.Parse(typeof(ChannelType), (entity.ChannelType).ToString(CultureInfo.InvariantCulture)).ToString(); entity.IsActiveStr = Enum.Parse(typeof(Status), (entity.IsActive).ToString(CultureInfo.InvariantCulture)).ToString(); return(View(entity)); }
public void Register(string login, string password) { var hash = Encrypt(password); var account = new ManagerAccount { Id = Guid.NewGuid(), PasswordHash = hash, Login = login }; var service = ServiceCreator.GetRegistrationService(); service.CreateAccount(account); service.CreateConfig(account.Id); }
public bool ValiddatePermission(ManagerAccount account, string controller, string action, string filePath) { bool bResult = false; string actionName = string.IsNullOrEmpty(ActionName) ? action : ActionName; if (account != null) { List <GetPermissionCode> perm = null; // 测试当前controller是否已赋权限值,如果没有从 // 如果存在区域,Seesion保存(区域+控制器) if (!string.IsNullOrEmpty(_area)) { controller = _area + "/" + controller; } perm = (List <GetPermissionCode>)HttpContext.Current.Session[filePath]; if (perm == null) { using (var channelPermissionBll = new ChannelPermissionBll() { ChannelPermissionRepository = new ChannelPermissionRepository() }) { perm = channelPermissionBll.GetPermission(account.ManagerId, controller); // 获取当前用户的权限列表 HttpContext.Current.Session[filePath] = perm; // 获取的劝降放入会话由Controller调用 } //perm = ChannelPermissionBll.GetPermission(account.ManagerId, controller); //HttpContext.Current.Session[filePath] = perm; } // 当用户访问index时,只要权限大于0就可以访问 if (actionName.ToLower() == "index") { if (perm.Count > 0) { return(true); } } // 查询当前Action 是否有操作权限,大于0表示有,否则没有 int count = perm.Count(a => a.KeyCode.ToLower() == actionName.ToLower()); if (count > 0) { bResult = true; } else { bResult = false; HttpContext.Current.Response.Write("您没有操作权限!"); } } return(bResult); }
public void Setup() { conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection(); // подготовить свежие котировки QuoteMaker.FillQuoteStorageWithDefaultValues(); // словари TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock); ManagerTrade.MakeTestInstance(); testManager = ManagerAccount.Instance; // тестовые данные MakeTestData(); }
public JsonResult AccountPerfect(ManagerAccount model) { if (model != null && ModelState.IsValid) { if (ManagerAccountBll.AddManager(model, ref _errors)) { return(Json(JsonHandler.CreateMessage(1, Suggestion.AddChannelUserSuccess), JsonRequestBehavior.AllowGet)); } string err = _errors.Error; return(Json(JsonHandler.CreateMessage(0, Suggestion.AddChannelUserFailed + err), JsonRequestBehavior.AllowGet)); } return(Json(JsonHandler.CreateMessage(0, Suggestion.AddChannelUserFailed), JsonRequestBehavior.AllowGet)); }
public JsonResult AddManager(ManagerAccount model) { if (ManagerAccountBll.AddManager(model, ref _errors)) { return(new ToJsonResult { Data = 1, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } return(new ToJsonResult { Data = 0, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult EditManager(ManagerAccount model) { if (ManagerAccountBll.EditManager(model)) { return(new ToJsonResult { Data = 1, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } return(new ToJsonResult { Data = 0, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
/// <summary> /// 用户登录 /// </summary> /// <param name="account"></param> /// <param name="passWord"></param> /// <returns></returns> public ResultModel Login(string userName, string passWord) { ResultModel result = new ResultModel(); string cmdText = "select * from dbo.Sys_ManagerAccount where ManAccount =@manAccount and ManPassWord=@manPassWord"; SqlParameter[] paras = new SqlParameter[2]; SqlParameter para1 = new SqlParameter("@manAccount", userName); paras[0] = para1; SqlParameter para2 = new SqlParameter("@manPassWord", passWord); paras[1] = para2; ResultModel <ManagerAccount> resultAcc = this.Get <ManagerAccount>(CommandType.Text, cmdText, paras); if (resultAcc.ResultStatus == 0 && resultAcc.ReturnValue != null) { ManagerAccount account = resultAcc.ReturnValue; //EmployeeDal empDal = new EmployeeDal(); //ResultModel<Employee> resultEmp = empDal.Get<Employee>(ConfigValue.SysUser, account.EmpId); //Employee emp = resultEmp.ReturnValue; UserModel user = new UserModel(); user.AccountId = account.ManagerId; user.UserName = account.UserName; //user.EmpId = emp.EmpId; //user.EmpName = emp.Name; //user.DeptId = emp.DeptId; result.AffectCount = 0; result.Message = "登录成功"; result.ResultStatus = 0; result.ReturnValue = user; } else { result.ResultStatus = -1; result.Message = "用户名或密码错误"; result.ReturnValue = null; } return(result); }
public ManagerForm() { InitializeComponent(); Course customer = new Course(); List <string> list = new List <string>(); list = customer.getCoursePrice(); CorseList.DataSource = list; ManagerAccount accounting = new ManagerAccount(); List <string> accountingList = new List <string>(); accountingList = accounting.getStatus(); HallList.DataSource = accountingList; EmailLbl.Text = "*****@*****.**"; PhoneLbl.Text = "(984) 898-9080"; NameLbl.Text = "ALLA"; }
private ManagerAccount SetOneRow(SqlDataReader rd) { ManagerAccount account = new ManagerAccount(); if (rd["ManagerId"] != DBNull.Value) { account.ManagerId = int.Parse(rd["ManagerId"].ToString()); } account.ManAccount = rd["ManAccount"].ToString(); account.ManPassWord = rd["ManPassWord"].ToString(); account.UserName = rd["UserName"].ToString(); account.Depment = rd["Depment"].ToString(); if (rd["ManStatus"] != DBNull.Value) { account.ManStatus = int.Parse(rd["ManStatus"].ToString()); } return(account); }
public ActionResult DetailManager(Int64 managerId) { ManagerAccount entity = ManagerAccountBll.GetManagerById(managerId); var citySelectItems = new List <SelectListItem> { new SelectListItem { Text = entity.City, Value = entity.CityId.ToString(CultureInfo.InvariantCulture), Selected = true } }; ViewData["CityList"] = citySelectItems; var provSelectItems = new List <SelectListItem> { new SelectListItem { Text = entity.Province, Value = entity.ProvinceId.ToString(CultureInfo.InvariantCulture), Selected = true } }; ViewData["ProvList"] = provSelectItems; var statusSelectItems = new List <SelectListItem> { new SelectListItem { Text = EnumHelper.GetDescription((Status)(entity.IsActive)), Value = (entity.IsActive).ToString(CultureInfo.InvariantCulture), Selected = true } }; ViewData["Status"] = statusSelectItems; return(View(entity)); }
public JsonResult CheckValidUser(string username, string password) { string result = "Success"; ManagerAccount cur = new ManagerAccount(); try { cur = ManagerAccountService.CheckLogin(username, password); } catch (Exception e) { if (e.Message != null) { result = e.Message; } } ViewBag.currentAccount = cur; Session["vendorID"] = cur.id; return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult AccountLogin(Int64 memberNo) { JsonMessage msg = null; var manager = ManagerAccountBll.Login(memberNo); if (manager == null) { msg = new JsonMessage(false, Suggestion.LoginToProfile); return(Json(msg, JsonRequestBehavior.AllowGet)); } else { if (manager.IsActive == (int)Status.Pending) { msg = new JsonMessage(false, Suggestion.AccountPending); return(Json(msg, JsonRequestBehavior.AllowGet)); } else if (manager.IsActive == (int)Status.Disable) { msg = new JsonMessage(false, Suggestion.AccountDisabled); return(Json(msg, JsonRequestBehavior.AllowGet)); } else { var model = new ManagerAccount { ManagerId = manager.ManagerId, ManagerName = manager.ManagerName, ManagerEmail = manager.ManagerEmail, MobilePhone = manager.MobilePhone }; // 创建身份验证票证,即转换为"已登录状态" FormsAuthentication.SetAuthCookie(manager.ManagerName, false); Session["Account"] = model; msg = new JsonMessage(true, ""); return(Json(msg, JsonRequestBehavior.AllowGet)); } } }
private void bt_acc_add_Click(object sender, RoutedEventArgs e) { if (tbAcc.Text.Equals("") || tbPw.Text.Equals("") || tbLv.Text.Equals("")) { lbNotice.Content = "信息输入不完整!"; return; } try { Int32.Parse(tbLv.Text); } catch (FormatException error) { lbNotice.Content = "权限必须是数字!"; return; } MysqlUtil mysql = new MysqlUtil(); mysql.GetConnection(); if (mysql.InsertData("manager", "", tbAcc.Text, tbPw.Text, tbLv.Text) > 0) { //链表!! ManagerAccount manager = new ManagerAccount(); manager.ID = managerLinkLists.Length() + 1; manager.Username = tbAcc.Text; manager.Password = tbPw.Text; manager.Level = Int32.Parse(tbLv.Text); managerLinkLists.Add(manager); //链表!! lbNotice.Content = "添加成功。"; //initManager(); initListBox(); } else { lbNotice.Content = "添加失败。"; } mysql.Close(); }
public ManagerAccount Login(string account, string passWord) { string sql = string.Format(@"select * from Sys_ManagerAccount where ManAccount = @ManAccount and ManPassWord = @ManPassWord and ManStatus = {0}", (int)Common.StatusEnum.已完成); SqlParameter[] parmes = new[] { new SqlParameter("@ManAccount", SqlDbType.VarChar, 100), new SqlParameter("@ManPassWord", SqlDbType.VarChar, 100) }; parmes[0].Value = account; parmes[1].Value = passWord; ManagerAccount manAccount = null; using (SqlDataReader rd = SqlHelper.ExecuteReader(ConnectString, CommandType.Text, sql, parmes)) { while (rd.Read()) { manAccount = SetOneRow(rd); } } return(manAccount); }
public ActionResult AccountPerfect() { var model = new ManagerAccount(); if (Request.Cookies["memberNo"] != null) { //var statusSelectItems = new List<SelectListItem> //{ // new SelectListItem {Text = "请选择", Value = "-1", Selected = true} //}; //statusSelectItems.AddRange(from object value in Enum.GetValues(typeof (Status)) // select new SelectListItem // { // Text = EnumHelper.GetDescription((Status) (value)), // Value = value.ToString(), // Selected = false // }); var shareChannelSelectItems = new List <SelectListItem> { new SelectListItem { Text = EnumHelper.GetDescription(ChannelShare.ZhuGuan), Value = (ChannelShare.ZhuGuan).ToString(), Selected = true } }; ViewData["ShareChannel"] = shareChannelSelectItems; var statusSelectItems = new List <SelectListItem> { new SelectListItem { Text = EnumHelper.GetDescription(Status.Pending), Value = (Status.Pending).ToString(), Selected = true } }; ViewData["Status"] = statusSelectItems; var typeSelectItems = new List <SelectListItem> { new SelectListItem { Text = "请选择", Value = "-1", Selected = true } }; typeSelectItems.AddRange(from object value in Enum.GetValues(typeof(ChannelType)) select new SelectListItem { Text = EnumHelper.GetDescription((ChannelType)(value)), Value = value.ToString(), Selected = false }); ViewData["ChannelType"] = typeSelectItems; var provinceList = RegionProvinceCityRepository.GetProvinceList(); var provSelectItems = new List <SelectListItem> { new SelectListItem { Text = "请选择", Value = "-1", Selected = true } }; provSelectItems.AddRange(from prov in provinceList select new SelectListItem { Text = prov.Name, Value = prov.PId.ToString(CultureInfo.InvariantCulture), Selected = false }); ViewData["ProvList"] = provSelectItems; var cityList = RegionProvinceCityRepository.GetCityListByProvId(0); var citySelectItems = new List <SelectListItem> { new SelectListItem { Text = "请选择", Value = "-1", Selected = true } }; citySelectItems.AddRange(from city in cityList select new SelectListItem { Text = city.Name, Value = city.CId.ToString(CultureInfo.InvariantCulture), Selected = false }); ViewData["CityList"] = citySelectItems; var memberNoCookie = Request.Cookies["memberNo"].Value; var memberNo = Int64.Parse(memberNoCookie); var loginNameCookie = Request.Cookies["loginName"]; if (loginNameCookie != null) { var loginName = HttpUtility.UrlDecode(loginNameCookie.Value); model.ManagerEmail = loginName; } model.ManagerId = memberNo; return(View(model)); } return(View()); }
public void Exec(string SessionId) { Session session; if (Sessions.TryGetValue(SessionId, out session)) { // start switch validation thread ThreadPool.QueueUserWorkItem(o => { EvseSwitch.ISwitch evse; if (EvseSwitch.Switches.TryGetValue(session.evseid, out evse)) { while (session.IsActive()) { Console.WriteLine("Checking " + session.evseid + " status ..."); if (!(evse.IsOn())) { session.switchInterrupted = true; } Thread.Sleep(1500); } } }); // start approve validation thread ThreadPool.QueueUserWorkItem(o => { int checkcount = 0; bool @continue = true; while (@continue) { Indexer.Approve approve; if (Indexer.ApproveOps.TryGetValue(session.approveHash, out approve)) { @continue = false; if (approve.Status == "applied") { if (Int64.Parse(approve.Value) != session.amount) { session.approveState = Session.ApproveState.InvalidAmount; // TODO: should cancel approve } else if (approve.Spender != Env.PrivateKey.PubKey.Address) { session.approveState = Session.ApproveState.InvalidSpender; // Cannot cancel approve ... } else // Transaction approved { session.approveState = Session.ApproveState.Approved; }; } else { session.approveState = Session.ApproveState.NotApplied; // TODO: should cancel approve } } if (checkcount++ > Env.Timeout) { @continue = false; session.approveState = Session.ApproveState.TimeElapsed; } Thread.Sleep(1000); } }); bool @continue = true; while (@continue) { // compute continue if (session.userInterrupted || session.switchInterrupted) { if (session.chargeState == Session.ChargingState.On) { // Switch evse OFF SwitchEvseOff(session); session.chargeState = Session.ChargingState.Off; // compute amount to transfer ThreadPool.QueueUserWorkItem(o => { double duration = (DateTime.Now - session.startChargingDate).TotalSeconds; double ratio = duration / session.duration; long approveAmount = Convert.ToInt64(session.amount); long amount = (long)(ratio * approveAmount); amount = Math.Min(amount, approveAmount); Indexer.Evse evse; if (Indexer.Evses.TryGetValue(session.evseid, out evse)) { ManagerAccount.Add(session, session.userAddress, evse.Owner, amount); } else { Console.WriteLine("ANOMALY! evse not found"); } }); } session.sessionState = Session.SessionState.Success; @continue = false; } else if (session.IsInvalidApprove()) { if (session.chargeState == Session.ChargingState.On) { // Switch evse OFF SwitchEvseOff(session); session.chargeState = Session.ChargingState.Off; } session.sessionState = Session.SessionState.Failed; @continue = false; } else if (session.chargeState == Session.ChargingState.FailedOn) { session.sessionState = Session.SessionState.Failed; @continue = false; } else if (session.chargeState == Session.ChargingState.On) { // is charging session over? double duration = (DateTime.Now - session.startChargingDate).TotalSeconds; if (duration >= session.duration) { @continue = false; // Switch evse OFF SwitchEvseOff(session); session.chargeState = Session.ChargingState.Off; session.sessionState = Session.SessionState.Success; // Originate transfer transaction ThreadPool.QueueUserWorkItem(o => { Indexer.Evse evse; bool continue_wait_approve = true; while (continue_wait_approve) { if (session.IsValidApprove()) { continue_wait_approve = false; if (Indexer.Evses.TryGetValue(session.evseid, out evse)) { ManagerAccount.Add(session, session.userAddress, evse.Owner, Convert.ToInt64(session.amount)); } else { Console.WriteLine("ANOMALY! evse not found"); } } else if (session.IsInvalidApprove()) { continue_wait_approve = false; } Thread.Sleep(1000); } }); } } Thread.Sleep(2000); } } else { Console.WriteLine("Error : session not found " + SessionId); } }
/// <summary> /// 添加负责人 /// </summary> /// <param name="model"></param> /// <param name="errors"></param> /// <returns></returns> public bool AddManager(ManagerAccount model, ref ValidationErrors errors) { try { Manager entity = ManagerRepository.GetManagerById(model.ManagerId); int channelType = Convert.ToInt32(Enum.Parse(typeof(ChannelType), model.ChannelTypeStr)); if (entity != null) { errors.Add(Suggestion.ExistUser); return(false); } if (channelType != 4) { entity = new Manager { ManagerId = model.ManagerId, ManagerName = model.ManagerName, ManagerEmail = model.ManagerEmail, MobilePhone = model.MobilePhone, IdCardNo = model.IdCardNo, ChannelType = Convert.ToInt32(Enum.Parse(typeof(ChannelType), model.ChannelTypeStr)), ChannelId = model.ChannelId, ShareChannelId = 1, CId = model.CityId, CreatedTime = DateTime.Now, ModifiedTime = null, IsActive = Convert.ToInt32(Enum.Parse(typeof(Status), model.IsActiveStr)) }; if (ManagerRepository.AddManager(entity) == 1) { return(true); } errors.Add(Suggestion.AddNotShareUserFailed); return(false); } else { var shareChannel = new ShareChannel { ShareChannelId = model.ManagerId, ChannelName = model.ShareChannelName + "-" + model.ManagerId, Rank = 1, ChannelType = Convert.ToInt32(Enum.Parse(typeof(ChannelType), model.ChannelTypeStr)), ParentId = 1, Sort = 1, CreatedTime = DateTime.Now, ModifiedTime = null, IsActive = 1 }; //var flag = ShareChannelRepository.AddShareChannel(shareChannel); //var flag = ShareChannelRepository.AddShareChannelByfk("ShareChannel", shareChannel); //if (flag > 0) //{ entity = new Manager { ManagerId = model.ManagerId, ManagerName = model.ManagerName, ManagerEmail = model.ManagerEmail, MobilePhone = model.MobilePhone, IdCardNo = model.IdCardNo, ChannelType = Convert.ToInt32(Enum.Parse(typeof(ChannelType), model.ChannelTypeStr)), ChannelId = 1, ShareChannel = shareChannel, CId = model.CityId, CreatedTime = DateTime.Now, ModifiedTime = null, IsActive = Convert.ToInt32(Enum.Parse(typeof(Status), model.IsActiveStr)) }; var flag = ManagerRepository.AddManager(entity); //var flag = ManagerRepository.AddManagerByfk("Managers", entity); if (flag > 0) { return(true); } errors.Add(Suggestion.AddShareUserFailed); return(false); //} //errors.Add(Suggestion.AddShareUserChannelFailed); //return false; } } catch (Exception ex) { errors.Add(ex.Message); return(false); } }