コード例 #1
0
        public async Task <IActionResult> OnPostRemove(int id)
        {
            ModelState.Remove("Input.Name");

            var result = await PolicyService.Delete(new ReturnResult <int> {
                Value = id
            });

            ModelState.Merge(result);

            if (!ModelState.IsValid)
            {
                RolesList = RolesService.GetAll();
                return(Page());
            }
            ShowMessage(CoreEnumerations.MessageTypes.info, SharedResources.DeleteSuccess);
            return(RedirectToPage("/Policies/Index", new { area = "UserManagementAdmin" }));
        }
コード例 #2
0
        public void IsVehicleInsuredShouldReturnFalseOnNonExistingVehicle()
        {
            var repository = new Mock <IDeletableEntityRepository <Policy> >();
            var vehicle    = new Vehicle {
                Id = 1
            };

            repository.Setup(r => r.AllWithDeleted()).Returns(new List <Policy>
            {
                new Policy {
                    VehicleId = vehicle.Id, IsValid = true
                },
            }.AsQueryable());
            var service = new PolicyService(repository.Object);
            int nonExistingVehicleId = 2;

            Assert.False(service.IsVehicleInsured(nonExistingVehicleId));
        }
コード例 #3
0
        public void GetMyPoliciesIssuedShouldReturnCorrectCountOnNonEmptyRepository()
        {
            var repository = new Mock <IDeletableEntityRepository <Policy> >();

            repository.Setup(r => r.AllWithDeleted()).Returns(new List <Policy>
            {
                new Policy {
                    AgentId = "Pesho"
                },
                new Policy {
                    AgentId = "test"
                },
            }.AsQueryable());
            var    service  = new PolicyService(repository.Object);
            string clientId = "test";

            Assert.Equal(1, service.GetMyPoliciesIssued(clientId).Count);
        }
コード例 #4
0
        public void removePurchasingPolicyTest()
        {
            purchasingExp = new FalseCondition();
            Policystatus status = PolicyService.addPurchasingPolicy(storeOwner, idStore, purchasingExp);

            Assert.IsTrue(status == Policystatus.Success);
            int oldNumPolicies = store.purchasePolicies.Count;

            IBooleanExpression policy = store.getPolicy(-2);

            idpurchasingExp = policy.id;
            status          = PolicyService.removePurchasingPolicy(storeOwner, idStore, idpurchasingExp);
            Assert.IsTrue(status == Policystatus.Success);

            int newNumPolicies = store.purchasePolicies.Count;

            Assert.AreNotEqual(oldNumPolicies, newNumPolicies);
        }
コード例 #5
0
        T GetDirectInherited(PolicyContainer initialContainer)
        {
            if (initialContainer == policyContainer && !loaded && hasCachedPolicy)
            {
                return((T)cachedPolicy);
            }
            PolicyContainer pc = initialContainer;

            while (pc != null)
            {
                if (pc.DirectHas <T> (mimeType))
                {
                    return(pc.DirectGet <T> (mimeType));
                }
                pc = pc.ParentPolicies;
            }
            return(PolicyService.GetUserDefaultPolicySet().Get <T> (mimeType));
        }
