public RulesBundle(ContextModel context, IRule rule) { var userId = context.Parent.Id.GetValueOrDefault(); UserResourceRule = new ResourceRule <Olma.User>(userId, rule) .IgnoreQueryFilter() .UseEagleLoad(t => t .Include(p => p.Person) .Include(p => p.Customers).ThenInclude(r => r.Customer) .Include(p => p.UserSettings) .Include(p => p.Permissions) .Include(p => p.Submissions) .Include(p => p.UserGroups) ); UserIdRequired = new ValidOperatorRule <ContextModel>( context, ctx => ctx.Parent.Id.HasValue, parentRule: rule, ruleName: nameof(UserIdRequired), message: new NotAllowedByRule()); UserLockedRequired = new ValidOperatorRule <ContextModel>( context, ctx => ctx.Parent.Locked.HasValue, parentRule: rule, ruleName: nameof(UserLockedRequired), message: new NotAllowedByRule()); }
public override void RenderPage() { ResourceRule objResourceRule = new ResourceRule(); rptImglist.DataSource = objResourceRule.GetResourceVerFilePathInfo(1); rptImglist.DataBind(); }
public ResourceRule Create(Resource resource, Rule rule) { var lnk = LinkLookup.First(l => l.ResourceId == resource.ResourceId); if (lnk == null) { return(null); } var rl = RuleLookup.First(r => r.RuleId == rule.RuleId); if (rl == null) { return(null); } var lnkr = new ResourceRule() { Resource = lnk, Rule = rl }; CRUD.Add(lnkr); return(lnkr); }
public override void RenderPage() { ResourceRule objResourceRule = new ResourceRule(); rptResourceType.DataSource = objResourceRule.Sys_ResourceType.OrderBy(r => r.ResourceTypeID); rptResourceType.DataBind(); }
public RulesBundle(ContextModel context, IRule rule) { LoadCarrierReceiptResourceRule = new ResourceRule <Olma.LoadCarrierReceipt>(context.Parent, rule) .UseEagleLoad(i => i.Include(r => r.Positions) .ThenInclude(lc => lc.LoadCarrier).ThenInclude(lc => lc.Quality) .Include(d => d.Document) .Include(lc => lc.DepotPreset)); }
public RulesBundle(ContextModel context, IRule rule) { OrderResourceRule = new ResourceRule <Olma.Order>(context.Id, rule).Include(o => o.Group) .Include(o => o.CreatedBy).Include(u => u.CreatedBy.Person) .Include(i => i.DplNotes); var getOperatorRule = new GetOperatorRule <ContextModel, Olma.Order>(context, (c) => c.Rules.OrderResourceRule.Context.Resource); AuthorizationRule = new AuthorizationRule <Olma.Order, ContextModel, DivisionPermissionResource, CanCancelOrderRequirement>(getOperatorRule, rule); OrderCancelStatusValidationRule = new OrderCancelStatusValidationRule <Olma.Order, ContextModel>(getOperatorRule, rule); }
public RulesBundle(ContextModel context, IRule rule) { PartnerDirectoryResourceRule = new ResourceRule <Olma.PartnerDirectory>(context.Parent.DirectoryId, rule) .Include(i => i.OrganizationPartnerDirectories); CustomerNameRequiredRule = new ValidOperatorRule <ContextModel>( context, model => !string.IsNullOrEmpty(model.Parent.CompanyName), new CustomerNameRequired()); BlacklistTermsRule = new BlacklistTermsRule(context, rule); }
public RulesBundle(ContextModel context, IRule rule) { VoucherResourceRule = new ResourceRule <Olma.Voucher>(x => x.Document.Number == context.Number, rule); var getOperator = new GetOperatorRule <ContextModel, Olma.Voucher>(context, model => model.Rules.VoucherResourceRule.Context.Resource); VoucherAuthorizationRule = new AuthorizationRule < Olma.Voucher, ContextModel, DivisionPermissionResource, CanReadVoucherRequirement>(getOperator, rule); }
public RulesBundle(ContextModel context, MainRule rule) { UserResourceRule = new ResourceRule <Olma.User>(context.UserId, rule) .IgnoreQueryFilter() .UseEagleLoad(t => t .Include(p => p.Person) .Include(p => p.UserSettings) .Include(p => p.Permissions) .Include(p => p.Submissions) .Include(p => p.UserGroups) ); Password = new RandomPasswordRule(); }
public override void InitDataPage() { ResourceRule objResourceRule = new ResourceRule(); radWaterImageID.DataSource = objResourceRule.Sys_WaterImage; radWaterImageID.DataTextField = "WaterName"; radWaterImageID.DataValueField = "WaterImageID"; radWaterImageID.DataBind(); radWatermarkType.Items.Clear(); foreach (var EnumMember in typeof(WatermarkType).GetEnumMembers()) { radWatermarkType.Items.Add(new ListItem(EnumMember.Description, EnumMember.Value.ToString())); } }
public override void InitDataPage() { ResourceRule objResourceRule = new ResourceRule(); rptImglist.DataSource = objResourceRule.GetResourceVerFilePathInfo(1); LogRule objLogRule = new LogRule(); chkDataList.Items.Clear(); dropCote.Items.Insert(0, new ListItem("无设定", "-1")); foreach (Sys_ModuleCote objSys_ModuleCote in objModuleRule.Sys_ModuleCote) { dropCote.Items.Add(new ListItem(objSys_ModuleCote.CoteTitle, objSys_ModuleCote.ModuleCoteID.ToString())); } }
public void Evaluate_GetsExpectedConfigSettings_ForGlobalResourceRule() { // arrange var resource = "/api/resource1"; var serverIP = "172.39.67.32"; var resourceRule = new ResourceRule("/api/resource1 : all regions : requests per timespan : default settings", resource, Region.All, RateLimitType.RequestsPerTimespan, RateLimitLevel.Default); var regionRule = new RegionRule("US", RateLimitType.TimespanPassedSinceLastCall, RateLimitLevel.Low); var expected = new RateLimitSettingsConfig(); expected[RateLimitType.RequestsPerTimespan] = new TokenBucketSettings() { MaxAmount = 5, RefillAmount = 5, RefillTime = 60 }; var expectedSettings = (TokenBucketSettings)expected[RateLimitType.RequestsPerTimespan]; var fakeRepository = Substitute.For <IRuleRepository>(); var fakeCache = Substitute.For <IRuleCache>(); fakeCache["/api/resource1All"].Returns(resourceRule); fakeCache["US"].Returns(regionRule); var rulesEngine = new RulesEngine(fakeRepository, fakeCache); // act var result = rulesEngine.Evaluate(resource, serverIP); var resultSettings = (TokenBucketSettings)result[RateLimitType.RequestsPerTimespan]; // assert Assert.AreEqual(resultSettings.MaxAmount, expectedSettings.MaxAmount); Assert.AreEqual(resultSettings.RefillAmount, expectedSettings.RefillAmount); Assert.AreEqual(resultSettings.RefillTime, expectedSettings.RefillTime); }
public void SendMsgToUser(int meetCode) { ConferenceManageBFL ebfl = new ConferenceManageBFL(); ConferenceManageModel conferenceManage = new ConferenceManageModel(); conferenceManage = ebfl.GetConferenceManage(meetCode); string strUser = conferenceManage.ChaterMember; string text2 = string.Format("{0} 会议", conferenceManage.Topic); string text3 = string.Format("主办单位: <b>{0}</b>\r\n会议地点: <b>{1}</b>\r\n会议时间:<b>{2}</b>\r\n<a href='../RmsOA/XZ_Conference.aspx?Type=Read&Code={3}'>详细内容</a>\r\n<a href='../RmsOA/XZ_ConferenceWeek.aspx'>本周会议</a>", new object[] { conferenceManage.Dept, conferenceManage.Place, conferenceManage.StartTime, meetCode.ToString() }); DateTime now = DateTime.Now; string code = SystemManageDAO.GetNewSysCode("Notice"); EntityData entity = new EntityData("Standard_Notice"); DataRow newRecord = entity.GetNewRecord(); newRecord["NoticeCode"] = code; newRecord["Title"] = text2; newRecord["SubmitPerson"] = strUser; newRecord["SubmitDate"] = DateTime.Now; newRecord["UpdateDate"] = DateTime.Now; newRecord["UserCode"] = strUser; newRecord["Content"] = text3; newRecord["Type"] = "1"; newRecord["IsAll"] = "0"; newRecord["status"] = "1"; entity.AddNewRecord(newRecord); string strTmp = this.UserListString(meetCode); ArrayList arOperator = new ArrayList(); this.SaveRS(arOperator, StringRule.CutRepeat(strTmp), "", "080104"); this.SaveRS(arOperator, strUser, "", "080102,080103,080104"); if (arOperator.Count > 0) { ResourceRule.SetResourceAccessRange(code, "0801", "", arOperator, false); } RemindDAO.InsertNotice(entity); entity.Dispose(); }
public void AddResourceRule(ResourceRule rule) { }
public void AddResourceRule(ResourceRule rule) { // if rule type is Region, translate region to this.ruleRepository.AddResourceRule(rule); }
private void ValidationInit() { if ((this.ValidationGroup.IsNoNull() && this.ResourceTypeID.IsNoNull()) && this.RestrictCode.IsNoNull()) { Sys_ResourceRestrict resourceRestrict = new ResourceRule().GetResourceRestrict(this.ResourceTypeID, this.RestrictCode); if (resourceRestrict.FileExtension.IsNoNull()) { this.ValidationExpression = "(" + resourceRestrict.FileExtension.Replace(',', '|') + ")$"; } if (this.HintMessage.IsNull()) { if ((resourceRestrict.FileMaxSize > 0) || resourceRestrict.FileExtension.IsNoNull()) { this.HintMessage = (resourceRestrict.FileExtension.IsNoNull() ? ("文件类型:" + resourceRestrict.FileExtension) : "") + ((resourceRestrict.FileMaxSize > 0) ? ((resourceRestrict.FileExtension.IsNoNull() ? "," : "") + "文件必须小于" + ((int)(resourceRestrict.FileMaxSize * 0x400)).RenderFileSize()) : ""); this.ErrorMessage = "请上传:" + (resourceRestrict.FileExtension.IsNoNull() ? ("文件类型:" + resourceRestrict.FileExtension) : "") + ((resourceRestrict.FileMaxSize > 0) ? ((resourceRestrict.FileExtension.IsNoNull() ? "," : "") + "文件必须小于" + ((int)(resourceRestrict.FileMaxSize * 0x400)).RenderFileSize()) : ""); } Sys_ResourceRestrictPic pic = (from s in resourceRestrict.Sys_ResourceRestrictPic orderby s.ImageWidth descending select s).FirstOrDefault <Sys_ResourceRestrictPic>(); if ((pic != null) && (pic.ImageWidth > 0)) { object hintMessage = this.HintMessage; this.HintMessage = string.Concat(new object[] { hintMessage, ",尺寸:", pic.ImageWidth, " x ", pic.ImageHeight }); hintMessage = this.ErrorMessage; this.ErrorMessage = string.Concat(new object[] { hintMessage, ",尺寸:", pic.ImageWidth, " x ", pic.ImageHeight }); } } if (!string.IsNullOrEmpty(this.ValidationGroup)) { base.Attributes.Add("ValidationGroup", this.ValidationGroup); } else { base.Attributes.Remove("ValidationGroup"); } if (!string.IsNullOrEmpty(this.ValidationExpression)) { base.Attributes.Add("ValidationExpression", this.ValidationExpression); } else { base.Attributes.Remove("ValidationExpression"); } if (!string.IsNullOrEmpty(this.ErrorMessage)) { base.Attributes.Add("ErrorMessage", this.ErrorMessage); base.Attributes.Add("onblur", "$(this).BlurValidationError(" + (this.BlurSucessCall.IsNull() ? "" : this.BlurSucessCall) + ");"); } else { base.Attributes.Remove("ErrorMessage"); base.Attributes.Remove("onblur"); } if (!string.IsNullOrEmpty(this.HintMessage)) { base.Attributes.Add("HintMessage", this.HintMessage); base.Attributes.Add("onfocus", "$(this).FocusValidationHint();"); } else { base.Attributes.Remove("HintMessage"); base.Attributes.Remove("onfocus"); } if (this.MessageWidth != 0) { base.Attributes.Add("MessageWidth", this.MessageWidth.ToString()); } else { base.Attributes.Remove("MessageWidth"); } if (this.CheckValueEmpty) { base.Attributes.Add("CheckValueEmpty", this.CheckValueEmpty.ToString()); } else { base.Attributes.Remove("CheckValueEmpty"); } } }
public void Save() { if (base.HasFile) { ResourceInfo info; ResourceRule rule = new ResourceRule(); this.ResourceTypeID.CheckIsNull("请设置资源类型标识", LogModuleType.ResourceLog); this.RestrictCode.CheckIsNull("请设置RestrictCode", LogModuleType.ResourceLog); Sys_ResourceRestrict resourceRestrict = rule.GetResourceRestrict(this.ResourceTypeID, this.RestrictCode); string fileExtension = Path.GetExtension(base.FileName).ToLower(); SysAssert.InfoHintAssert(!string.IsNullOrEmpty(resourceRestrict.FileExtension) && (resourceRestrict.FileExtension.IndexOf(fileExtension.Trim(new char[] { '.' })) == -1), "上传的文件扩展名必须是" + resourceRestrict.FileExtension); SysAssert.InfoHintAssert(((((double)base.PostedFile.ContentLength) / 1024.0) > resourceRestrict.FileMaxSize) && (resourceRestrict.FileMaxSize > 0), "对不起支持上传的文件大小为" + ((int)(resourceRestrict.FileMaxSize * 0x400)).RenderFileSize() + ",当前的文件大小超出"); if (this.ResourceID.IsNull()) { if (this.ResourceName.IsNull()) { this.ResourceName = string.Concat(new object[] { "类型:", resourceRestrict.ResourceTypeID, "限制标识", resourceRestrict.ResourceRestrictID.ToString(), base.FileName }); } this.ResourceID = rule.InsertResource(this.ResourceName, this.ResourceTypeID); } else { if (this.ResourceName.IsNull()) { this.ResourceName = string.Concat(new object[] { "类型:", resourceRestrict.ResourceTypeID, "限制标识", resourceRestrict.ResourceRestrictID.ToString(), base.FileName }); } rule.CheckResourceID(this.ResourceID, this.ResourceName, resourceRestrict.ResourceTypeID); } if ((base.PostedFile.ContentType.IndexOf("image") != -1) && (resourceRestrict.Sys_ResourceRestrictPic.Count > 0)) { System.Drawing.Image image; Sys_WaterImage image2; System.Drawing.Image image3; if (resourceRestrict.Sys_ResourceRestrictPic.Count > 1) { this._MoveResourceInfo = new List <ResourceInfo>(); using (List <Sys_ResourceRestrictPic> .Enumerator enumerator = (from s in resourceRestrict.Sys_ResourceRestrictPic orderby s.VerNo orderby s.ResourceRestrictPicID select s).ToList <Sys_ResourceRestrictPic>().GetEnumerator()) { while (enumerator.MoveNext()) { Stream stream; Sys_ResourceRestrictPic objFileVerInfo = enumerator.Current; int verNo = objFileVerInfo.VerNo; if (verNo == 0) { verNo = rule.GetResourceMaxVerNo(this.ResourceID, resourceRestrict.BeginVerNo, resourceRestrict.EndVerNo); } image = base.PostedFile.InputStream.StreamToImage(); if ((objFileVerInfo.ImageWidth > 0) && (objFileVerInfo.ImageHeight > 0)) { if ((image.Width > objFileVerInfo.ImageWidth) || (image.Height > objFileVerInfo.ImageHeight)) { image = image.CreateThumbnail("<=" + objFileVerInfo.ImageWidth.ToString(), "<=" + objFileVerInfo.ImageHeight.ToString()); if (objFileVerInfo.CreateWaterMark) { if (objFileVerInfo.WatermarkType == 2) { SysAssert.CheckCondition(string.IsNullOrEmpty(objFileVerInfo.WatermarkText), "请输入水印的文本", LogModuleType.ResourceLog); image = image.CreateWatermark(objFileVerInfo.WatermarkText, (HorizontalAlign)objFileVerInfo.HorizontalAlign, (VerticalAlign)objFileVerInfo.VerticalAlign); } else { image2 = rule.Sys_WaterImage.FirstOrDefault <Sys_WaterImage>(s => s.WaterImageID == objFileVerInfo.WaterImageID); if (image2.IsNoNull()) { image3 = System.Drawing.Image.FromFile(SysVariable.CurrentContext.Server.MapPath(image2.WaterImagePath), false); image = image.CreateWatermark(image3, (HorizontalAlign)objFileVerInfo.HorizontalAlign, (VerticalAlign)objFileVerInfo.VerticalAlign); image3.Dispose(); } } } this._MoveResourceInfo.Add(rule.InsertResourceVer(this.ResourceID, Path.GetFileName(base.PostedFile.FileName), base.PostedFile.ContentLength, base.PostedFile.ContentType, "admin", image.ImageToStream(fileExtension), verNo, this.Remark)); image.Dispose(); } else if (objFileVerInfo.CreateWaterMark) { if (objFileVerInfo.WatermarkType == 2) { SysAssert.CheckCondition(string.IsNullOrEmpty(objFileVerInfo.WatermarkText), "请输入水印的文本", LogModuleType.ResourceLog); image = image.CreateWatermark(objFileVerInfo.WatermarkText, (HorizontalAlign)objFileVerInfo.HorizontalAlign, (VerticalAlign)objFileVerInfo.VerticalAlign); } else { image2 = rule.Sys_WaterImage.FirstOrDefault <Sys_WaterImage>(s => s.WaterImageID == objFileVerInfo.WaterImageID); if (image2.IsNoNull()) { image3 = System.Drawing.Image.FromFile(SysVariable.CurrentContext.Server.MapPath(image2.WaterImagePath), false); image = image.CreateWatermark(image3, (HorizontalAlign)objFileVerInfo.HorizontalAlign, (VerticalAlign)objFileVerInfo.VerticalAlign); image3.Dispose(); } } this._MoveResourceInfo.Add(rule.InsertResourceVer(this.ResourceID, Path.GetFileName(base.PostedFile.FileName), base.PostedFile.ContentLength, base.PostedFile.ContentType, "admin", image.ImageToStream(fileExtension), verNo, this.Remark)); image.Dispose(); } else { stream = image.ImageToStream(fileExtension); this._MoveResourceInfo.Add(rule.InsertResourceVer(this.ResourceID, Path.GetFileName(base.PostedFile.FileName), base.PostedFile.ContentLength, base.PostedFile.ContentType, "admin", stream, verNo, this.Remark)); } } else if (objFileVerInfo.CreateWaterMark) { if (objFileVerInfo.WatermarkType == 2) { SysAssert.CheckCondition(string.IsNullOrEmpty(objFileVerInfo.WatermarkText), "请输入水印的文本", LogModuleType.ResourceLog); image = image.CreateWatermark(objFileVerInfo.WatermarkText, (HorizontalAlign)objFileVerInfo.HorizontalAlign, (VerticalAlign)objFileVerInfo.VerticalAlign); } else { image2 = rule.Sys_WaterImage.FirstOrDefault <Sys_WaterImage>(s => s.WaterImageID == objFileVerInfo.WaterImageID); if (image2.IsNoNull()) { image3 = System.Drawing.Image.FromFile(SysVariable.CurrentContext.Server.MapPath(image2.WaterImagePath), false); image = image.CreateWatermark(image3, (HorizontalAlign)objFileVerInfo.HorizontalAlign, (VerticalAlign)objFileVerInfo.VerticalAlign); image3.Dispose(); } } this._MoveResourceInfo.Add(rule.InsertResourceVer(this.ResourceID, Path.GetFileName(base.PostedFile.FileName), base.PostedFile.ContentLength, base.PostedFile.ContentType, "admin", image.ImageToStream(fileExtension), verNo, this.Remark)); image.Dispose(); } else { stream = image.ImageToStream(fileExtension); this._MoveResourceInfo.Add(rule.InsertResourceVer(this.ResourceID, Path.GetFileName(base.PostedFile.FileName), base.PostedFile.ContentLength, base.PostedFile.ContentType, "admin", stream, objFileVerInfo.VerNo, this.Remark)); } image.Dispose(); } } return; } Sys_ResourceRestrictPic objSys_ResourceRestrictPic = resourceRestrict.Sys_ResourceRestrictPic.FirstOrDefault <Sys_ResourceRestrictPic>(); if (this.VerNo == 0) { this.VerNo = objSys_ResourceRestrictPic.VerNo; } if (objSys_ResourceRestrictPic.CreateWaterMark && (fileExtension != ".gif")) { image = base.PostedFile.InputStream.StreamToImage(); if (((objSys_ResourceRestrictPic.ImageWidth > 0) && (objSys_ResourceRestrictPic.ImageHeight > 0)) && ((image.Width > objSys_ResourceRestrictPic.ImageWidth) || (image.Height > objSys_ResourceRestrictPic.ImageHeight))) { image = image.CreateThumbnail("<=" + objSys_ResourceRestrictPic.ImageWidth.ToString(), "<=" + objSys_ResourceRestrictPic.ImageHeight.ToString()); } if (objSys_ResourceRestrictPic.WatermarkType == 2) { SysAssert.CheckCondition(string.IsNullOrEmpty(objSys_ResourceRestrictPic.WatermarkText), "请输入水印的文本", LogModuleType.ResourceLog); image = image.CreateWatermark(objSys_ResourceRestrictPic.WatermarkText, (HorizontalAlign)objSys_ResourceRestrictPic.HorizontalAlign, (VerticalAlign)objSys_ResourceRestrictPic.VerticalAlign); } else { image2 = rule.Sys_WaterImage.FirstOrDefault <Sys_WaterImage>(s => s.WaterImageID == objSys_ResourceRestrictPic.WaterImageID); if (image2.IsNoNull()) { image3 = System.Drawing.Image.FromFile(SysVariable.CurrentContext.Server.MapPath(image2.WaterImagePath), false); image = image.CreateWatermark(image3, (HorizontalAlign)objSys_ResourceRestrictPic.HorizontalAlign, (VerticalAlign)objSys_ResourceRestrictPic.VerticalAlign); } } info = rule.InsertResourceVer(this.ResourceID, Path.GetFileName(base.PostedFile.FileName), base.PostedFile.ContentLength, base.PostedFile.ContentType, "admin", image.ImageToStream(fileExtension), (this.VerNo != 0) ? this.VerNo : rule.GetResourceMaxVerNo(this.ResourceID, resourceRestrict.BeginVerNo, resourceRestrict.EndVerNo), this.Remark); image.Dispose(); } else if ((objSys_ResourceRestrictPic.ImageWidth > 0) && (objSys_ResourceRestrictPic.ImageHeight > 0)) { image = base.PostedFile.InputStream.StreamToImage(); if ((objSys_ResourceRestrictPic.ImageWidth > 0) && (objSys_ResourceRestrictPic.ImageHeight > 0)) { if ((image.Width > objSys_ResourceRestrictPic.ImageWidth) || (image.Height > objSys_ResourceRestrictPic.ImageHeight)) { image = image.CreateThumbnail("<=" + objSys_ResourceRestrictPic.ImageWidth.ToString(), "<=" + objSys_ResourceRestrictPic.ImageHeight.ToString()); info = rule.InsertResourceVer(this.ResourceID, Path.GetFileName(base.PostedFile.FileName), base.PostedFile.ContentLength, base.PostedFile.ContentType, "admin", image.ImageToStream(fileExtension), (this.VerNo != 0) ? this.VerNo : rule.GetResourceMaxVerNo(this.ResourceID, resourceRestrict.BeginVerNo, resourceRestrict.EndVerNo), this.Remark); } else { info = rule.InsertResourceVer(this.ResourceID, (this.VerNo != 0) ? this.VerNo : rule.GetResourceMaxVerNo(this.ResourceID, resourceRestrict.BeginVerNo, resourceRestrict.EndVerNo), "admin", base.PostedFile, this.Remark); } } else { info = rule.InsertResourceVer(this.ResourceID, (this.VerNo != 0) ? this.VerNo : rule.GetResourceMaxVerNo(this.ResourceID, resourceRestrict.BeginVerNo, resourceRestrict.EndVerNo), "admin", base.PostedFile, this.Remark); } image.Dispose(); } else { info = rule.InsertResourceVer(this.ResourceID, (this.VerNo != 0) ? this.VerNo : rule.GetResourceMaxVerNo(this.ResourceID, resourceRestrict.BeginVerNo, resourceRestrict.EndVerNo), "admin", base.PostedFile, this.Remark); } } else { if (this.VerNo == 0) { this.VerNo = resourceRestrict.VerNo; } info = rule.InsertResourceVer(this.ResourceID, (this.VerNo != 0) ? this.VerNo : rule.GetResourceMaxVerNo(this.ResourceID, resourceRestrict.BeginVerNo, resourceRestrict.EndVerNo), "admin", base.PostedFile, this.Remark); } this.ResourceID = info.ResourceID; this.ResourcePath = info.ResourcePath; this.VerNo = info.VerNo; } }
public void AddResourceRule(ResourceRule rule) { resourceRules.Add(this.regionRules.Count + 1, rule); }
public void UpdateResourceRule(ResourceRule rule) { this.resourceRules[rule.Id] = rule; }
public RulesBundle(ContextModel context, IRule rule) { PostingAccountResourceRule = new ResourceRule <Olma.PostingAccount>(context.Request.Key, rule).IgnoreQueryFilter(); }
public RulesBundle(ContextModel context, IRule rule) { CustomerDivisionResourceRule = new ResourceRule <Olma.CustomerDivision>(context.Request.Id, rule).IgnoreQueryFilter(); }
public void Save() { if (base.HasFile) { ResourceInfo info; ResourceRule rule = new ResourceRule(); string fileExtension = Path.GetExtension(base.FileName).ToLower(); SysAssert.InfoHintAssert(!string.IsNullOrEmpty(this.FileExtension) && (this.FileExtension.IndexOf(fileExtension.Trim(new char[] { '.' })) == -1), "上传的文件扩展名必须是" + this.FileExtension); SysAssert.InfoHintAssert((this.MaxFileSize > 0) && ((((double)base.PostedFile.ContentLength) / 1024.0) > this.MaxFileSize), "对不起支持上传的文件大小为" + ((int)(this.MaxFileSize * 0x400)).RenderFileSize() + "当前的文件大小超出"); if (this.ResourceID.IsNull()) { SysAssert.CheckCondition(this.ResourceTypeID <= 0, "请选择资源类型参数标识", LogModuleType.ResourceLog); if (this.ResourceName.IsNull()) { this.ResourceName = "类型:" + this.ResourceTypeID + base.FileName; } this.ResourceID = rule.InsertResource(this.ResourceName, this.ResourceTypeID); } else { if (this.ResourceName.IsNull()) { this.ResourceName = "类型:" + this.ResourceTypeID + base.FileName; } rule.CheckResourceID(this.ResourceID, this.ResourceName, this.ResourceTypeID); } if (base.PostedFile.ContentType.IndexOf("image") != -1) { System.Drawing.Image image; if (this.FileVers.Count > 0) { this._MoveResourceInfo = new List <ResourceInfo>(); foreach (FileVerInfo info2 in this.FileVers) { Stream stream; if (info2.VerNo == 0) { info2.VerNo = rule.GetResourceMaxVerNo(this.ResourceID, this.BeginVerNo, this.EndVerNo); } image = base.PostedFile.InputStream.StreamToImage(); if ((info2.ImageWidth > 0) && (info2.ImageHeight > 0)) { if ((image.Width > info2.ImageWidth) || (image.Height > info2.ImageHeight)) { image = image.CreateThumbnail("<=" + info2.ImageWidth.ToString(), "<=" + info2.ImageHeight.ToString()); this._MoveResourceInfo.Add(rule.InsertResourceVer(this.ResourceID, Path.GetFileName(base.PostedFile.FileName), base.PostedFile.ContentLength, base.PostedFile.ContentType, "admin", image.ImageToStream(fileExtension), info2.VerNo, this.Remark)); } else { stream = image.ImageToStream(fileExtension); this._MoveResourceInfo.Add(rule.InsertResourceVer(this.ResourceID, Path.GetFileName(base.PostedFile.FileName), base.PostedFile.ContentLength, base.PostedFile.ContentType, "admin", stream, info2.VerNo, this.Remark)); } } else { stream = image.ImageToStream(fileExtension); this._MoveResourceInfo.Add(rule.InsertResourceVer(this.ResourceID, Path.GetFileName(base.PostedFile.FileName), base.PostedFile.ContentLength, base.PostedFile.ContentType, "admin", stream, info2.VerNo, this.Remark)); } image.Dispose(); } return; } if (this.CreateWaterMark && (fileExtension != ".gif")) { image = base.PostedFile.InputStream.StreamToImage(); if (((this.ImageWidth > 0) && (this.ImageHeight > 0)) && ((image.Width > this.ImageWidth) || (image.Height > this.ImageHeight))) { image = image.CreateThumbnail("<=" + this.ImageWidth.ToString(), "<=" + this.ImageHeight.ToString()); } if (this.WatermarkTypeValue == WatermarkType.WaterText) { SysAssert.CheckCondition(string.IsNullOrEmpty(this.WatermarkText), "请输入水印的文本", LogModuleType.ResourceLog); image = image.CreateWatermark(this.WatermarkText, this.WatermarkHorizontalAlign, this.WatermarkVerticalAlign); } info = rule.InsertResourceVer(this.ResourceID, Path.GetFileName(base.PostedFile.FileName), base.PostedFile.ContentLength, base.PostedFile.ContentType, "admin", image.ImageToStream(fileExtension), (this.VerNo != 0) ? this.VerNo : rule.GetResourceMaxVerNo(this.ResourceID, this.BeginVerNo, this.EndVerNo), this.Remark); image.Dispose(); } else if ((this.ImageWidth > 0) && (this.ImageHeight > 0)) { image = base.PostedFile.InputStream.StreamToImage(); if ((this.ImageWidth > 0) && (this.ImageHeight > 0)) { if ((image.Width > this.ImageWidth) || (image.Height > this.ImageHeight)) { image = image.CreateThumbnail("<=" + this.ImageWidth.ToString(), "<=" + this.ImageHeight.ToString()); info = rule.InsertResourceVer(this.ResourceID, Path.GetFileName(base.PostedFile.FileName), base.PostedFile.ContentLength, base.PostedFile.ContentType, "admin", image.ImageToStream(fileExtension), (this.VerNo != 0) ? this.VerNo : rule.GetResourceMaxVerNo(this.ResourceID, this.BeginVerNo, this.EndVerNo), this.Remark); } else { info = rule.InsertResourceVer(this.ResourceID, (this.VerNo != 0) ? this.VerNo : rule.GetResourceMaxVerNo(this.ResourceID, this.BeginVerNo, this.EndVerNo), "admin", base.PostedFile, this.Remark); } } else { info = rule.InsertResourceVer(this.ResourceID, (this.VerNo != 0) ? this.VerNo : rule.GetResourceMaxVerNo(this.ResourceID, this.BeginVerNo, this.EndVerNo), "admin", base.PostedFile, this.Remark); } image.Dispose(); } else { info = rule.InsertResourceVer(this.ResourceID, (this.VerNo != 0) ? this.VerNo : rule.GetResourceMaxVerNo(this.ResourceID, this.BeginVerNo, this.EndVerNo), "admin", base.PostedFile, this.Remark); } } else { info = rule.InsertResourceVer(this.ResourceID, (this.VerNo != 0) ? this.VerNo : rule.GetResourceMaxVerNo(this.ResourceID, this.BeginVerNo, this.EndVerNo), "admin", base.PostedFile, this.Remark); } this.ResourceID = info.ResourceID; this.ResourcePath = info.ResourcePath; this.VerNo = info.VerNo; } }
public RulesBundle(ContextModel context, IRule rule) { DocumentNumberSequenceResourceRule = new ResourceRule <Olma.DocumentNumberSequence>(context.Request.Key, rule); }
public RulesBundle(ContextModel context, IRule rule) { PartnerResourceRule = new ResourceRule <Olma.Partner>(context.Request.Id, rule).IgnoreQueryFilter(); }
public RulesBundle(ContextModel context, IRule rule) { AddressResourceRule = new ResourceRule <Olma.Address>(context.Request.Id, rule); }
public void UpdateResourceRule(ResourceRule rule) { }
public RulesBundle(ContextModel context, IRule rule) { OrganizationResourceRule = new ResourceRule <Olma.Organization>(context.Request.Id, rule).IgnoreQueryFilter(); }
public RulesBundle(ContextModel context, IRule rule) { CustomerDivisionDocumentSettingResourceRule = new ResourceRule <Olma.CustomerDivisionDocumentSetting>(context.Request.Key, rule); }