/// <summary> /// To get all the sites. /// </summary> /// <returns></returns> public List <KeyValueModel> GetAllSites() { List <KeyValueModel> allSitesKeyValue = null; try { List <Site> listOfSites = _siteRepository.GetSites(false); if (listOfSites?.Count > 0) { allSitesKeyValue = new List <KeyValueModel>(); foreach (Site site in listOfSites) { KeyValueModel keyValue = new KeyValueModel(); keyValue.Key = site.SiteName; keyValue.Value = site.SiteName; allSitesKeyValue.Add(keyValue); } } } catch (Exception ex) { _logger.Log(ex, LogLevel.Error, ex.Message); } return(allSitesKeyValue); }
public void Put() { // Arrange ValuesController controller = new ValuesController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); KeyValueModel model = new KeyValueModel() { _namespace = "test002", key = "t2", value = "002" }; // Act controller.Put(model); IHttpActionResult actionResult = controller.Get("test002"); var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <object> >; // Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.AreEqual("002", contentResult.Content.Select(x => x).First()); }
public List <KeyValueModel> GetJobParaList(string jobName, string jobGroupName) { List <KeyValueModel> list = new List <KeyValueModel>(); try { JobKey jobKey = CreateJobKey(jobName, jobGroupName); var jobData = _scheduler.GetJobDetail(jobKey).GetAwaiter().GetResult(); if (jobData == null || jobData.JobDataMap == null) { return(list); } foreach (var item in jobData.JobDataMap) { KeyValueModel model = new KeyValueModel(); model.key = item.Key; model.value = item.Value.ToString(); list.Add(model); } } catch (Exception ex) { logger.Error(ex); } return(list); }
public CustomerMasterModel GetData() { var model = new CustomerMasterModel(); var Texts = new MainSetting_Logic(); model.SiteTexts = Texts.GetMainSetting(); var Pics = new PicsSetting_Logic(); model.SitePics = Pics.GetPicsSetting(); /////////// List <KeyValueModel> ServiceModels = new List <KeyValueModel>(); base.Connect(); DataTable dt = base.Select("SELECT top 4 [S_Id],[Subject] FROM [tbl_Services] WHERE [Deleted]=0 AND [Show_Menu]=1 AND [Active]=1"); base.DC(); for (int i = 0; i < dt.Rows.Count; i++) { var m = new KeyValueModel() { Key = Convert.ToInt32(dt.Rows[i]["S_Id"]), Value = dt.Rows[i]["Subject"].ToString() }; ServiceModels.Add(m); } model.ServiceList = ServiceModels; return(model); }
public List <KeyValueModel> GetJobParaList(string jobName, string jobGroupName) { List <KeyValueModel> list = new List <KeyValueModel>(); try { JobKey jobKey = CreateJobKey(jobName, jobGroupName); JobDataModel jobData = Xml.XmlJobManage.GetJobDataByKey(jobKey); if (jobData == null || jobData.CallbackParams == null) { return(list); } foreach (var item in jobData.CallbackParams) { KeyValueModel model = new KeyValueModel(); model.key = item.Key; model.value = item.Value; list.Add(model); } } catch (Exception ex) { logger.Error(ex); } return(list); }
public async Task <IActionResult> Save(KeyValueModel model) { var namespaceId = HttpContext.Session.GetString("namespaceId"); var client = GetClient(namespaceId); if (string.IsNullOrWhiteSpace(model.Key)) { return(RedirectToAction("ViewNamespace", "Namespaces", new { Id = namespaceId })); } object obj; try { obj = JsonConvert.DeserializeObject(model.Json); } catch { return(RedirectToAction("Index", "KeyValues", new { model.Key })); } await client.KeyValues.Write(model.Key, obj); return(RedirectToAction("Index", "KeyValues", new { model.Key })); }
public void Delete() { // Arrange ValuesController controller = new ValuesController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); KeyValueModel model = new KeyValueModel() { _namespace = "test003", key = "t3", value = "003" }; // Act controller.Put(model); //add key controller.Delete(model._namespace, model.key); //delete key IHttpActionResult actionResult = controller.Get("test003", "t3"); //lookup key by namespace var contentResult = actionResult as ExceptionResult; // Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Exception); Assert.AreEqual("combination of namespace and key not found in memory", contentResult.Exception.Message); }
private void UCPrinterJobDetail_Load(object sender, EventArgs e) { //LoadPriterMapp(); this.cbPrintContent.DisplayMember = "Value"; this.cbPrintContent.ValueMember = "Key"; var temp = new KeyValueModel(); temp.Key = 1; temp.Value = "All Lines"; this.cbPrintContent.Items.Add(temp); }
public ResultModel <List <KeyValueModel> > GetAllSexEnum() { try { List <KeyValueModel> result = KeyValueModel.GetAllCode(typeof(SexEnum)); return(ResultModel <List <KeyValueModel> > .Success(result)); } catch (ArgumentException ex) { return(ResultModel <List <KeyValueModel> > .Fail(ex.Message)); } }
/// <summary> /// To the model. /// </summary> /// <param name="model">The model.</param> /// <returns></returns> public static KeyValueModel ToModel(this KeyValueViewModel model) { if (model == null) { return(null); } var entity = new KeyValueModel { Key = model.Key, Value = model.Value }; return(entity); }
/// <summary> /// To the view model. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static KeyValueViewModel ToViewModel(this KeyValueModel entity) { if (entity == null) { return(null); } var model = new KeyValueViewModel { Key = entity.Key, Value = entity.Value }; return(model); }
private static void KeyValueArray() { var model = new KeyValueModel(); model.Parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("121", "dsadsa"), new KeyValuePair <string, string>("122", "dsadsa"), new KeyValuePair <string, string>("123", "dsadsa"), }; var json = JsonConvert.SerializeObject(model); Console.WriteLine(json); var obj = JsonConvert.DeserializeObject <KeyValueModel>(json); Console.WriteLine(obj.Parameters.Count); }
/// <summary> /// Save key value by namespace as group name /// </summary> /// <param name="value"></param> /// <returns></returns> // PUT api/values/5 public IHttpActionResult Put([FromBody] KeyValueModel value) { bool result = false; try { IStoreKeyValue store = StoreKeyValue.Instance; KeyValueModel copyOfKvp = value.Clone() as KeyValueModel; result = store.AddKeyValue(copyOfKvp._namespace, copyOfKvp.key, copyOfKvp.value); } catch (Exception) { return(InternalServerError()); } return(Ok()); }
private void frmNewShift_Load(object sender, EventArgs e) { userid = UserLoginModel.UserLoginInfo.StaffID; if (userid == 0) { Form1 frm = new Form1(); this.Close(); frm.ShowDialog(); } else { fname = UserLoginModel.UserLoginInfo.UserName; var historyshift = ShiftService.GetListShiftHistoryByUserid(userid, 1).FirstOrDefault(); double startcash = 0; if (historyshift != null) { startcash = (historyshift.CashEnd ?? 0) - (historyshift.SafeDrop ?? 0); } MoneyFortmat Fomat = new MoneyFortmat(1); startcash = Fomat.getValue(startcash); var data = ShiftService.GetAllStaffActive().ToList(); this.cbStaff.DisplayMember = "Value"; this.cbStaff.ValueMember = "Key"; foreach (var item in data) { var temp = new KeyValueModel(); temp.Key = item.StaffID; temp.Value = item.UserName; this.cbStaff.Items.Add(temp); } this.cbStaff.Text = fname; this.txtCashStart.Text = startcash.ToString(); } }
protected internal void AddCallTag(CallTag type, string value) { if (Model.Action.CallTags == null) { Model.Action.CallTags = new[] { new KeyValueModel { Key = type, Value = value } }; return; } var newTags = new KeyValueModel[Model.Action.CallTags.Length + 1]; Array.Copy(Model.Action.CallTags, newTags, Model.Action.CallTags.Length); newTags[newTags.Length - 1] = new KeyValueModel { Key = type, Value = value }; Model.Action.CallTags = newTags; }
public async Task <IEnumerable <ContentList> > GetContentList(int PageIndex = 1, int PageSize = 20)//ContentList contentList, KeyValueModel keyValue, { ContentList contentList = new ContentList() { Content = "Test", Author = "Test" }; KeyValueModel keyValue = new KeyValueModel() { }; var abcdefg = WhereLambdas(contentList, keyValue); int a1 = ContentListService.GetCount(abcdefg).Result; Expression <Func <ContentList, bool> > exp = StringToLambda.LambdaParser.Parse <ContentList>("s=>s.Content.Contains(\"Test\")&&s.Author == \"Test\""); int a2 = ContentListService.GetCount(exp).Result; Expression <Func <ContentList, bool> > exp0 = StringToLambda.LambdaParser.Parse <ContentList>("s=>s.Author == \"Test\""); Expression <Func <ContentList, bool> > exp1 = StringToLambda.LambdaParser.Parse <ContentList>("s=>s.Content.Contains(\"Test\")"); Expression <Func <ContentList, bool> > exp2 = StringToLambda.LambdaParser.Parse <ContentList>("s => s.Time"); Pages.PageSize = PageSize; Pages.PageIndex = PageIndex; return(await ContentListService.GetEntitiesByPpage(Pages.PageSize, Pages.PageIndex, false, s => s.Content.Contains("Test") && s.Author == "Test", exp2));//WhereLambdas(contentList, keyValue) }
public ActionResult GetIcons() { KeyValueModel ret = base.error_r; try { using (WechatEntities et = new WechatEntities()) { var Icons = et.T_FontIcons.Where(i => i.IsDeleted == false).OrderBy(s => s.SortNum).Select(p => new { FontClass = p.FontClass }).ToList(); ret = base.success_r; ret.Value = JsonConvert.SerializeObject(Icons); } } catch (Exception ex) { ret.Value = ex.Message; } return(Json(ret, JsonRequestBehavior.AllowGet)); }
private void btnAdd_Click(object sender, EventArgs e) { pDetail.Controls.Clear(); Button addNew = (Button)sender; int tag = Convert.ToInt32(addNew.Tag); switch (tag) { case 1: UCDepartmentListDetail ucDepartment = new UCDepartmentListDetail(); ucDepartment.Dock = DockStyle.Fill; ucDepartment.btnSave.Click += btnSaveDepartment_Click; ucDepartment.btnDelete.Hide(); pDetail.Controls.Add(ucDepartment); break; case 2: UCUserListDetail ucUser = new UCUserListDetail(); ucUser.Dock = DockStyle.Fill; ucUser.btnSave.Click += btnSaveUser_Click; ucUser.btnDelete.Hide(); ucUser.cbRole.DisplayMember = "Value"; ucUser.cbRole.ValueMember = "Key"; var department = UserService.GetListDepartment().ToList(); foreach (var item in department) { var temp = new KeyValueModel(); temp.Key = item.DepartmentID; temp.Value = item.DepartmentName; ucUser.cbRole.Items.Add(temp); } //ucUser.cbRole.SelectedIndex = 0; pDetail.Controls.Add(ucUser); break; } }
public KeyValueModel SearchCountPerCountry() { var client = SetupElasticSearch(); var request = new SearchRequest <Triathlete> { Aggregations = new TermsAggregation("countries") { Field = new Field { }.Name = "country", MinimumDocumentCount = 0, Size = 0, Missing = "n/a", Order = new List <TermsOrder> { TermsOrder.CountDescending, TermsOrder.TermAscending } } }; var response = client.Search <Triathlete>(request); var countries = response.Aggs.Terms("countries"); var model = new KeyValueModel(); model.KeyValuePairs = new List <KeyValuePair <string, string> >(); foreach (var item in countries.Buckets) { model.KeyValuePairs.Add( new KeyValuePair <string, string>( item.Key.ToUpper(), item.DocCount.ToString()) ); } return(model); }
private void cbGroupItem_SelectedIndexChanged(object sender, EventArgs e) { this.cbItem.Items.Clear(); var cbGroup = (KeyValueModel)cbGroupItem.SelectedItem; var datagroup = PrinterService.GetProductListByCategory(cbGroup.Key).ToList(); var temp = new KeyValueModel(); temp.Key = 0; temp.Value = "-- All --"; this.cbItem.Items.Add(temp); foreach (var item in datagroup) { var tempitem = new KeyValueModel(); tempitem.Key = item.ProductID; tempitem.Value = item.ProductNameDesc; this.cbItem.Items.Add(tempitem); } this.cbItem.SelectedIndex = 0; }
/// <summary> /// mapper utility to convert a business checklist type list to a KeyValueModel list /// </summary> /// <param name="checkListType"></param> /// <returns></returns> public static List <KeyValueModel> CheckListTypeMap(this IEnumerable <M3Pact.BusinessModel.BusinessModels.CheckListType> checkListType) { if (checkListType == default(List <M3Pact.BusinessModel.BusinessModels.CheckListType>)) { return(new List <KeyValueModel>()); } try { return(checkListType.Select(e => { KeyValueModel j = new KeyValueModel { Key = e.CheckListTypeID.ToString(), Value = e.CheckListTypeName }; return j; }).ToList()); } catch (Exception ex) { throw ex; } }
public static MvcHtmlString CheckBoxListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, DisplayDirection direction, int colOrRows, object htmlAttribute, object itemAttribute) { string resultStr = ""; string checkPropertyName; string displayPropertyName; MemberExpression nameExpr = (MemberExpression)expression.Body; checkPropertyName = nameExpr.Member.Name; PropertyInfo property = typeof(TModel).GetProperty(checkPropertyName); KeyValueAttribute attribute = (KeyValueAttribute)property.GetCustomAttributes(typeof(KeyValueAttribute), false)[0]; if (attribute == null) { throw new Exception(); } displayPropertyName = attribute.DisplayProperty; string validAttribute = ""; //RequiredAttribute requiredAttribute = (RequiredAttribute)property.GetCustomAttributes(typeof(RequiredAttribute), false)[0]; //if (requiredAttribute != null) //{ // validAttribute += " data-val='true' "; // if (String.IsNullOrEmpty(requiredAttribute.ErrorMessage)) // { // string template = "The {0} field is required."; // validAttribute += " data-val-required='" + string.Format(template, displayPropertyName) + "' "; // } // else // { // validAttribute += " data-val-required='" + requiredAttribute.ErrorMessage + "' "; // } //} IEnumerable checkList = (IEnumerable)htmlHelper.ViewData.Eval(displayPropertyName); var isCheckedList = htmlHelper.ViewData.Eval(checkPropertyName) as IEnumerable; IDictionary <string, object> htmlAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttribute); IDictionary <string, object> itemAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(itemAttribute); string htmlAttributeStr = ""; foreach (var item in htmlAttributes) { htmlAttributeStr += " " + item.Key + "='" + item.Value + "' "; } string itemAttributeStr = ""; foreach (var item in itemAttributes) { itemAttributeStr += " " + item.Key + "='" + item.Value + "' "; } string directionAppend = ""; if (direction == DisplayDirection.Vertical) { directionAppend = "<br/>"; } int index = 1; resultStr += "<div " + validAttribute + htmlAttributeStr + ">"; foreach (KeyValueModel check in checkList) { resultStr += "<span " + itemAttributeStr + ">"; string checkedStr = ""; bool isCheck = false; foreach (var checkvalue in isCheckedList) { isCheck = check.Value == checkvalue.ToString(); if (isCheck) { checkedStr = " checked='checked' "; break; } } KeyValueModel checkModel = (KeyValueModel)check; if (check.Disable == "disabled" && check.Disable != null) { resultStr += "<label class='label-multi'><input class='" + check.Disable + "'disabled='" + check.Disable + "'name='" + checkPropertyName + "' type=\"checkbox\" value='" + check.Value + "'" + checkedStr + " ></input>" + " "; resultStr += checkModel.Text + "</label>"; } else { resultStr += "<label class='label-multi'><input name='" + checkPropertyName + "' type=\"checkbox\" value='" + check.Value + "'" + checkedStr + " ></input>" + " "; resultStr += checkModel.Text + "</label>"; } resultStr += "</span>"; if (index % colOrRows == 0) { resultStr += directionAppend; } index = index + 1; } resultStr += "</div>"; MvcHtmlString result = new MvcHtmlString(resultStr); return(result); }
private Expression <Func <ContentList, bool> > WhereLambdas(ContentList contentList, KeyValueModel keyValue) { Expression <Func <ContentList, bool> > where = s => s.IsDraft == false; if (contentList != null) { if (contentList.Id != 0) { where = Helper.LambdasHelper.And(where, s => s.Id == contentList.Id); } if (string.IsNullOrEmpty(contentList.Title)) { where = Helper.LambdasHelper.And(where, s => s.Title == contentList.Title); } if (string.IsNullOrEmpty(contentList.Content)) { where = Helper.LambdasHelper.And(where, s => s.Content.Contains(contentList.Content)); } if (contentList.IsShow != null) { where = Helper.LambdasHelper.And(where, s => s.IsShow == contentList.IsShow); } if (string.IsNullOrEmpty(contentList.Label)) { where = Helper.LambdasHelper.And(where, s => s.Label.Contains(contentList.Label)); } if (string.IsNullOrEmpty(contentList.Author)) { where = Helper.LambdasHelper.And(where, s => s.Author.Contains(contentList.Author)); } if (string.IsNullOrEmpty(contentList.TypeValue)) { where = Helper.LambdasHelper.And(where, s => s.TypeValue.Contains(contentList.TypeValue)); } } if (keyValue != null) { if (keyValue.StartDate != null) { Helper.LambdasHelper.And(where, s => s.Time.CompareTo(TextToDateTime(keyValue.StartDate)) >= 0); } if (keyValue.EndDate != null) { Helper.LambdasHelper.And(where, s => s.Time.CompareTo(TextToDateTime(keyValue.EndDate)) <= 0); } if (keyValue.StartDate != null) { Helper.LambdasHelper.And(where, s => TextToDateTime(keyValue.StartDate2).CompareTo((DateTime)s.LastTime) >= 0); } if (keyValue.EndDate != null) { Helper.LambdasHelper.And(where, s => TextToDateTime(keyValue.EndDate2).CompareTo((DateTime)s.LastTime) <= 0); } } return(where); }
public static MvcHtmlString RadioListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, int cols, object warpHtmlAttribute, object itemHtmlAttribute, int width = 0, int indent = 0) { string tableClassStr = ""; string tdClassStr = ""; string result = ""; string radioPropertyName; string displayPropertyName; MemberExpression nameExpr = (MemberExpression)expression.Body; radioPropertyName = nameExpr.Member.Name; // 获取特性 PropertyInfo property = typeof(TModel).GetProperty(radioPropertyName); KeyValueAttribute attribute = (KeyValueAttribute)property.GetCustomAttributes(typeof(KeyValueAttribute), false)[0]; if (attribute == null) { throw new Exception(); } displayPropertyName = attribute.DisplayProperty; //获取显示列表 和选择值 IEnumerable radioList = (IEnumerable)htmlHelper.ViewData.Eval(displayPropertyName); var checkValue = htmlHelper.ViewData.Eval(radioPropertyName); // 转换objectHtmlAttrbute IDictionary <string, object> wrapKeyValue = HtmlHelper.AnonymousObjectToHtmlAttributes(warpHtmlAttribute); IDictionary <string, object> itemKeyValue = HtmlHelper.AnonymousObjectToHtmlAttributes(itemHtmlAttribute); // 生成Html if (wrapKeyValue.Count > 0) // wrapClassStr { foreach (KeyValuePair <string, object> keyValue in wrapKeyValue) { tableClassStr += keyValue.Key + "=" + keyValue.Value.ToString(); } } //if (itemKeyValue.Count > 0) //{ // foreach (KeyValuePair<string, object> keyValue in itemKeyValue) // { // tdClassStr += keyValue.Key + "='" + keyValue.Value.ToString() + "' "; // } //} int index = 0; result += "<table " + tableClassStr + ">"; foreach (var radio in radioList) { if (index % cols == 0) { result += "<tr>"; } KeyValueModel radioModel = (KeyValueModel)radio; bool isCheck = checkValue == null ? false : checkValue.ToString() == radioModel.Value; if (width > 0) { result += "<td width=\"" + width + "px\" style=\"margin-right:" + indent + "px; display:inline-block;\">"; } else { result += "<td style=\"margin-right:" + indent + "px; display:inline-block;\" " + ">"; //"<td " + tdClassStr + ">"; } result += (htmlHelper.RadioButton(radioPropertyName, radioModel.Value, isCheck, itemHtmlAttribute)).ToHtmlString(); result += radioModel.Text; //ResourceHelper.GetResourceObject(typeof(CommonResource), radioModel.ResourceKey) result += "</td>"; if (index % cols == cols - 1) { result += "</tr>"; } index += 1; } result += "</table>"; return(new MvcHtmlString(result)); }
public ActionResult WxMenusSave(T_Wx_Menus menu, string operatype) { KeyValueModel ret = new KeyValueModel { Key = "error", Value = "操作失败!" }, successret = new KeyValueModel { Key = "success", Value = "操作成功!" }; try { using (WechatEntities context = new WechatEntities()) { switch (operatype) { #region 新增 case "add": if (context.T_Wx_Menus.Any(m => m.MenuId == menu.MenuId)) { ret.Value = "已经存在菜单代码为" + menu.MenuId + "的菜单"; } else { switch (menu.MenuLevel) { case "button": case "sub_button": var cnt = context.T_Wx_Menus.Where(m => m.MenuLevel == menu.MenuLevel && m.IsDeleted == false); #region 一级菜单 if (menu.MenuLevel == "button") { if (cnt.Count() >= 3) { ret.Value = "已经存在3个1级菜单"; } else { menu.CreateTime = DateTime.Now; context.T_Wx_Menus.Add(menu); context.SaveChanges(); ret = successret; } } #endregion #region 二级菜单 else { if (cnt.Where(k => k.ParentMenu == menu.ParentMenu).Count() >= 5) { ret.Value = "已经存在5个二级菜单"; } else { menu.CreateTime = DateTime.Now; context.T_Wx_Menus.Add(menu); context.SaveChanges(); ret = successret; } } #endregion break; } } break; #endregion #region 修改 case "modify": T_Wx_Menus _menu = context.T_Wx_Menus.Where(m => m.MenuId == menu.MenuId && m.IsDeleted == false).FirstOrDefault(); if (_menu != null) { _menu.ModifyTime = DateTime.Now; _menu.SortNum = menu.SortNum; _menu.MenuName = menu.MenuName; _menu.MenuUrl = menu.MenuUrl; _menu.MenuType = menu.MenuType; context.SaveChanges(); ret = successret; } else { ret.Value = "未能找到此菜单,可能已被删除!"; } break; #endregion #region 除 case "delete": T_Wx_Menus MN = context.T_Wx_Menus.Where(m => m.MenuId == menu.MenuId).FirstOrDefault(); if (MN != null) { MN.IsDeleted = true; MN.ModifyTime = DateTime.Now; context.SaveChanges(); ret = successret; } break; #endregion } } } catch (Exception ex) { ret.Value = ex.Message; } return(Json(ret, JsonRequestBehavior.AllowGet)); }
public ActionResult SysMenusSave(T_SysMenus menu, string operatype) { KeyValueModel ret = base.error_r; try { using (WechatEntities context = new WechatEntities()) { switch (operatype) { #region 新增 case "add": if (context.T_SysMenus.Any(m => m.MenuId == menu.MenuId)) { ret.Value = "已经存在菜单代码为" + menu.MenuId + "的菜单"; } else { switch (menu.MenuLevel) { case 1: case 2: var cnt = context.T_SysMenus.Where(m => m.MenuLevel == menu.MenuLevel && m.IsDeleted == false); menu.CreateTime = DateTime.Now; context.T_SysMenus.Add(menu); context.SaveChanges(); ret = base.success_r; break; } } break; #endregion #region 修改 case "modify": T_SysMenus _menu = context.T_SysMenus.Where(m => m.MenuId == menu.MenuId && m.IsDeleted == false).FirstOrDefault(); if (_menu != null) { _menu.ModifyTime = DateTime.Now; _menu.SortNum = menu.SortNum; _menu.MenuName = menu.MenuName; _menu.ParentId = menu.ParentId; _menu.ParentMenuName = menu.ParentMenuName; _menu.Islink = menu.Islink; _menu.MenuIcon = menu.MenuIcon; _menu.MenuUrl = menu.MenuUrl; context.SaveChanges(); ret = base.success_r; } else { ret.Value = "未能找到此菜单,可能已被删除!"; } break; #endregion #region 除 case "delete": T_SysMenus MN = context.T_SysMenus.Where(m => m.MenuId == menu.MenuId && m.IsDeleted == false).FirstOrDefault(); if (MN != null) { MN.IsDeleted = true; MN.ModifyTime = DateTime.Now; context.SaveChanges(); ret = base.success_r; } break; #endregion } } } catch (Exception ex) { ret.Value = ex.Message; } return(Json(ret, JsonRequestBehavior.AllowGet)); }
public static void Import_Diagnoses(string connectionString, SessionSecurityTicket securityTicket) { string folder = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName; string filePath = Path.Combine(folder, "Excel\\ICD10.xlsx"); bool hasHeader = true; IFormatProvider culture = new System.Globalization.CultureInfo("de", true); DataTable excelData = null; Console.WriteLine("Loading data from excel..."); try { excelData = ExcelUtils.getDataFromExcelFileMM(filePath, hasHeader); } catch (Exception ex) { filePath = Path.Combine(folder, "Excel\\ICD10.xls"); excelData = ExcelUtils.getDataFromExcelFileMM(filePath, hasHeader); } List <KeyValueModel> diagnoses = new List <KeyValueModel>(); int i = 1; Console.WriteLine("Validate diagnoses in the excel file? [y/n]"); var validate = Console.ReadLine().ToLower() == "y"; var message = validate ? "validated." : "imported."; try { foreach (System.Data.DataRow item in excelData.Rows) { KeyValueModel diagnose = new KeyValueModel(); #region DIAGNOSE IMPORT diagnose.key = (string)item.ItemArray[0]; diagnose.value = (string)item.ItemArray[1]; diagnose.isValid = true; #endregion if (validate) { if (diagnoses.Any(h => h.key == diagnose.key)) { diagnose.isValid = false; diagnose.validationMessage = "Drug ICD10 code "; } } diagnoses.Add(diagnose); Console.Write("\rDiagnose {0} of {1} {2}", i++, excelData.Rows.Count, message); } } catch (Exception ex) { Console.Clear(); Console.Write(ex.StackTrace); } string file = ExportDiagnosesBeforeUpload.ExportDiagnosesBeforeUploadToElastic(diagnoses); MemoryStream ms = new MemoryStream(File.ReadAllBytes(file)); Console.WriteLine("----- XLS created."); if (diagnoses.Any(vl => !vl.isValid)) { Console.WriteLine("Data not valid, won't be saved."); } else { if (Elastic_Utils.IfIndexOrTypeExists("external_data", Elastic_Utils.ElsaticConnection()) && Elastic_Utils.IfIndexOrTypeExists("external_data/diagnose", Elastic_Utils.ElsaticConnection())) { Elastic_Utils.Delete_Type("external_data", "diagnose"); } var pageSize = 1000; var page = 0; while (true) { var skip = pageSize * page; if (skip < diagnoses.Count) { var diagnoseList = diagnoses.Skip(skip).Take(pageSize).Select(diag => { return(new Diagnose_Model() { id = Guid.NewGuid().ToString(), icd10 = diag.key, name = diag.value.Trim() }); }).ToList(); Add_New_Diagnose.Import_Diagnose_Data_to_ElasticDB(diagnoseList, "external_data"); } else { break; } page++; } } }
public void getInnitData() { var data = new PrintJobDetailModel(); data.ID = 0; data.PrinteJobID = 0; data.CategoryID = 0; data.ProductID = 0; data.PrinterID = 0; data.TemplatesID = 0; this.Tag = data; // get cbTemplate this.cbTemplate.DisplayMember = "Value"; this.cbTemplate.ValueMember = "Key"; var temp = new KeyValueModel(); temp.Key = 1; temp.Value = "Template"; this.cbTemplate.Items.Add(temp); this.cbTemplate.SelectedIndex = 0; // get cbPrinter this.cbPrinter.DisplayMember = "Value"; this.cbPrinter.ValueMember = "Key"; var dataPrinter = PrinterService.GetListPrinter().ToList(); foreach (var item in dataPrinter) { var tempprint = new KeyValueModel(); tempprint.Key = item.ID; tempprint.Value = item.PrintName; this.cbPrinter.Items.Add(tempprint); } this.cbPrinter.SelectedIndex = 0; // get Group this.cbGroupItem.DisplayMember = "Value"; this.cbGroupItem.ValueMember = "Key"; var datagroup = PrinterService.GetCategoryList().ToList(); var tempgroup1 = new KeyValueModel(); tempgroup1.Key = 0; tempgroup1.Value = "-- All --"; this.cbGroupItem.Items.Add(tempgroup1); foreach (var itemgroup in datagroup) { var tempgroup = new KeyValueModel(); tempgroup.Key = itemgroup.CategoryID; tempgroup.Value = itemgroup.CategoryName; this.cbGroupItem.Items.Add(tempgroup); } this.cbGroupItem.SelectedIndex = 0; // get Item this.cbItem.DisplayMember = "Value"; this.cbItem.ValueMember = "Key"; this.cbItem.Items.Add(tempgroup1); this.cbItem.SelectedIndex = 0; }
void addStaffDetail(StaffModel data) { // pDetail.Controls.Clear(); if (data.StaffID > 0) { UCUserListDetail ucUserDetail = new UCUserListDetail(); if (pDetail.Controls.Count > 0) { ucUserDetail = (UCUserListDetail)pDetail.Controls[0]; } else { ucUserDetail.Dock = DockStyle.Fill; pDetail.Controls.Add(ucUserDetail); } // ucUserDetail.Dock = DockStyle.Fill; ucUserDetail.lbTitle.Text = data.Fname + " " + data.Lname; ucUserDetail.txtFname.Text = data.Fname; ucUserDetail.txtLname.Text = data.Lname; ucUserDetail.txtUserName.Text = data.UserName; ucUserDetail.txtPinCode.Text = StaffModel.Decrypt(data.Password); var department = UserService.GetListDepartment().ToList(); ucUserDetail.cbRole.DisplayMember = "Value"; ucUserDetail.cbRole.ValueMember = "Key"; var textDefault = ""; ucUserDetail.cbRole.Items.Clear(); foreach (var item in department) { if (item.DepartmentID == data.DepartmentID) { textDefault = item.DepartmentName; } var temp = new KeyValueModel(); temp.Key = item.DepartmentID; temp.Value = item.DepartmentName; ucUserDetail.cbRole.Items.Add(temp); } if (textDefault != "") { ucUserDetail.cbRole.Text = textDefault; } else { ucUserDetail.cbRole.SelectedIndex = 0; } ucUserDetail.btnSave.Tag = data; ucUserDetail.btnSave.Click += btnSaveUser_Click; ucUserDetail.btnDelete.Tag = data; ucUserDetail.btnDelete.Click += btnDeleteUser_Click; ucUserDetail.btnDelete.Show(); } }
public static void Import_HIPs(string connectionString, SessionSecurityTicket securityTicket) { string folder = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName; string filePath = Path.Combine(folder, "Excel\\HIPs.xlsx"); bool hasHeader = true; IFormatProvider culture = new System.Globalization.CultureInfo("de", true); DataTable excelData = null; Console.WriteLine("Loading data from excel..."); try { excelData = ExcelUtils.getDataFromExcelFileMM(filePath, hasHeader); } catch (Exception ex) { filePath = Path.Combine(folder, "Excel\\HIPs.xls"); excelData = ExcelUtils.getDataFromExcelFileMM(filePath, hasHeader); } List <KeyValueModel> hips = new List <KeyValueModel>(); int i = 1; Console.WriteLine(); try { foreach (System.Data.DataRow item in excelData.Rows) { KeyValueModel hip = new KeyValueModel(); #region CASE IMPORT hip.key = (string)item.ItemArray[0]; hip.value = (string)item.ItemArray[1]; hip.isValid = true; #endregion if (hips.Any(h => h.key == hip.key)) { hip.isValid = false; hip.validationMessage = "Hip number not unique"; } hips.Add(hip); Console.Write("\rHIP {0} of {1} validated.", i++, excelData.Rows.Count); } } catch (Exception ex) { Console.Clear(); Console.Write(ex.StackTrace); } string file = ExportHIPsBeforeUpload.ExportHIPsBeforeUploadToDB(hips); MemoryStream ms = new MemoryStream(File.ReadAllBytes(file)); Console.WriteLine("----- XLS created."); if (hips.Any(vl => !vl.isValid)) { Console.WriteLine("Data not valid, won't be saved."); } else { if (Elastic_Utils.IfIndexOrTypeExists("external_data", Elastic_Utils.ElsaticConnection()) && Elastic_Utils.IfIndexOrTypeExists("external_data/hip", Elastic_Utils.ElsaticConnection())) { Elastic_Utils.Delete_Type("external_data", "hip"); } Add_New_HIP.Import_HIP_Data_to_ElasticDB(hips.Select(hip => { return(new HIP_Model() { id = Guid.NewGuid().ToString(), ik_number = hip.key.Trim(), name = hip.value.Trim() }); }).ToList(), "external_data"); } }