コード例 #6
0
        /// <summary>
        /// Updates the header from genius.
        /// </summary>
        /// <param name="xiapHeader">The xiap header.</param>
        /// <param name="results">The results.</param>
        /// <exception cref="System.ServiceModel.FaultException">new FaultCode(Sender)</exception>
        /// <exception cref="FaultReason"></exception>
        /// <exception cref="FaultCode">Sender</exception>
        private void UpdateFromGenius(Header xiapHeader, ProcessResultsCollection results)
        {
            try
            {
                IUWHeader externalHeader = null;
                IPolicyService riskService = null;
                // Create an external policy service to the external service linked on the Header product.
                // This external service will be Genius.
                riskService = new PolicyService(xiapHeader.GetProduct().Product.ExternalDataSource);
                externalHeader = riskService.GetPolicy(xiapHeader.HeaderReference);
                if (this.ValidateExternalHeader(xiapHeader, externalHeader, results).Count == 0)
                {
                    // Count is 0, i.e. no errors added to the ProcessResultsCollection 'results' in the Validation of External Header
                    this.UpdateHeader(xiapHeader, externalHeader);

                    // Apply the external policy terms to the GeniusX policy.
                    foreach (IUWTerms externalTerm in externalHeader.ITerms)
                    {
                        this.ProcessTerms(xiapHeader, externalTerm);
                    }

                    // Order the external policy sections by the External Reference, which will be a Genius Reference,
                    // thus the sections will be ordered as they are in the Genius policy.
                    // Then apply each to the GeniusX policy in turn.
                    var sections = externalHeader.ISections.OrderBy(x => x.ExternalReference);
                    foreach (IUWSection externalSection in sections)
                    {
                        this.ProcessSection(xiapHeader, externalSection);
                    }

                    // Finally, update NameInvolvements from the external Genius policy
                    this.UpdateNameInvolvement(xiapHeader, externalHeader);
                }
            }
            catch (Exception e)
            {
                if (_logger.IsErrorEnabled)
                {
                    _logger.Error(e);
                }

                throw new FaultException(new FaultReason(e.Message), new FaultCode("Sender"));
            }
        }
コード例 #7
0
        protected void OnButtonOkClicked(object sender, EventArgs e)
        {
            if (radioCustom.Active)
            {
                if (entryName.Text.Length == 0)
                {
                    MessageService.ShowError(GettextCatalog.GetString("Policy name not specified"));
                    return;
                }
                PolicySet pset = CreatePolicySet();
                pset.Name = entryName.Text;
                PolicyService.AddUserPolicySet(pset);
                PolicyService.SavePolicies();
            }
            else
            {
                if (fileEntry.Path == null || fileEntry.Path.Length == 0)
                {
                    MessageService.ShowError(GettextCatalog.GetString("File name not specified"));
                    return;
                }
                FilePath file = fileEntry.Path;
                if (file.Extension != ".mdpolicy")
                {
                    file = file + ".mdpolicy";
                }
                DefaultFileDialogPolicyDir = file.ParentDirectory;

                if (System.IO.File.Exists(file) && !MessageService.Confirm(GettextCatalog.GetString("The file {0} already exists. Do you want to replace it?", file), AlertButton.Replace))
                {
                    return;
                }

                PolicySet pset = CreatePolicySet();
                pset.Name = file.FileName;
                try {
                    pset.SaveToFile(file);
                } catch (Exception ex) {
                    MessageService.ShowError(GettextCatalog.GetString("The policy file could not be saved"), ex);
                    return;
                }
            }
            Respond(Gtk.ResponseType.Ok);
        }
コード例 #8
0
        T GetCurrentPolicy()
        {
            object pol = null;

            if (loaded)
            {
                pol = GetPolicy();
            }
            else if (hasCachedPolicy)
            {
                pol = cachedPolicy;
            }

            if (pol == null)
            {
                pol = policyContainer.Get <T> (mimeTypeScopes) ?? PolicyService.GetDefaultPolicy <T> (mimeTypeScopes);
            }
            return((T)pol);
        }
コード例 #9
0
        public async Task <IHttpActionResult> GetPolicy(long id)
        {
            long?tokenId = User.Identity.GetPolicyIdFromToken();

            if (tokenId != id)
            {
                return(Unauthorized());
            }

            try
            {
                PolicyService service = _serviceFactory.GetPolicyService();
                return(Ok(service.ConvertToDto(await service.GetPolicy(id))));
            }
            catch (Exception)
            {
                return(NotFound());
            }
        }
