public EditLicensViewModel() { Shared = StaticClassSingleton.Instance; GoBackBtn = new GoBackCommand(); ChanceBtn = new RelayCommand(Change); _originalLicens = Shared.SelectedLicens; }
public EditLicensViewModel() { Shared = StaticClassSingleton.Instance; GoBackBtn = new GoBackCommand(); SaveChangesBtn = new ExecuteAndNavigateBackCommand(SaveChanges); _originalLicense = Shared.SelectedLicens; }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { using (Licens load_form = new Licens()) { if (load_form.ShowDialog() == DialogResult.OK) { string licens_path = @"licens.cer"; string licens_text = File.ReadAllText(licens_path); if (Crypt.Decrypt(licens_text) == getUnique()) { access = true; timer1.Interval = 0; timer1.Start(); } } } }
//Metoder private void SaveChanges() { for (int i = 0; i < Shared.Products.Count; i++) { Product p = Shared.Products[i]; Licens l = (Licens)p; if (l.LicenseKey == _originalLicense.LicenseKey) { Shared.Products[i] = SelectedLicense; //l.LicenseKey = LicenseKey; //l.ExpireDate = ExpireDate; //l.Units = Units; //c.StartDate = StartDate; } } }
//Metoder private void Change() { for (int i = 0; i < Shared.Products.Count; i++) { Product p = Shared.Products[i]; Licens l = (Licens)p; if (l.LicenseKey == _originalLicens.LicenseKey) { Shared.Products[i] = SelectedLicens; //l.LicenseKey = LicenseKey; //l.ExpireDate = ExpireDate; //l.Units = Units; //c.StartDate = StartDate; } } Navigation.GoBack(); }
protected override void Execute(CodeActivityContext context) { // Get the context service. IWorkflowContext Icontext = context.GetExtension <IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = context.GetExtension <IOrganizationServiceFactory>(); // Use the context service to create an instance of IOrganizationService. IOrganizationService service = serviceFactory.CreateOrganizationService(Icontext.InitiatingUserId); var SystemUser = service.Retrieve(Icontext.PrimaryEntityName, Icontext.PrimaryEntityId, new ColumnSet(true)); // make query for roles var query = new QueryExpression(); query.EntityName = "role"; query.ColumnSet = new ColumnSet(true); // link entity - fra rolle til rolle relation LinkEntity role = new LinkEntity(); role.LinkFromEntityName = "role"; role.LinkFromAttributeName = "roleid"; role.LinkToEntityName = "systemuserroles"; role.LinkToAttributeName = "roleid"; // fra rolle relation til bruger LinkEntity userRoles = new LinkEntity(); userRoles.LinkFromEntityName = "systemuserroles"; userRoles.LinkFromAttributeName = "systemuserid"; userRoles.LinkToEntityName = "systemuser"; userRoles.LinkToAttributeName = "systemuserid"; // lav condition til query ConditionExpression conditionExpression = new ConditionExpression(); conditionExpression.AttributeName = "systemuserid"; conditionExpression.Operator = ConditionOperator.Equal; conditionExpression.Values.Add(SystemUser.Id); userRoles.LinkCriteria = new FilterExpression(); userRoles.LinkCriteria.Conditions.Add(conditionExpression); // link entiterne sammen role.LinkEntities.Add(userRoles); query.LinkEntities.Add(role); // definer regler! var sales = new List <string> { "Lead", "Opportunity", "Goal", "Contract", "Quote", "Order", "Invoice", "Competitor", "Campaign", "List", "cdi_" }; // CLICKDIMENSION // få alle roller fra user var UserRoles = service.RetrieveMultiple(query).Entities; List <string> allRolesList = new List <string>(); foreach (var Role in UserRoles) { allRolesList.AddRange(getMasterRole(Role.GetAttributeValue <string>("name"), service, true)); } // få alle roller fra team var TeamRoles = getRolesFromTeam(SystemUser, service); foreach (var teamRole in TeamRoles) { allRolesList.AddRange(getMasterRole(teamRole, service, false)); } // fjern dupletter var allRolesListDistinct = allRolesList.Distinct(); var allRolesListDistinctList = allRolesListDistinct.ToList(); // returner en streng. var returnString = new StringBuilder(); var salesString = new StringBuilder(); var customEntitiesString = new StringBuilder(); var salesCounter = 0; var customEntityCounter = 0; var customEntities = new List <string>(); var salesEntities = new List <string>(); string[] seperator = { "_" }; // tjek om der er roller der matcher med sales -> stor licens! foreach (var privilege in allRolesListDistinctList) { for (int i = 0; i < sales.Count; i++) { var salesSplit = privilege.Split(seperator, StringSplitOptions.RemoveEmptyEntries); var salesLastMember = salesSplit.Length - 1; var salesName = salesSplit.GetValue(salesLastMember).ToString(); // "SalesProcess" bliver ekskluderet - det er en adgang til BPF if (privilege.Contains(sales.ElementAt(i)) && !privilege.Contains("SalesProcess") && !salesEntities.Contains(salesName)) { salesEntities.Add(salesName); salesCounter = salesCounter + 1; salesString.AppendLine(privilege); } } if ((privilege.Contains("sdu_") || privilege.Contains("mp_") || privilege.Contains("nn_") || privilege.Contains("alumne_")) && !privilege.Contains("bpf_")) { var entitySplit = privilege.Split(seperator, StringSplitOptions.RemoveEmptyEntries); var entityLastMember = entitySplit.Length - 1; var entityName = entitySplit.GetValue(entityLastMember).ToString(); if (!customEntities.Contains(entityName)) { customEntities.Add(entityName); customEntityCounter = 1 + customEntityCounter; customEntitiesString.AppendLine(privilege); } else { continue; } } } LastLogin.Set(context, CheckLastLoginDate(service, SystemUser.Id)); if (salesCounter > 0 || customEntityCounter > 15) { Licens.Set(context, "Sales"); } else { Licens.Set(context, "Team Member"); } returnString.AppendLine("- SALES: " + salesCounter.ToString()); returnString.AppendLine("- Custom Entities: " + customEntityCounter.ToString()); returnString.AppendLine(""); returnString.AppendLine("Sales: "); returnString.AppendLine(salesString.ToString()); returnString.AppendLine(""); returnString.AppendLine("Custom Entities: "); returnString.AppendLine(customEntitiesString.ToString()); Roller.Set(context, returnString.ToString()); }