private async void OnEditorClosed(IDialogResult result)
        {
            if (result.Result != ButtonResult.OK)
            {
                return;
            }
            if (!result.Parameters.ContainsKey("id"))
            {
                return;
            }

            var id = result.Parameters.GetValue <int>("id");

            if (id == 0)
            {
                return;
            }

            var savedItem = await _domains.GetItem(id);

            var oldItem = Domains.FirstOrDefault(d => d.Model.Id == id);

            if (oldItem != null)
            {
                Domains.Remove(oldItem);
            }
            Domains.Add(new BindableEntity(savedItem));
        }
Пример #2
0
        private PluginDomain CreateDomain(string path)
        {
            lock (Domains)
            {
                for (int i = Domains.Count - 1; i >= 0; i--)
                {
                    PluginDomain other = Domains[i];
                    if (other.Path == path)
                    {
                        return(other);
                    }
                }

                PluginDomain domain = new PluginDomain(this, path);
                domain.Initialize();
                if (domain.Plugin.State == PluginState.Failed)
                {
                    return(null);
                }
                Plugin otherPlugin = GetPlugin(domain.Plugin.Meta.Id);
                if (otherPlugin != null)
                {
                    Bridge.Logger.Warn(
                        "Could not loading plugin {ID} on path \"{PATH}\" because the id is already occupied by the plugin {ID2} on the path {PATH2}!",
                        domain.Plugin.Meta.Id, domain.Path, otherPlugin.Meta.Id, otherPlugin.FilePath);
                    return(null);
                }

                Domains.Add(domain);
                return(domain);
            }
        }
Пример #3
0
 public void AddDomains(params Guid[] domainIDs)
 {
     foreach (var id in domainIDs)
     {
         Domains.Add(new Metric_Domain {
             Metric = this, DomainID = id
         });
     }
 }
Пример #4
0
 public CSP(IEnumerable <Var> vars)
 {
     foreach (Var @var in vars)
     {
         Variables.Add(@var);
         Domains.Add(new Domain <Val>());
         _varToConstraints.TryAdd(@var, new List <IConstraint <Var, Val> >());
     }
 }
Пример #5
0
        /// <summary>
        /// Создание нового домена
        /// </summary>
        /// <returns>Возвращает новый экземпляр с новым доменом для текущей сессии</returns>
        internal SeparatedAppDomain CreateDomain()
        {
            var domain = new SeparatedAppDomain(this);

            lock (SessionLocker)
                Domains.Add(domain);

            return(domain);
        }
Пример #6
0
 public void AddDomains(params Domain[] domains)
 {
     foreach (var domain in domains)
     {
         Domains.Add(new Metric_Domain {
             Metric = this, Domain = domain, DomainID = domain.ID
         });
     }
 }
Пример #7
0
        public Domain AddDomain(Domains domains, string sName)
        {
            Domain domain = domains.Add();

            domain.Name   = sName;
            domain.Active = true;
            domain.Save();

            return(domain);
        }
Пример #8
0
        public Domain AddDomain(Domains oDomains, string sName)
        {
            Domain oDomain = oDomains.Add();

            oDomain.Name   = sName;
            oDomain.Active = true;
            oDomain.Save();

            return(oDomain);
        }
Пример #9
0
        public void AddDomain(Domain domain)
        {
            var exists = Domains.FirstOrDefault(k => k.Name == domain.Name);

            if (exists != null)
            {
                throw new Exception("Domain with name arelady repated");
            }
            Domains.Add(domain);
        }
        public EpinionsCrossDomainDataContainer(int numDomains)
            : base()
        {
            NumDomains = numDomains;

            for (int i = 0; i < numDomains; i++)
            {
                string dId = "ep" + i;
                Domains.Add(dId, new Domain(dId));
            }
        }
