Ejemplo n.º 1
0
        public HomeController(ILogger <HomeController> logger, IConfiguration configuration)
        {
            _logger        = logger;
            _configuration = configuration;
            _helper        = new Helper.Helper(_configuration);

            SearchArtistDataUrl = _configuration.GetSection("AppSettings").GetSection("SearchArtistDataUrl").Value;
        }
Ejemplo n.º 2
0
            protected override string RunInBackground(params string[] @params)
            {
                string stream    = null;
                string urlString = @params[0];

                Helper.Helper http = new Helper.Helper();
                stream = http.GetHTTPData(urlString);
                return(stream);
            }
Ejemplo n.º 3
0
        public ActionResult <OrderdCars> Post([FromBody] ReserverCar value)
        {
            CarRepository cr = new CarRepository();

            cr.UpdateStatusByCarID(1, value.CarID);

            Helper.Helper helper = new Helper.Helper();

            var orderCar = new OrderdCars {
                Status = 1, CreateDT = DateTime.Now, ValidityDT = DateTime.Now.AddMinutes(20), PinkCode = helper.GetPinkCode().ToString(), CustomerID = value.CustomerID, CarID = value.CarID
            };

            OrderdCarsRepository oc = new OrderdCarsRepository();

            oc.Add(orderCar);
            oc.Dispose();

            return(orderCar);
        }
Ejemplo n.º 4
0
        public async Task UpdateAsync(string cityName)
        {
            var    helper = new Helper.Helper();
            string url    = _externalApiSettings.Path + cityName + _externalApiSettings.Appid;
            string json   = await helper.GetWeatherDataFromURLAsync(url);

            var jObject = JObject.Parse(json);

            bool isCityExistsInDb = await CheckIfExistsCityRecordInDateBase(cityName);

            if (!isCityExistsInDb)
            {
                await _cityRepository.CreateAsync(new Cities(cityName));
            }

            List <WeatherMeasures> weatherMeasuresRecords = await _externalApiWeatherHandler.ConvertDataFromExternalApiToWeatherMeasureRecord(jObject, cityName);

            await CreateOrUpdateRecordList(weatherMeasuresRecords);
        }
