public AddPurchaseService(Guid companyGuid = default(Guid)) { InitializeComponent(); Dispatcher.BeginInvoke(new Action(async() => { if (companyGuid == default(Guid)) { ModernDialog.ShowMessage("Choisir un client", "eStation", MessageBoxButton.OK); Close(); return; } _STATUS.ItemsSource = EnumsHelper.GetAllValuesAndDescriptions <PurchaseState>(); _GRID.DataContext = new Purchase { Sum = 0, ProductType = ProductType.Service, PurchaseDate = DateTime.Now, PurchaseState = PurchaseState.UnPaid, CompanyGuid = companyGuid }; _TITLE_TEXT.Text = $"Bon de {(await App.Store.Sales.Get(companyGuid))?.Name}"; })); }
public ResponseResult <GridResponse <CommonSearchItem> > GetMaterialCode(string code, GridSettings gridSettings) { var result = _unitOfWork.MaterialRepository.GetAll(); if (!string.IsNullOrEmpty(code)) { result = result.Where( i => i.F01_MaterialCode.ToUpper().Contains(code.ToUpper()) || i.F01_MaterialDsp.ToUpper().Contains(code.ToUpper())); } // Sort and paging var itemCount = result.Count(); OrderByAndPaging(ref result, gridSettings); var resultLst = result.ToList().Select(s => new CommonSearchItem { F01_MaterialCode = s.F01_MaterialCode, F01_MaterialDsp = s.F01_MaterialDsp, F01_Unit = s.F01_Unit, F01_RtrPosCls = s.F01_RtrPosCls, F01_EntrustedClass = s.F01_EntrustedClass, F01_PackingUnit = s.F01_PackingUnit, F01_LiquidClass = EnumsHelper.GetDescription <Constants.Liquid>(ConvertHelper.ToInteger(s.F01_LiquidClass)) }); //var lstResult = Mapper.Map<IEnumerable<TM01_Material>, IEnumerable<MaterialItem>>(result.ToList()); var resultModel = new GridResponse <CommonSearchItem>(resultLst, itemCount); return(new ResponseResult <GridResponse <CommonSearchItem> >(resultModel, true)); //return result; }
private void RunUntappd(string filePath) { FileStatus fileStatus = FileHelper.Check(filePath, Extensions.GetSupportExtensions()); if (!EnumsHelper.IsValidFileStatus(fileStatus)) { interactionRequestService.ShowMessage(Properties.Resources.Warning, CommunicationHelper.GetFileStatusMessage(fileStatus, filePath)); return; } try { string untappdUserName = String.Empty; if (FileHelper.GetExtensionWihtoutPoint(filePath).Equals(Extensions.CSV)) { if (!interactionRequestService.AskReplaceText(Properties.Resources.UntappdUserNameCaption, ref untappdUserName)) { return; } } untappdService.Initialize(filePath, untappdUserName); } catch (ArgumentException ex) { interactionRequestService.ShowError(Properties.Resources.Error, StringHelper.GetFullExceptionMessage(ex)); return; } settingService.SetRecentFilePaths(FileHelper.AddFilePath(settingService.GetRecentFilePaths(), filePath, settingService.GetMaxRecentFilePaths())); moduleManager.LoadModule(typeof(MainModule).Name); ActivateView(RegionNames.RootRegion, typeof(Main)); interactionRequestService.ShowMessageOnStatusBar(filePath); }
public async Task UpdateActivity(long athleteId, long activityId, string activityTitle, string activityType, bool?isPrivate) { var activityInDb = await this.db.Activities.FirstOrDefaultAsync(p => p.Id == activityId && p.AthleteId == athleteId); if (activityInDb == null) { return; } if (!string.IsNullOrEmpty(activityTitle)) { activityInDb.Name = activityTitle; } if (!string.IsNullOrEmpty(activityType)) { var activityTypeId = EnumsHelper.GetEnumIdByName <ActivityTypeEnum>(activityType); activityInDb.ActivityTypeId = activityTypeId; } if (isPrivate.HasValue) { activityInDb.IsPrivate = isPrivate.Value; } await this.db.SaveChangesAsync(); }
public void Autogenerate() { foreach (var processType in EnumsHelper.GetEnumList <TProcessEnum>()) { Add(processType); } }
/// <summary> /// Function to change user's Theme in realtime /// when user chooses a different Theme preference /// </summary> void ChangeTheme(string theme) { var appTheme = EnumsHelper.ConvertToEnum <Settings.Theme>(theme); switch (appTheme) { case Settings.Theme.LightTheme: IsLightTheme = true; ThemeHelper.ChangeToLightTheme(); break; case Settings.Theme.DarkTheme: IsDarkTheme = true; ThemeHelper.ChangeToDarkTheme(); break; case Settings.Theme.SystemPreferred: IsSystemPreferredTheme = true; ThemeHelper.ChangeToSystemPreferredTheme(); break; default: IsSystemPreferredTheme = true; ThemeHelper.ChangeToSystemPreferredTheme(); break; } }
/// <summary> /// Function to get the current user's Theme preference /// </summary> void GetThemeSetting() { string theme = Settings.GetSetting(Settings.AppPrefrences.AppTheme); var appTheme = EnumsHelper.ConvertToEnum <Settings.Theme>(theme); switch (appTheme) { case Settings.Theme.LightTheme: IsLightTheme = true; break; case Settings.Theme.DarkTheme: IsDarkTheme = true; break; case Settings.Theme.SystemPreferred: IsSystemPreferredTheme = true; break; default: IsSystemPreferredTheme = true; break; } }
// GET: /<controller>/ public IActionResult Index() { SiteEnums.ClientUIMode clientMode = _configGeneral.ClientUIMode; var viewName = EnumsHelper.GetTriEnumString(clientMode, "Index", "IndexMVC", "IndexTempl"); return(View(viewName)); }
public override async Task <bool> Save(FilesGroup filesGroup, FileWriteMode writeMode) { var endpointPath = writeMode switch { FileWriteMode.Override => Endpoints.UpdateEndpoint, FileWriteMode.CreateNew => Endpoints.CreateEndpoint, _ => throw new ArgumentOutOfRangeException(nameof(writeMode), writeMode, "such operation can't be done") }; var multipartFormDataContent = new MultipartFormDataContent(); var streamData = await Task.WhenAll(filesGroup.RelatedFiles.Select(MakeStreamContent)).ConfigureAwait(false); var fullBookmarkPath = GetFullPath(filesGroup); var stringContent = new StringContent(fullBookmarkPath); foreach (var streamContent in streamData) { var ext = streamContent.Headers.First(kvp => kvp.Key == "Extension").Value.First() !; multipartFormDataContent.Add(streamContent, EnumsHelper.ParseType(ext).ToString(), $"{filesGroup.Name}.{ext}"); } multipartFormDataContent.Add(stringContent, "bookmarkPath"); using var httpRequestMessage = await CreateHttpRequestMessageWithAuthHeader(HttpMethod.Post, endpointPath, multipartFormDataContent).ConfigureAwait(false); using var responseMessage = await _httpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false); return(responseMessage.IsSuccessStatusCode); }
/// <summary> /// Les roles dans ce espace /// </summary> /// <param name="profileGuid"></param> /// <param name="userSpace"></param> /// <returns></returns> public IEnumerable GetUserClearances(Guid profileGuid, UserSpace userSpace) { switch (userSpace) { case UserSpace.AdminSpace: return(EnumsHelper.GetAllValuesAndDescriptions <AdminClearances>().Select(role => new ViewCard { Info1 = role.Key, Info2 = role.Value.ToString(), Info3 = Roles.IsUserInRole(Membership.GetUser(profileGuid)?.UserName, role.Value.ToString()) ? "Blue" : "Red", Bool1 = Roles.IsUserInRole(Membership.GetUser(profileGuid)?.UserName, role.Value.ToString()) })); //case UserSpace.PompisteSpace: // return EnumsHelper.GetAllValuesAndDescriptions<TeacherClearances>().Select(role => // new DataCard // { // Info1 = role.Key, // Info2 = role.Value.ToString(), // Info3 = Roles.IsUserInRole(Membership.GetUser(profileGuid)?.UserName, role.Value.ToString()) ? "Blue" : "Red", // Bool1 = Roles.IsUserInRole(Membership.GetUser(profileGuid)?.UserName, role.Value.ToString()) // }); } return(null); }
/// <summary> /// Get's and applies the users preferred Theme /// </summary> public static void GetAppTheme() { string theme = Settings.GetSetting(Settings.AppPrefrences.AppTheme); if (theme != null) { var appTheme = EnumsHelper.ConvertToEnum <Settings.Theme>(theme); switch (appTheme) { case Settings.Theme.LightTheme: ChangeToLightTheme(); break; case Settings.Theme.DarkTheme: ChangeToDarkTheme(); break; case Settings.Theme.SystemPreferred: ChangeToSystemPreferredTheme(); break; default: ChangeToSystemPreferredTheme(); break; } } else { ChangeToSystemPreferredTheme(); } }
/// <summary> /// 设定子节点 /// Created:20170602(ChengMengjia) /// </summary> /// <param name="advTree1"></param> /// <param name="ProjectID"></param> private static void SetMainSubTreeData(IList <PNode> listNode, PNode parent, DevComponents.AdvTree.Node node) { string parentID = parent.ID.Substring(0, 36); IEnumerable <PNode> children = listNode.Where(t => t.ParentID == parentID).OrderBy(t => t.No).OrderByDescending(t => t.No.HasValue); if (children.Count <PNode>() < 1) { parent.FinishStatus = parent.FinishStatus == null ? 0 : parent.FinishStatus; node.Style = MatchColor(parent.FinishStatus); return; } DevComponents.AdvTree.Node node2; foreach (PNode child in children) { node2 = new DevComponents.AdvTree.Node() { Name = child.ID, Text = string.IsNullOrEmpty(child.WBSNo) ? child.Name + "(" + EnumsHelper.GetDescription((WBSPType)child.PType) + ")" : child.WBSNo + "-" + child.Name, Tag = JsonHelper.EntityToString <PNode>(child) }; #region 交付物需要检查完成情况 #endregion SetMainSubTreeData(listNode, child, node2); node.Nodes.Add(node2); } parent.FinishStatus = (from p in children select p.FinishStatus).Max(); node.Style = MatchColor(parent.FinishStatus); }
// GET: EnvironmentManagement/CreepingAndRollSpeed public ActionResult Index() { var model = new CreepingAndRollSpeedDurationModel() { SearchCriteriaModel = new SearchCriteriaModel() { Location = "Machine", EndDate = DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy"), StartDate = DateTime.Now.AddDays(-89).ToString("dd/MM/yyyy"), }, LeftModel = new ChartModel() { ChartName = "Left" }, RightModel = new ChartModel() { ChartName = "Right" }, RollModel = new ChartModel() { ChartName = "Roll" } }; ViewBag.ListLocation = new SelectList(EnumsHelper.GetListItemsWithDescription <Constants.RollMachine>(), "Value", "Text"); return(View(model)); }
private async Task <IActionResult> StoreBookmark(IFormFileCollection formFileCollection, string bookmarkPath, DateTime lastWriteDate, FileWriteMode writeMode) { FormatPath(ref bookmarkPath); lastWriteDate = new DateTime(lastWriteDate.Year, lastWriteDate.Month, lastWriteDate.Day, lastWriteDate.Hour, lastWriteDate.Minute, lastWriteDate.Second, lastWriteDate.Kind); // truncate milliseconds off var dataDictionary = new Dictionary <BookmarkFileType, Stream>(); foreach (var formFile in formFileCollection) { var formFileHeader = formFile.Headers["Extension"]; dataDictionary.Add(EnumsHelper.ParseType(formFileHeader), formFile.OpenReadStream()); } var fileTypes = formFileCollection.Select(formFile => formFile.Headers["Extension"].ToString()).Select(EnumsHelper.ParseType).ToArray(); if (EnumsHelper.RecognizeFilesGroupType(fileTypes) == null) { return(BadRequest("bookmark type isn't recognized")); } var fakeFilesGroup = _storageService.MakeFake(bookmarkPath); var filesGroup = new ProxyFilesGroup(fakeFilesGroup, dataDictionary, lastWriteDate); var result = await _storageService.Save(filesGroup, writeMode); return(result ? (IActionResult)Ok() : BadRequest()); }
/// <summary> /// After dvUserInfo data binding. /// </summary> /// <param name="sender">Object sender : dvUserInfo.</param> /// <param name="e">EventArgs e.</param> protected void OnUserInfoDataBound(Object sender, EventArgs e) { Address address = AddressRepository.GetUserAddress(this._userID); PersonalInfo personalInfo = PersonalInfoRepository.GetUserInfo(this._userID); #region // Inner controls Label lblBirthday = dvUserInfo.FindControl("lblBirthday") as Label; Label lblPhone = dvUserInfo.FindControl("lblPhone") as Label; Label lblSex = dvUserInfo.FindControl("lblSex") as Label; Label lblCountry = dvUserInfo.FindControl("lblCountry") as Label; Label lblCity = dvUserInfo.FindControl("lblCity") as Label; Label lblArea = dvUserInfo.FindControl("lblArea") as Label; Label lblStreet = dvUserInfo.FindControl("lblStreet") as Label; Label lblHome = dvUserInfo.FindControl("lblHome") as Label; Label lblApartment = dvUserInfo.FindControl("lblApartment") as Label; #endregion imgUserAvatar.ImageUrl = personalInfo.ImagePath; if (this.imgUserAvatar.ImageUrl == Constants._defaultAvatarImage) { this.imgUserAvatar.ImageUrl = String.Concat(Constants._defaultPhotoPath, Constants._defaultAvatarImage); } else { this.imgUserAvatar.ImageUrl = String.Concat(Constants._defaultPhotoPath, imgUserAvatar.ImageUrl); } // If user have address -> set values to controls. if (address != null) { this.SetValueOrInvisible( this.dvUserInfo, 0, lblBirthday, String.Format("{0:" + Constants._dateFormat + "}", personalInfo.Birthday)); if (this.SetValueOrInvisible(this.dvUserInfo, 1, lblSex, personalInfo.Sex.ToString())) { lblSex.Text = EnumsHelper.ToString((Sex)Convert.ToInt32(lblSex.Text)); } this.SetValueOrInvisible(this.dvUserInfo, 2, lblPhone, personalInfo.Phone); Guid?countryID = address.CountryID; if (countryID != null) { this.SetValueOrInvisible( this.dvUserInfo, 3, lblCountry, AddressRepository.GetCountryName((Guid)countryID)); } Guid?cityID = address.CityID; if (cityID != null) { this.SetValueOrInvisible( this.dvUserInfo, 4, lblCity, AddressRepository.GetCityName((Guid)cityID)); } this.SetValueOrInvisible(this.dvUserInfo, 5, lblArea, address.Area); this.SetValueOrInvisible(this.dvUserInfo, 6, lblStreet, address.Street); this.SetValueOrInvisible(this.dvUserInfo, 7, lblHome, address.Home); this.SetValueOrInvisible(this.dvUserInfo, 8, lblApartment, address.Apartment); } }
public async Task <IActionResult> GetMenuBtnTypes() { return(await Task.Run(() => { var result = EnumsHelper.GetEnumDictionary <MenusTypeEnum.MenuBtnTypeEnum>(); return Success(result); })); }
public void Given_KnownDescription_When_GetByDescriptionInvoked_Then_EnumRetrived() { var enumType = TestEnum.WithoutDescription; var enumDescription = enumType.GetDescription(); var enumTypeRetrived = EnumsHelper.GetByDescription <TestEnum>(enumDescription); Assert.AreEqual(enumType, enumTypeRetrived); }
public void Given_KnownString_When_GetByStringInvoked_Then_EnumRetrived() { var enumType = TestEnum.WithDescription1; var enumStr = enumType.ToString(); var enumTypeRetrived = EnumsHelper.GetByString <TestEnum>(enumStr); Assert.AreEqual(enumType, enumTypeRetrived); }
public Task(int numTask, Enum priority, Enum difficult) { Number = numTask; Priority = priority; Difficulty = difficult; Difficulty listDifficult; Enum.TryParse(Difficulty.ToString(), true, out listDifficult); Duration = int.Parse(EnumsHelper.GetDescription(listDifficult)); }
/// <summary> /// Espaces Utilisateur /// </summary> /// <param name="profileGuid"></param> /// <returns></returns> public IEnumerable UserSpaces(Guid profileGuid) { return(EnumsHelper.GetAllValuesAndDescriptions <UserSpace>().Select(role => new DataCard { Info1 = role.Key, Info2 = role.Value.ToString(), Info3 = Roles.IsUserInRole(Membership.GetUser(profileGuid)?.UserName, role.Value.ToString()) ? "Blue" : "Red", Bool1 = Roles.IsUserInRole(Membership.GetUser(profileGuid)?.UserName, role.Value.ToString()) })); }
public void Given_FullEnumTypeWithDescriptions_When_Add_Then_AllProcessDefinitionWithNameAndDescriptionCreated() { var builder = new ProcessDefinitionBuilder <int, TestUndefinedProcesses>(); var expectedList = EnumsHelper.GetEnumList <TestUndefinedProcesses>(); builder.Autogenerate(); Assert.AreEqual(builder.Count, expectedList.Count()); Assert.IsTrue(builder.Definitions.Any(x => expectedList.Contains(EnumsHelper.GetByString <TestUndefinedProcesses>(x.Name)))); Assert.IsTrue(builder.Definitions.Any(x => expectedList.Contains(EnumsHelper.GetByDescription <TestUndefinedProcesses>(x.Description)))); }
public void Init(DriverTypes driver, ScreenSizes windowSize) { Driver = GetDriver(driver); Driver.Manage().Window.Size = new System.Drawing.Size( EnumsHelper.GetWidth(windowSize), EnumsHelper.GetHeight(windowSize)); var l = Driver.Manage().Window.Size.Height; var fl = Driver.Manage().Window.Size.Width; }
public static string GetSetting(AppPrefrences prefrence) { bool hasKey = Preferences.ContainsKey(EnumsHelper.ConvertToString(prefrence)); if (hasKey) { return(Preferences.Get(EnumsHelper.ConvertToString(prefrence), null)); } return(null); }
public static BreackedFilter GetFilterForSport(ESport sport) { if (!EnumsHelper.GetAllSports().ContainsKey(sport)) { throw new ArgumentException(string.Format("Нет такого спорта {0}", (object)sport)); } return(new BreackedFilter() { Id = sport.ToServerSportId(), Name = sport.ToNormalString() }); }
public static async Task SetSecureSetting(AppPrefrences prefrence, string setting) { try { await SecureStorage.SetAsync(EnumsHelper.ConvertToString(prefrence), setting); } catch (Exception ex) { // Possible that device doesn't support secure storage on device. Debug.WriteLine(ex.Message); } }
public void Given_EnumWithProcessDefinitionAttributes_When_Add_Then_AllProcessDefinitionWithNameDescriptionAndTypeCreated() { var builder = new ProcessDefinitionBuilder <int, TestExtraDefinedProcesses>(); var expectedList = EnumsHelper.GetEnumList <TestExtraDefinedProcesses>(); builder.Autogenerate(); Assert.AreEqual(builder.Count, expectedList.Count()); Assert.IsTrue(builder.Definitions.Any(x => expectedList.Contains(EnumsHelper.GetByString <TestExtraDefinedProcesses>(x.Name)))); Assert.IsTrue(builder.Definitions.Any(x => expectedList.Contains(EnumsHelper.GetByDescription <TestExtraDefinedProcesses>(x.Description)))); Assert.IsTrue(builder.Definitions.Any(x => x.Type == Enums.ProcessType.Background)); Assert.IsTrue(builder.Definitions.Any(x => x.Type == Enums.ProcessType.Batch)); }
/// <summary> /// 获取分类用户查询类型枚举列表 /// </summary> /// <returns></returns> public ActionResult GetCommonStatusList() { var dataResult = EnumsHelper.GetKeyValuePairs <CustomerQueryCategory>(EnumAppendItemType.Select); PortalResult result = new PortalResult() { Code = 0, Success = true, Data = dataResult, Message = "" }; return(View(result)); }
/// <summary> /// Bind data to ddlStatus. /// </summary> /// <param name="sender">Object sender : DropDownList.</param> /// <param name="e">EventArgs e.</param> protected void OnStatusDataBinding(Object sender, EventArgs e) { String[] names = Enum.GetNames(typeof(UserStatus)); Array values = Enum.GetValues(typeof(UserStatus)); Dictionary <Int32, String> dictionary = new Dictionary <Int32, String>(); for (Int32 i = 0; i < names.Length; i++) { dictionary.Add((Int32)values.GetValue(i), EnumsHelper.ToString((UserStatus)values.GetValue(i))); } ddlStatus.DataSource = dictionary; ddlStatus.DataTextField = "Value"; ddlStatus.DataValueField = "Key"; }
public static List <BreackedFilter> GetAllBreackedFilters() { Dictionary <ESport, Dictionary <EBetType, int> > allSports = EnumsHelper.GetAllSports(); List <BreackedFilter> breackedFilterList = new List <BreackedFilter>(); foreach (KeyValuePair <ESport, Dictionary <EBetType, int> > keyValuePair in allSports) { breackedFilterList.Add(new BreackedFilter() { Id = keyValuePair.Key.ToServerSportId(), Name = keyValuePair.Key.ToNormalString() }); } return(breackedFilterList); }
/// <summary> /// 获取短信状态枚举列表 /// </summary> /// <returns></returns> public ActionResult GetSMSStatusList() { var dataResult = EnumsHelper.GetKeyValuePairs <SMSStatus>(EnumAppendItemType.Select); dataResult.RemoveAt(1); PortalResult result = new PortalResult() { Code = 0, Success = true, Data = dataResult, Message = "" }; return(View(result)); }