Пример #11
0
        public DelveInfoBuilder WithDomains(string domainInput)
        {
            int randomDomains = 0;

            DomainInput = domainInput;

            string[] seperators = new string[] { DelveResources.ListSeperator, DelveResources.ListSeperator.Trim() };
            var      domains    = domainInput.Split(seperators, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < domains.Length; i++)
            {
                domains[i] = domains[i].Trim();
                if (randomAliases.Any(alias => alias.Equals(domains[i], StringComparison.OrdinalIgnoreCase)))
                {
                    randomDomains++;
                    continue;
                }

                var matchingDomain = DelveService.Domains.Find(d => d.DelveSiteDomain.Equals(domains[i], StringComparison.OrdinalIgnoreCase));
                if (matchingDomain != null)
                {
                    Domains.Add(matchingDomain);
                    continue;
                }

                if (int.TryParse(domains[i], out int domainValue) && domainValue - 1 < DelveService.Domains.Count)
                {
                    Domains.Add(DelveService.Domains[domainValue - 1]);
                    continue;
                }

                throw new ArgumentException(String.Format(DelveResources.UnknownDomainError, domains[i]));
            }

            for (int i = 0; i < randomDomains; i++)
            {
                Domain toAdd = null;
                while (toAdd == null)
                {
                    int value = BotRandom.Instance.Next(0, DelveService.Domains.Count);
                    var check = DelveService.Domains[value];
                    if (!this.Domains.Contains(check))
                    {
                        toAdd = check;
                    }
                }

                Domains.Add(toAdd);
            }

            return(this);
        }
Пример #12
0
        public MovieLensCrossDomainContainer(int numDomains, bool randomClusters = false)
            : base()
        {
            _mapper        = new Mapping();
            NumDomains     = numDomains;
            RandomClusters = randomClusters;
            _itemsCluster  = new Dictionary <string, int>();

            for (int i = 0; i < numDomains; i++)
            {
                string dId = "ml" + i;
                Domains.Add(dId, new Domain(dId));
            }
        }
Пример #13
0
        private void LoadV1(string[] data)
        {
            Domains.Clear();
            Domain   = data != null && data.Length > 0 ? data[0] : "";
            Token    = data != null && data.Length > 1 ? CharSwitch(data[1]) : "";
            Interval = data != null && data.Length > 2 ? data[2] : "30m";
            var ownResolveOfIPs = data != null && data.Length > 3 ? data[3] == "OwnResolveIpv6" || data[3] == "OwnResolveIPs" : false;

            if (ownResolveOfIPs)
            {
                Domains.Add(new DDnsDomain()
                {
                    Domain = Domain, ResolutionMode = DDnsResolutionMode.Local
                });
                Domain = "*";
            }
        }
Пример #14
0
        /// <summary>
        /// Добавление домена в сессию
        /// </summary>
        /// <param name="domain">Домен</param>
        internal void Add(SeparatedAppDomain domain)
        {
            if (domain == null)
            {
                return;
            }

            try
            {
                lock (SessionLocker)
                    Domains.Add(domain);

                domain.Disposed += OnDomainDisposed;
            }
            catch (Exception ex)
            {
                m_Loger.Log("Возникло исключение при добавлении домена в сессию", ex
                            , new LogParameter("ID сессии", ID.ToString()));
            }
        }
Пример #15
0
 protected void btnAdd_Click(Object Sender, EventArgs e)
 {
     if (Request.Form[hdnId.UniqueID] == "0")
     {
         oDomain.Add(txtName.Text, txtZeus.Text, Int32.Parse(txtEnvironment.Text), (chkAccountSetup.Checked ? 1 : 0), (chkAccountMaintenance.Checked ? 1 : 0), (chkGroupMaintenance.Checked ? 1 : 0), (chkTest.Checked ? 1 : 0), (chkMove.Checked ? 1 : 0), (oDomain.Gets(0).Tables[0].Rows.Count + 1), (chkEnabled.Checked ? 1 : 0));
     }
     else
     {
         oDomain.Update(Int32.Parse(Request.Form[hdnId.UniqueID]), txtName.Text, txtZeus.Text, Int32.Parse(txtEnvironment.Text), (chkAccountSetup.Checked ? 1 : 0), (chkAccountMaintenance.Checked ? 1 : 0), (chkGroupMaintenance.Checked ? 1 : 0), (chkTest.Checked ? 1 : 0), (chkMove.Checked ? 1 : 0), (chkEnabled.Checked ? 1 : 0));
     }
     if (Request.Form[hdnOrder.UniqueID] != "")
     {
         string strOrder = Request.Form[hdnOrder.UniqueID];
         int    intCount = 0;
         while (strOrder != "")
         {
             intCount++;
             int intId = Int32.Parse(strOrder.Substring(0, strOrder.IndexOf("&")));
             strOrder = strOrder.Substring(strOrder.IndexOf("&") + 1);
             oDomain.UpdateOrder(intId, intCount);
         }
     }
     Response.Redirect(Request.Path);
 }
