void IOperationFlowEngine.FirstOperation(Guid tenantId, WorkFlowProcessProperties properties) { var entityId = iMetadataManager.GetEntityContextByEntityName(properties.EntityName); var workFlow = _managerWorkFlow.GetWorkFlow(tenantId, entityId, properties.SubTypeCode); if (workFlow != null) { var steps = _managerWorkFlowStep.GetWorkFlowSteps(tenantId, workFlow.WorkFlowId).ToList(); if (steps.Count > 0) { transactionHistory.CreateTransitionHistory(tenantId, new WorkFlowTransition { TransitionHistoryId = Guid.NewGuid(), RefId = properties.resultId, EntityId = entityId, WorkFlowStepId = steps[0].WorkFlowStepId, StartTime = DateTime.UtcNow, EndTime = DateTime.UtcNow, AssignedUserId = Guid.Empty, AuditInfo = new Entities.Common.AuditDetail { CreatedBy = properties.UserId } }); dynamic jsonObject = new JObject(); jsonObject.CurrentWorkFlowStep = steps[0].TransitionType.Id; IEntityResourceManager _iEntityResourceManager = new VPC.Framework.Business.EntityResourceManager.Contracts.EntityResourceManager(); _iEntityResourceManager.UpdateSpecificField(tenantId, properties.EntityName, properties.resultId, "CurrentWorkFlowStep", steps[0].TransitionType.Id.ToString()); // var resultId = _iEntityResourceManager.UpdateResult (tenantId, properties.UserId,properties.resultId,properties.EntityName, jsonObject, properties.SubTypeCode); } } }
/// <summary> /// Prepare GetTemplate model /// </summary> /// <param name="tenantId">tenant Id</param> /// <param name="entityname"> emailtemplate or SMS</param> /// <param name="contextname">contextname like user,product etc..</param> /// <param name="resource">tag replaced value key pair</param> /// <returns>EmailTemplate model</returns> public EmailTemplate GetWellKnownTemplate(Guid tenantId, string entityname, string contextname, int welknowntype, JObject resource) { var queryFilter1 = new List <QueryFilter> (); queryFilter1.Add(new QueryFilter { FieldName = "Context", Operator = "Equal", Value = _iMetadataManager.GetEntityContextByEntityName(contextname) }); queryFilter1.Add(new QueryFilter { FieldName = "TenantId", Operator = "Equal", Value = tenantId.ToString() }); queryFilter1.Add(new QueryFilter { FieldName = "CommunicationContextType", Operator = "Equal", Value = welknowntype }); var queryContext1 = new QueryContext { Fields = "Title,Body,Context,CommunicationContextType", Filters = queryFilter1, PageSize = 100, PageIndex = 1 }; DataTable templatedt = _queryManager.GetResult(tenantId, entityname, queryContext1); var template = EntityMapper <EmailTemplate> .Mapper(templatedt); if (template != null) { if (template.Body != null && !string.IsNullOrEmpty(template.Body.Value)) { template.Body.Value = _iMetadataManager.GetTemplateBodyWithTagablesValue(template.Body.Value, resource); } } return(template); }
public IActionResult Get(string entityName, [FromQuery] string fields, string searchText, string orderBy, string filters, int pageIndex, int pageSize) { try { var stopwatch = StopwatchLogger.Start(_log); _log.Info("Called RuleController Get All"); var tenantId = TenantCode; var queryFilter = ApiHelper.GetQueryFilter(filters, tenantId, IsSystemAdmin, entityName); var queryContext = new Entities.EntityCore.Model.Query.QueryContext { Fields = fields, Filters = queryFilter, PageSize = pageSize, PageIndex = pageIndex, OrderBy = orderBy }; if (!string.IsNullOrEmpty(searchText)) { var defaultLayout = _iILayoutManager.GetDefaultLayoutForEntity(TenantCode, entityName, (int)LayoutType.List, "", 0); if (defaultLayout != null && defaultLayout.ListLayoutDetails != null && defaultLayout.ListLayoutDetails.SearchProperties != null) { var freeTextSearch = defaultLayout.ListLayoutDetails.SearchProperties.FirstOrDefault(t => t.Name.Equals("FreeTextSearch")); if (freeTextSearch != null && freeTextSearch.Properties != null && freeTextSearch.Properties.Any()) { queryContext.FreeTextSearch = new List <QueryFilter>(); foreach (var prop in freeTextSearch.Properties) { var filter = new QueryFilter(); filter.FieldName = prop.Name; filter.Operator = Comparison.Like.ToString(); filter.Value = searchText; queryContext.FreeTextSearch.Add(filter); } } } } string entityId = null; if (!String.IsNullOrEmpty(entityName)) { entityId = _iMetadataManager.GetEntityContextByEntityName(entityName); } var retVal = _manageRule.GetAllRules(TenantCode, entityId); dynamic totalRow = retVal.Count; stopwatch.StopAndLog("End RuleController Get all"); return(Ok(new { retVal, totalRow })); } catch (FieldAccessException fx) { _log.Error(ExceptionFormatter.SerializeToString(fx)); return(StatusCode((int)HttpStatusCode.BadRequest, ApiConstant.CustomErrorMessage)); } catch (Exception ex) { _log.Error(ExceptionFormatter.SerializeToString(ex)); return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage)); } }
public IActionResult CreateMenu([FromBody] MenuItem menuItem) { try { var stopwatch = StopwatchLogger.Start(_log); _log.Info("Called MenuController CreateMenu"); if (menuItem != null && menuItem.ReferenceEntityId != null) { if (menuItem.MenuTypeId == 1) { menuItem.ReferenceEntityId = _iMetadataManager.GetEntityContextByEntityName(menuItem.ReferenceEntityId, false); } else if (menuItem.MenuTypeId == 2) { menuItem.ReferenceEntityId = _iMetadataManager.GetEntityContextByEntityName(menuItem.ReferenceEntityId, true); } } using (TransactionScope ts = new TransactionScope()) { //create menu var retVal = _iMenuManager.CreateMenu(menuItem, UserId, TenantCode); _iMenuManager.ClearMenuCache(TenantCode); //create resource //get language key value string langKey = ""; string langValue = ""; var retLan = _resourceManager.GetDefaultLanguageByTenant(TenantCode); if (retLan != null && retLan.Key != null) { langKey = Convert.ToString(retLan.Key); } if (retLan != null && retLan.Text != null) { langValue = Convert.ToString(retLan.Text); } //check resource by key var retRes = _resourceManager.GetResourcesByKey(TenantCode, menuItem.Menucode); if (retRes.Count == 0) { string msg = ""; _resourceManager.Create(TenantCode, new Entities.EntityCore.Model.Resource.Resource(menuItem.Menucode, menuItem.Name, langKey, langValue, menuItem.ReferenceEntityId, false), UserId, ref msg); } ts.Complete(); stopwatch.StopAndLog("CreateMenu method of MenuController"); return(Ok(retVal)); } } catch (Exception ex) { _log.Error(ExceptionFormatter.SerializeToString(ex)); return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage)); } }
LayoutModel GetDefaultLayoutForEntity(Guid tenantId, string entityName, int layoutType, string subType, int context) { var entityContext = _iMetadataManager.GetEntityContextByEntityName(entityName, false); if (string.IsNullOrEmpty(entityContext)) { return(null); } //return _review.GetLayoutsDetail(tenantId, entityContext, layoutType, _iMetadataManager.GetSubTypeId(subType), context); var layout = _review.GetLayoutsDetail(tenantId, entityContext, layoutType, _iMetadataManager.GetSubTypeId(entityName, subType), context); if (layout != null) { MapLayoutDetails(tenantId, layout); if (layoutType.Equals((int)LayoutType.List) && layout.ListLayoutDetails != null && layout.ListLayoutDetails.Fields != null && layout.ListLayoutDetails.Fields.Any()) { foreach (var field in layout.ListLayoutDetails.Fields) { if (field.DataType.ToLower().Equals("picklist") && !string.IsNullOrEmpty(field.DefaultView)) { var splitPicklist = field.Name.Split('.'); var picklistName = splitPicklist[splitPicklist.Count() - 1]; var view = GetDefaultPicklistLayout(tenantId, picklistName, LayoutType.View, 0); //it should be view layout... if (view != null && view.ViewLayoutDetails != null && view.ViewLayoutDetails.Fields != null && view.ViewLayoutDetails.Fields.Any()) { foreach (var item in view.ViewLayoutDetails.Fields) { layout.ListLayoutDetails.Fields.Add(item); } } } } } //append plural name var result = _iMetadataManager.GetEntitityByName(entityName); if (result != null && result.PluralName != null) { layout.PluralName = result.PluralName; } //append singular name if (result != null && result.DisplayName != null) { layout.SingularName = result.DisplayName; } //append version name if (result != null && result.VersionControl != null && !string.IsNullOrEmpty(result.VersionControl.Name)) { layout.VersionName = Char.ToLowerInvariant(result.VersionControl.Name[0]) + result.VersionControl.Name.Substring(1);; } } return(layout); }
public IActionResult Get(string entityname, [FromQuery] Guid?roleId) { try { var stopwatch = StopwatchLogger.Start(_log); _log.Info("Called EntitySecurityController Get {0}=", JsonConvert.SerializeObject(entityname)); var entityId = _iMetadataManager.GetEntityContextByEntityName(entityname); var roles = _managerRole.Roles(TenantCode, roleId); var functionSecurities = _managerEntitySecurity.GetFunctionSecurities(TenantCode, entityId, roleId); var accessLevel = _managerEntitySecurity.GetAccessLevel(); var operationLevel = _managerEntitySecurity.GetOperationLevel(); foreach (var role in roles) { // var itsEntitySecurity=(from entitySecurity in entitySecurities where entitySecurity.RoleId==role.RoleId select entitySecurity).FirstOrDefault(); // if(itsEntitySecurity!=null) // itsEntitySecurity.EntityId=string.Empty; var thisEntityFunctions = DataUtility.GetFunctionEntityWise(entityId); foreach (var thisEntityFunction in thisEntityFunctions) { var itsFunctionSecurity = (from functionSecurity in functionSecurities where functionSecurity.RoleId == role.RoleId && functionSecurity.FunctionContext == thisEntityFunction.FunctionContext select functionSecurity).FirstOrDefault(); if (itsFunctionSecurity != null) { thisEntityFunction.EntityId = itsFunctionSecurity.EntityId; thisEntityFunction.EntitySecurityId = itsFunctionSecurity.EntitySecurityId; thisEntityFunction.SecurityCode = itsFunctionSecurity.SecurityCode; thisEntityFunction.RoleId = itsFunctionSecurity.RoleId; } else { thisEntityFunction.RoleId = role.RoleId; thisEntityFunction.EntityId = entityId; } } role.Entity = new RoleMapperEntityInfo() { Functions = thisEntityFunctions, AccessLevel = RoleMapper.GetAccessLevels(accessLevel, new Guid(AccessLevelGuid.RoleFunction)), OperationLevel = RoleMapper.GetAccessLevels(operationLevel, new Guid(AccessLevelGuid.RoleFunction)) }; } stopwatch.StopAndLog("End EntitySecurityController Get"); return(Ok(roles)); } catch (Exception ex) { _log.Error(ExceptionFormatter.SerializeToString(ex)); return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage)); } }
public IActionResult Get([FromRoute] string entityname, [FromQuery] Guid transitionType, [FromQuery] Guid workFlowId) { try { var stopwatch = StopwatchLogger.Start(_log); _log.Info("Called WorkFlowStepController Get {0}=", JsonConvert.SerializeObject(entityname)); var entityId = _iMetadataManager.GetEntityContextByEntityName(entityname); var retVal = WorkFlowHelper.GetAllSteps(entityId); var itsSavedInnerSteps = _managerWorkFlowInnerSteps.GetWorkFlowInnerStep_ByStepTransactionType(TenantCode, transitionType, workFlowId); if (retVal.Count > 0) { retVal = (from retV in retVal where retV.Id != transitionType select retV).ToList(); } List <WorkFlowResource> filteredInnerSteps = new List <WorkFlowResource>(); foreach (var retV in retVal) { var checkExistance = (from itsSavedInnerStep in itsSavedInnerSteps where itsSavedInnerStep.TransitionType.Id == retV.Id select itsSavedInnerStep).ToList(); if (checkExistance.Count == 0) { filteredInnerSteps.Add(retV); } } stopwatch.StopAndLog("End WorkFlowStepController Get"); return(Ok(filteredInnerSteps)); } catch (Exception ex) { _log.Error(ExceptionFormatter.SerializeToString(ex)); return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage)); } }
public IActionResult GetPickListLayoutByPicklistName([FromRoute] string name, [FromQuery] string type) { try { var stopwatch = StopwatchLogger.Start(_log); _log.Info("Called PicklistController GetPickListLayoutByPicklistName"); _log.Info("Called PicklistController UpdatePicklistValue with name {0}=", name); if (string.IsNullOrEmpty(name)) { return(BadRequest("Entity name required!")); } if (string.IsNullOrEmpty(type)) { var result = _iLayoutManager.GetLayoutsByPicklistName(TenantCode, name); stopwatch.StopAndLog("GetPickListLayoutByPicklistName method of PicklistController."); return(Ok(result)); } else { var result = _iLayoutManager.GetLayoutsByEntityName(TenantCode, _iMetadataManager.GetEntityContextByEntityName(name, true), _iMetadataManager.GetTypeId(type), true); stopwatch.StopAndLog("GetPickListLayoutByPicklistName method of PicklistController."); return(Ok(result)); } } catch (Exception ex) { _log.Error(ExceptionFormatter.SerializeToString(ex)); return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage)); } }
public IActionResult Get(string operationName, string entityName) { try { var stopwatch = StopwatchLogger.Start(_log); _log.Info("Called WorkFlowProcessTaskController Get {0}=", JsonConvert.SerializeObject(operationName)); var entityId = _iMetadataManager.GetEntityContextByEntityName(entityName); var retVal = WorkFlowHelper.GetProcessorTitleByOperation(operationName, entityId); stopwatch.StopAndLog("End WorkFlowProcessTaskController Get"); return(Ok(retVal)); } catch (Exception ex) { _log.Error(ExceptionFormatter.SerializeToString(ex)); return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage)); } }
public IActionResult GetFeatures(string entityId) { try { var stopwatch = StopwatchLogger.Start(_log); _log.Info("Called SubscriptionFeatureController Get features {0}=", JsonConvert.SerializeObject(entityId)); entityId = _iMetadataManager.GetEntityContextByEntityName(entityId); var features = DataUtility.GetFeatureEntityWise(entityId); stopwatch.StopAndLog("End SubscriptionFeatureController Get features"); return(Ok(features)); } catch (Exception ex) { _log.Error(ExceptionFormatter.SerializeToString(ex)); return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage)); } }
public IActionResult Post([FromBody] TenantSubscriptionEntityInfo info) { try { if (info == null) { return(BadRequest("Invalid parameter")); } var stopwatch = StopwatchLogger.Start(_log); _log.Info("Called SubscriptionEntityController Post {0}=", JsonConvert.SerializeObject(info)); info.EntityId = _iMetadataManager.GetEntityContextByEntityName(info.EntityId); var subscriptionEntityId = _managerSubscriptionEntity.Create(TenantCode, info); stopwatch.StopAndLog("End SubscriptionEntityController Post"); return(Ok(subscriptionEntityId)); } catch (Exception ex) { _log.Error(ExceptionFormatter.SerializeToString(ex)); return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage)); } }
private List <WorkFlowProcessInfo> WorkFlowCommon(Guid tenantId, string entityName, string subTypeName, Guid innerStepId) { var entityId = iMetadataManager.GetEntityContextByEntityName(entityName); var subTypeCode = iMetadataManager.GetSubTypeId(entityName, subTypeName); var workFlow = _managerWorkFlow.GetWorkFlow(tenantId, entityId, subTypeCode); if (workFlow == null) { return(new List <WorkFlowProcessInfo>()); } //get its all pre/post/process var allProcess = _managerWorkFlowProcess.GetWorkFlowProcess(tenantId, workFlow.WorkFlowId); var itsOperationProcess = (from workFlowPro in allProcess where workFlowPro.OperationOrTransactionId == innerStepId select workFlowPro).ToList(); return(itsOperationProcess); }
public IActionResult GetLayouts(string entityName, [FromQuery] string type) { try { var stopwatch = StopwatchLogger.Start(_log); _log.Info("Called LayoutController GetLayouts"); //var layout = new List<LayoutModel>(); List <LayoutModel> layout = new List <LayoutModel> (); if (string.IsNullOrEmpty(type)) { layout = _iLayoutManager.GetLayoutsByEntityName(TenantCode, entityName); } else { try { int entitytype = _iMetadataManager.GetTypeId(type); layout = _iLayoutManager.GetLayoutsByEntityName(TenantCode, _iMetadataManager.GetEntityContextByEntityName(entityName, false), entitytype, false); } catch (Exception ex) { _log.Error(ExceptionFormatter.SerializeToString(ex)); return(BadRequest("Incorrect Type.")); } } stopwatch.StopAndLog("GetLayouts of LayoutController"); if (layout.Any()) { var settings = new JsonSerializerSettings(); settings.NullValueHandling = NullValueHandling.Ignore; settings.ContractResolver = new CamelCasePropertyNamesContractResolver(); return(Json(layout, settings)); } else { var settings = new JsonSerializerSettings(); settings.NullValueHandling = NullValueHandling.Ignore; settings.ContractResolver = new CamelCasePropertyNamesContractResolver(); return(Json(layout, settings)); } // return NotFound("Layout not found"); } catch (Exception ex) { _log.Error(ExceptionFormatter.SerializeToString(ex)); return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage)); } }
List <WorkFlowInfo> IManagerWorkFlow.GetWorkFlows(Guid tenantId, string entityname) { var entityId = iMetadataManager.GetEntityContextByEntityName(entityname); return(_reviewWorkFlow.GetWorkFlows(tenantId, entityId)); }
object IManagerWorkFlowSecurity.GetWorkFlowSecurity(Guid tenantId, string entityname) { var subTypes = iMetadataManager.GetSubTypesDetails(entityname); var entityId = iMetadataManager.GetEntityContextByEntityName(entityname); var workFlowItems = _managerWorkFlow.GetWorkFlows(tenantId, entityname); var allRoles = _managerRole.Roles(tenantId); var mainObj = new { roleList = allRoles, workFlows = new List <object>() }; var allSteps = WorkFlowHelper.GetAllSteps(entityId); var workFlowSteps = _managerWorkFlowStep.GetWorkFlowStepsByWorkFlowIds(tenantId, workFlowItems.Select(p => p.WorkFlowId).ToList()); var roles = _managerWorkFlowRole.GetWorkFlowRolesByWorkFlowIds(tenantId, workFlowItems.Select(p => p.WorkFlowId).ToList()); foreach (var workFlowItem in workFlowItems) { var subTypeName = subTypes.FirstOrDefault(t => t.Key.Equals(workFlowItem.SubTypeCode)); var thisWorkFlowRoles = (from role in roles where role.WorkFlowId == workFlowItem.WorkFlowId select role).ToList(); var workFLowObj = new { EntityId = entityname, SubTypeCode = subTypeName.Value, WorkFlowId = workFlowItem.WorkFlowId, Steps = new List <object>() }; var thisWorkFLowSteps = (from workFlowStep in workFlowSteps where workFlowStep.WorkFlowId == workFlowItem.WorkFlowId select workFlowStep).ToList(); foreach (var step in allSteps) { var filteredStep = (from workFlowStep in thisWorkFLowSteps where workFlowStep.TransitionType.Id == step.Id select workFlowStep).FirstOrDefault(); if (filteredStep != null) { var stepObj = new { filteredStep.WorkFlowStepId, filteredStep.WorkFlowId, Name = step.Value, filteredStep.IsAssigmentMandatory, filteredStep.AllotedTime, filteredStep.CriticalTime, ActivatedList = new List <object>(), AccessedList = new List <object>(), AssignedList = new List <object>() }; var checkRoles = (from role in thisWorkFlowRoles where role.WorkFlowStepId == filteredStep.WorkFlowStepId select role).ToList(); if (checkRoles.Count > 0) { foreach (var checkRole in checkRoles) { var rolObj = new { checkRole.RoleAssignmetId, checkRole.RoleId, checkRole.WorkFlowId, checkRole.WorkFlowStepId, name = checkRole.RoleName, checkRole.AssignmentOperationType }; if (checkRole.AssignmentOperationType == (int)WorkFlowRoleType.ActivatedRoles) { stepObj.ActivatedList.Add(rolObj); } if (checkRole.AssignmentOperationType == (int)WorkFlowRoleType.AccessedRoles) { stepObj.AccessedList.Add(rolObj); } if (checkRole.AssignmentOperationType == (int)WorkFlowRoleType.AssignedRoles) { stepObj.AssignedList.Add(rolObj); } } } workFLowObj.Steps.Add(stepObj); } } mainObj.workFlows.Add(workFLowObj); } return(mainObj); }