Ejemplo n.º 1
0
        public async Task <WebAddress> GetLinksFromHtmlAsync(WebAddress wa)
        {
            var config  = Configuration.Default.WithDefaultLoader();
            var context = BrowsingContext.New(config);
            var sitemap = new Sitemap {
                SitemapLink = "-",
                Pages       = new List <Page>()
            };

            wa.Sitemaps = new List <Sitemap>();
            wa.Sitemaps.Add(sitemap);
            sitemap.Pages.Add(new Page {
                PageLink = "", Sitemap = sitemap
            });

            for (int i = 0; i < sitemap.Pages.Count; i++)
            {
                var document = await context.OpenAsync(wa.Url + sitemap.Pages.ElementAt(i).PageLink);

                var links = document.QuerySelectorAll("a")
                            .Where(l => ((IHtmlAnchorElement)l).Href.Count() > wa.Url.Length &&
                                   ((IHtmlAnchorElement)l).Href.Contains(wa.Url.Substring(5)) &&
                                   ((IHtmlAnchorElement)l).Href[wa.Url.Length + 1] != '#')
                            .Select(l => ((IHtmlAnchorElement)l).Href.Substring(wa.Url.Length))
                            .ToList();

                sitemap = CheckLinksInDb(links.Distinct(), sitemap, wa.Url);
            }

            return(wa);
        }
        public static T PostWithConverter<T>(string function, JsonConverter converter, params object[] postData)
        {
            if (string.IsNullOrWhiteSpace(AuthToken) && WebAddress.Equals("https://compute.rhino3d.com"))
                throw new UnauthorizedAccessException("AuthToken must be set for compute.rhino3d.com");

            for( int i=0; i<postData.Length; i++ )
            {
                if( postData[i]!=null &&
                    postData[i].GetType().IsGenericType &&
                    postData[i].GetType().GetGenericTypeDefinition() == typeof(Remote<>) )
                {
                    var mi = postData[i].GetType().GetMethod("JsonObject");
                    postData[i] = mi.Invoke(postData[i], null);
                }
            }

            string json = converter == null ?
                JsonConvert.SerializeObject(postData, Formatting.None) :
                JsonConvert.SerializeObject(postData, Formatting.None, converter);
            var response = DoPost(function, json);
            using (var streamReader = new StreamReader(response.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                if (converter == null)
                    return JsonConvert.DeserializeObject<T>(result);
                return JsonConvert.DeserializeObject<T>(result, converter);
            }
        }
Ejemplo n.º 3
0
        public IActionResult CreateWebSite(int?Id, WebAddress Model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!Id.HasValue)
                    {
                        _context.Add(Model);               //Insert
                    }
                    else
                    { //Update
                        WebAddress EditModel = _context.Set <WebAddress>().SingleOrDefault(x => x.WebAddressId == Id);
                        EditModel.Interval = Model.Interval;
                        EditModel.IsDelete = Model.IsDelete;
                        EditModel.Name     = Model.Name;
                        EditModel.Url      = Model.Url;
                    }
                    _context.SaveChanges();
                    Logger.Log(NLog.LogLevel.Info, string.Format("Yeni uygulama eklendi."));
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "CreateWebSite");
                throw;
            }

            return(View());
        }
Ejemplo n.º 4
0
        public void Constructor()
        {
            WebAddress address;

            address = new WebAddress();
            Assert.IsNotNull(address);
        }
Ejemplo n.º 5
0
        public void WebAddress_TwoAddressesDifferentValue_AreNotEqual()
        {
            var address  = new WebAddress("http://www.google2.com", "test");
            var address2 = new WebAddress("http://www.google.com", "test");

            Assert.IsTrue(address != address2);
        }
Ejemplo n.º 6
0
        public void WebAddress_TwoAddressesDifferentValue_AreNotEqual()
        {
            var address = new WebAddress("http://www.google2.com", "test");
            var address2 = new WebAddress("http://www.google.com", "test");

            Assert.IsTrue(address != address2);
        }
Ejemplo n.º 7
0
        public void WebAddress_TwoAddressesSameValue_AreEqual()
        {
            var address  = new WebAddress("http://www.google.com", "test");
            var address2 = new WebAddress("http://www.google.com", "test");

            Assert.IsTrue(address == address2);
        }
 /// <summary>
 /// Check the data in current object
 /// </summary>
 /// <param name='address'>The address.</param>
 public static void CheckData(this WebAddress address)
 {
     if (!address.IsDataChecked)
     {
         address.CheckStrings();
         address.IsDataChecked = true;
     }
 }
