/// <summary> /// 发送验证码 /// </summary> /// <param name="name"></param> /// <param name="code"></param> /// <returns></returns> public virtual PasswordDto SendCode(string name, CodeEntity code) { var account = GetAccount(name); var result = new PasswordDto { IsTimeout = CheckTemporary(name) }; if (result.IsTimeout) { return(result); } if (code.Type == CodeType.Email && !account.IsActiveEmail) { return(result); } if (code.Type == CodeType.Mobile && !account.IsActiveMobile) { return(result); } code.Tag = Tag; code.Name = name; code.ToAddress = code.Type == CodeType.Email ? account.Email : account.Mobile; code.SaveType = SaveType.Add; var unitofworks = CodeDomainService.Handle(code); result.Result = Winner.Creator.Get <IContext>().Commit(unitofworks); result.Errors = result.Errors; result.SendStep = result.SendStep; return(result); }
/// <inheritdoc/> public void Append(CodeEntity codeEntity) { lock (_lockObj) { #if DEBUG //Log($"codeEntity = {codeEntity}"); #endif var name = codeEntity.Name; #if DEBUG //Log($"name = {name}"); #endif if (_codeEntitiesDict.ContainsKey(name)) { var targetList = _codeEntitiesDict[name]; if (!targetList.Contains(codeEntity)) { targetList.Add(codeEntity); } } else { _codeEntitiesDict[name] = new List <CodeEntity>() { codeEntity }; } SetAsMainCodeEntity(codeEntity); } }
private void CheckCodeEntity(CodeEntity codeEntity, string name) { Assert.AreEqual(codeEntity.Kind, KindOfCodeEntity.LinguisticVariable); Assert.AreEqual(codeEntity.Name, NameHelper.CreateName(name)); Assert.AreNotEqual(codeEntity.LinguisticVariable, null); Assert.AreEqual(codeEntity.InheritanceItems.Count, 0); }
private static async Task <CodeEntity> GetOrAddEntity(IDataContract contract, Guid moduleId, CodeEntity en) { CodeEntity entity = contract.CodeEntities.FirstOrDefault(m => m.ModuleId == moduleId && m.Name == en.Name && m.Display == en.Display); if (entity != null) { return(entity); } CodeEntityInputDto dto = new CodeEntityInputDto() { Name = en.Name, Display = en.Display, PrimaryKeyTypeFullName = en.PrimaryKeyTypeFullName, Icon = en.Icon, Listable = en.Listable, Addable = en.Addable, Updatable = en.Updatable, Deletable = en.Deletable, IsDataAuth = en.IsDataAuth, HasCreatedTime = en.HasCreatedTime, HasLocked = en.HasLocked, HasSoftDeleted = en.HasSoftDeleted, HasCreationAudited = en.HasCreationAudited, HasUpdateAudited = en.HasUpdateAudited, IsLocked = en.IsLocked, ModuleId = moduleId }; await contract.UpdateCodeEntities(dto); entity = contract.CodeEntities.First(m => m.ModuleId == moduleId && m.Name == en.Name && m.Display == en.Display); return(entity); }
/// <summary> /// 获取识别后的结果 /// </summary> /// <param name="img"></param> /// <returns></returns> public static string GetCode(Image img) { Image imgCommon = img; Bitmap bmp = Handler(Handler(imgCommon)); int v = ImageHelper.ComputeThresholdValue(bmp); bmp = ImageHelper.PBinary(bmp, v); bmp = ImageHelper.ClearNoise(bmp, 2); List <Bitmap> bmpList = ImageHelper.CutImage(bmp, 12, 16); string r = string.Empty; if (bmpList != null) { for (int j = 0; j < bmpList.Count; j++) { Bitmap _bmp = bmpList[j]; CodeEntity ce = Realize(_bmp, StaticValues.CodeList); if (ce != null) { string charStr = ce.CharStr; r = r + charStr; } } } return(r); }
public override DbgEntity Create(FSEntity aEntity) { // Returns null if not supported CodeEntity ret = CodeEntity.New(this, aEntity); return(ret); }
/// <summary> /// 获取识别后的结果 /// </summary> /// <param name="img"></param> /// <returns></returns> public static string GetCode0(Image img) { ImageHandler ih = new ImageHandler(); Bitmap bmp = new Bitmap(img); int v = ImageHelper.ComputeThresholdValue(bmp); //二值化 bmp = ImageHelper.PBinary(bmp, v); bmp = ih.TrimBmp(bmp); List <Bitmap> bmpList = ih.CutImage(bmp, 8); string r = string.Empty; if (bmpList != null) { for (int j = 0; j < bmpList.Count; j++) { Bitmap _bmp = bmpList[j]; CodeEntity ce = Realize(_bmp, StaticValues.CodeList0); if (ce != null) { string charStr = ce.CharStr; r = r + charStr; } } } return(r); }
protected CodeEntity CreateCodeEntity() { var result = new CodeEntity(); DefaultSettingsOfCodeEntityHelper.SetUpCodeEntity(result, CurrentDefaultSetings); return(result); }
private void SetAsMainCodeEntity(CodeEntity codeEntity) { if (codeEntity.Kind == KindOfCodeEntity.App && codeEntity.CodeFile != null && codeEntity.CodeFile.IsMain) { _mainCodeEntity = codeEntity; } }
/// <summary>重写以提供要初始化的种子数据</summary> /// <returns></returns> protected override CodeProperty[] SeedData(IServiceProvider provider) { IRepository <CodeEntity, Guid> repository = provider.GetRequiredService <IRepository <CodeEntity, Guid> >(); CodeEntity entity = repository.GetFirst(m => m.Name == "User"); List <CodeProperty> properties = new List <CodeProperty>() { new CodeProperty() { Name = "UserName", Display = "用户名", TypeName = "System.String", Updatable = true, Sortable = true, Filterable = true, Order = 1, IsRequired = true, MaxLength = 200, EntityId = entity.Id }, new CodeProperty() { Name = "NickName", Display = "用户昵称", TypeName = "System.String", Order = 2, IsRequired = true, MaxLength = 200, EntityId = entity.Id }, new CodeProperty() { Name = "Email", Display = "邮箱", TypeName = "System.String", Order = 3, MaxLength = 200, EntityId = entity.Id }, new CodeProperty() { Name = "EmailConfirmed", Display = "邮箱确认", TypeName = "System.Boolean", Order = 4, EntityId = entity.Id }, new CodeProperty() { Name = "PhoneNumber", Display = "手机号", TypeName = "System.String", Order = 5, MaxLength = 50, EntityId = entity.Id }, new CodeProperty() { Name = "PhoneNumberConfirmed", Display = "手机号确认", TypeName = "System.Boolean", Order = 6, EntityId = entity.Id }, }; entity = repository.GetFirst(m => m.Name == "Role"); properties = new List <CodeProperty>() { new CodeProperty() { Name = "Name", Display = "名称", TypeName = "System.String", Order = 1, MaxLength = 200, EntityId = entity.Id }, new CodeProperty() { Name = "Remark", Display = "备注", TypeName = "System.String", Order = 2, MaxLength = 500, EntityId = entity.Id }, new CodeProperty() { Name = "IsAdmin", Display = "是否管理", TypeName = "System.Boolean", Order = 3, EntityId = entity.Id }, new CodeProperty() { Name = "IsDefault", Display = "是否默认", TypeName = "System.Boolean", Order = 4, EntityId = entity.Id }, }; return(properties.ToArray()); }
public static EntityViewModel ToViewModel(this CodeEntity entity, ModuleViewModel moduleModel = null) { EntityViewModel model = IoC.Get <EntityViewModel>(); model = entity.MapTo(model); model.Module = moduleModel; return(model); }
/// <inheritdoc/> protected override void OnEnter() { Result = CreateCodeEntityAndSetAsCurrent(KindOfCodeEntity.LinguisticVariable); _linguisticVariable = CreateLinguisticVariable(); _linguisticVariable.CodeEntity = Result; Result.LinguisticVariable = _linguisticVariable; }
/// <summary> /// 更新 /// </summary> private void Update() { CodeEntity entity = new CodeEntity(this.CodeID); entity.CodeName = txtCodeName.Text.Trim(); entity.CodeValue = txtCodeValue.Text.Trim(); entity.Memo = txtMemo.Text.Trim(); new CodeRule().Update(entity); }
/// <summary> /// 获取项目代码输出文件名 /// </summary> public string GetCodeFileName(CodeEntity entity) { string fileName = OutputFileFormat.Replace("{Project.NamespacePrefix}", entity.Module.Project.NamespacePrefix) .Replace("{Module.Name:Lower}", entity.Module.Name.UpperToLowerAndSplit()) .Replace("{Entity.Name:Lower}", entity.Name.UpperToLowerAndSplit()) .Replace("{Module.Name}", entity.Module.Name).Replace("{Entity.Name}", entity.Name); return(fileName); }
/// <inheritdoc/> protected override void OnEnter() { #if DEBUG //Log("Begin"); #endif Result = CreateCodeEntityAndSetAsCurrent(KindOfCodeEntity.World); #if DEBUG //Log("End"); #endif }
public CodeResponse ToCodeResponse(CodeEntity code) { return(new CodeResponse { Active = code.Active, Code = code.Code, Description = code.Description, Id = code.Id, SocialWork = ToSocialWorkResponse(code.SocialWork) }); }
/// <summary> /// 保存 /// </summary> private void Save() { CodeEntity entity = new CodeEntity(); entity.CodeGroupID = this.CodeGroupID; entity.CodeName = txtCodeName.Text.Trim(); entity.CodeValue = txtCodeValue.Text.Trim(); entity.Memo = txtMemo.Text.Trim(); entity.IsDeleted = false; new CodeRule().Add(entity); }
private CodeEntity InsertCode(string code) { int id = _codes.Count; var entity = new CodeEntity { Id = id, Code = code }; _codes.Add(entity); return(entity); }
/// <summary> /// 添加代码 /// </summary> /// <param name="ce">代码实体</param> /// <returns></returns> public static bool AddCode(CodeEntity ce) { DataBase db = new DataBase(); try { db.ExCommand("INSERT INTO tb_code ( pid, uid, lid,path) VALUES (" + ce.Pid + "," + ce.Uid + "," + ce.Lid + ",'" + ce.Path + "')"); return true; } catch { return false; } }
/// <summary> /// 添加代码 /// </summary> /// <param name="ce">代码实体</param> /// <returns></returns> public static bool AddCode(CodeEntity ce) { DataBase db = new DataBase(); try { db.ExCommand("INSERT INTO tb_code ( pid, uid, lid,path) VALUES (" + ce.Pid + "," + ce.Uid + "," + ce.Lid + ",'" + ce.Path + "')"); return(true); } catch { return(false); } }
/// <inheritdoc/> protected override void OnEnter() { Result = CreateCodeEntityAndSetAsCurrent(KindOfCodeEntity.InlineTrigger); Result.Name = NameHelper.CreateRuleOrFactName(); _inlineTrigger = CreateInlineTrigger(); _inlineTrigger.CodeEntity = Result; Result.InlineTrigger = _inlineTrigger; if (Result.ParentCodeEntity != null) { _inlineTrigger.Holder = Result.ParentCodeEntity.Name; } }
/// <summary> /// 更新代码实体信息信息 /// </summary> /// <param name="dtos">包含更新信息的代码实体信息DTO信息</param> /// <returns>业务操作结果</returns> public async Task <OperationResult> UpdateCodeEntities(params CodeEntityInputDto[] dtos) { List <string> names = new List <string>(); UnitOfWork.EnableTransaction(); foreach (var dto in dtos) { dto.Validate(); CodeModule module = await ModuleRepository.GetAsync(dto.ModuleId); if (module == null) { return(new OperationResult(OperationResultType.Error, $"编号为“{dto.ModuleId}”的模块信息不存在")); } if (await CheckCodeEntityExists(m => m.Name == dto.Name && m.ModuleId == dto.ModuleId, dto.Id)) { return(new OperationResult(OperationResultType.Error, $"模块“{module.Name}”中名称为“{dto.Name}”的实体信息已存在")); } if (dto.Order == 0) { dto.Order = EntityRepository.Query(m => m.ModuleId == module.Id).Count() + 1; } int count; if (dto.Id == default) { CodeEntity entity = dto.MapTo <CodeEntity>(); count = await EntityRepository.InsertAsync(entity); } else { CodeEntity entity = await EntityRepository.GetAsync(dto.Id); entity = dto.MapTo(entity); count = await EntityRepository.UpdateAsync(entity); } if (count > 0) { names.Add(dto.Name); } } await UnitOfWork.CommitAsync(); return(names.Count > 0 ? new OperationResult(OperationResultType.Success, $"实体“{names.ExpandAndToString()}”保存成功") : OperationResult.NoChanged); }
/// <summary> /// Page_Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (UserOperation.CheckLoged(Session) == false) { SmallScript.goRedirect(Response, Session, "请登录后再浏览本页", "/Login.aspx"); } string id = Request.QueryString["id"].ToString(); try { codeEntity = CodeOperation.GetCode(int.Parse(id)); langEntity = LangOperation.GetLang(codeEntity.Lid); userEntity = UserOperation.GetUser(codeEntity.Uid); /*Pre += "<pre style=\"margin:auto;\" class=\"brush: " + langEntity.BrushAliases + ";toolbar: false;\">";*/ Pre += File.ReadAllText(Server.MapPath(AppConfiger.GetProjectsDir(Server) + codeEntity.Path), System.Text.Encoding.GetEncoding("GBK")); //取出相关的注释 List <NoteEntity> assnotes = CodeOperation.GetAssNotes(codeEntity.Id); //对注释进行分组 List <int> index = new List <int>(); List <int> indexCount = new List <int>(); foreach (NoteEntity ne in assnotes) { if (!index.Contains(ne.StartLine)) { index.Add(ne.StartLine); indexCount.Add(1); } else { int myindex = 0; while (index[myindex] != ne.StartLine) { myindex++; } indexCount[myindex]++; } } //编译成js支持的数组格式 jsaLineNum = complieArray(index); jsaLineCount = complieArray(indexCount); /* Pre += "</pre>";*/ if (index.Count == 0) { jsaLineNum = "[]"; jsaLineCount = "[]"; } } catch { } }
public static string GetCode1(Image img) { Image imgCommon = img; //1.先灰度 Image grayImage = ImageHelper.Gray(imgCommon, ImageHelper.AlgorithmsType.WeightAverage); Bitmap bmp1 = grayImage as Bitmap; //2.亮度100 int v = ImageHelper.GetDgGrayValue(grayImage); Image lightImage = ImageHelper.PBinary(bmp1, v); // picGrayNoBg.Image = lightImage; //3.去除孤点 Bitmap bmp2 = lightImage as Bitmap; Image clearImage = ImageHelper.ClearImage(bmp2); Bitmap bmp = new Bitmap(clearImage); //0,1化 for (int m = 0; m < bmp.Height; m++) { for (int n = 0; n < bmp.Width; n++) { Color color = bmp.GetPixel(n, m); if (color.R == 255 && color.G == 255 && color.B == 255) { } else { bmp.SetPixel(n, m, Color.Black); } } } string r = string.Empty; List <Bitmap> bmpList = ImageHelper.CutImage(bmp, 16, 16); if (bmpList != null) { for (int j = 0; j < bmpList.Count; j++) { Bitmap _bmp = bmpList[j]; CodeEntity result = Realize(_bmp, StaticValues.CodeList1); if (result != null) { string charStr = result.CharStr; r = r + charStr; } } } return(r); }
/// <summary> /// Page_Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (UserOperation.CheckLoged(Session) == false) { SmallScript.goRedirect(Response,Session,"请登录后再浏览本页","/Login.aspx"); } string id = Request.QueryString["id"].ToString(); try { codeEntity = CodeOperation.GetCode(int.Parse(id)); langEntity = LangOperation.GetLang(codeEntity.Lid); userEntity = UserOperation.GetUser(codeEntity.Uid); /*Pre += "<pre style=\"margin:auto;\" class=\"brush: " + langEntity.BrushAliases + ";toolbar: false;\">";*/ Pre += File.ReadAllText(Server.MapPath(AppConfiger.GetProjectsDir(Server) + codeEntity.Path), System.Text.Encoding.GetEncoding("GBK")); //取出相关的注释 List<NoteEntity> assnotes = CodeOperation.GetAssNotes(codeEntity.Id); //对注释进行分组 List<int> index = new List<int>(); List<int> indexCount = new List<int>(); foreach (NoteEntity ne in assnotes) { if (!index.Contains(ne.StartLine)) { index.Add(ne.StartLine); indexCount.Add(1); } else { int myindex = 0; while (index[myindex] != ne.StartLine) { myindex++; } indexCount[myindex]++; } } //编译成js支持的数组格式 jsaLineNum = complieArray(index); jsaLineCount = complieArray(indexCount); /* Pre += "</pre>";*/ if (index.Count == 0) { jsaLineNum = "[]"; jsaLineCount = "[]"; } } catch { } }
/// <summary> /// toolbar事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void toolbar_MenuItemClick(object sender, MenuEventArgs e) { switch (e.Item.Value) { case "Delete": int succeed = 0; string CodeNames = ""; for (int i = 0; i < grid.Rows.Count; i++) { CheckBox chkItem = (CheckBox)grid.Rows[i].FindControl("chkItem"); if (chkItem != null && chkItem.Checked == true) { this.CodeID = NDConvert.ToInt64(grid.DataKeys[i]["CodeID"].ToString()); CodeEntity entity = new CodeEntity(CodeID); if (!CodeDetailQuery.IsExistCodeDetail(CodeID)) { entity.IsDeleted = true; new CodeRule().Update(entity); succeed++; } else { CodeNames += "[" + entity.CodeName + "]"; } } } this.CurOperation = (int)OperationEnum.INSERT; this.CodeID = 0; txtCodeName.Text = ""; txtCodeValue.Text = ""; txtMemo.Text = ""; if (succeed > 0) { BindGridView(); PageHelper.ShowMessage("删除成功!"); } if (CodeNames != "") { string msgErr = "代码名称为" + CodeNames + "的记录存在子记录,不可删除!\\n\\n" + "可先删除代码子记录后再删除相应代码!"; PageHelper.ShowExceptionMessage(msgErr); } break; } }
/// <inheritdoc/> protected override void OnEnter() { Result = CreateCodeEntity(); Result.Kind = KindOfCodeEntity.Function; _namedFunction = CreateNamedFunction(); _namedFunction.CodeEntity = Result; Result.NamedFunction = _namedFunction; Result.CodeFile = _context.CodeFile; Result.ParentCodeEntity = CurrentCodeEntity; SetCurrentCodeEntity(Result); if (Result.ParentCodeEntity != null) { _namedFunction.Holder = Result.ParentCodeEntity.Name; } }
private void AddSystemDefinedSettingsToClass(CodeEntity codeEntity) { var inheritanceItem = new InheritanceItem() { IsSystemDefined = true }; inheritanceItem.SubName = codeEntity.Name; inheritanceItem.SuperName = _context.CommonNamesStorage.ClassName; inheritanceItem.Rank = new LogicalValue(1.0F); #if DEBUG //Log($"inheritanceItem = {inheritanceItem}"); #endif codeEntity.InheritanceItems.Add(inheritanceItem); }
/// <summary> /// 更新实体外键信息信息 /// </summary> /// <param name="dtos">包含更新信息的实体外键信息</param> /// <returns>业务操作结果</returns> public async Task <OperationResult> UpdateCodeForeigns(params CodeForeignInputDto[] dtos) { List <string> names = new List <string>(); UnitOfWork.EnableTransaction(); foreach (var dto in dtos) { dto.Validate(); CodeEntity entity = await EntityRepository.GetAsync(dto.EntityId); if (entity == null) { return(new OperationResult(OperationResultType.Error, $"编号为“{dto.EntityId}”的实体信息不存在")); } if (await CheckCodeForeignExists(m => m.SelfNavigation == dto.SelfNavigation && m.EntityId == dto.EntityId, dto.Id)) { return(new OperationResult(OperationResultType.Error, $"实体“{entity.Name}”中名称为“{dto.SelfNavigation}”的外键信息已存在")); } int count; if (dto.Id == default) { CodeForeign foreign = dto.MapTo <CodeForeign>(); count = await ForeignRepository.InsertAsync(foreign); } else { CodeForeign foreign = await ForeignRepository.GetAsync(dto.Id); foreign = dto.MapTo(foreign); count = await ForeignRepository.UpdateAsync(foreign); } if (count > 0) { names.Add($"{entity.Name}-{dto.SelfNavigation}"); } } await UnitOfWork.CommitAsync(); return(names.Count > 0 ? new OperationResult(OperationResultType.Success, $"导航属性“{names.ExpandAndToString()}”更新成功") : OperationResult.NoChanged); }
protected override CommandResult ExecuteDetailed(GetProgramsCommandArgs args, ChangeObservable observable) { ExecutionContext.WriteWarning("This command is deprecated. Use 'get project-information' instead.", false); TemplateEntity project = TemplateEntity.Decorate(entityFactory.Create(Guid.NewGuid().ToByteString(), args).Root); IEnumerable <Entity> programs = project.EntityHierarchy.Where(e => e.Type.Equals("program", StringComparison.OrdinalIgnoreCase)) .ToArray(); if (!string.IsNullOrEmpty(args.Component)) { Entity component = project.EntityHierarchy.FirstOrDefault(e => e.HasName && e.Name == args.Component && e.Type.Equals("component", StringComparison.OrdinalIgnoreCase)); if (component != null) { programs = programs.Where(p => TemplateEntity.Decorate(p).RelatedEntites.Contains(component)); } else { ExecutionContext.WriteError($"A component with name {args.Component} does not exist in project {project.Name}."); return(new CommandResult(-1, ProgramsCommandResult.Empty)); } } if (!programs.Any()) { ExecutionContext.WriteInformation($"No programs found."); return(new CommandResult(0, ProgramsCommandResult.Empty)); } return(new CommandResult(0, new ProgramsCommandResult(programs.Select(p => { CodeEntity codeEntity = CodeEntity.Decorate(p); TemplateEntity templateEntity = TemplateEntity.Decorate(p); Entity componentEntity = templateEntity.RelatedEntites.FirstOrDefault(e => e.Type == "component"); if (componentEntity == null) { throw new InvalidOperationException($"Program {p.Name} has no related component. This should not be possible."); } CodeEntity componentCodeEntity = CodeEntity.Decorate(componentEntity); return new ProgramResult(p.Name, codeEntity.Namespace, componentEntity.Name, componentCodeEntity.Namespace); })))); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { int RowIndex = NDConvert.ToInt32(e.CommandArgument.ToString()); this.CodeID = NDConvert.ToInt64(grid.DataKeys[RowIndex].Values["CodeID"].ToString()); CodeEntity entity = new CodeEntity(CodeID); switch (e.CommandName) { case "Children": Page.ClientScript.RegisterStartupScript(this.GetType(), "CodeDetail", "showModalWindow('CodeDetailLY','子代码信息',600, 560,'../../Web/SysManager/CodeDetail.aspx?CodeID=" + this.CodeID + "');", true); break; case "Modify": txtCodeName.Text = entity.CodeName; txtCodeValue.Text = entity.CodeValue; txtMemo.Text = entity.Memo; this.CurOperation = (int)OperationEnum.UPDATE; break; case "Del": if (!CodeDetailQuery.IsExistCodeDetail(this.CodeID)) { entity.IsDeleted = true; new CodeRule().Update(entity); PageHelper.ShowMessage("删除成功!"); BindGridView(); } else { string msgErr = "该代码存在子记录,不可删除!\\n\\n" + "可先删除代码子记录后再删除该代码!"; PageHelper.ShowExceptionMessage(msgErr); } txtCodeName.Text = ""; txtCodeValue.Text = ""; txtMemo.Text = ""; this.CurOperation = (int)OperationEnum.INSERT; this.CodeID = 0; break; } }
/// <summary> /// 获取源代码信息 /// </summary> /// <param name="id">源码ID</param> /// <returns>返回源码的实例</returns> public static CodeEntity GetCode(int id) { DataBase db = new DataBase(); DataSet ds = db.ExCommand("select * from tb_code where id=" + id.ToString()); CodeEntity ce = new CodeEntity(); try { ce.Id = (int)ds.Tables[0].Rows[0]["id"]; ce.Pid = int.Parse(ds.Tables[0].Rows[0]["pid"].ToString()); ce.UpTime = DateTime.Parse(ds.Tables[0].Rows[0]["uptime"].ToString()); ce.Uid = int.Parse(ds.Tables[0].Rows[0]["uid"].ToString()); ce.Lid = int.Parse(ds.Tables[0].Rows[0]["lid"].ToString()); ce.Path = ds.Tables[0].Rows[0]["path"].ToString(); return ce; } catch { return null; } }
/// <summary> /// 利用源代码路径获取源代码信息 /// </summary> /// <param name="path">源码路径</param> /// <returns>返回源码的实例</returns> public static CodeEntity GetCodeFromPath(string path) { DataBase db = new DataBase(); DataSet ds = db.ExCommand("select * from tb_code where path='" + path.ToString() + "'"); CodeEntity ce = new CodeEntity(); try { ce.Id = (int)ds.Tables[0].Rows[0]["id"]; ce.Pid = int.Parse(ds.Tables[0].Rows[0]["pid"].ToString()); ce.UpTime = DateTime.Parse(ds.Tables[0].Rows[0]["uptime"].ToString()); ce.Uid = int.Parse(ds.Tables[0].Rows[0]["uid"].ToString()); ce.Lid = int.Parse(ds.Tables[0].Rows[0]["lid"].ToString()); ce.Path = ds.Tables[0].Rows[0]["path"].ToString(); return(ce); } catch { return(null); } }
private static CodeEntity Realize(Bitmap bmp,List<CodeEntity> codeList) { CodeEntity _ce = new CodeEntity(); string code = ImageHelper.GetBinaryCode(bmp).Trim(); int _rate = 0; string result = string.Empty; for (int i = 0; i < codeList.Count; i++) { CodeEntity ce = codeList[i]; string code1 = ce.GuiyiCode; string charStr = ce.CharStr; int rate = ImageHelper.CalcRate(code1, code); if (rate >=_rate) { _rate = rate; result = charStr; _ce = ce; } } return _ce; }
/// <summary> /// 上传按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_OK_Click(object sender, EventArgs e) { if (btn_OK.Text == "完成") { Response.Redirect("RSManager.aspx?dir=" + AppConfiger.GetProjectsDir(Server) + "\\" + ddl_Project.SelectedValue); } /*找读取工程目录*/ string targetFolder = AppConfiger.GetSiteSetting(Server, "projects"); string zipPath = ""; /*获取解压路径*/ string UnzipPath = Server.MapPath(targetFolder + "\\" + ddl_Project.SelectedValue.ToString() + "\\"); /*检查是否已上传文件*/ if (this.FileUpload1.FileName.LastIndexOf(".rar") == -1 && this.FileUpload1.FileName.LastIndexOf(".zip") == -1) { AddInfo("只允许上传rar和zip文件,请检查文件格式。"); return; } int pid = int.Parse(ddl_Project.SelectedValue); string filename = this.FileUpload1.FileName; zipPath = Server.MapPath(AppConfiger.GetProjectsZDir(Server) + "\\" + DateTime.Now.ToFileTimeUtc() + filename.Substring(filename.LastIndexOf(".") + 1, filename.Length - filename.LastIndexOf(".") - 1) ); this.FileUpload1.SaveAs(zipPath); /*zipPath = CookiesHelper.GetCookieValue("savePath"); if (zipPath == string.Empty || zipPath == null) { AddInfo("文件尚未上传!工程上传终止。"); return; }*/ /*如果已经勾选了清除工程*/ if (cb_Clear.Checked) { /*清除工程*/ ProjectManager.ClearDir(UnzipPath); AddInfo("已删除目录:" + UnzipPath); }/*End If*/ AddInfo("开始解压工程压缩包:" + zipPath); UnPackHelper uph = new UnPackHelper(zipPath, UnzipPath); uph.DoUnPack(); AddInfo("工程压缩包解压完成,开始整理代码。"); /*----------------------------------------------*/ ProjectManager.ClearCodes(pid); /*获取全部支持代码*/ List<LangEntity> langs = ProjectManager.GetLangs(); /*得到所有的工程内的文件*/ int count = 0; foreach (string fileName in Directory.GetFiles(UnzipPath, "*.*", SearchOption.AllDirectories)) { /*如果是已经支持的源码文件*/ string ext = GetExt(fileName); /*是否在支持的语言中*/ if (ProjectManager.IsLangsList(langs, ext)) { CodeEntity ce = new CodeEntity(); ce.Lid = ProjectManager.GetLid(langs, ext); ce.Pid = pid; ce.Uid = int.Parse(Session["uid"].ToString()); ce.UpTime = DateTime.Now; /*修正目录*/ ce.Path = fileName.Replace(Server.MapPath(AppConfiger.GetProjectsDir(Server)), ""); if (ProjectManager.AddCode(ce)) { count++; AddInfo("已将文件: " + ce.Path + " 加入代码库。"); } } } AddInfo("所有支持的代码已经入库,总共处理了 " + count.ToString() + " 份代码。"); btn_OK.Text = "完成"; Response.Cookies["savepath"].Expires = DateTime.Now; }
protected void btn_OK_Click(object sender, EventArgs e) { if (btn_OK.Text == "完成") { Response.Redirect("RSManager.aspx?dir=" + AppConfiger.GetProjectsDir(Server) + "\\" + ddl_Project.SelectedValue); } /*找读取工程目录*/ string targetFolder = AppConfiger.GetSiteSetting(Server, "projects"); string zipPath = ""; /*获取解压路径*/ string UnzipPath = Server.MapPath(targetFolder + "\\" + ddl_Project.SelectedValue.ToString() + "\\"); /*检查是否已上传文件*/ int pid = int.Parse(ddl_Project.SelectedValue); if (Session["savepath"] != null) { /*读取*/ zipPath = Session["savepath"].ToString(); } if (zipPath != string.Empty) { /*如果已经勾选了清除工程*/ if (cb_Clear.Checked) { /*清除工程*/ ProjectManager.ClearDir(UnzipPath); AddInfo("已删除目录:" + UnzipPath); }/*End If*/ AddInfo("开始解压工程压缩包:" + zipPath); UnPackHelper uph = new UnPackHelper(zipPath, UnzipPath); uph.DoUnPack(); AddInfo("工程压缩包解压完成,开始整理代码。"); /*----------------------------------------------*/ ProjectManager.ClearCodes(pid); /*获取全部支持代码*/ List<LangEntity> langs = ProjectManager.GetLangs(); /*得到所有的工程内的文件*/ int count=0; foreach (string fileName in Directory.GetFiles(UnzipPath, "*.*", SearchOption.AllDirectories)) { /*如果是已经支持的源码文件*/ string ext = GetExt(fileName); /*是否在支持的语言中*/ if (ProjectManager.IsLangsList(langs, ext)) { CodeEntity ce = new CodeEntity(); ce.Lid = ProjectManager.GetLid(langs, ext); ce.Pid = pid; ce.Uid =int.Parse(Session["uid"].ToString()); ce.UpTime = DateTime.Now; /*修正目录*/ ce.Path=fileName.Replace(Server.MapPath(AppConfiger.GetProjectsDir(Server)),""); if (ProjectManager.AddCode(ce)) { count++; AddInfo("已将文件: " + ce.Path + " 加入代码库。"); } } } AddInfo("所有支持的代码已经入库,总共处理了 " + count.ToString() + " 份代码。"); btn_OK.Text = "完成"; } else { AddInfo("文件尚未上传!工程上传终止。"); } }