Ejemplo n.º 5
0
        public bool UpdateUserToken(UserEL user)
        {
            bool isTokenUpdated = false;

            if (user.AuthToken != null)
            {
                using (uow = new UnitOfWork.UnitOfWork())
                {
                    AuthenticationToken authToken    = new Helper.Helper().GetAuthenticationToken(user.AuthToken);
                    StoreUser           existingUser = null;
                    existingUser = uow.StoreUserRepository.Get().Where(u => u.StoreUserID.Equals(authToken.FkUserID)).FirstOrDefault();

                    #region Get Existing User

                    if (existingUser != null)
                    {
                        existingUser.DeviceID   = user.DeviceID;
                        existingUser.DeviceType = user.DeviceType;
                        uow.StoreUserRepository.Update(existingUser);
                        uow.Save();
                        isTokenUpdated = true;
                        return(isTokenUpdated);
                    }
                    else
                    {
                        isTokenUpdated = false;
                    }
                    #endregion
                }
            }
            else
            {
                isTokenUpdated = false;
            }
            return(isTokenUpdated);
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            if (File.Exists("Reference.xml"))
            {
                String      referenceFilePath = @"Reference.xml";
                XmlDocument document          = new XmlDocument();
                document.Load(referenceFilePath);
                String csdFilePath       = String.Empty;
                String configFilePath    = String.Empty;
                String projectFolderPath = String.Empty;
                String objectLogFilePath = String.Empty;
                Dictionary <String, String> dictionary = new Dictionary <string, string>();
                if (document.SelectSingleNode("//CsdFilePath") != null)
                {
                    csdFilePath = document.SelectSingleNode("//CsdFilePath").InnerText;
                }
                else
                {
                    throw new Exception("No node named 'CsdFilePath' found in the reference file");
                }
                if (document.SelectSingleNode("//ConfigFilePath") != null)
                {
                    configFilePath = document.SelectSingleNode("//ConfigFilePath").InnerText;
                }
                else
                {
                    throw new Exception("No node named 'ConfigFilePath' found in the reference file");
                }
                if (document.SelectSingleNode("//ProjectPath") != null)
                {
                    projectFolderPath = document.SelectSingleNode("//ProjectPath").InnerText;
                }
                else
                {
                    throw new Exception("No node named 'ProjectPath' found in the reference file");
                }
                if (document.SelectSingleNode("//LogObjectListPath") != null)
                {
                    objectLogFilePath = document.SelectSingleNode("//LogObjectListPath").InnerText;
                }
                else
                {
                    throw new Exception("No node named 'LogObjectListPath' found in the reference file");
                }

                Helper.Helper helper = null;
                if (document.SelectSingleNode("//CsdFilePath").Attributes["GetAllObjects"].Value.ToUpper().Equals("TRUE"))
                {
                    helper = new Helper.Helper(csdFilePath, configFilePath, objectLogFilePath);
                    helper.SearchObjects("*");
                    helper = null;
                }

                String objectType = String.Empty;
                String source     = String.Empty;
                String target     = String.Empty;
                String fileTypes  = String.Empty;

                if (document.SelectSingleNode("//Objects").HasChildNodes)
                {
                    foreach (XmlNode node in document.SelectNodes("//Object"))
                    {
                        if (node.Attributes["Type"] != null)
                        {
                            if (node.HasChildNodes)
                            {
                                foreach (XmlNode childNode in node.ChildNodes)
                                {
                                    if (childNode.Name.Equals("Source"))
                                    {
                                        source = childNode.InnerText;
                                    }
                                    else if (childNode.Name.Equals("Target"))
                                    {
                                        target = childNode.InnerText;
                                    }
                                    else if (childNode.Name.Equals("FileTypes"))
                                    {
                                        fileTypes = childNode.InnerText;
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }

                            objectType = node.Attributes["Type"].Value;

                            switch (objectType)
                            {
                            case "CheckBox":
                                Console.WriteLine(String.Format("Object Type - '{0}' is being modified from {1} to {2} in files {3}", objectType, source, target, fileTypes));
                                helper     = new Helper.Helper(csdFilePath, configFilePath, objectLogFilePath);
                                dictionary = helper.SearchObjects(objectType);
                                ConvertFiles(projectFolderPath, fileTypes, dictionary, source, target);
                                helper = null;
                                break;

                            case "DateTime":
                                Console.WriteLine("");
                                helper     = new Helper.Helper(csdFilePath, configFilePath, objectLogFilePath);
                                dictionary = helper.SearchObjects(objectType);
                                ConvertFiles(projectFolderPath, fileTypes, dictionary, source, target);
                                helper = null;
                                break;
                            }
                        }
                        else
                        {
                            Console.WriteLine("Object Type is not defined");
                        }
                    }
                }
            }
            else
            {
                throw new Exception("Reference File Not found or read properly from root directory");
            }
        }
 public WeatherForecastController(ILogger <WeatherForecastController> logger)
 {
     _logger     = logger;
     _helper     = new Helper.Helper();
     _httpClient = new HttpClient();
 }
Ejemplo n.º 8
0
        public ActionResult AddArticle( string url)
        {
            if (String.IsNullOrEmpty(url))
            {
                ViewBag.Message = "Ju lutem shtoeni adresen a artikullit!";
                return View();
            }

            //e lexojme permbajtjen e faqes se dhene
            WebRequest request = WebRequest.Create(url);
            request.Method = "GET";
            WebResponse response = request.GetResponse();
            Stream stream = response.GetResponseStream();
            StreamReader reader = new StreamReader(stream);
            string permbajtja = reader.ReadToEnd();
            reader.Close();
            response.Close();

            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(permbajtja);
              string paHtml = "";

              ArticleDBContext context = new ArticleDBContext();

              Article a = new Article();

            //Te shekulli permbajtja eshte brenda klases tekst

                if (url.ToLower().Contains("shekulli"))
                {
                    paHtml = doc.DocumentNode.SelectNodes("//div[@class='tekst']").First().InnerText;

                    a.Author  = doc.DocumentNode.SelectNodes("//ul[@class='li-info1lajmi']").Descendants()
                                .Where(x => x.Name == "li" && x.ChildNodes.FirstOrDefault().Name == "a").FirstOrDefault().InnerText;

                    string data = doc.DocumentNode.SelectNodes("//ul[@class='li-info1lajmi']").Descendants()
                                .Where(x => x.Name == "li").ToList()[1].InnerText;

                    int dita, muaji, viti;
                    dita = Convert.ToInt32(data.Split(',')[0].Split(' ')[0]);
                    Helper.Helper h = new Helper.Helper();

                    muaji = h.Muajt[data.Split(',')[0].Split(' ')[1]];
                    viti = Convert.ToInt32(data.Split(',')[0].Split(' ')[2]);
                    a.DateRetrieved = new DateTime(viti, muaji, dita);
                    a.MediaName = "Shekulli";
                }
                else if (url.ToLower().Contains("gazeta-shqip"))
                {
                    paHtml = doc.DocumentNode.SelectNodes("//div[@class='td-ss-main-content']").First().InnerText;
                    a.Author = doc.DocumentNode.SelectNodes("//div[@class='td-post-author-name']")[0].InnerText.Replace("Nga", "").Replace("-", "");
                    a.MediaName = "Gazeta Shqip";

                    string data = doc.DocumentNode.SelectNodes("//div[@class='td-post-date']")[0].InnerText;

                    int dita, muaji, viti;
                    dita = Convert.ToInt32(data.Split(' ')[0]);
                    Helper.Helper h = new Helper.Helper();

                    muaji = h.Muajt[data.Split(' ')[1]];
                    viti = Convert.ToInt32(data.Split(' ')[2]);
                    a.DateRetrieved = new DateTime(viti, muaji, dita);

                }
                else if (url.ToLower().Contains("mapo"))
                {
                  paHtml = doc.GetElementbyId("content").InnerText;
                  a.Author = "Mapo";
                  a.MediaName = "Mapo";
                }
                else //if (url.ToLower().Contains("sot.com.al")) //kjo pjese te c'komentohet nese shtohen mediume tjera
                {
                  paHtml = doc.GetElementbyId("block-system-main").InnerText;
                  a.MediaName = "Gazeta Sot";
                  //Sunday, July 26, 2015
                  string data = doc.DocumentNode.SelectNodes("//span[@class='date-display-single']")[0].InnerText.Split('-')[0];

                  a.Author = "Gazeta Sot";

                  int dita, muaji, viti;
                  dita = Convert.ToInt32(data.Split(',')[1].Split(' ')[2]);
                  Helper.Helper h = new Helper.Helper();

                  muaji = h.Muajt[data.Split(',')[1].Split(' ')[1]];
                  viti = Convert.ToInt32(data.Split(',')[2]);
                  a.DateRetrieved = new DateTime(viti, muaji, dita);

                }

            a.Url = url;
            context.Articles.Add(a);

            context.SaveChanges();

            //Pastrojme hapesirat e shprazeta
            var regex = new Regex(
               "(\\<script(.+?)\\</script\\>)|(\\<style(.+?)\\</style\\>)",
               RegexOptions.Singleline | RegexOptions.IgnoreCase
            );

            paHtml = regex.Replace(paHtml, "");
            paHtml = paHtml.Replace('\n', ' ');
            paHtml = paHtml.Replace('\t', ' ');

            //nxjerim fjalite. Supozojme se fjalite ndahen me !, ., ;, ?
            char[] delim_fjalite = {'.', '!', '?', ';' };
            string[] fjalite = paHtml.Split(delim_fjalite);
            char[] delim_fjalet = { '“', '”', ' ', '.', '!', '?', ';', '"', '}', '{', '(', ')', '-', '=', '+', '*', '"', ';', ':', '!', '?','<', '>', ',' };

            foreach (string fjali in fjalite)
            {
                Phrase f = new Phrase();
                string[] words = fjali.Split(delim_fjalet);
                f.Text = String.Join(" ", words.Where(x => x.Length > 3));

                f.ArticleId = a.ArticleId;

                foreach (char c in delim_fjalet)
                {
                    f.Text = f.Text.Replace(c, ' ');
                }

                context.Phrases.Add(f);
            }

            //nxjerim fjalet. Supozojme se fjalet ndahen si fjalite, por edhe me hapesire te shprazet dhe presje

            string[] fjalet = paHtml.Split(delim_fjalet);
            foreach (string fjale in fjalet.Where(x=>x.Length > 3))
            {
                //nese fjala nuk ekziston ne databaze
                if (context.Words.Where(x => x.Text.ToLower() == fjale.ToLower()).Count() == 0)
                {
                    Word w = new Word();
                    w.Text = fjale.ToLower();

                    context.Words.Add(w);
                    context.SaveChanges();

                    WordFrequency wf = new WordFrequency();
                    wf.ArticleId = a.ArticleId;
                    wf.WordId = w.WordId;
                    wf.Frequency = 1;
                    context.WordFrequenies.Add(wf);
                    context.SaveChanges();
                }
                else
                {
                    Word w = context.Words.Where(x => x.Text.ToLower() == fjale.ToLower()).First();
                    WordFrequency wf = context.WordFrequenies.Where(x => x.WordId == w.WordId && x.ArticleId == a.ArticleId).FirstOrDefault();

                    if (wf != null)
                    {
                        wf.Frequency++;
                        context.SaveChanges();
                    }
                    else
                    {
                       WordFrequency wfNew = new WordFrequency();
                       wfNew.ArticleId = a.ArticleId;
                       wfNew.WordId = w.WordId;
                       wfNew.Frequency = 1;
                       context.WordFrequenies.Add(wfNew);
                       context.SaveChanges();
                    }
                }
            }

            //regjistrojme ne db

            return View("DocumentUploader");
        }
Ejemplo n.º 9
0
 static void Main(string[] args)
 {
     Helper.Helper helper = new Helper.Helper();
     helper.Starter();
 }