Пример #16
0
 public void AddDomain(Domain domain)
 {
     Domains.Add(domain.Id, domain);
 }
Пример #17
0
        public Domain AddDomain(Domains oDomains, string sName)
        {
            Domain oDomain = oDomains.Add();
             oDomain.Name = sName;
             oDomain.Active = true;
             oDomain.Save();

             return oDomain;
        }
Пример #18
0
        public virtual void AddField(TextSpan field)
        {
            if (Condition.TryParse(field, out var condition))
            {
                Conditions.Add(condition);
                return;
            }

            var(k, v) = field.SplitTuple(':');

            switch (k.Value)
            {
            case "PROHIBITSPELL":
                ProhibitedSpells.Add(ProhibitedSpell.Parse(v));
                return;

            case "BONUS":
                Bonuses.Add(Bonus.Parse(v));
                return;

            case "DEFINE":
            {
                var parts = v.Split('|').ToArray();
                if (parts.Length != 2)
                {
                    throw new ParseFailedException(field, "Unable to parse variable definition.");
                }

                Definitions.Add(new VariableDefinition(parts[0].Value, Helpers.ParseInt(parts[1])));
                return;
            }

            case "ABILITY":
                Abilities.Add(AbilityReference.Parse(v));
                return;

            case "DOMAIN":
                Domains.Add(DomainReference.Parse(v));
                return;

            case "CSKILL":
                ClassSkills.AddRange(v.Value.Split('|'));
                return;

            case "SOURCEPAGE":
                SourcePage = v.Value;
                return;

            case "SPELLLEVEL":
                SpellLists.AddRange(SpellList.Parse(v));
                return;

            case "WEAPONBONUS":
                WeaponBonusProficiencySelections.Add(v.Value.Split('|').ToList());
                return;

            case "KIT":
                // we are ignoring this one
                return;

            case "ADD":
            {
                var(type, parameter) = v.SplitTuple('|');
                switch (type.Value)
                {
                case "SPELLCASTER":
                    AddedSpellCasterLevels.Add(AddedSpellCasterLevel.Parse(parameter));
                    return;
                }
                break;
            }
            }

            throw new ParseFailedException(field, $"Unknown field '{field.Value}'");
        }
        public async Task ManageInternalCrawl(InBoundLinkCheckerViewModel model, List <Examine.SearchResult> PublishedPages)
        {
            // Instantiate Crawler Variables
            var LinksAvailableToCrawl = true;
            var TaskCount             = 0;
            var TaskID     = 0;
            var TaskStatus = new Dictionary <int, string>();
            var TaskList   = new Dictionary <int, Task <CrawlerModel> >();

            // Keep going while there are still umbraco pages to crawl
            while (LinksAvailableToCrawl)
            {
                try
                {
                    // While there are less than 8 async tasks running and at least 1 page to crawl.
                    while (TaskCount < 8 && PublishedPages.Count > 0)
                    {
                        TaskCount++;
                        TaskID++;
                        TaskList.Add(TaskID, Task.Run(() => ProcessPage(model, PublishedPages.Take(1).ToList())));
                        PublishedPages.RemoveRange(0, 1);
                        TaskStatus.Add(TaskID, "Started");
                    }
                    // If there are no pages left to crawl after assigning tasks, set LinksAvailableToCrawl to false to end the while loop after this iteration
                    if (PublishedPages.Count() <= 0 && TaskCount == 0)
                    {
                        LinksAvailableToCrawl = false;
                    }

                    // Instantiate a List to store the results of the aysnc tasks.
                    var ResultsModelList = new List <CrawlerModel>();

                    // Foreach task in the list, if one is completed, gather its result and log its status as completed.
                    foreach (var Task in TaskList)
                    {
                        if (Task.Value.IsCompleted)
                        {
                            ResultsModelList.Add(Task.Value.Result);
                            TaskStatus[Task.Key] = "Completed";
                        }
                    }

                    // Create a tempory list to log which task keys should be removed.
                    var KeysToRemove = new List <int>();
                    // Foreach task in the status list, if it is logged as completed, remove the task from the task list and add its key to the keystoremove list.
                    foreach (var Task in TaskStatus)
                    {
                        if (Task.Value == "Completed")
                        {
                            TaskList.Remove(Task.Key);
                            TaskCount--;
                            KeysToRemove.Add(Task.Key);
                        }
                    }
                    foreach (var Key in KeysToRemove)
                    {
                        TaskStatus.Remove(Key);
                    }

                    // Instantiate the Collections to store results in.
                    var ResultsDictionary = cache["ResultsDictionary"] as Dictionary <string, ContentModel>;
                    if (ResultsDictionary == null)
                    {
                        ResultsDictionary = new Dictionary <string, ContentModel>();
                    }

                    var BrokenLinks = cache["BrokenLinks"] as List <BrokenPageModel>;
                    if (BrokenLinks == null)
                    {
                        BrokenLinks = new List <BrokenPageModel>();
                    }
                    var LinksFound = cache["LinksFound"] as List <string>;
                    if (LinksFound == null)
                    {
                        LinksFound = new List <string>();
                    }
                    var Domains = cache["Domains"] as List <string>;
                    if (Domains == null)
                    {
                        Domains = new List <string>();
                    }

                    // For each result model in the resultmodellist, if it is not null, process the models results into the results collections.
                    foreach (var ResultModel in ResultsModelList)
                    {
                        if (ResultModel != null)
                        {
                            model.CrawledLinks += ResultModel.CrawledLinks;
                            foreach (var item in ResultModel.BrokenLinks)
                            {
                                if (!BrokenLinks.Contains(item))
                                {
                                    BrokenLinks.Add(item);
                                }
                            }
                            foreach (var item in ResultModel.ResultsDictionary)
                            {
                                if (!ResultsDictionary.Keys.Contains(item.Key))
                                {
                                    ResultsDictionary.Add(item.Key, item.Value);
                                }
                            }
                            foreach (var item in ResultModel.LinksFound)
                            {
                                if (!LinksFound.Contains(item))
                                {
                                    LinksFound.Add(item);
                                }
                            }
                            foreach (var item in ResultModel.Domains)
                            {
                                if (!Domains.Contains(item))
                                {
                                    Domains.Add(item);
                                }
                            }
                        }
                    }

                    // make a note of the number of pages that have been crawled and verified.
                    model.IndexedPagesTotal = ResultsDictionary.Count();
                    StoreModelInCache(model);
                    // store the results in the cache
                    StoreResultsInCache(ResultsDictionary, LinksFound, BrokenLinks, Domains);
                }
                catch (Exception ex)
                {
                    // If an Exception occurs then stop the crawl and store the results up till now.
                    model.DataBeingGenerated  = false;
                    model.CachedDataAvailable = true;
                    model.ErrorOccured        = ex.InnerException.Message;
                    StoreModelInCache(model);
                    break;
                }
            }

            // Now the Crawl has ended, set the view model booleans to let the view know that data is no longer being generated, and their is cached data to view.
            model.DataBeingGenerated  = false;
            model.CachedDataAvailable = true;
            StoreModelInCache(model);
        }