コード例 #10
0
        public void removeStorePolicyTest()
        {
            storeExp = new FalseCondition();
            Policystatus status = PolicyService.addStorePolicy(storeOwner, idStore, storeExp);

            Assert.IsTrue(status == Policystatus.Success);

            IBooleanExpression policy = store.getPolicy(-1);

            idstoreExp = policy.id;

            int oldNumPolicies = store.storePolicies.Count;

            status = PolicyService.removeStorePolicy(storeOwner, idStore, idstoreExp);
            Assert.IsTrue(status == Policystatus.Success);
            int newNumPolicies = store.storePolicies.Count;

            Assert.AreNotEqual(oldNumPolicies, newNumPolicies);
        }
コード例 #11
0
        public string FormatText(PolicyContainer policyParent, string mimeType, string input)
        {
            TextStylePolicy policy;

            if (policyParent != null)
            {
                policy = policyParent.Get <TextStylePolicy> (DesktopService.GetMimeTypeInheritanceChain(mimeType));
            }
            else
            {
                policy = PolicyService.GetDefaultPolicy <TextStylePolicy> (DesktopService.GetMimeTypeInheritanceChain(mimeType));
            }

            XmlTextReader reader = new XmlTextReader(new StringReader(input));

            reader.WhitespaceHandling = WhitespaceHandling.None;

            StringWriter      indentedXmlWriter = new StringWriter();
            XmlWriterSettings settings          = new XmlWriterSettings();

            settings.Indent = true;
            if (policy.TabsToSpaces)
            {
                settings.IndentChars = new string (' ', policy.TabWidth);
            }
            else
            {
                settings.IndentChars = "\t";
            }
            settings.NewLineChars = policy.GetEolMarker();

            try {
                XmlWriter xmlWriter = XmlTextWriter.Create(indentedXmlWriter, settings);
                xmlWriter.WriteNode(reader, false);
                xmlWriter.Flush();
            } catch {
                // Ignore malfored xml
                return(input);
            }

            return(indentedXmlWriter.ToString());
        }
コード例 #12
0
        public async Task ImportClient_Insert_NoIdButHasPolicyNumber_UnknowClientType()
        {
            var options = TestHelper.GetDbContext("ImportClient_Insert_NoIdButHasPolicyNumber_UnknowClientType");

            var user1 = TestHelper.InsertUserDetailed(options);

            var company = TestHelper.InsertCompany(options);

            using (var context = new DataContext(options))
            {
                var auditService           = new AuditServiceMock();
                var clientService          = new ClientService(context, auditService);
                var policyService          = new PolicyService(context, auditService);
                var contactService         = new ContactService(context, auditService);
                var lookupService          = new ClientLookupService(context);
                var directoryLookupService = new DirectoryLookupService(context);
                var service = new ClientImportService(context, clientService, policyService, contactService, lookupService, directoryLookupService);

                //When
                var data = new ImportClient()
                {
                    IdNumber           = "",
                    PolicyNumber       = "123456798",
                    LastName           = "Some Business",
                    PolicyCompanyId    = company.Id,
                    PolicyUserFullName = user1.User.FirstName + " " + user1.User.LastName
                };

                var scope = TestHelper.GetScopeOptions(user1);

                var result = await service.ImportClient(scope, data);

                //Then
                Assert.True(result.Success);

                var actual = await context.Client.FirstOrDefaultAsync();

                Assert.Null(actual.IdNumber);
                Assert.Equal(data.LastName, actual.LastName);
                Assert.Equal(ClientType.CLIENT_TYPE_UNKNOWN_ENTITY, actual.ClientTypeId);
            }
        }
コード例 #13
0
        public void Mock()
        {
            var policyRepositoryMock  = new Mock <IPolicyRepository>();
            var riskRepositorMock     = new Mock <IRiskRepository>();
            var premiumCalculatorMock = new Mock <IPremiumCalculator>();

            policyRepositoryMock.Setup(pService => pService.Get("Obj05.05.2020 00:00:00"))
            .Returns(new PolicyModel());

            riskRepositorMock.Setup(riskRepo => riskRepo.GetAll()).Returns(new List <RiskModel> {
                new RiskModel()
            });

            PolicyService ps = new PolicyService(policyRepositoryMock.Object,
                                                 riskRepositorMock.Object, premiumCalculatorMock.Object);

            var mockGetPolicyCall = ps.GetPolicy("Obj", new DateTime(2020, 5, 5));

            policyRepositoryMock.Verify(polRepMock => polRepMock.Get("Obj05.05.2020 00:00:00"), Times.Once);
        }
