public static string GetControlDisplayName(bool supportMutiLangs, string className, string ctrlName, List<Annex> annexes, string defDisplayName) { try { if (defDisplayName.IsNullOrEmpty()) { if (!ctrlName.Contains("_")) defDisplayName = ctrlName; else defDisplayName = ctrlName.GetLastSeparatedString('_'); } if (supportMutiLangs) { var text = AnnexHelper.GetText(className, ctrlName, annexes, AnnexTextType.DisplayName, CultureHelper.CurrentLanguageCode, GetAnnexMode.OnlyByCurLang); if (text.IsNullOrEmpty()) text = defDisplayName; return text; } else { return defDisplayName; } } catch (Exception ex) { throw new ArgumentException("\n>> " + TypeName + ".GetDisplayName Error: " + ex.Message); } }
protected void RefreshBackgroundTaskComponent(List <BackgroundTaskPool.BackgroundTask> backTasks) { try { var backTasksProcessingNo = backTasks.FindAll(x => x.Status == (int)TaskStatus.Processing).Count; var backTasksWaitingNo = backTasks.FindAll(x => x.Status == (int)TaskStatus.Waiting).Count; RunningStatusSectionBackgroundTaskRegionImageTextButton.Text = BackgroundTaskImageTextButtonText + @" " + backTasksProcessingNo + @"/" + backTasksWaitingNo; if (backTasksProcessingNo > 0) { RunningStatusSectionBackgroundTaskRegionProgressCircleZone.Width = BackgroundTaskProgressCircleSize; RunningStatusSectionBackgroundTaskRegionProgressCircle.Visible = true; RunningStatusSectionBackgroundTaskRegionProgressCircle.Width = BackgroundTaskProgressCircleSize; RunningStatusSectionBackgroundTaskRegionProgressCircle.Start(); } else { RunningStatusSectionBackgroundTaskRegionProgressCircle.Visible = false; RunningStatusSectionBackgroundTaskRegionProgressCircle.Stop(); RunningStatusSectionBackgroundTaskRegionProgressCircleZone.Width = 0; } BackgroundTaskDetailLabel.Text = BackgroundTaskInfoLabelText; var idValTextList = new List <IdValueText>(); foreach (var task in backTasks) { var typeIdName = _backgroundTaskTypeList.Find(x => x.Id == task.Type); if (typeIdName != null) { task.TypeName = AnnexHelper.GetText("", typeIdName.Name, _backgroundTaskTypeAnnexes, AnnexTextType.DisplayName, CultureHelper.CurrentLanguageCode, GetAnnexMode.StepByStep); } else { task.TypeName = WinformRes.Unknown; } Type t = task.GetType(); var myFields = t.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); for (int i = 0; i < myFields.Length; i++) { var idValueText = new IdValueText(); idValueText.Id = task.Id; idValueText.Value = myFields[i].Name; var obj = myFields[i].GetValue(task); idValueText.Text = obj == null ? "" : obj.ToString(); idValTextList.Add(idValueText); } } ////BackgroundTaskDetailListViewEx.Render(idValTextList); } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + "." + "RefreshBackgroundTaskComponent Error: " + ex.Message); } }
private static string GetAnnexText(bool supportMultiLangs, AnnexTextType annexTextType, string className, string ctrlName, List <Annex> annexes, string defText) { if (supportMultiLangs) { var text = AnnexHelper.GetText(className, ctrlName, annexes, annexTextType, CultureHelper.CurrentLanguageCode, GetAnnexMode.OnlyByCurLang); if (text.IsNullOrEmpty()) { text = defText; } return(text); } else { return(defText); } }
internal string GetJobDisplayName() { try { var job = JobServiceData.Job; var txt = ""; if (GlobalConfiguration.SupportMutiCultures) { txt = AnnexHelper.GetText("", job.Id, JobServiceData.JobAnnexes, AnnexTextType.DisplayName, GlobalConfiguration.CurrentLanguageCode, GetAnnexMode.OnlyByCurLang); } if (txt.IsNullOrEmpty()) { txt = job.DisplayName; } return(txt); } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + ".GetJobDisplayName Error: " + ex.Message); } }
internal string GetValidationResult(string text, string validationRule) { try { var subParamSeparator = validationRule.GetSubParamSeparator(); var ruleArray = validationRule.Split(subParamSeparator); var ruleName = ruleArray[0]; if (ruleName == "PasswordFormat2") { if (text.IsPassword()) { return("true"); } else { if (ValidationServiceData.ValidationAnnexes == null) { ValidationServiceData.Init(); } var txt = ""; txt = GlobalConfiguration.SupportMutiCultures ? AnnexHelper.GetText("", ruleName, ValidationServiceData.ValidationAnnexes, AnnexTextType.Description, GlobalConfiguration.CurrentLanguageCode, GetAnnexMode.StepByStep) : AnnexHelper.GetText("", ruleName, JobServiceData.JobAnnexes, AnnexTextType.Description, "", GetAnnexMode.FirstAnnex); return(txt); } } else { throw new ArgumentException(" has no validation rule: " + ruleArray[0] + "! "); } } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + ".GetValidationResult Error: " + ex.Message); } }
//#WinConfigGroup //##GetWinConfigGroupProperty internal string GetWinConfigGroupProperty(int id, string property) { try { var winConfigGrp = WinConfigServiceData.WinConfigGroups.Find(x => x.Id == id); if (property.ToLower() == "DisplayName".ToLower()) { var text = GlobalConfiguration.SupportMutiCultures ? AnnexHelper.GetText("", id, WinConfigServiceData.WinConfigGroupAnnexes, AnnexTextType.DisplayName, GlobalConfiguration.CurrentLanguageCode, GetAnnexMode.StepByStep) : AnnexHelper.GetText("", id, WinConfigServiceData.WinConfigGroupAnnexes, AnnexTextType.DisplayName, GlobalConfiguration.CurrentLanguageCode, GetAnnexMode.FirstAnnex); return(text); } else if (property.ToLower() == "Description".ToLower()) { var text = GlobalConfiguration.SupportMutiCultures ? AnnexHelper.GetText("", id, WinConfigServiceData.WinConfigGroupAnnexes, AnnexTextType.Description, GlobalConfiguration.CurrentLanguageCode, GetAnnexMode.StepByStep) : AnnexHelper.GetText("", id, WinConfigServiceData.WinConfigGroupAnnexes, AnnexTextType.Description, GlobalConfiguration.CurrentLanguageCode, GetAnnexMode.FirstAnnex); return(text); } else if (property.ToLower() == "ManualFixDes".ToLower()) { var text = GlobalConfiguration.SupportMutiCultures ? AnnexHelper.GetText("", id, WinConfigServiceData.WinConfigGroupAnnexes, AnnexTextType.Remark, GlobalConfiguration.CurrentLanguageCode, GetAnnexMode.StepByStep) : AnnexHelper.GetText("", id, WinConfigServiceData.WinConfigGroupAnnexes, AnnexTextType.Remark, GlobalConfiguration.CurrentLanguageCode, GetAnnexMode.FirstAnnex); return(text); } else if (property.ToLower() == "ManualFix1Des".ToLower()) { var text = GlobalConfiguration.SupportMutiCultures ? AnnexHelper.GetText("", id, WinConfigServiceData.WinConfigGroupAnnexes, AnnexTextType.Remark1, GlobalConfiguration.CurrentLanguageCode, GetAnnexMode.StepByStep) : AnnexHelper.GetText("", id, WinConfigServiceData.WinConfigGroupAnnexes, AnnexTextType.Remark1, GlobalConfiguration.CurrentLanguageCode, GetAnnexMode.FirstAnnex); return(text); } else if (property.ToLower() == "ManualFix2Des".ToLower()) { var text = GlobalConfiguration.SupportMutiCultures ? AnnexHelper.GetText("", id, WinConfigServiceData.WinConfigGroupAnnexes, AnnexTextType.Remark2, GlobalConfiguration.CurrentLanguageCode, GetAnnexMode.StepByStep) : AnnexHelper.GetText("", id, WinConfigServiceData.WinConfigGroupAnnexes, AnnexTextType.Remark2, GlobalConfiguration.CurrentLanguageCode, GetAnnexMode.FirstAnnex); return(text); } else if (property.ToLower() == "HasManualJudge".ToLower()) { return(winConfigGrp.HasManualJudge.ToString()); } else if (property.ToLower() == "HasSeeDetail".ToLower()) { return(winConfigGrp.HasSeeDetail.ToString()); } else if (property.ToLower() == "HasRefresh".ToLower()) { return(winConfigGrp.HasRefresh.ToString()); } else if (property.ToLower() == "HasAutoFix".ToLower()) { return(winConfigGrp.HasAutoFix.ToString()); } else if (property.ToLower() == "HasManualFix".ToLower()) { return(winConfigGrp.HasManualFix.ToString()); } else if (property.ToLower() == "ManualFixAction".ToLower()) { return(winConfigGrp.ManualFixAction); } else if (property.ToLower() == "HasManualFix1".ToLower()) { return(winConfigGrp.HasManualFix1.ToString()); } else if (property.ToLower() == "ManualFix1Action".ToLower()) { return(winConfigGrp.ManualFix1Action); } else if (property.ToLower() == "HasManualFix2".ToLower()) { return(winConfigGrp.HasManualFix2.ToString()); } else if (property.ToLower() == "ManualFix2Action".ToLower()) { return(winConfigGrp.ManualFix2Action); } else if (property.ToLower() == "HasSave".ToLower()) { return(winConfigGrp.HasSave.ToString()); } else if (property.ToLower() == "HasReadDoc".ToLower()) { return(winConfigGrp.HasReadDoc.ToString()); } else if (property.ToLower() == "ReadDocAction".ToLower()) { return(winConfigGrp.ReadDocAction); } else { throw new ArgumentException("has no property: " + property); } } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + ".GetWinConfigGroupProperty Error: " + ex.Message); } }
public void ProcessRequest(HttpContext context) { var Request = context.Request; var Response = context.Response; int statusCode = 200; string result = string.Empty; try { // 获取数据 HttpPostedFile file = Request.Files[0]; string extname = System.IO.Path.GetExtension(file.FileName.ToLower()); string diskPath = null, urlPath = null; if (!string.IsNullOrWhiteSpace(extname)) { extname = extname.TrimStart('.'); if (!AnnexHelper.AllowFiles.Contains(extname)) { statusCode = -240; throw new Exception("不允许上传“*." + extname + "”类型的文件"); } if (AnnexHelper.MaxSize < file.InputStream.Length) { statusCode = -110; throw new Exception("文件尺寸超出大小限制(最大允许上传" + AnnexHelper.MaxSizeName + "的文件"); } string isTemp = context.Request["isTemp"]; if (string.IsNullOrEmpty(isTemp)) { isTemp = "true"; } AnnexHelper.CreateSaveDirectory(Convert.ToBoolean(isTemp), out urlPath, out diskPath); string fname = string.Format("{0}.{1}", Guid.NewGuid(), extname); diskPath = System.IO.Path.Combine(diskPath, fname); urlPath = urlPath + fname; using (System.IO.FileStream fs = new System.IO.FileStream(diskPath, System.IO.FileMode.CreateNew)) { byte[] buff = new byte[file.InputStream.Length]; file.InputStream.Position = 0; file.InputStream.Read(buff, 0, buff.Length); fs.Write(buff, 0, buff.Length); fs.Close(); fs.Dispose(); } } statusCode = 200; result = urlPath; } catch (Exception ex) { statusCode = statusCode == 200 ? 500 : statusCode; result = ex.Message; } finally { Response.StatusCode = statusCode; Response.Write(result); Response.End(); } }