Ejemplo n.º 9
0
 private WebAddress GetAddress(Boolean refresh)
 {
     if (_address.IsNull() || refresh)
     {
         _address = new WebAddress();
     }
     return(_address);
 }
Ejemplo n.º 10
0
        protected virtual UnityWebRequest GetWebRequest()
        {
            var     address = WebAddress.BuildUrl(PhpFile);
            WWWForm form    = new WWWForm();

            form.AddField("ACTION", "checkSession");
            form.AddField("deviceid", SystemInfo.deviceUniqueIdentifier);
            return(UnityWebRequest.Post(address, form));
        }
Ejemplo n.º 11
0
        private static WebAddress FromWebAddressModelToWebAddress(WebAddressModel webAddressModel)
        {
            WebAddress webAddress = new WebAddress();

            webAddress.Id       = webAddressModel.Id;
            webAddress.Category = webAddressModel.SocialNetwork;
            webAddress.Url      = webAddressModel.URL;
            return(webAddress);
        }
        public WebContentDetails GetWebsiteContent([FromBody] WebAddress website)
        {
            WebContentDetails websiteContentCountResult = new WebContentDetails();

            websiteContentCountResult.WebsiteURL = website.websiteURL;
            DownloadWebsiteContent(website.websiteURL, websiteContentCountResult);

            return(websiteContentCountResult);
        }
Ejemplo n.º 13
0
        private static WebAddressModel FromWebAddressToWebAddressModel(WebAddress webAddress)
        {
            WebAddressModel webAddressModel = new WebAddressModel();

            webAddressModel.Id            = webAddress.Id;
            webAddressModel.SocialNetwork = webAddress.Category;
            webAddressModel.URL           = webAddress.Url;
            return(webAddressModel);
        }
Ejemplo n.º 14
0
        /**
         * Downloads all available and applicable menu files to display on the main manu.
         * Returns them as a MenuCase item
         */
        public void Register(string username, string password, string email)
        {
            var url  = WebAddress.BuildUrl(PhpFile);
            var form = CreateForm(username, password, email);

            var webRequest   = UnityWebRequest.Post(url, form);
            var serverResult = ServerReader.Begin(webRequest);

            serverResult.AddOnCompletedListener(ProcessResults);
        }
Ejemplo n.º 15
0
        public JsonResult IsDeleteWeb(int Id)
        {
            WebAddress EditModel = _context.Set <WebAddress>().SingleOrDefault(x => x.WebAddressId == Id);

            EditModel.IsDelete = EditModel.IsDelete == false ? true : false;
            Logger.Log(NLog.LogLevel.Info, string.Format("Web uygulaması silindi.", EditModel.Name));
            bool Result = _context.SaveChanges() > 0;

            return(Json(Result));
        }
Ejemplo n.º 16
0
        public IActionResult CreateWebSite(int?Id)
        {
            WebAddress Model = new WebAddress();

            if (Id.HasValue)
            {
                Model = _context.Set <WebAddress>().Where(x => x.WebAddressId == Id).SingleOrDefault();
            }
            return(View(Model));
        }
Ejemplo n.º 17
0
        public void Country()
        {
            Assert.IsNull(GetAddress().Country);
            String     value   = "Sverige";
            WebAddress address = GetAddress(true);

            address.Country            = new WebCountry();
            address.Country.NativeName = value;
            Assert.AreEqual(value, address.Country.NativeName);
        }
Ejemplo n.º 18
0
        public void AddressType()
        {
            Assert.IsNull(GetAddress().Type);
            String     value   = "Arbete";
            WebAddress address = GetAddress(true);

            address.Type      = new WebAddressType();
            address.Type.Name = value;
            Assert.AreEqual(value, address.Type.Name);
        }