コード例 #14
0
        PolicySet GetPolicySet(bool notifyErrors)
        {
            if (radioCustom.Active)
            {
                return(PolicyService.GetPolicySet(combPolicies.ActiveText));
            }

            var f = fileEntry.Path;

            if (string.IsNullOrEmpty(f) || !System.IO.File.Exists(f))
            {
                return(null);
            }

            var pset = new PolicySet();

            pset.LoadFromFile(fileEntry.Path);
            ExportProjectPolicyDialog.DefaultFileDialogPolicyDir = System.IO.Path.GetDirectoryName(fileEntry.Path);
            return(pset);
        }
コード例 #15
0
        public void GetAllExpiredPoliciesShouldReturnCorrectCountOnNonEmptyRepository()
        {
            var repository = new Mock <IDeletableEntityRepository <Policy> >();

            repository.Setup(r => r.AllWithDeleted()).Returns(new List <Policy>
            {
                new Policy {
                    IsValid = false
                },
                new Policy {
                    IsValid = false
                },
                new Policy {
                    IsValid = true
                },
            }.AsQueryable());
            var service = new PolicyService(repository.Object);

            Assert.Equal(2, service.GetAllExpiredPolicies().Count);
        }
コード例 #16
0
        public ApplyPolicyDialog(IPolicyProvider policyProvider)
        {
            this.Build();
            this.policyProvider = policyProvider;

            foreach (PolicySet pset in PolicyService.GetPolicySets())
            {
                if (pset.Visible)
                {
                    combPolicies.AppendText(pset.Name);
                }
            }

            fileEntry.DefaultPath = ExportProjectPolicyDialog.DefaultFileDialogPolicyDir;
            fileEntry.FileFilters.AddFilter(GettextCatalog.GetString("MonoDevelop policy files"), "*.mdpolicy");
            fileEntry.FileFilters.AddAllFilesFilter();
            combPolicies.Active = 0;
            OnRadioCustomToggled(null, null);
            UpdateContentLabels();
        }
コード例 #17
0
        public async Task <IActionResult> OnPostSubmit()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var result = await PolicyService.SaveApplyPolicyChanges(WebHostEnvironment.ContentRootPath, new ReturnResult <List <SitePage> >() { Value = Input });

            ModelState.Merge(result);

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            ShowMessage(CoreEnumerations.MessageTypes.info, PoliciesManagementResources.msg_ApplyPolicy_Saved);

            return(RedirectToPage(UserManagementNavConstants.Pages.ApplyPoliciesMessage, new { area = UserManagementNavConstants.Area }));
        }
コード例 #18
0
        public HttpResponseMessage DownloadFile([FromBody] DownloadDoc doc)
        {
            //byte[] fileBytes = null;
            IPolicyService policyService = new PolicyService();
            Stream         stream        = null;

            if (doc != null)
            {
                stream = policyService.DownloadDocument(doc.Name, doc.Path);
            }
            else
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);

            byte[] buffer = new byte[16 * 1024];
            using (MemoryStream ms = new MemoryStream())
            {
                stream.CopyTo(ms);
                response.Content = new ByteArrayContent(ms.GetBuffer());
                response.Content.Headers.ContentLength = ms.Length;
            }

            response.Headers.AcceptRanges.Add("bytes");
            response.StatusCode = HttpStatusCode.OK;
            response.Content.Headers.ContentDisposition
                = new ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentType
                = new MediaTypeHeaderValue("application/octet-stream");
            //response.Content.Headers.ContentLength = stream.Length;
            //response.Content.Headers.ContentLength = contentInfo.Length;

            response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
            //response.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/pdf");

            response.Content.Headers.ContentDisposition.FileName = doc.Name;

            return(response);
        }
