Beispiel #1
0
        /// <summary>
        /// This method get invoke contentder scheduler to fetch mail on schedule date and send mail.
        /// </summary>
        /// <param name="ScheduleOn"></param>
        /// <returns></returns>
        private async void SendMailFromContentder(DateTime ScheduleOn, string DomainName)
        {
            try
            {
                string        scheduleOn    = ScheduleOn.ToString("yyyy-MM-dd HH:mm:ss");
                FetchRest     fetchRest     = new FetchRest();
                SettingHelper settingHelper = new SettingHelper(_memoryCache);
                string        configurecode = settingHelper.GetCachedSettingValue(SettingKeys.Configurecode);

                ClientRequestInfo clientRequest = new ClientRequestInfo();
                clientRequest.Sender      = DomainName;
                clientRequest.RequestType = 1;
                clientRequest.ExecuteOn   = scheduleOn;
                string PostData           = JsonConvert.SerializeObject(clientRequest);
                string MassMailRequestURL = ContentderAPI.AutomatedTaskRequest;
                Uri    URI = new Uri(MassMailRequestURL);
                HttpResponseMessage responseMessage = await Task.Run(() => fetchRest.PostData(DomainName, configurecode, URI, PostData));

                if (responseMessage.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);

                    PostResponse postResponse = JsonConvert.DeserializeObject <PostResponse>(responseContent);
                    if (postResponse.Code == (int)ePostResponseCode.PackageLimitExceed)
                    {
                        MassMailProvider mailProvider = new MassMailProvider();
                        _ = mailProvider.UpdateStausOfMail(ScheduleOn, eEmailStatus.LimitExceeded);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Beispiel #2
0
        public string GetServiceToken(string securetoken, string userName)
        {
            string authToken   = string.Empty;
            string sessionName = "Secret_" + securetoken;
            //if (HttpContext.Current.Session[sessionName] != null && HttpContext.Current.Session[sessionName].ToString().Length > 0)
            //{
            //    authToken = HttpContext.Current.Session[sessionName].ToString();
            //}
            //else
            //{

            Encryption    objEncrypt    = new Encryption();
            SettingHelper settingHelper = new SettingHelper(_memoryCache);
            string        configureCode = settingHelper.GetCachedSettingValue(SettingKeys.Configurecode);
            string        key           = objEncrypt.GetRandomStr(24);
            Dictionary <string, object> objCollection = new Dictionary <string, object>();

            objCollection.Add("key", key);
            objCollection.Add("userToken", objEncrypt.DESEncrypt(userName, key));
            objCollection.Add("configureCodeToken", objEncrypt.DESEncrypt(configureCode, key));
            objCollection.Add("application", "cbuilder");
            authToken = GetSecureToken("token", objCollection);
            dynamic dyn = JsonConvert.DeserializeObject(authToken);

            if (dyn != null)
            {
                authToken = dyn.token.Value;
            }
            // HttpContext.Current.Session[sessionName] = authToken;
            // }
            return(authToken);
        }
Beispiel #3
0
        public object GetOnlineSites([FromBody] OnlineApiInfo onlineApiInfo)
        {
            SettingHelper        settingHelper = new SettingHelper(_memoryCache);
            string               version       = settingHelper.GetCachedSettingValue(SettingKeys.Cbuilderversion);
            WebBuilderController objController = new WebBuilderController(_memoryCache);

            return(objController.GetOnlineSites(onlineApiInfo.Offset, onlineApiInfo.Limit, onlineApiInfo.ThemeName, onlineApiInfo.SectorID, onlineApiInfo.SiteCategoryID, onlineApiInfo.BusinessTypeID, onlineApiInfo.ApplicationName, secureToken, GetUsername, version));
        }
Beispiel #4
0
        public object GetRowOnlineComponents([FromBody] OnlineApiInfo onlineApiInfo)
        {
            SettingHelper        settingHelper = new SettingHelper(_memoryCache);
            string               version       = settingHelper.GetCachedSettingValue(SettingKeys.Cbuilderversion);
            WebBuilderController objController = new WebBuilderController(_memoryCache);

            return(objController.GetRowOnlineComponents(onlineApiInfo.Offset, onlineApiInfo.Limit, onlineApiInfo.SearchText, onlineApiInfo.Type, onlineApiInfo.Category, onlineApiInfo.ApplicationName, secureToken, GetUsername, version));
        }
Beispiel #5
0
        public object GetOnlineThemeFile([FromBody] ThemeDetail themeDetail)
        {
            SettingHelper        settingHelper = new SettingHelper(_memoryCache);
            string               version       = settingHelper.GetCachedSettingValue(SettingKeys.Cbuilderversion);
            WebBuilderController objController = new WebBuilderController(_memoryCache);
            object               returnVaue    = objController.GetOnlineTheme(themeDetail.ThemeID, GetUsername, secureToken, version);
            WBCachehelper        wBCachehelper = new WBCachehelper(_appLifetime);

            wBCachehelper.RemoveAllCachedFile(_webHostEnvironment);
            wBCachehelper.RecycleApplicationPool();
            return(returnVaue);
        }
Beispiel #6
0
        public object DownloadComponent([FromBody] BuilderComponent objBuilComponent)
        {
            SettingHelper        settingHelper = new SettingHelper(_memoryCache);
            string               version       = settingHelper.GetCachedSettingValue(SettingKeys.Cbuilderversion);
            WebBuilderController cont          = new WebBuilderController(_memoryCache);
            var           resultobj            = cont.InstallComponent(objBuilComponent.ComponentID, objBuilComponent.DownloadType, objBuilComponent.Version, GetUsername, objBuilComponent.SecureToken, version);
            WBCachehelper wBCachehelper        = new WBCachehelper(_appLifetime);

            wBCachehelper.RemoveAllCachedFile(_webHostEnvironment);
            wBCachehelper.RecycleApplicationPool();
            return(resultobj);
        }
        public HelperElasticSearchTest()
        {
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json")
                                .Build();

            SQLHelperConfig.ConnectionConfig = configuration.GetConnectionString("ContentderAIConnection");

            var provider = new ServiceCollection()
                           .AddMemoryCache()
                           .BuildServiceProvider();
            var memoryCache   = provider.GetService <IMemoryCache>();
            var settingHelper = new SettingHelper(memoryCache);

            settingHelper.CacheAllSettings();

            var url = settingHelper.GetCachedSettingValue(SettingKeys.ElasticSearchEndpoint);

            index          = settingHelper.GetCachedSettingValue(SettingKeys.ElasticSearchIndex);
            _elasticSearch = new ElasticSearch(url, index);
        }
Beispiel #8
0
        public Dictionary <string, string> GetJsonData([FromBody] GetLanguage lstParam)
        {
            string LanguageCode = lstParam.LanguageCode;
            string URL          = CurrentHostEnvironment.WebRootPath + lstParam.FilePath + "." + LanguageCode + ".json";

            if (!System.IO.File.Exists(URL))
            {
                SettingHelper settingHelper = new SettingHelper(_memoryCache);
                LanguageCode = settingHelper.GetCachedSettingValue(SettingKeys.DefaultCulture);
                URL          = CurrentHostEnvironment.WebRootPath + lstParam.FilePath + "." + LanguageCode + ".json";
            }
            var jsonString = System.IO.File.ReadAllText(URL);
            Dictionary <string, string> localizeValue = JsonSerializer.Deserialize <Dictionary <string, string> >(jsonString);

            return(localizeValue);
        }
 public async Task <int> UpdateStausOfFailMail(long MailID, List <RequestSubscriber> Subscribers, string AuthToken)
 {
     try
     {
         SettingHelper settingHelper = new SettingHelper(_memoryCache);
         string        configCode    = settingHelper.GetCachedSettingValue(SettingKeys.Configurecode);
         if (AuthToken == configCode)
         {
             MassMailHelper objController = new MassMailHelper();
             return(await objController.UpdateStausOfFailMail(MailID, Subscribers));
         }
         else
         {
             return(-1);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 // This api is invoked by data i/o to fetch mail
 public async Task <SendsEmail> GetMassMail(string ScheduleDate, string AuthToken)
 {
     try
     {
         SettingHelper settingHelper = new SettingHelper(_memoryCache);
         string        configCode    = settingHelper.GetCachedSettingValue(SettingKeys.Configurecode);
         if (AuthToken == configCode)
         {
             MassMailHelper objController = new MassMailHelper();
             return(await objController.GetMailAndUserToSendMail(ScheduleDate));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #11
0
        public object WebClientInvokerPOST(string methodName, Dictionary <string, object> objCollection, string serverToken, string secureToken, string userName, int counter)
        {
            object result = null;

            using (WebClient client = new WebClient())
            {
                client.Headers["Content-Type"] = "application/json";
                client.Headers[HttpRequestHeader.Authorization] = "Bearer " + serverToken;
                client.Encoding = Encoding.UTF8;
                SettingHelper settingHelper = new SettingHelper(_memoryCache);
                string        configureCode = settingHelper.GetCachedSettingValue(SettingKeys.Configurecode);
                objCollection.Add("Code", configureCode);
                var    data = Encoding.ASCII.GetBytes(DictToJson(objCollection));
                string url  = APIURL + methodName;
                System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
                System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => { return(true); };
                byte[] responsebytes = client.UploadData(url, "POST", data);
                if (client.ResponseHeaders["Token-Expired"] != null)
                {
                    bool expired = client.ResponseHeaders["Token-Expired"].ToString() == "true" ? true : false;
                    if (expired && counter == 0)
                    {
                        serverToken = GetServiceToken(secureToken, userName);
                        return(WebClientInvokerPOST(methodName, objCollection, serverToken, secureToken, userName, 1));
                    }
                    else
                    {
                        result = Encoding.UTF8.GetString(responsebytes);
                    }
                }
                else
                {
                    result = Encoding.UTF8.GetString(responsebytes);
                }
            }
            return(result);
        }
Beispiel #12
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            string imageURL             = HttpContextCommons.HostURL + "/images/logos/dashboard/Contentder.jpg";
            string dashboardImageFolder = Path.Combine(CurrentHostEnvironment.WebRootPath, "images", "logos", "dashboard");

            if (Directory.Exists(dashboardImageFolder) && Directory.GetFiles(dashboardImageFolder).Length > 0)
            {
                string imagePath = Directory.GetFiles(dashboardImageFolder)[0];
                imagePath = imagePath.Replace(CurrentHostEnvironment.WebRootPath, string.Empty).Replace("\\", "/");
                imageURL  = HttpContextCommons.HostURL + imagePath;
            }

            if (HttpContextCommons.LocalizationEnabled)
            {
                WebBuilderController webBuilderController = new WebBuilderController();
                ViewBag.Languages = await webBuilderController.GetLanguageLists(SiteID);

                SettingHelper settingHelper = new SettingHelper(_memoryCache);
                ViewBag.DefaultLanguage = settingHelper.GetCachedSettingValue(SettingKeys.CultureLanguage);
            }
            ViewBag.DropdownURL = HostUrl + "/dashboard/" + PageName + "/" + ActionName + "/";
            ViewBag.ImageURL    = imageURL;
            return(await Task.FromResult((IViewComponentResult)View("Default")));
        }