Esempio n. 1
0
        public string AddWebsite(pcms_List list)
        {
            string Msg = "";

            try
            {
                using (PCMS_DbContext _pcmsDbContext = new PCMS_DbContext())
                {
                    string url = list.url[0].WEBSITE_URL;
                    if (_pcmsDbContext.pcms_website.Any(u => u.WEBSITE_URL == url))
                    {
                        return(Msg = "Duplicate");
                    }
                    else
                    {
                        pcms_website objWebsite = new pcms_website();
                        objWebsite.WEBSITE_URL         = list.url[0].WEBSITE_URL;
                        objWebsite.WEBSITE_SITEMAP_URL = list.url[0].WEBSITE_SITEMAP_URL != null ? list.url[0].WEBSITE_SITEMAP_URL : "";
                        objWebsite.SDK_VERIFIED        = Convert.ToBoolean(list.url[0].SDK_VERIFIED);
                        objWebsite.INSERTED_BY         = list.url[0].INSERTED_BY;
                        objWebsite.INSERTED_DATE       = list.url[0].INSERTED_DATE;
                        objWebsite.TS_CNT     = list.url[0].TS_CNT;
                        objWebsite.WEBSITE_PK = Guid.NewGuid();
                        pcms_rules objRules = new pcms_rules();
                        string     webmap   = list.url[0].WEBSITE_URL != null?Cryptographys.Encrypt(list.url[0].WEBSITE_URL) : "";

                        objRules.RULE_APPLIED_URL = webmap;
                        objRules.INSERTED_BY      = list.url[0].INSERTED_BY;
                        objRules.INSERTED_DATE    = list.url[0].INSERTED_DATE;
                        objRules.WEBSITE_URL      = Cryptographys.Encrypt(list.url[0].WEBSITE_URL);
                        objRules.TS_CNT           = list.url[0].TS_CNT;
                        objRules.RULE_PK          = Guid.NewGuid();
                        _pcmsDbContext.AddTopcms_website(objWebsite);
                        _pcmsDbContext.AddTopcms_rules(objRules);
                        _pcmsDbContext.SaveChanges();
                        Msg = "Inserted";
                        return(Msg);
                    }
                }
            }
            catch (Exception ex)
            {
                Utilities objUtilities = new Utilities();
                objUtilities.LogError(ex);
                Msg = "Something went wrong";
                return(null);
            }
        }
Esempio n. 2
0
 public ActionResult Website(pcms_List website)
 {
     try
     {
         website.url[0].INSERTED_DATE = DateTime.Now;
         website.url[0].TS_CNT        = 0;
         website.url[0].INSERTED_BY   = Session["userKey"].ToString();
         var KEY = objBAL.AddWebsite(website);
         if (KEY.Contains("Duplicate"))
         {
             ViewBag.Message = "Url already exist";
             return(View());
         }
         else
         {
             TempData["url"] = website.url[0].WEBSITE_URL;
             if (KEY != null)
             {
                 if (website.url[0].WEBSITE_SITEMAP_URL != "" && website.url[0].WEBSITE_SITEMAP_URL != null)
                 {
                     var baseurl = website.url[0].WEBSITE_SITEMAP_URL;
                     /*Create a new instance of the System.Net Webclient*/
                     WebClient wc = new WebClient();
                     /*Set the Encodeing on the Web Client*/
                     wc.Encoding = System.Text.Encoding.UTF8;
                     /* Download the document as a string*/
                     string reply = wc.DownloadString(baseurl);
                     /*Create a new xml document*/
                     XmlDocument urldoc = new XmlDocument();
                     /*Load the downloaded string as XML*/
                     urldoc.LoadXml(reply);
                     /*Create an list of XML nodes from the url nodes in the sitemap*/
                     XmlNodeList xnList = urldoc.GetElementsByTagName("url");
                     /*Loops through the node list and prints the values of each node*/
                     var inserted = "";
                     int i = 1, j = 1;
                     foreach (XmlNode node in xnList)
                     {
                         string   weburl        = website.url[0].WEBSITE_URL.ToString();
                         string   INSERTED_BY   = Session["userKey"].ToString();
                         DateTime INSERTED_DATE = DateTime.Now;
                         int      TS_CNT        = 0;
                         inserted = objBAL.UpdateUrlList(weburl, INSERTED_BY, INSERTED_DATE, TS_CNT, node["loc"].InnerText);
                         if (inserted.Contains("Inserted"))
                         {
                             i = i + 1;
                         }
                         j = j + 1;
                     }
                     if (i > 0)
                     {
                         if (i == j)
                         {
                             TempData["Key"] = KEY;
                             return(RedirectToAction("URLList"));
                         }
                         else
                         {
                             ViewBag.Message = i + " url/s has been added out of " + j + " url/s";
                         }
                     }
                     else
                     {
                         ViewBag.Message = "Something went wrong while adding url/s";
                     }
                 }
                 else
                 {
                     TempData["Key"] = KEY;
                     return(RedirectToAction("URLList"));
                 }
             }
             else
             {
                 ViewBag.Message = "Something went wrong while adding url/s";
             }
         }
     }
     catch (Exception ex)
     {
         ErrorLog obj = new ErrorLog();
         obj.LogError(ex);
         ViewBag.Message = ex.Message;
     }
     return(View());
 }
Esempio n. 3
0
 public string AddWebsite(pcms_List list)
 {
     return(objDAL.AddWebsite(list));
 }