コード例 #19
0
        public void removeDiscountPolicyTest()
        {
            IOutcome           outcome = new Percentage(20);
            IBooleanExpression exp     = new FalseCondition();

            discount = new Discount(exp, outcome);
            Policystatus status = PolicyService.addDiscountPolicy(storeOwner, idStore, discount);

            Assert.IsTrue(status == Policystatus.Success);
            Discount theNewDiscount = store.getDiscountPolicy(-1);

            idDiscount = theNewDiscount.id;

            int oldNumPolicies = store.discountPolicies.Count;

            status = PolicyService.removeDiscountPolicy(storeOwner, idStore, idDiscount);
            Assert.IsTrue(status == Policystatus.Success);
            int newNumPolicies = store.discountPolicies.Count;

            Assert.AreNotEqual(oldNumPolicies, newNumPolicies);
        }
コード例 #20
0
 void OnPolicySelectionChanged(object s, ComboSelectionChangedArgs args)
 {
     Gtk.TreeIter iter;
     if (store.GetIter(out iter, new Gtk.TreePath(args.Path)))
     {
         MimeTypePanelData mt = (MimeTypePanelData)store.GetValue(iter, 0);
         if (args.Active != -1)
         {
             string sel = args.ActiveText;
             if (sel == (panel.IsCustomUserPolicy ? systemPolicyText : parentPolicyText))
             {
                 mt.UseParentPolicy = true;
             }
             else if (sel != customPolicyText)
             {
                 PolicySet pset = PolicyService.GetPolicySet(sel);
                 mt.AssignPolicies(pset);
             }
         }
     }
 }
コード例 #21
0
        private void MoveFromStepInternalCredentials()
        {
            dtoInternalCredentials credentials = View.GetInternalCredentials;
            InternalLoginInfo      info        = InternalService.GetAuthenticatedUser(credentials.Login, credentials.Password);

            if (info == null || info.Person == null)
            {
                View.DisplayInvalidCredentials();
            }
            else
            {
                UrlAuthenticationProvider provider = GetProvider();
                if (provider == null)
                {
                    View.DisplayInternalCredentialsMessage(ProfileSubscriptionMessage.ProviderUnknown);
                }
                else
                {
                    ExternalLoginInfo account = UrlService.AddFromInternalAccount(info, provider, View.UrlIdentifierValue);
                    if (account == null)
                    {
                        View.DisplayInternalCredentialsMessage(ProfileSubscriptionMessage.UnableToConnectToInternalProvider);
                    }
                    else if (account != null && account.Person.isDisabled)
                    {
                        View.LoadRegistrationMessage(ProfileSubscriptionMessage.AccountDisabled);
                    }
                    else if (PolicyService.UserHasPolicyToAccept(account.Person))
                    {
                        View.IdProfile = account.Person.Id;
                        InternalService.UpdateUserAccessTime(account.Person);
                        View.DisplayPrivacyPolicy(account.Person.Id, provider.Id, provider.RemoteLoginUrl, false);
                    }
                    else
                    {
                        View.LogonUser(account.Person, View.idProvider, provider.RemoteLoginUrl, false, CurrentManager.GetUserDefaultIdOrganization(account.Person.Id));
                    }
                }
            }
        }
コード例 #22
0
        public async Task <IActionResult> OnPostSubmit()
        {
            if (!ModelState.IsValid)
            {
                RolesList = RolesService.GetAll();
                return(Page());
            }

            var result = await PolicyService.Save(new ReturnResult <PolicyViewModel>() { Value = Input });

            ModelState.Merge(result);

            if (!ModelState.IsValid)
            {
                RolesList = RolesService.GetAll();
                return(Page());
            }

            ShowMessage(CoreEnumerations.MessageTypes.info, SharedResources.CreateSuccess);

            return(RedirectToPage(UserManagementNavConstants.Pages.PolicyIndex, new { area = UserManagementNavConstants.Area }));
        }
