コード例 #1
0
        public DetailsController(DataContext context,
                                 IPInfoProvider client,
                                 IMemoryCache cache,
                                 IBackgroundTaskQueue queue,
                                 MonsterJobs jobs)
        {
            _context = context;
            _client  = client;
            _cache   = cache;

            Queue = queue;
            _jobs = jobs;
        }
コード例 #2
0
    /// <summary>
    /// UniGrid action handler.
    /// </summary>
    private void gridElem_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "delete")
        {
            ContactInfo contact = ContactInfoProvider.GetContactInfo(ContactID);

            // Check permission
            if ((contact != null) && ContactHelper.AuthorizedModifyContact(contact.ContactSiteID, true))
            {
                int ipId = ValidationHelper.GetInteger(actionArgument, 0);
                IPInfoProvider.DeleteIPInfo(ipId);
            }
        }
    }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        chkEmail.Enabled      = !String.IsNullOrEmpty(ContactHelper.GetEmailDomain(CurrentContact.ContactEmail));
        chkAddress.Enabled    = !String.IsNullOrEmpty(CurrentContact.ContactAddress1) || !String.IsNullOrEmpty(CurrentContact.ContactAddress2) || !String.IsNullOrEmpty(CurrentContact.ContactCity) || !String.IsNullOrEmpty(CurrentContact.ContactZIP);
        chkBirthDay.Enabled   = (CurrentContact.ContactBirthday != DateTimeHelper.ZERO_TIME);
        chkPhone.Enabled      = !String.IsNullOrEmpty(CurrentContact.ContactBusinessPhone) || !String.IsNullOrEmpty(CurrentContact.ContactHomePhone) || !String.IsNullOrEmpty(CurrentContact.ContactMobilePhone);
        chkMembership.Visible = chkIPaddress.Visible = ci.ContactSiteID != 0;

        if (chkMembership.Visible)
        {
            var relationships = ContactMembershipInfoProvider.GetRelationships()
                                .WhereEquals("ActiveContactID", CurrentContact.ContactID);
            chkMembership.Enabled = relationships.Any();

            var ips = IPInfoProvider.GetIps()
                      .WhereEquals("IPActiveContactID", CurrentContact.ContactID);
            chkIPaddress.Enabled = ips.Any();
        }

        // Current contact is global object
        if (ci.ContactSiteID == 0)
        {
            plcSite.Visible = true;
            // Display site selector in site manager
            if (ContactHelper.IsSiteManager)
            {
                siteOrGlobalSelector.Visible = false;
            }
            // Display 'site or global' selector in CMS desk for global objects
            else if (ContactHelper.AuthorizedReadContact(SiteContext.CurrentSiteID, false) && ContactHelper.AuthorizedModifyContact(SiteContext.CurrentSiteID, false))
            {
                siteSelector.Visible = false;
            }
            else
            {
                plcSite.Visible = false;
            }
        }
    }
コード例 #4
0
        public void GetsIPDetailsSuccessfully()
        {
            //Arrange
            IntegrationTestsStartup integrationTestsStartup = new IntegrationTestsStartup();
            string    ip            = "141.237.3.189";
            IPDetails detailsGolden = new IPDetailsDTO()
            {
                City      = "Agios Dimitrios",
                Continent = "Europe",
                Country   = "Greece",
                Latitude  = 37.93333053588867,
                Longitude = 23.75
            };

            //Act
            IPDetails details = new IPInfoProvider(integrationTestsStartup.Configuration, new NullLogger <IPInfoProvider>()).GetDetails(ip);

            //Assert
            (bool, List <string>)AssertEqual = AreEqualHelper.HasEqualPropertyValues <IPDetails>(detailsGolden, details, null);

            Assert.True(AssertEqual.Item1);
        }