Пример #20
0
 public void AddDomain(ConnectDomain domain)
 {
     Domains.Add(domain);
 }
Пример #21
0
        /// <summary>
        /// Add Ip.
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="source"></param>
        /// <param name="domainSource"></param>
        public void AddIP(string ip, string source, string domainSource, int MaxRecursion, bool doptr)
        {
            ip = ip.Trim();

            if (isIPv6(ip))
            {
                ip = ParseIPV6(ip);
            }

            if (!Ips.Items.Any(I => I.Ip.ToLower() == ip.ToLower()))
            {
                if (isPublicIP(ip))
                {
                    var isInNetrange = Project.IsIpInNetrange(ip);

                    if (!isInNetrange)
                    {
                        var host = string.Empty;
                        try
                        {
                            host = Dns.GetHostEntry(ip).HostName;

                            if (Program.data.Project.LstNetRange.Count == 0)
                            {
                                if (Program.data.Project.Domain != null)
                                {
                                    if (!IsMainDomainOrAlternative(host))
                                    {
                                        if (Program.data.Project.AlternativeDomains.Select(S => host.Contains(S.ToString())).Count() == 0)
                                        {
                                            string[] arrDom = host.Split(new char[] { '.' });
                                            if (arrDom.Count() > 1)
                                            {
                                                string auxFinalDom = arrDom[arrDom.Length - 2] + "." + arrDom[arrDom.Length - 1];
                                                Program.data.Project.AlternativeDomains.Add(auxFinalDom);
                                                MessageBox.Show("IP address associated to " + Program.data.Project.Domain + " belongs to a Netrange of " + auxFinalDom + ". It is going to be added as an alternative domain.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }

                        if (IsMainDomainOrAlternative(host))
                        {
                            var netrange = Project.GetNetrange(ip);

                            if (netrange != null)
                            {
                                Project.LstNetRange.Add(netrange);
#if PLUGINS
                                Thread tPluginOnNetrange = new Thread(new ParameterizedThreadStart(Program.data.plugins.OnNewNetrange));
                                tPluginOnNetrange.IsBackground = true;
                                object[] oNetRange = new object[] { new object[] { netrange.from, netrange.to } };
                                tPluginOnNetrange.Start(oNetRange);
#endif

                                if (!Program.cfgCurrent.ScanNetranges255 || Project.GetIpsOfNetrange(netrange) <= 255)
                                {
                                    List <string> lstIps = netrange.GenerateIpsOfNetrange();
                                    Program.LogThis(new Log(Log.ModuleType.IPRangeSearch, "Netrange with " + lstIps.Count.ToString() + " IPs", Log.LogType.low));
                                    Thread tAddIps = new Thread(new ParameterizedThreadStart(AddIpListAsync));
                                    tAddIps.IsBackground = true;
                                    tAddIps.Priority     = ThreadPriority.Lowest;
                                    tAddIps.Start(lstIps);
                                }
                            }
                        }
                    }
                }

                var ipItem = new IPsItem(ip, source);
                Ips.Items.Add(ipItem);

                // OnNewIP
#if PLUGINS
                Thread tPluginOnIP = new Thread(new ParameterizedThreadStart(Program.data.plugins.OnNewIP));
                tPluginOnIP.IsBackground = true;

                object[] oIP = new object[] { new object[] { ip } };
                tPluginOnIP.Start(oIP);
#endif
                if (MaxRecursion <= 0)
                {
                    OnChangeEvent(null);
                    return;
                }

                List <string> domains;
                if (doptr)
                {
                    if (domainSource != null)
                    {
                        if (Program.cfgCurrent.UseAllDns)
                        {
                            domains = new List <string>();
                            List <string> dnsServers = DNSUtil.GetNSServer(resolver, domainSource, DNSUtil.GetLocalNSServer().First().ToString());

                            foreach (string dns in dnsServers)
                            {
                                OnLog(null, new EventsThreads.ThreadStringEventArgs(string.Format("Making reverse resolution to IP: {0} Using DNS server: {1}", ip, dns)));

                                foreach (var domain in DNSUtil.GetHostNames(resolver, ip, dns).Where(domain => !domains.Contains(domain)))
                                {
                                    domains.Add(domain);
                                }
                            }
                        }
                        else
                        {
                            var dnsserver = DNSUtil.GetNSServer(resolver, domainSource);
                            OnLog(null, new EventsThreads.ThreadStringEventArgs(string.Format("Making reverse resolution to IP: {0} Using DNS server: {1}", ip, dnsserver)));
                            domains = DNSUtil.GetHostNames(resolver, ip, dnsserver);
                        }
                    }
                    else
                    {
                        domains = DNSUtil.GetHostNames(resolver, ip);
                    }
                    foreach (var domain in domains)
                    {
                        AddResolution(domain, ip, string.Format("{0} > DNS reverse resolution [{1}]", GetIpSource(ip), domain), MaxRecursion - 1, Program.cfgCurrent, true);
                    }
                }
                OnChangeEvent(null);
            }
        }
        public async void OnNavigatedTo(NavigationContext navigationContext)
        {
            var items = await _domains.GetItems();

            items.ForEach(e => Domains.Add(new BindableEntity(e)));
        }
Пример #23
0
 public void JoinDomain(Domain domain)
 {
     Domains.Add(new UserDomainAssignment(Guid.NewGuid(), domain, this));
 }
Пример #24
0
 private void AddDomain()
 {
     Domains.Add(new DomainViewModel(new Domain().Default(DateTime.Now, Guid.NewGuid().ToString().ToLower())));
 }