コード例 #23
0
        public void SetUpFixture()
        {
            using (var db = new EDeviceClaimsContext())
            {
                _user = CreateUser("*****@*****.**", "*****@*****.**", db);
                db.SaveChanges();

                db.Policies.Add(new PolicyEntity {
                    Id = Guid.NewGuid(), Number = "11121", SerialNumber = "MNOPQ", DeviceName = "iPhone 6+", CustomerEmail = "*****@*****.**", UserId = _user.Id
                });
                db.Policies.Add(new PolicyEntity {
                    Id = Guid.NewGuid(), Number = "11122", SerialNumber = "ABCDE", DeviceName = "iPhone 6+", CustomerEmail = "*****@*****.**", UserId = _user.Id
                });
                db.Policies.Add(new Policyentity {
                    Id = Guid.NewGuid(), Number = "11123", SerialNumber = "EDCBA", DeviceName = "iPhone 6+", CustomerEmail = "*****@*****.**"
                });

                db.SaveChanges();
            }

            _service = new PolicyService();
        }
コード例 #24
0
 public ActionResult Get(Guid id)
 {
     try
     {
         string cookieValue   = Request.Cookies["clientId"];
         var    authorizeCode = Authorize.AuthorizeClient(cookieValue, eRoles.admin.ToString());
         if (authorizeCode < 200 || authorizeCode > 299)
         {
             return(StatusCode(authorizeCode));
         }
         else
         {
             PolicyService pService  = new PolicyService();
             var           clientDTO = pService.GetUserFromPolicy(id);
             return(StatusCode(200, clientDTO != null ? JsonConvert.SerializeObject(clientDTO) : "Client not found/ Error with Policy number"));
         }
     }
     catch (Exception ex)
     {
         return(StatusCode(500));
     }
 }
コード例 #25
0
        public override void Initialize(MonoDevelop.Ide.Gui.Dialogs.OptionsDialog dialog, object dataObject)
        {
            base.Initialize(dialog, dataObject);
            panelData = (MimeTypePanelData)dataObject;

            IPolicyProvider provider = panelData.DataObject as IPolicyProvider;

            if (provider == null)
            {
                provider       = PolicyService.GetUserDefaultPolicySet();
                isGlobalPolicy = true;
            }

            bag      = provider.Policies as PolicyBag;
            polSet   = provider.Policies as PolicySet;
            mimeType = panelData.MimeType;
            panelData.SectionPanel = this;
            isRoot = polSet != null || bag.IsRoot;
            if (IsCustomUserPolicy)
            {
                isRoot = false;
            }
        }
コード例 #26
0
        void FillPolicies()
        {
            if (!IsRoot)
            {
                store.AppendValues(GettextCatalog.GetString("Parent Policy"), null);
                store.AppendValues("--", null);
            }

            bool added = false;

            foreach (PolicySet set in PolicyService.GetPolicySets <T> ())
            {
                store.AppendValues(set.Name, set);
                added = true;
            }

            if (added)
            {
                store.AppendValues("--", null);
            }

            store.AppendValues(GettextCatalog.GetString("Custom"), null);
        }
コード例 #27
0
        public void CreateNewPolicy()
        {
            var rs      = GetReportingService();
            var taskIDs = new List <string>();

            taskIDs.AddRange(
                rs.ListTasks("All")
                .Where(t => new[] { "Manage all subscriptions", "View reports" }.Contains(t.Name))
                .Select(t => t.TaskID)
                );
            rs.CreateRole("*Test* My First Role", "My First Role description", taskIDs.ToArray());

            var service   = new PolicyService(rs);
            var newPolicy = new Tuple <string, string[]>("*Test* My First Role", new[] { GetUserName() });

            service.Create("/ReportFolder", Enumerable.Repeat(newPolicy, 1));

            var inherit  = true;
            var policies = rs.GetPolicies("/ReportFolder", out inherit);

            Assert.That(policies.Where(p => p.GroupUserName == GetUserName()).Count(), Is.EqualTo(1));
            Assert.That(inherit, Is.False);
        }