コード例 #5
0
ファイル: Filter.ascx.cs プロジェクト: itymofieiev/Kentico9
    /// <summary>
    /// Generates complete filter where condition.
    /// </summary>
    private string GenerateWhereCondition()
    {
        var whereCondition = new WhereCondition();

        // Create WHERE condition for basic filter
        int contactStatus = ValidationHelper.GetInteger(fltContactStatus.Value, -1);

        if (fltContactStatus.Value == null)
        {
            whereCondition = whereCondition.WhereNull("ContactStatusID");
        }
        else if (contactStatus > 0)
        {
            whereCondition = whereCondition.WhereEquals("ContactStatusID", contactStatus);
        }


        whereCondition = whereCondition
                         .Where(fltFirstName.GetCondition())
                         .Where(fltLastName.GetCondition())
                         .Where(fltEmail.GetCondition());

        // Only monitored contacts
        if (radMonitored.SelectedIndex == 1)
        {
            whereCondition = whereCondition.WhereTrue("ContactMonitored");
        }
        // Only not monitored contacts
        else if (radMonitored.SelectedIndex == 2)
        {
            whereCondition = whereCondition.WhereEqualsOrNull("ContactMonitored", 0);
        }

        // Only contacts that were replicated to SalesForce leads
        if (radSalesForceLeadReplicationStatus.SelectedIndex == 1)
        {
            whereCondition = whereCondition.WhereNotNull("ContactSalesForceLeadID");
        }
        // Only contacts that were not replicated to SalesForce leads
        else if (radSalesForceLeadReplicationStatus.SelectedIndex == 2)
        {
            whereCondition = whereCondition.WhereNull("ContactSalesForceLeadID");
        }

        // Create WHERE condition for advanced filter (id needed)
        if (IsAdvancedMode)
        {
            whereCondition = whereCondition
                             .Where(fltMiddleName.GetCondition())
                             .Where(fltCity.GetCondition())
                             .Where(fltPhone.GetCondition())
                             .Where(fltCreated.GetCondition())
                             .Where(GetOwnerCondition(fltOwner))
                             .Where(GetCountryCondition(fltCountry))
                             .Where(GetStateCondition(fltState));

            if (!String.IsNullOrEmpty(txtIP.Text))
            {
                var nestedIpQuery = IPInfoProvider.GetIps().WhereLike("IPAddress", SqlHelper.EscapeLikeText(SqlHelper.EscapeQuotes(txtIP.Text)));

                whereCondition = whereCondition.WhereIn("ContactID", nestedIpQuery.Column("IPOriginalContactID")).Or().WhereIn("ContactID", nestedIpQuery.Column("IPActiveContactID"));
            }
        }

        // When "merged/not merged" filter is hidden or in advanced mode display contacts according to filter or in basic mode don't display merged contacts
        if ((HideMergedFilter && NotMerged) ||
            (IsAdvancedMode && !HideMergedFilter && !chkMerged.Checked) ||
            (!HideMergedFilter && !NotMerged && !IsAdvancedMode))
        {
            whereCondition = whereCondition
                             .Where(
                new WhereCondition(
                    new WhereCondition()
                    .WhereNull("ContactMergedWithContactID")
                    .WhereGreaterOrEquals("ContactSiteID", 0)
                    )
                .Or(
                    new WhereCondition()
                    .WhereNull("ContactGlobalContactID")
                    .WhereNull("ContactSiteID")
                    ));
        }

        // Hide contacts merged into global contact when displaying list of available contacts for global contact
        if (HideMergedIntoGlobal)
        {
            whereCondition = whereCondition.WhereNull("ContactGlobalContactID");
        }

        if (!DisableGeneratingSiteClause)
        {
            // Filter by site
            if (!plcSite.Visible)
            {
                // Filter site objects
                if (SiteID > 0)
                {
                    whereCondition = whereCondition.WhereEquals("ContactSiteID", SiteID);
                }
                // Filter only global objects
                else if (SiteID == UniSelector.US_GLOBAL_RECORD)
                {
                    whereCondition = whereCondition.WhereNull("ContactSiteID");
                }
            }
            // Filter by site filter
            else
            {
                // Only global objects
                if (SelectedSiteID == UniSelector.US_GLOBAL_RECORD)
                {
                    whereCondition = whereCondition.WhereNull("ContactSiteID");
                }
                // Global and site objects
                else if (SelectedSiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD)
                {
                    whereCondition = whereCondition.WhereEqualsOrNull("ContactSiteID", SiteContext.CurrentSiteID);
                }
                // Site objects
                else if (SelectedSiteID != UniSelector.US_ALL_RECORDS)
                {
                    whereCondition = whereCondition.WhereEquals("ContactSiteID", mSelectedSiteID);
                }
            }
        }

        return(whereCondition.ToString(true));
    }
コード例 #6
0
 public MonsterJobs(IServiceScopeFactory serviceScopeFactory, ILoggerFactory loggerFactory, IPInfoProvider client)
 {
     _client = client;
     _serviceScopeFactory = serviceScopeFactory;
     _logger = loggerFactory.CreateLogger <MonsterJobs>();
 }
コード例 #7
0
        private async Task <IPDetails> GetIPDetailsFromIPStack(string ip)
        {
            IIPInfoProvider pr = new IPInfoProvider();

            return(await pr.GetDetails(ip));
        }
コード例 #8
0
        public static IIPInfoProvider GetProvider()
        {
            IIPInfoProvider provider = new IPInfoProvider();

            return(provider);
        }