/// <summary> /// 添加 /// </summary> /// <param name="userModel"></param> /// <param name="model"></param> /// <returns></returns> public virtual bool AddCurrency(UserModel userModel, Currency model) { model.CurrencyId = SeqGuid.NewGuid(); model.CreateDate = DateTime.Now; Da.Add <Guid, Currency>(model); return(true); }
/// <summary> /// 添加 /// </summary> /// <param name="userModel"></param> /// <param name="model"></param> /// <returns></returns> public virtual bool AddUserRole(UserModel userModel, UserRole model) { model.UserRoleId = SeqGuid.NewGuid(); model.CreateDate = DateTime.Now; Da.Add <Guid, UserRole>(model); return(true); }
public DeviceTappedCommand(Guid accountId, string location, string mode) { AccountId = accountId; Location = location; Mode = mode; CorrelationId = SeqGuid.NewGuid(); }
/// <summary> /// 添加 /// </summary> /// <param name="userModel"></param> /// <param name="model"></param> /// <returns></returns> public virtual bool AddAccount(UserModel userModel, Account model) { model.AccountId = SeqGuid.NewGuid(); model.CreateDate = DateTime.Now; Da.Add <Guid, Account>(model); return(true); }
/// <summary> /// 添加 /// </summary> /// <param name="userModel"></param> /// <param name="model"></param> /// <returns></returns> public virtual bool AddBuySupplier(UserModel userModel, BuySupplier model) { model.UserId = userModel.UserId; model.BuySupplierId = SeqGuid.NewGuid(); model.CreateDate = DateTime.Now; Da.Add <Guid, BuySupplier>(model); return(true); }
/// <summary> /// 添加 /// </summary> /// <param name="userModel"></param> /// <param name="model"></param> /// <returns></returns> public virtual bool AddSaleOrderProduct(UserModel userModel, SaleOrderProduct model) { model.UserId = userModel.UserId; model.SaleOrderProductId = SeqGuid.NewGuid(); model.CreateDate = DateTime.Now; Da.Add <Guid, SaleOrderProduct>(model); return(true); }
/// <summary> /// 添加 /// </summary> /// <param name="model"></param> /// <returns></returns> public virtual bool AddFriendLink(FriendLink model) { model.FriendLinkId = SeqGuid.NewGuid(); model.IsEnabled = true; model.CreateDate = DateTime.Now; Da.Add <Guid, FriendLink>(model); return(true); }
/// <summary> /// Creates a references associated to a given reference id. /// </summary> public Reference(Guid referenceId, string link, string description = null) { this.Id = SeqGuid.Create(); this.ReferenceId = referenceId; this.Link = link; this.Description = description ?? ""; }
public dynamic Insert <T>(IDbConnection connection, T entity, IDbTransaction transaction, int?commandTimeout) where T : class { var classMap = SqlGenerator.Configuration.GetMap <T>(); var nonIdentityKeyProperties = classMap.LinqPropertyMaps.Where(p => p.KeyType == KeyType.Guid || p.KeyType == KeyType.Assigned) .ToList(); var identityColumn = classMap.LinqPropertyMaps.SingleOrDefault(p => p.KeyType == KeyType.Identity); foreach (var column in nonIdentityKeyProperties) { if (column.KeyType == KeyType.Guid) { var comb = SeqGuid.Create(); column.PropertyInfo.SetValue(entity, comb, null); } } IDictionary <string, object> keyValues = new ExpandoObject(); var sql = SqlGenerator.Insert(classMap); if (identityColumn != null) { IEnumerable <long> result; if (SqlGenerator.SupportsMultipleStatements()) { sql += SqlGenerator.Configuration.Dialect.BatchSeperator + SqlGenerator.IdentitySql(classMap); result = connection.Query <long>(sql, entity, transaction, false, commandTimeout, CommandType.Text); } else { connection.Execute(sql, entity, transaction, commandTimeout, CommandType.Text); sql = SqlGenerator.IdentitySql(classMap); result = connection.Query <long>(sql, entity, transaction, false, commandTimeout, CommandType.Text); } var identityValue = result.First(); var identityInt = Convert.ToInt32(identityValue); keyValues.Add(identityColumn.PropertyInfo.Name, identityInt); identityColumn.PropertyInfo.SetValue(entity, identityInt, null); } else { connection.Execute(sql, entity, transaction, commandTimeout, CommandType.Text); } foreach (var column in nonIdentityKeyProperties) { keyValues.Add(column.PropertyInfo.Name, column.PropertyInfo.GetValue(entity, null)); } if (keyValues.Count == 1) { return(keyValues.First().Value); } return(keyValues); }
/// <summary> /// Creates a new instance. /// </summary> public ApplicationAccess(StakeholderLogin login) { Guard.ArgumentNotNull(login, nameof(login)); this.DateLastModified = DateTime.UtcNow; this.UserName = ""; this.StakeholderLoginId = login.Id; this.Id = SeqGuid.Create(); }
public Guid?AddUser(User model) { model.UserId = SeqGuid.NewGuid(); model.UserPwd = model.UserPwd.ToMd5(); model.Status = (int)UserStatusEnum.Ok; model.IsAdmin = false; model.CreateDate = DateTime.Now; return(Da.AddUser(model)); }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="name">The name of the scenario.</param> /// <param name="description">A description of the scenario.</param> /// <param name="externalId">External id.</param> public Scenario(string name, string description, string externalId) { Id = SeqGuid.Create(); // todo: replace with combguid or snowflake DisplayName = name; Description = description; ExternalId = externalId ?? ""; DateCreated = DateTime.UtcNow; DateLastModified = DateCreated; }
public UserGroup(string displayName, string description) { this.Id = SeqGuid.Create(); this.DisplayName = displayName; this.Description = description ?? ""; this.DateLastModified = DateTime.UtcNow; this.DateCreated = DateLastModified; this.UserName = ""; }
/// <summary> /// Creates a new instance with a given display name and description. /// </summary> /// <param name="displayName">The display name of the domain.</param> /// <param name="description">The description of the domain.</param> public DesignDomain(string displayName, string description = null) { Guard.ArgumentNotNullOrEmptyOrWhiteSpace(displayName, nameof(displayName)); Id = SeqGuid.Create(); DateCreated = DateTime.UtcNow; DisplayName = displayName; Description = description ?? ""; }
/// <summary> /// 添加 /// </summary> /// <param name="userModel"></param> /// <param name="model"></param> /// <param name="msg"></param> /// <returns></returns> public virtual bool AddBuyPay(UserModel userModel, BuyPay model, out string msg) { var order = Da.Get <BuyOrder>(model.BuyOrderId); var b1 = CheckAuthOrder(userModel, order, out msg); if (!b1) { return(false); } var b2 = CheckAuthFinanceOrder(userModel, order, out msg); if (!b2) { return(false); } var account = Da.Get <Account>(model.AccountId); var b3 = CheckAuthAccount(userModel, account, out msg); if (!b3) { return(false); } var currency = Da.Get <Currency>(model.CurrencyId); var b4 = CheckAuthCurrency(userModel, currency, out msg); if (!b4) { return(false); } var m = new BuyPay() { BuyPayId = SeqGuid.NewGuid(), BuyOrderId = model.BuyOrderId, AccountInfo = $"{account.AccountBank}({account.AccountNumber})", Amount = model.Amount, CurrencySymbol = currency.CurrencySymbol, CurrencyRate = currency.CurrencyRate, TransactionNumber = model.TransactionNumber, Remark = model.Remark, CreateName = userModel.UserNickName, CreateDate = DateTime.Now, AccountId = account.AccountId, CurrencyId = currency.CurrencyId, }; Da.Add <Guid, BuyPay>(m); return(true); }
/// <summary> /// 添加 /// </summary> /// <param name="userModel"></param> /// <param name="model"></param> /// <param name="msg"></param> /// <returns></returns> public virtual bool AddSaleTrack(UserModel userModel, SaleTrack model, out string msg) { var order = Da.Get <SaleOrder>(model.SaleOrderId); var b1 = CheckAuthOrder(userModel, order, out msg); if (!b1) { return(false); } var status = new List <int>() { (int)SaleOrderStatusEnum.StockedAfterPay, (int)SaleOrderStatusEnum.StockedPay, (int)SaleOrderStatusEnum.ShipedAfterPay, (int)SaleOrderStatusEnum.ShipedPay, }; if (!status.Contains(order.Status)) { msg = "状态已改变,操作失败"; return(false); } var currency = Da.Get <Currency>(model.CurrencyId); var b2 = CheckAuthCurrency(userModel, currency, out msg); if (!b2) { return(false); } var m = new SaleTrack() { SaleTrackId = SeqGuid.NewGuid(), SaleOrderId = model.SaleOrderId, TrackName = model.TrackName, TrackNumber = model.TrackNumber, TrackRemark = model.TrackRemark, Feight = model.Feight, CurrencyId = currency.CurrencyId, CurrencyName = currency.CurrencyName, CurrencyText = currency.CurrencyText, CurrencySymbol = currency.CurrencySymbol, CurrencyRate = currency.CurrencyRate, CreateName = userModel.UserNickName, CreateDate = DateTime.Now, }; Da.Add <Guid, SaleTrack>(m); return(true); }
/// <summary> /// Creates a new instance with a given name, description and external id. /// </summary> public DeviceConnection(string displayName, string description = null) { Id = SeqGuid.Create(); ExternalId = ""; DisplayName = displayName ?? ""; Description = description ?? ""; DateCreated = DateTime.UtcNow; DateAdded = DateCreated; DateLastModified = DateCreated; UserName = ""; TargetAddress = ""; }
/// <summary> /// Creates a device model dependency to a given software model. /// </summary> /// <param name="softwareModel"></param> /// <param name="displayName">The display name of the dependency.</param> /// <param name="description">An optional description of the dependency.</param> /// <param name="deviceModel"></param> public DeviceModelDependency(DeviceModel deviceModel, SoftwareModel softwareModel, string displayName, string description) { Guard.ArgumentNotNull(deviceModel, nameof(deviceModel)); Guard.ArgumentNotNull(softwareModel, nameof(softwareModel)); this.Id = SeqGuid.Create(); this.ScenarioId = deviceModel.ScenarioId; this.DeviceModelId = deviceModel.Id; this.SoftwareModelDependencyId = softwareModel.Id; this.DisplayName = displayName ?? $"Dependency to '{softwareModel.DisplayName}'"; this.Description = description ?? ""; this.DateCreated = DateTime.UtcNow; }
/// <summary> /// Creates a new instance with a given display name and description. /// </summary> public BusinessUnit(string externalId, string name, string description, string currency = "USD") { Guard.ArgumentNotNullOrEmpty(externalId, nameof(externalId)); Id = SeqGuid.Create(); ExternalId = externalId; Currency = currency ?? ""; DateActive = DateTime.UtcNow; DateLastModified = DateActive; Description = description; DisplayName = name; }
/// <summary> /// Creates a new instance. /// </summary> public SoftwareModelInterface(SoftwareModel model, string externalId, string displayName, string description = null) { Guard.ArgumentNotNull(model, nameof(model)); this.Id = SeqGuid.Create(); this.ExternalId = externalId; this.DisplayName = displayName; this.DateCreated = DateTime.UtcNow; this.Description = description ?? ""; this.ScenarioId = model.ScenarioId; this.SoftwareModelId = model.Id; this.UserName = ""; }
/// <summary> /// Creates a new instance with a given display name and description. /// </summary> public Project(string externalId, string displayName, string description, string currency = "USD") { Guard.ArgumentNotNullOrEmpty(externalId, nameof(externalId)); this.Id = SeqGuid.Create(); this.DisplayName = displayName ?? ""; this.Description = description ?? ""; this.ExternalId = externalId ?? ""; this.Currency = currency; this.DateCreated = DateTime.UtcNow; this.DateLastModified = this.DateCreated; this.StartDate = this.DateCreated; }
public void CreateGenerateHtml() { //生成首页 Da.Add <Guid, GenerateHtml>(new GenerateHtml() { GenerateHtmlId = SeqGuid.NewGuid(), GenerateHtmlUrl = $"{Config.Domain}/Home/Index?ver={DateTime.Now.Ticks}&allow=true", GenerateHtmlPath = $"{AppDomain.CurrentDomain.BaseDirectory}index.html", IsGenerate = false, IsSuccess = false }); Task.Run(() => GenerateHtml()); }
/// <summary> /// Creates a new instance with a given display name and description. /// </summary> public Policy(string externalId, string displayName, string description) { Guard.ArgumentNotNullOrEmptyOrWhiteSpace(externalId, nameof(externalId)); Guard.ArgumentNotNullOrEmptyOrWhiteSpace(displayName, nameof(displayName)); this.Id = SeqGuid.Create(); this.DisplayName = displayName ?? ""; this.Description = description ?? ""; this.ExternalId = externalId ?? ""; this.DateAdded = DateTime.UtcNow; this.DateLastModified = this.DateAdded; this.UserName = ""; }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="device">Gets the device the login or group has access to.</param> /// <param name="deviceModelDependency">Gets the application/device model the login has access to.</param> /// <param name="group"></param> public ApplicationAccess(Device device, DeviceModelDependency deviceModelDependency, UserGroup group) { Guard.ArgumentNotNull(device, nameof(device)); Guard.ArgumentNotNull(deviceModelDependency, nameof(deviceModelDependency)); Guard.ArgumentNotNull(group, nameof(group)); this.DeviceId = device.Id; this.DeviceModelDependencyId = deviceModelDependency.Id; this.UserGroupId = group.Id; this.DateLastModified = DateTime.UtcNow; this.UserName = ""; this.Id = SeqGuid.Create(); }
/// <summary> /// Creates a new instance with a given name, description and external id. /// </summary> public Device(Network network, string name, string description, string externalId) { Guard.ArgumentNotNull(network, nameof(network)); this.Id = SeqGuid.Create(); this.DisplayName = name ?? ""; this.ScenarioId = network.ScenarioId; this.NetworkId = network.Id; this.Description = description ?? ""; this.DateAdded = DateTime.UtcNow; this.AvailabilityTier = ""; // bronze etc this.ExternalId = externalId ?? ""; this.Attributes = new List <Item>(); }
/// <summary> /// 添加款项 /// </summary> /// <param name="userModel"></param> /// <param name="request"></param> /// <param name="msg"></param> /// <returns></returns> public bool AddSaleOrderReceive(UserModel userModel, SaleReceive request, out string msg) { var order = Da.Get <SaleOrder>(request.SaleOrderId); var b1 = CheckAuthOrder(userModel, order, out msg); if (!b1) { return(false); } if (order.Status == (int)SaleOrderStatusEnum.Draft || order.Status == (int)SaleOrderStatusEnum.ShipedPay) { msg = "添加失败"; return(false); } var currency = Da.Get <Currency>(request.CurrencyId); var b2 = CheckAuthCurrency(userModel, currency, out msg); if (!b2) { return(false); } var accout = Da.Get <Account>(request.AccountId); var b3 = CheckAuthAccount(userModel, accout, out msg); if (!b3) { return(false); } var m = new SaleReceive() { SaleReceiveId = SeqGuid.NewGuid(), SaleOrderId = order.SaleOrderId, AccountInfo = $"{accout.AccountBank}[{accout.AccountNumber}]", Amount = request.Amount, CurrencySymbol = currency.CurrencySymbol, CurrencyRate = currency.CurrencyRate, Remark = null, CreateName = userModel.UserNickName, CreateDate = DateTime.Now, }; Da.Add <Guid, SaleReceive>(m); return(true); }
/// <summary> /// Creates a new instance associated with a given architectural artefact, display name and/or description. /// </summary> public Capability(SoftwareModel softwareModel, string externalId, string displayName, string description = null) { Guard.ArgumentNotNull(softwareModel, nameof(softwareModel)); Guard.ArgumentNotNullOrEmptyOrWhiteSpace(displayName, nameof(displayName)); this.DisplayName = displayName; this.Description = description ?? ""; this.DateCreated = DateTime.UtcNow; this.ExternalId = externalId ?? ""; this.ScenarioId = softwareModel.ScenarioId; this.SoftwareModelId = softwareModel.Id; this.DateLastModified = DateCreated; this.UserName = ""; this.Id = SeqGuid.Create(); }
/// <summary> /// /// </summary> public void UpsertUserRoleMenu(UserRoleSettingModel model) { Db((db, tran) => { db.DeleteList <UserRoleMenu>(new { model.UserRoleId }, tran); model.UserMenuIds?.ForEach(id => { db.Insert <Guid, UserRoleMenu>(new UserRoleMenu() { UserRoleMenuId = SeqGuid.NewGuid(), UserRoleId = model.UserRoleId, UserMenuId = id }, tran); }); }); }
/// <summary> /// 添加 /// </summary> /// <param name="userModel"></param> /// <param name="model"></param> /// <param name="msg"></param> /// <returns></returns> public virtual bool AddUser(UserModel userModel, User model, out string msg) { if (model.UserEmail.IsWhiteSpace() || !model.UserEmail.IsEmail()) { msg = "邮箱不正确"; return(false); } if (model.UserPwd.IsWhiteSpace()) { msg = "请输入密码"; return(false); } //密码加密 model.UserPwd = model.UserPwd.ToMd5(); if (model.UserNickName.IsWhiteSpace()) { msg = "请输入英文名"; return(false); } if (model.UserChnName.IsWhiteSpace()) { msg = "请输入中文名"; return(false); } //验证角色 var roles = Da.GetList <UserRole>(); if (!roles.Exists(p => p.UserRoleId == model.UserRoleId)) { msg = "角色不正确"; return(false); } model.UserId = SeqGuid.NewGuid(); model.Status = (int)UserStatusEnum.Ok; model.CreateDate = DateTime.Now; Da.Add <Guid, User>(model); msg = null; return(true); }
/// <summary> /// /// </summary> /// <param name="userModel"></param> /// <returns></returns> protected static FileUploadResult UploadFile(UserModel userModel) { var files = HttpContext.Current.Request.Files; if (files.Count == 0) { return(null); } var item = files[0]; var tempPath = $"/Files/Temp/{SeqGuid.NewGuid()}"; item.SaveAs(tempPath); //判断是否是图片 return(null); }