Ejemplo n.º 19
0
        private List <WebAddress> GetDistinctWebAddres()
        {
            List <string>     webAddresKeyList       = new List <string>();
            List <WebAddress> distinctWebAddressList = new List <WebAddress>(); // distinct web url ve en küçük eşleşme uzunluğuna göre firma ismi tutacak liste

            try
            {
                foreach (var item in allMatchedWEBADDRESS)
                {
                    webAddresKeyList.Add(item.webKey);
                }

                IEnumerable <string> distinctWebList = webAddresKeyList.Distinct(); // web url tutulan liste
                List <int>           matchLengthList = new List <int>();            // eşleşme uzunluklarının tutulduğu liste

                foreach (var item in distinctWebList)
                {
                    foreach (var webAdres in allMatchedWEBADDRESS)
                    {
                        if (webAdres.webKey.Equals(item))
                        {
                            matchLengthList.Add(webAdres.matcLength);
                        }
                    }
                    int minLength = 1001;
                    foreach (var count in matchLengthList)
                    {
                        if (count < minLength)
                        {
                            minLength = count;
                        }
                    }
                    matchLengthList.Clear();
                    foreach (var webAdres in allMatchedWEBADDRESS)
                    {
                        if (webAdres.matcLength.Equals(minLength) && webAdres.webKey.Equals(item))
                        {
                            WebAddress webValue = new WebAddress();
                            webValue.firmNameKey = webAdres.firmNameKey;
                            webValue.webKey      = item;
                            distinctWebAddressList.Add(webValue);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                PrintConsole.LOG(e.StackTrace, e.Message);
            }

            return(distinctWebAddressList);
        }
Ejemplo n.º 20
0
        public IHttpActionResult Delete(WebAddress webAddress)
        {
            string response = crudFuction.BizDeleteAddress(webAddress.WebAddressToBizAddress());

            if (!response.Equals("EXITO"))
            {
                return(BadRequest(response));
            }
            else
            {
                return(Ok(response));
            }
        }
 /// <summary>
 /// Load data into the WebAddress instance.
 /// </summary>
 /// <param name="address">this address.</param>
 /// <param name='dataReader'>An open data reader.</param>
 public static void LoadData(this WebAddress address,
                             DataReader dataReader)
 {
     address.Id             = dataReader.GetInt32(AddressData.ID);
     address.PersonId       = dataReader.GetInt32(AddressData.PERSON_ID, 0);
     address.OrganizationId = dataReader.GetInt32(AddressData.ORGANIZATION_ID, 0);
     address.PostalAddress1 = dataReader.GetString(AddressData.POSTALADDRESS1);
     address.PostalAddress2 = dataReader.GetString(AddressData.POSTALADDRESS2);
     address.ZipCode        = dataReader.GetString(AddressData.ZIPCODE);
     address.City           = dataReader.GetString(AddressData.CITY);
     address.CountryId      = dataReader.GetInt32(AddressData.COUNTRY_ID);
     address.TypeId         = dataReader.GetInt32(AddressData.ADDRESS_TYPE_ID);
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Bizs the address to web address.
        /// </summary>
        /// <param name="DataAddress">The data address.</param>
        /// <returns>WebAddress.</returns>
        public static WebAddress BizAddressToWebAddress(this BizAddress DataAddress)
        {
            WebAddress webAdress = new WebAddress
            {
                Id         = DataAddress.Id,
                UserId     = DataAddress.UserId,
                StreetName = DataAddress.StreetName,
                Number     = DataAddress.Number,
                PostalCode = DataAddress.PostalCode,
                Active     = DataAddress.Active,
            };

            return(webAdress);
        }
Ejemplo n.º 23
0
        public void Addresses()
        {
            Assert.IsNull(GetPerson().Addresses);
            List <WebAddress> addresses = new List <WebAddress>();

            for (int i = 1; i <= 5; i++)
            {
                WebAddress address = new WebAddress();
                address.PostalAddress1 = "Agatan1" + i;
                addresses.Add(address);
            }
            GetPerson(true).Addresses = addresses;
            Assert.AreEqual(addresses, GetPerson().Addresses);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Webs the address to biz address.
        /// </summary>
        /// <param name="DataAddress">The data address.</param>
        /// <returns>BizAddress.</returns>
        public static BizAddress WebAddressToBizAddress(this WebAddress DataAddress)
        {
            BizAddress bizAdress = new BizAddress
            {
                Id         = DataAddress.Id,
                UserId     = DataAddress.UserId,
                StreetName = DataAddress.StreetName,
                Number     = DataAddress.Number,
                PostalCode = DataAddress.PostalCode,
                Active     = DataAddress.Active,
            };

            return(bizAdress);
        }
Ejemplo n.º 25
0
        static void Main(string[] args)
        {
            // ex: http://skydrive.live.com/some/long/path?version=1&id=123
            if (args.Length != 1)
            {
                Console.WriteLine("URI splitting");
                Console.WriteLine("Usage");
                Console.WriteLine("UriSplitter <valid uri>");
                return;
            }

            var addr = WebAddress.Parse(args[0]);

            Console.Write(addr.ToString());
            Console.ReadLine();
        }
        public static T0 Post<T0, T1>(string function, out T1 out1, params object[] postData)
        {
            if (string.IsNullOrWhiteSpace(AuthToken) && WebAddress.Equals("https://compute.rhino3d.com"))
                throw new UnauthorizedAccessException("AuthToken must be set for compute.rhino3d.com");

            string json = Newtonsoft.Json.JsonConvert.SerializeObject(postData);
            var response = DoPost(function, json);
            using (var streamReader = new StreamReader(response.GetResponseStream()))
            {
                var jsonString = streamReader.ReadToEnd();
                object data = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonString);
                var ja = data as Newtonsoft.Json.Linq.JArray;
                out1 = ja[1].ToObject<T1>();
                return ja[0].ToObject<T0>();
            }
        }
Ejemplo n.º 27
0
        public void CheckData()
        {
            _address      = new WebAddress();
            _address.City = "abcd<Uppsala>";
            _address.CheckData();
            Assert.AreEqual("abcdUppsala", _address.City);
            Assert.IsTrue(_address.IsDataChecked);

            // Test IsDataChecked
            // Try a second time -- CheckData removes "<" and ">" one time only
            _address.City = "abcd<Uppsala>";
            _address.CheckData();
            Assert.AreEqual("abcd<Uppsala>", _address.City);

            _address.IsDataChecked = false;
            _address.City          = "abcd<Uppsala";
            _address.CheckData();
            Assert.AreEqual("abcd<Uppsala", _address.City);
        }
Ejemplo n.º 28
0
        public WebAddressEditTest(TestFixture fixture)
            : base(fixture)
        {
            var person = new People(this.Session).Extent().First;

            this.editContactMechanism = new WebAddressBuilder(this.Session)
                                        .WithElectronicAddressString("www.acme.com")
                                        .Build();

            var partyContactMechanism = new PartyContactMechanismBuilder(this.Session).WithContactMechanism(editContactMechanism).Build();

            person.AddPartyContactMechanism(partyContactMechanism);

            this.Session.Derive();
            this.Session.Commit();

            this.Login();
            this.personListPage = this.Sidenav.NavigateToPeople();
        }
Ejemplo n.º 29
0
        private bool ValidateForm1()
        {
            FormElement firstName   = new FirstName(txtFirstName.Text);
            FormElement lastName    = new LastName(txtLastName.Text);
            FormElement email       = new EmailAddress("Email addess ", txtEmail.Text);
            FormElement webAddress  = new WebAddress(txtWebSite.Text);
            FormElement mobileNo    = new MobileNo(txtMobileNo.Text);
            FormElement phoneNumber = new PhoneNumber("Phone Number ", txtTelePhoneNo.Text);

            CompositeFormElement nameElements = new CompositeFormElement("Name");

            nameElements.Add(firstName);
            nameElements.Add(lastName);

            CompositeFormElement webInformation = new CompositeFormElement("WebInfo");

            webInformation.Add(email);
            webInformation.Add(webAddress);

            CompositeFormElement phoneInformation = new CompositeFormElement("Phone Numbers");

            phoneInformation.Add(mobileNo);
            phoneInformation.Add(phoneNumber);

            CompositeFormElement form1 = new CompositeFormElement("Form1");

            form1.Add(nameElements);
            form1.Add(webInformation);
            form1.Add(phoneInformation);

            if (form1.IsValid())
            {
                lblForm1ErrorMsg.ForeColor = Color.Green;
                lblForm1ErrorMsg.Text      = "All Data in Form 1 is Okay";
            }
            else
            {
                lblForm1ErrorMsg.ForeColor = Color.Red;
                lblForm1ErrorMsg.Text      = form1.ErrorMessage;
            }
            return(form1.IsValid());
        }
        public void UpdateOrganizationAddress()
        {
            String city, postalAddress1, postalAddress2, zipCode;

            WebOrganization organization, updatedOrganization;
            WebAddress      address;
            WebCountry      country;
            WebAddressType  addressType;

            organization           = new WebOrganization();
            organization           = GetOneOrganization();
            address                = new WebAddress();
            city                   = "Uppsala";
            address.City           = city;
            country                = new WebCountry();
            country                = CountryManager.GetCountry(GetContext(), Settings.Default.TestCountryId);
            address.Country        = country;
            postalAddress1         = "";
            address.PostalAddress1 = postalAddress1;
            postalAddress2         = "ArtDatabanken, SLU";
            address.PostalAddress2 = postalAddress2;
            zipCode                = "752 52";
            address.ZipCode        = zipCode;
            addressType            = new WebAddressType();
            addressType.Id         = 1;
            address.Type           = addressType;
            organization.Addresses.Add(address);

            updatedOrganization = new WebOrganization();
            updatedOrganization = OrganizationManager.UpdateOrganization(GetContext(), organization);

            Assert.IsNotNull(updatedOrganization);
            Assert.IsTrue(updatedOrganization.Addresses.IsNotEmpty());
            Assert.AreEqual(1, updatedOrganization.Addresses.Count);
            Assert.AreEqual(city, updatedOrganization.Addresses[0].City);
            Assert.AreEqual(country.Id, updatedOrganization.Addresses[0].Country.Id);
            Assert.AreEqual(postalAddress1, updatedOrganization.Addresses[0].PostalAddress1);
            Assert.AreEqual(postalAddress2, updatedOrganization.Addresses[0].PostalAddress2);
            Assert.AreEqual(zipCode, updatedOrganization.Addresses[0].ZipCode);
        }
Ejemplo n.º 31
0
        void isOnline(object obj)
        {
            try
            {
                bool _isOnline = WebAddressRun.Ping((obj as WebAddress));

                var optionsBuilder = new DbContextOptionsBuilder <WebContext>();
                optionsBuilder.UseSqlServer(Startup.ConnectionString);

                using (var context = new WebContext(optionsBuilder.Options))
                {
                    WebAddress EditModel = context.Set <WebAddress>().ToList().Where(x => x.WebAddressId == (obj as WebAddress).WebAddressId).FirstOrDefault();
                    EditModel.IsOnline = _isOnline;
                    Logger.Log(NLog.LogLevel.Info, string.Format("{0} - {1} - {2}", EditModel.Name, EditModel.Url, EditModel.IsOnline));
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 32
0
        public void WebAddress_ValidWebAddress_IsReachable()
        {
            var address = new WebAddress("http://www.google.com", "test");

            Assert.IsTrue(address.UrlReachable());
        }
Ejemplo n.º 33
0
        public void WebAddress_TwoAddressesSameValue_AreEqual()
        {
            var address = new WebAddress("http://www.google.com", "test");
            var address2 = new WebAddress("http://www.google.com", "test");

            Assert.IsTrue(address == address2);
        }
Ejemplo n.º 34
0
        public void WebAddress_NullUrl_RaisesException()
        {
            var address = new WebAddress(null, "Test");

            Assert.Fail("Expected Exception to be raised");
        }
Ejemplo n.º 35
0
        public void WebAddress_NullPurpose_RaisesException()
        {
            var address = new WebAddress("http://www.someplace.com", null);

            Assert.Fail("Expected Exception to be raised");
        }
Ejemplo n.º 36
0
        public void WebAddress_InvalidWebAddress_IsNotReachable()
        {
            var address = new WebAddress("http://www.somerubishendpoint.com", "test");

            Assert.IsFalse(address.UrlReachable());
        }
Ejemplo n.º 37
0
        public void WebAddress_InvalidUrl_RaisesException()
        {
            var address = new WebAddress("www.somerubbish", "test");

            Assert.Fail("Expected Exception to be raised");
        }
Ejemplo n.º 38
0
        public void WebAddress_httpWebAddress_IsValid()
        {
            var address = new WebAddress("http://www.google.com", "test");

            Assert.IsNotNull(address);
        }
Ejemplo n.º 39
0
        public void WebAddress_wwwWebAddress_IsNotValid()
        {
            var address = new WebAddress("www.google.com", "test");

            Assert.IsNotNull(address);
        }