コード例 #28
0
        public async Task GetPolicy_ByNumber()
        {
            var options = TestHelper.GetDbContext("GetPolicy_ByNumber");

            var user1   = TestHelper.InsertUserDetailed(options);
            var client1 = TestHelper.InsertClient(options, user1.Organisation);

            //Given
            var policy1 = new PolicyEntity
            {
                Id        = Guid.NewGuid(),
                CompanyId = Guid.NewGuid(),
                ClientId  = client1.Client.Id,
                UserId    = user1.User.Id,
                Number    = "AABBCC"
            };

            using (var context = new DataContext(options))
            {
                context.Policy.Add(policy1);

                context.SaveChanges();
            }

            using (var context = new DataContext(options))
            {
                var auditService = new AuditServiceMock();
                var service      = new PolicyService(context, auditService);

                //When
                var scopeOptions = TestHelper.GetScopeOptions(user1);
                var actual       = await service.GetPolicy(scopeOptions, "aabbcc"); //Shouldnt be case sensitive

                //Then
                Assert.Equal(policy1.Id, actual.Id);
            }
        }
コード例 #29
0
        void FillPolicies()
        {
            ((ListStore)store).Clear();

            if (IsCustomUserPolicy)
            {
                store.AppendValues(GettextCatalog.GetString("System Default"), null);
                store.AppendValues("--", null);
            }
            else if (!IsRoot)
            {
                store.AppendValues(GettextCatalog.GetString("Parent Policy"), null);
                store.AppendValues("--", null);
            }

            setsInCombo.Clear();
            foreach (PolicySet set in PolicyService.GetPolicySets <T> ())
            {
                if (polSet != null && set.Name == polSet.Name)
                {
                    continue;
                }
                if (IsCustomUserPolicy && set.Name == "Default")                 // There is already a System Default entry
                {
                    continue;
                }
                store.AppendValues(set.Name, set);
                setsInCombo.Add(set);
            }

            if (setsInCombo.Count > 0)
            {
                store.AppendValues("--", null);
            }

            store.AppendValues(GettextCatalog.GetString("Custom"), null);
        }
コード例 #30
0
        void HandleNewButtonClicked(object sender, EventArgs e)
        {
            HashSet <PolicySet> esets = new HashSet <PolicySet> (PolicyService.GetPolicySets());

            esets.ExceptWith(PolicyService.GetUserPolicySets());
            esets.UnionWith(sets);
            esets.RemoveWhere(p => !p.Visible);

            NewPolicySetDialog dlg = new NewPolicySetDialog(new List <PolicySet> (esets));

            try {
                if (MessageService.RunCustomDialog(dlg, this) == (int)Gtk.ResponseType.Ok)
                {
                    PolicySet pset = new PolicySet();
                    pset.CopyFrom(dlg.SourceSet);
                    pset.Name = dlg.PolicyName;
                    sets.Add(pset);
                    FillPolicySets();
                    policiesCombo.Active = sets.IndexOf(pset);
                }
            } finally {
                dlg.Destroy();
            }
        }
コード例 #31
0
        void IMimeTypePolicyOptionsPanel.LoadSetPolicy(PolicyContainer pset)
        {
            object selected = pset.Get <T> (mimeTypeScopes);

            if (selected == null)
            {
                selected = PolicyService.GetDefaultPolicy <T> (mimeTypeScopes);
            }

            if (loaded)
            {
                if (defaultSettingsButton != null)
                {
                    defaultSettingsButton.Active = false;
                    panelWidget.Sensitive        = true;
                }
                LoadFrom((T)selected);
            }
            else
            {
                cachedPolicy    = selected;
                hasCachedPolicy = true;
            }
        }