public DownloadStatusResponse CheckDownloadStatus(string FileName) { DownloadStatusResponse DownloadStatusResponse = new DownloadStatusResponse(); BusinessUtil ObjBusinessUtil = new BusinessUtil(); SICTLogger.WriteInfo(DownloadBusiness.CLASS_NAME, "CheckDownloadStatus", "Start "); try { string FilePath = string.Empty; FilePath = ObjBusinessUtil.GetDownloadFilePathByName(FileName); if (System.IO.File.Exists(FilePath)) { DownloadStatusResponse.IsDownloadComplete = true; DownloadStatusResponse.ReturnCode = 1; DownloadStatusResponse.ReturnMessage = "Download Completed"; } else { DownloadStatusResponse.IsDownloadComplete = false; DownloadStatusResponse.ReturnCode = 5; DownloadStatusResponse.ReturnMessage = "Download still in progress Completed"; } } catch (System.Exception Ex) { DownloadStatusResponse.ReturnCode = 1; DownloadStatusResponse.ReturnMessage = "Error in Function "; SICTLogger.WriteException(DownloadBusiness.CLASS_NAME, "CheckDownloadStatus", Ex); } SICTLogger.WriteInfo(DownloadBusiness.CLASS_NAME, "CheckDownloadStatus", "CheckDownloadStatusEnd"); return(DownloadStatusResponse); }
public DownloadResponse FormExcelExport(string Instance, string SessionId, DepartureFormFilterDetails DepartureFormFilterDetails) { DownloadResponse DownloadResponse = new DownloadResponse(); BusinessUtil ObjBusinessUtil = new BusinessUtil(); SICTLogger.WriteInfo(DownloadBusiness.CLASS_NAME, "FormExcelExport", "Start "); try { string FilePath = string.Empty; string FileLink = string.Empty; string FileName = string.Empty; ObjBusinessUtil.GetFormsExcelExportFilePath(Instance, ref FilePath, ref FileLink, ref FileName); DownloadResponse.ReturnCode = 1; DownloadResponse.ReturnMessage = "Downloaded Started"; DownloadResponse.FileLink = FileLink; DownloadResponse.FileName = FileName; Task.Factory.StartNew(delegate { this.DownloadDataInBackground(SessionId, DepartureFormFilterDetails, FilePath); }); } catch (System.Exception Ex) { DownloadResponse.ReturnCode = -1; DownloadResponse.ReturnMessage = "Error in Function "; SICTLogger.WriteException(DownloadBusiness.CLASS_NAME, "FormExcelExport", Ex); } SICTLogger.WriteInfo(DownloadBusiness.CLASS_NAME, "FormExcelExport", "FormExcelExportEnd"); return(DownloadResponse); }
/// <summary> /// This Function is used to write the Missing Targets Vs Missing Business Class Data Passed to corresponding FilePath /// </summary> /// <param name="LoginId"></param> /// <param name="MissingTargetsVsBusinessClass"></param> private void WriteMissingTargetsVsBusinessClassChartCacheFile(string LoginId, List <MissingTargetsVsBusinessClass> MissingTargetsVsBusinessClass) { const string FUNCTION_NAME = "WriteMissingTargetsVsBusinessClassChartCacheFile"; SICTLogger.WriteInfo(CLASS_NAME, FUNCTION_NAME, "Start for LoginId -" + LoginId); try { DepartureFormBusiness ObjDepartureFormBusiness = new DepartureFormBusiness(); BusinessUtil ObjBusinessUtil = new BusinessUtil(); string FilePath = string.Empty; string FolderPath = string.Empty; string MissingTargetsandBusinessClassData = string.Empty; ObjBusinessUtil.GetMissingTargetsVsBusinessClassChartsFilePath(LoginId, ref FilePath, ref FolderPath); Boolean IsFolderExists = System.IO.Directory.Exists(FolderPath); if (!IsFolderExists) { System.IO.Directory.CreateDirectory(FolderPath); } SICTLogger.WriteVerbose(CLASS_NAME, FUNCTION_NAME, "MissingTargetsVsBusinessClass Charts cache file for AirportLoginId- " + LoginId); using (var MemoryStream = new MemoryStream()) { var Serlizer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(List <MissingTargetsVsBusinessClass>)); Serlizer.WriteObject(MemoryStream, MissingTargetsVsBusinessClass); MissingTargetsandBusinessClassData = System.Text.Encoding.UTF8.GetString(MemoryStream.GetBuffer(), 0, Convert.ToInt32(MemoryStream.Length)); ObjDepartureFormBusiness.WriteToFile(MissingTargetsandBusinessClassData, FilePath); } } catch (Exception Ex) { SICTLogger.WriteException(CLASS_NAME, FUNCTION_NAME, Ex); } SICTLogger.WriteInfo(CLASS_NAME, FUNCTION_NAME, "End for LoginId -" + LoginId); }
private bool IsValid() { var branch = viewModel.CurrentBranch; if (string.IsNullOrEmpty(branch.Name)) { MessageBox.Show("Ad mütləq daxil edilməlidir!"); return(false); } if (branch.Name.Length > 50) { MessageBox.Show("Ad 50 simvoldan böyük ola bilməz!"); return(false); } if (branch.Address != null && branch.Address.Length > 50) { MessageBox.Show("Ünvan 50 simvoldan böyük ola bilməz!"); return(false); } if (branch.PhoneNumber != null && !BusinessUtil.PhoneMatches(branch.PhoneNumber)) { MessageBox.Show("Telefon nömrəsi düzgün formatda deyil! (Düzgün format: +99450XXXXXXX)"); return(false); } return(true); }
public override void Execute(object parameter) { int situation = viewModel.CurrentSituation; if (situation == (int)Constants.SITUATIONS.NORMAL) { viewModel.CurrentSituation = (int)Constants.SITUATIONS.ADD; } else if (situation == (int)Constants.SITUATIONS.SELECTED) { viewModel.CurrentSituation = (int)Constants.SITUATIONS.EDIT; } else { if (IsValid()) { CorrectData(); if (situation == (int)Constants.SITUATIONS.ADD) { var branch = BranchMapper.Map(viewModel.CurrentBranch, new Branch()); branch.IsDeleted = false; branch.CreationDate = DateTime.Now; branch.Creator = Kernel.AuthenticatedUser; DB.BranchRepository.Add(branch); } else if (situation == (int)Constants.SITUATIONS.EDIT) { int id = viewModel.CurrentBranch.Id; var existingBranch = DB.BranchRepository.FindById(id); if (existingBranch != null) { existingBranch = BranchMapper.Map(viewModel.CurrentBranch, existingBranch); existingBranch.CreationDate = DateTime.Now; existingBranch.Creator = Kernel.AuthenticatedUser; DB.BranchRepository.Update(existingBranch); } } viewModel.Message = "Əməliyyat uğurla həyata keçdi"; BusinessUtil.DoAnimation(viewModel.MessageDialog); // reload all branches List <Branch> branches = DB.BranchRepository.Get(); List <BranchModel> models = new List <BranchModel>(); foreach (var entity in branches) { var model = BranchMapper.Map(entity); models.Add(model); } viewModel.Branches = new List <BranchModel>(models); viewModel.InitializeViewModel(); } } }
/************************************************************************* * Create and Delete methods *************************************************************************/ /// <summary> /// Creates a new role /// </summary> public override void CreateRole(string roleName) { // No need to add if it already exists if (!RoleExists(roleName)) { var r = new RoleInfo { RoleName = roleName, LoweredRolename = roleName.ToLower(), Description = roleName }; BusinessUtil.AddRole(r); } }
protected T CommonOperation <T>(Func <T> func, BusinessBaseRequest businessBaseRequest, BusinessUtilMethod businessUtilMethod, string additionalInfo) { try { var result = func.Invoke(); BusinessUtil.Execute(businessUtilMethod, result, additionalInfo); return(result); } catch (Exception ex) { _logger.LogError(0, ex, $"{DefaultResponseMessages.AnErrorHasOccured} - {ex.Message}"); throw; } }
private async Task UniqueCheckForMatchIdAndTeamIdAndPlayerIdAsync(Stat entity, int?id = null) { var predicate = PredicateBuilder.New <Stat>(); predicate = predicate.And(p => p.MatchId == entity.MatchId); predicate = predicate.And(p => p.TeamId == entity.TeamId); predicate = predicate.And(p => p.PlayerId == entity.PlayerId); if (id != null) { predicate = predicate.And(p => p.Id != id); } var tempResult = await UnitOfWork.GetRepository <Stat, int>().GetAll(predicate: predicate).ToListAsync(); BusinessUtil.CheckUniqueValue(tempResult, WebApiConstants.MatchIdAndTeamIdAndPlayerId); }
public static bool IsUserInForumRole(string username, int forumid) { IForum dal = Factory <IForum> .Create("Forum"); string[] userroles = BusinessUtil.GetRolesForUser(username); string[] forumroles = dal.GetForumRoles(forumid); foreach (string forumrole in forumroles) { if (userroles.Contains(forumrole)) { return(true); } } return(false); }
/// <summary> /// public RoleProvider.CreateRoleFullInfo /// </summary> /// <param name="roleName"></param> /// <param name="roleDescription"></param> /// <param name="roleId"></param> /// <returns></returns> public bool CreateRoleFullInfo(string roleName, string roleDescription, int roleId) { if (roleName.Contains(",")) { throw new ArgumentException("Role names cannot contain commas."); } if (RoleExists(roleName)) { throw new ProviderException("Role name already exists."); } var r = new RoleInfo { Id = roleId, RoleName = roleName, LoweredRolename = roleName.ToLower(), Description = roleDescription }; BusinessUtil.AddRole(r); return(true); }
public ReturnValue UploadFile(System.IO.Stream FileStream, string Instance) { ReturnValue ReturnValue = new ReturnValue(); BusinessUtil ObjBusinessUtil = new BusinessUtil(); SICTLogger.WriteInfo(UploadBusiness.CLASS_NAME, "UploadFile", "Start "); try { MultiPartParser Parser = this.ParseFile(FileStream); string UploadFilePath = string.Empty; ObjBusinessUtil.GetUploadFilePath(ref UploadFilePath, System.IO.Path.GetFileNameWithoutExtension(Parser.Filename), System.IO.Path.GetExtension(Parser.Filename)); using (System.IO.FileStream FileToupload = new System.IO.FileStream(UploadFilePath, System.IO.FileMode.Create)) { FileToupload.Write(Parser.FileContents, 0, Parser.FileContents.Length); } bool IsFileValid = this.ValidateFile(UploadFilePath); if (IsFileValid) { Task.Factory.StartNew(delegate { this.BulkInsert(UploadFilePath, Instance); }); ReturnValue.ReturnCode = 1; ReturnValue.ReturnMessage = "Upload Successful"; } else { ReturnValue.ReturnCode = 5; ReturnValue.ReturnMessage = "Invalid File "; } FileStream.Close(); } catch (System.Exception Ex) { ReturnValue.ReturnCode = -1; ReturnValue.ReturnMessage = "Error in Function "; SICTLogger.WriteException(UploadBusiness.CLASS_NAME, "UploadFile", Ex); } SICTLogger.WriteInfo(UploadBusiness.CLASS_NAME, "UploadFile", "UploadFileEnd"); return(ReturnValue); }
/// <summary> /// Deletes a given role /// </summary> /// <param name="roleName">Role name to delete</param> /// <param name="throwOnPopulatedRole">Specifies whether the function should throw /// if there are assigned users to this role</param> /// <returns>True if successful. Defaults to false</returns> public override bool DeleteRole(string roleName, bool throwOnPopulatedRole) { // Return status. Defaults to false. bool ret = false; // You can only delete an existing role if (RoleExists(roleName)) { if (throwOnPopulatedRole) { if (BusinessUtil.GetUsersInRole(roleName).Any()) { throw new ProviderException("Cannot delete roles with users assigned to them"); } } BusinessUtil.DeleteRole(roleName); ret = true; } return(ret); }
public override void Execute(object parameter) { DialogViewModel dialogViewModel = new DialogViewModel(); dialogViewModel.DialogText = "Silmək istədiyinizdən əminsinizmi?"; Dialog dialog = new Dialog(); dialog.DataContext = dialogViewModel; if (dialog.ShowDialog() == true) { int id = viewModel.SelectedBranch.Id; var branch = DB.BranchRepository.FindById(id); if (branch != null) { branch.IsDeleted = true; DB.BranchRepository.Update(branch); } viewModel.Message = "Əməliyyat uğurla həyata keçdi"; BusinessUtil.DoAnimation(viewModel.MessageDialog); // reload all branches List <Branch> branches = DB.BranchRepository.Get(); List <BranchModel> models = new List <BranchModel>(); foreach (var entity in branches) { var model = BranchMapper.Map(entity); models.Add(model); } viewModel.Branches = new List <BranchModel>(models); viewModel.InitializeViewModel(); Logger.LogInformation($"Branch: {id} has been deleted"); } }
public static RoleInfo GetRoleFull(int roleid) { return(BusinessUtil.GetRoleFull(roleid)); }
/// <summary> /// Gets all the users in a particular role /// </summary> public override string[] GetUsersInRole(string roleName) { return(BusinessUtil.GetUsersInRole(roleName)); }
/************************************************************************* * Assign/Remove methods *************************************************************************/ /// <summary> /// Adds a collection of users to a collection of corresponding roles /// </summary> public override void AddUsersToRoles(string[] usernames, string[] roleNames) { BusinessUtil.AddUsersToRoles(usernames, roleNames); }
/************************************************************************* * Retrieval methods *************************************************************************/ /// <summary> /// Gets all available user roles /// </summary> /// <returns>Array of all available roles</returns> public override string[] GetAllRoles() { return(BusinessUtil.GetAllRoles()); }
/// <summary> /// Gets the assigned roles for a particular user. /// </summary> /// <param name="username">Matching username</param> /// <returns>Array of assigned roles</returns> public override string[] GetRolesForUser(string username) { return(BusinessUtil.GetRolesForUser(username)); }
public static void AddRolesToForum(int forumId, string[] newroles) { BusinessUtil.AddRolesToForum(forumId, newroles); }
public static void UpdateRoleInfo(int roleid, string name, string description) { BusinessUtil.UpdateRoleInfo(roleid, name, description); }
public static IEnumerable <RoleInfo> GetAllRolesFull(int maximumRows, int startRowIndex) { return(BusinessUtil.GetAllRolesFull().Skip(startRowIndex).Take(maximumRows)); }
/// <summary> /// Remove a collection of users from a collection of corresponding roles /// </summary> public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) { BusinessUtil.RemoverUsersFromRoles(usernames, roleNames); }
/************************************************************************* * Forum Specific Methods *************************************************************************/ public Dictionary <int, string> ListAllRolesForUser(string username) { return(BusinessUtil.GetRoleListForUser(username)); }
public bool RoleExists(int roleid) { return(BusinessUtil.RoleExists(roleid)); }
/************************************************************************* * Searching methods *************************************************************************/ /// <summary> /// Checks if a given username is in a particular role /// </summary> public override bool IsUserInRole(string username, string roleName) { // Return status defaults to false return(BusinessUtil.IsUserInRole(username, roleName)); }