#pragma warning restore 1998 private void DownloadAttachment(DocumentAttachment attachment, IExecutionContext context) { var fileName = $"{StatiqHelper.AttachmentPath}/{attachment.AttachmentName}"; var destination = context.FileSystem.GetOutputFile(fileName); if (!destination.Exists) { var thread = new CMSThread(() => { try { var binary = AttachmentBinaryHelper.GetAttachmentBinary(attachment); using (Stream fileStream = destination.OpenWrite(true)) { long initialPosition = fileStream.Position; fileStream.Write(binary, 0, binary.Length); long length = fileStream.Position - initialPosition; fileStream.SetLength(length); } } catch (Exception e) { Console.WriteLine(e.Message); } }); thread.Start(); } }
/// <summary> /// Checks for Url Slug Generation Queue Items and processes any asyncly. /// </summary> public static void CheckUrlSlugGenerationQueue() { // Clear any stuck tasks ClearStuckUrlGenerationTasks(); DataSet NextGenerationResult = ConnectionHelper.ExecuteQuery("DynamicRouting.SlugGenerationQueue.GetNextRunnableQueueItem", new QueryDataParameters() { { "@ApplicationID", SystemHelper.ApplicationIdentifier } , { "@SkipErroredGenerations", SkipErroredGenerations() } }); if (NextGenerationResult.Tables.Count > 0 && NextGenerationResult.Tables[0].Rows.Count > 0) { // Queue up task asyncly CMSThread UrlGenerationThread = new CMSThread(new ThreadStart(RunSlugGenerationQueueItem), new ThreadSettings() { Mode = ThreadModeEnum.Async, IsBackground = true, Priority = ThreadPriority.AboveNormal, UseEmptyContext = false, CreateLog = true }); UrlGenerationThread.Start(); } }
protected void btnRunDummy_Click(object sender, EventArgs e) { LogContext.EnsureLog(Guid.NewGuid()); CMSThread dummy = new CMSThread(RunTest); dummy.Start(); Thread.Sleep(100); ReloadData(); }
protected void Page_Load(object sender, EventArgs e) { Response.Cache.SetNoStore(); // Run the tasks SchedulingExecutorParameters schedulingParams = new SchedulingExecutorParameters() { SiteName = SiteContext.CurrentSiteName, ServerName = WebFarmHelper.ServerName }; ThreadStart threadStartObj = new ThreadStart(schedulingParams.ExecuteScheduledTasks); // Create synchronous thread CMSThread schedulerThread = new CMSThread(threadStartObj, true, ThreadModeEnum.Sync); schedulerThread.Start(); }
protected void btnRunDummy_Click(object sender, EventArgs e) { LogContext log = LogContext.EnsureLog(Guid.NewGuid()); log.Reversed = true; log.LineSeparator = "<br />"; CMSThread dummy = new CMSThread(RunTest); dummy.Start(); Thread.Sleep(100); ReloadData(); }
private static void LogErrorsInSeparateThread(Exception ex, string Source, string EventCode, string Description) { CMSThread LogErrorsThread = new CMSThread(new ThreadStart(() => LogErrors(ex, Source, EventCode, Description)), new ThreadSettings() { Mode = ThreadModeEnum.Async, IsBackground = true, Priority = ThreadPriority.AboveNormal, UseEmptyContext = false, CreateLog = true }); LogErrorsThread.Start(); }
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) { // CMSThread is supposed to copy the current context and make it available in the new thread var t = new CMSThread(new System.Threading.ThreadStart(() => { ShoppingCartService.GetDeliveryAndTotals().Wait(); }), new ThreadSettings() { UseEmptyContext = false }); t.Start(); }
private bool RunThreads() { var s = Settings; if (!String.IsNullOrEmpty(s.URLs)) { int newThreads = ValidationHelper.GetInteger(s.Threads, 0); if (newThreads > 0) { // Prepare the parameters string[] urls = s.URLs.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < urls.Length; i++) { urls[i] = URLHelper.GetAbsoluteUrl(urls[i]); } int duration = ValidationHelper.GetInteger(s.Duration, 0); int interval = ValidationHelper.GetInteger(s.Interval, 0); int iterations = ValidationHelper.GetInteger(s.Iterations, 0); bool splitUrls = ValidationHelper.GetBoolean(s.SplitURLs, false); DateTime runUntil = DateTime.Now.AddSeconds(duration); // Divide URLs between threads string[][] partUrls = null; if (splitUrls) { // Do not run more threads than URLs newThreads = Math.Min(urls.Length, newThreads); partUrls = new string[newThreads][]; int size = (int)Math.Ceiling((double)urls.Length / newThreads); for (int i = 0; i < newThreads; i++) { size = Math.Min(size, urls.Length - i * size); partUrls[i] = new string[size]; for (int j = 0; j < size; j++) { partUrls[i][j] = urls[i * size + j]; } } } // Run specified number of threads for (int i = 0; i < newThreads; i++) { // Prepare the loader object RequestLoader loader = new RequestLoader(); loader.URLs = (splitUrls ? partUrls[i] : urls); loader.WaitInterval = interval; loader.UserAgent = s.UserAgent; loader.UserName = ValidationHelper.GetString(userElem.Value, "").Trim(); if (duration > 0) { loader.RunUntil = runUntil; } if (iterations > 0) { loader.NumberOfIterations = iterations; } // Start new thread CMSThread newThread = new CMSThread(loader.Run); newThread.Start(); } return true; } } return false; }
public static void Update60() { EventLogProvider evp = new EventLogProvider(); evp.LogEvent("I", DateTime.Now, "Upgrade to 6.0", "Upgrade - Start"); DataClassInfo dci = null; #region "CMS.UserSettings" try { dci = DataClassInfoProvider.GetDataClass("cms.usersettings"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "UserAuthenticationGUID"; ffi.DataType = FormFieldDataTypeEnum.GUID; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserBounces"; ffi.DataType = FormFieldDataTypeEnum.Integer; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl; ffi.Visible = false; ffi.Caption = "UserBounces"; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserLinkedInID"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 100; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserLogActivities"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserPasswordRequestHash"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 100; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("CMS_UserSettings"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("CMS_UserSettings"); } } } catch (Exception ex) { evp.LogEvent("CMS.UserSettings - Upgrade", "Upgrade", ex); } #endregion #region "Ecommerce - Customer" try { dci = DataClassInfoProvider.GetDataClass("ecommerce.customer"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "CustomerSiteID"; ffi.DataType = FormFieldDataTypeEnum.Integer; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl; ffi.Visible = false; fi.AddFormField(ffi); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassFormDefinition = fi.GetXmlDefinition(); dci.ClassXmlSchema = tm.GetXmlSchema("COM_Customer"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("COM_Customer"); } } } catch (Exception ex) { evp.LogEvent("Ecommerce.Customer - Upgrade", "Upgrade", ex); } #endregion #region "Ecommerce - Order" try { dci = DataClassInfoProvider.GetDataClass("ecommerce.order"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "OrderCulture"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 10; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderIsPaid"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderTotalPriceInMainCurrency"; ffi.DataType = FormFieldDataTypeEnum.Decimal; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = fi.GetFormField("OrderStatusID"); if (ffi != null) { ffi.AllowEmpty = true; fi.UpdateFormField("OrderStatusID", ffi); } ffi = fi.GetFormField("OrderShippingAddressID"); if (ffi != null) { ffi.AllowEmpty = true; fi.UpdateFormField("OrderShippingAddressID", ffi); } dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("COM_Order"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("COM_Order"); } } } catch (Exception ex) { evp.LogEvent("Ecommerce.Order - Upgrade", "Upgrade", ex); } #endregion #region "Ecommerce - OrderItem" try { dci = DataClassInfoProvider.GetDataClass("ecommerce.orderitem"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "OrderItemBundleGUID"; ffi.DataType = FormFieldDataTypeEnum.GUID; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemIsPrivate"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemPrice"; ffi.DataType = FormFieldDataTypeEnum.Decimal; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemSendNotification"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemSKU"; ffi.DataType = FormFieldDataTypeEnum.LongText; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemText"; ffi.DataType = FormFieldDataTypeEnum.LongText; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemTotalPriceInMainCurrency"; ffi.DataType = FormFieldDataTypeEnum.Decimal; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemValidTo"; ffi.DataType = FormFieldDataTypeEnum.DateTime; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("COM_OrderItem"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("COM_OrderItem"); } } } catch (Exception ex) { evp.LogEvent("Ecommerce.OrderItem - Upgrade", "Upgrade", ex); } #endregion #region "Ecommerce - Shopping cart item" try { dci = DataClassInfoProvider.GetDataClass("ecommerce.shoppingcartitem"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "CartItemBundleGUID"; ffi.DataType = FormFieldDataTypeEnum.GUID; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "CartItemIsPrivate"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "CartItemPrice"; ffi.DataType = FormFieldDataTypeEnum.Decimal; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "CartItemText"; ffi.DataType = FormFieldDataTypeEnum.LongText; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "CartItemValidTo"; ffi.DataType = FormFieldDataTypeEnum.DateTime; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = fi.GetFormField("CartItemGuid"); if (ffi != null) { ffi.AllowEmpty = true; fi.UpdateFormField("CartItemGuid", ffi); } dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("COM_ShoppingCartSKU"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("COM_ShoppingCartSKU"); } } } catch (Exception ex) { evp.LogEvent("Ecommerce.ShoppingCartItem - Upgrade", "Upgrade", ex); } #endregion #region "Ecommerce - SKU" try { dci = DataClassInfoProvider.GetDataClass("ecommerce.sku"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "SKUBundleInventoryType"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 50; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUConversionName"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 100; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUConversionValue"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 200; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUMaxDownloads"; ffi.DataType = FormFieldDataTypeEnum.Integer; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUMaxItemsInOrder"; ffi.DataType = FormFieldDataTypeEnum.Integer; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUMaxPrice"; ffi.DataType = FormFieldDataTypeEnum.Decimal; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUMembershipGUID"; ffi.DataType = FormFieldDataTypeEnum.GUID; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUMinPrice"; ffi.DataType = FormFieldDataTypeEnum.Decimal; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUNeedsShipping"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUPrivateDonation"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUProductType"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 50; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUSiteID"; ffi.DataType = FormFieldDataTypeEnum.Integer; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUValidFor"; ffi.DataType = FormFieldDataTypeEnum.Integer; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUValidity"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 50; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUValidUntil"; ffi.DataType = FormFieldDataTypeEnum.DateTime; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = fi.GetFormField("SKUDepartmentID"); if (ffi != null) { ffi.AllowEmpty = true; fi.UpdateFormField("SKUDepartmentID", ffi); } dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("COM_SKU"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("COM_SKU"); } } } catch (Exception ex) { evp.LogEvent("Ecommerce.SKU - Upgrade", "Upgrade", ex); } #endregion #region "Community - Group" try { dci = DataClassInfoProvider.GetDataClass("Community.Group"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "GroupLogActivity"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.CheckBoxControl; ffi.Visible = true; ffi.DefaultValue = "true"; ffi.Caption = "GroupLogActivity"; fi.AddFormField(ffi); dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("Community_Group"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("Community_Group"); } } } catch (Exception ex) { evp.LogEvent("Community.Group - Upgrade", "Upgrade", ex); } #endregion #region "Newsletter - Subscriber" try { dci = DataClassInfoProvider.GetDataClass("newsletter.subscriber"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "SubscriberBounces"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("Newsletter_Subscriber"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("Newsletter_Subscriber"); } } } catch (Exception ex) { evp.LogEvent("Newsletter.Subscriber - Upgrade", "Upgrade", ex); } #endregion #region "CMS.Document" try { dci = DataClassInfoProvider.GetDataClass("cms.document"); if (dci != null) { SearchSettings ss = dci.ClassSearchSettingsInfos; SearchSettingsInfo ssi = ss.GetSettingsInfo("42f446ee-9818-4596-8124-54a38f64aa05"); if (ssi != null) { ssi.Searchable = true; ss.SetSettingsInfo(ssi); } DataClassInfoProvider.SetDataClass(dci); } } catch (Exception ex) { evp.LogEvent("CMS.Document - Upgrade", "Upgrade", ex); } #endregion // Set the path to the upgrade package mUpgradePackagePath = HttpContext.Current.Server.MapPath("~/CMSSiteUtils/Import/upgrade_55R2_60.zip"); mWebsitePath = HttpContext.Current.Server.MapPath("~/"); TableManager dtm = new TableManager(null); // Update all views dtm.RefreshDocumentViews(); // Set data version ObjectHelper.SetSettingsKeyValue("CMSDataVersion", "6.0"); // Clear hashtables CMSObjectHelper.ClearHashtables(); // Clear the cache CacheHelper.ClearCache(null, true); // Drop the routes CMSMvcHandler.DropAllRoutes(); // Init the Mimetype helper (required for the Import) MimeTypeHelper.LoadMimeTypes(); CMSThread thread = new CMSThread(Upgrade60Import); thread.Start(); }
private bool RunThreads() { var s = Settings; if (!String.IsNullOrEmpty(s.URLs)) { int newThreads = ValidationHelper.GetInteger(s.Threads, 0); if (newThreads > 0) { // Prepare the parameters string[] urls = s.URLs.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < urls.Length; i++) { urls[i] = URLHelper.GetAbsoluteUrl(urls[i]); } int duration = ValidationHelper.GetInteger(s.Duration, 0); int interval = ValidationHelper.GetInteger(s.Interval, 0); int iterations = ValidationHelper.GetInteger(s.Iterations, 0); bool splitUrls = ValidationHelper.GetBoolean(s.SplitURLs, false); DateTime runUntil = DateTime.Now.AddSeconds(duration); // Divide URLs between threads string[][] partUrls = null; if (splitUrls) { // Do not run more threads than URLs newThreads = Math.Min(urls.Length, newThreads); partUrls = new string[newThreads][]; int size = (int)Math.Ceiling((double)urls.Length / newThreads); for (int i = 0; i < newThreads; i++) { size = Math.Min(size, urls.Length - i * size); partUrls[i] = new string[size]; for (int j = 0; j < size; j++) { partUrls[i][j] = urls[i * size + j]; } } } // Run specified number of threads for (int i = 0; i < newThreads; i++) { // Prepare the loader object RequestLoader loader = new RequestLoader(); loader.URLs = (splitUrls ? partUrls[i] : urls); loader.WaitInterval = interval; loader.UserAgent = s.UserAgent; loader.UserName = ValidationHelper.GetString(userElem.Value, "").Trim(); if (duration > 0) { loader.RunUntil = runUntil; } if (iterations > 0) { loader.NumberOfIterations = iterations; } // Start new thread CMSThread newThread = new CMSThread(loader.Run); newThread.Start(); } return(true); } } return(false); }
protected void btnStart_Click(object sender, EventArgs e) { mLastError = ""; mCancel = false; mSuccessRequests = 0; mErrors = 0; mRun = true; mDuration = txtDuration.Text.Trim(); mInterval = txtInterval.Text.Trim(); mIterations = txtIterations.Text.Trim(); mThreads = txtThreads.Text.Trim(); mURLs = txtURLs.Text.Trim(); mUserAgent = txtUserAgent.Text.Trim(); mUserName = ValidationHelper.GetString(userElem.Value, ""); mSplitURLs = chkSplitUrls.Checked; if (!String.IsNullOrEmpty(txtURLs.Text)) { // Prepare the parameters string[] urls = txtURLs.Text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < urls.Length; i++) { urls[i] = URLHelper.GetAbsoluteUrl(urls[i]); } int newThreads = ValidationHelper.GetInteger(txtThreads.Text, 0); if (newThreads > 0) { int duration = ValidationHelper.GetInteger(txtDuration.Text, 0); int interval = ValidationHelper.GetInteger(txtInterval.Text, 0); int iterations = ValidationHelper.GetInteger(txtIterations.Text, 0); bool splitUrls = ValidationHelper.GetBoolean(chkSplitUrls.Checked, false); DateTime runUntil = DateTime.Now.AddSeconds(duration); // Divide URLs between threads string[][] partUrls = null; if (splitUrls) { // Do not run more threads than URLs newThreads = Math.Min(urls.Length, newThreads); partUrls = new string[newThreads][]; int size = (int)Math.Ceiling((double)urls.Length / newThreads); for (int i = 0; i < newThreads; i++) { size = Math.Min(size, urls.Length - i * size); partUrls[i] = new string[size]; for (int j = 0; j < size; j++) { partUrls[i][j] = urls[i * size + j]; } } } // Run specified number of threads for (int i = 0; i < newThreads; i++) { // Prepare the loader object RequestLoader loader = new RequestLoader(); loader.URLs = (splitUrls ? partUrls[i] : urls); loader.WaitInterval = interval; loader.UserAgent = txtUserAgent.Text.Trim(); loader.UserName = ValidationHelper.GetString(userElem.Value, "").Trim(); if (duration > 0) { loader.RunUntil = runUntil; } if (iterations > 0) { loader.NumberOfIterations = iterations; } // Start new thread CMSThread newThread = new CMSThread(loader.Run); newThread.Start(); } DisableAll(); btnStop.Enabled = true; btnReset.Enabled = true; } } }
public static void Upgrade55R2() { EventLogProvider evp = new EventLogProvider(); evp.LogEvent("I", DateTime.Now, "Upgrade to 5.5 R2", "Upgrade - Start"); DataClassInfo dci = null; #region "CMS.UserSettings" try { dci = DataClassInfoProvider.GetDataClass("cms.usersettings"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "UserSkype"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 100; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl; ffi.Visible = false; ffi.Caption = "User Skype account"; ffi.DefaultValue = String.Empty; ffi.Description = String.Empty; ffi.RegularExpression = String.Empty; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserIM"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 100; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl; ffi.Visible = false; ffi.Caption = "User instant messenger"; ffi.DefaultValue = String.Empty; ffi.Description = String.Empty; ffi.RegularExpression = String.Empty; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserPhone"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 26; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl; ffi.Visible = false; ffi.Caption = "User phone"; ffi.DefaultValue = String.Empty; ffi.Description = "User phone number."; ffi.RegularExpression = String.Empty; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserPosition"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 200; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = false; ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl; ffi.Visible = false; ffi.Caption = "Position"; ffi.DefaultValue = String.Empty; ffi.Description = String.Empty; ffi.RegularExpression = String.Empty; fi.AddFormField(ffi); dci.ClassFormDefinition = fi.GetXmlDefinition(); dci.ClassXmlSchema = TableManager.GetXmlSchema("CMS_UserSettings"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); } } } catch (Exception ex) { evp.LogEvent("CMS.UserSettings - Upgrade", "Upgrade", ex); } #endregion #region "WebTemplate meta file" try { WebTemplateInfo wti = WebTemplateInfoProvider.GetWebTemplateInfo("IntranetPortal"); if (wti != null) { string imgPath = HttpContext.Current.Server.MapPath("~/App_Data/CMSTemp/intranetportal.gif"); if (File.Exists(imgPath)) { MetaFileInfo mfi = new MetaFileInfo(imgPath, wti.WebTemplateId, "cms.webtemplate", "Thumbnail"); if (mfi != null) { MetaFileInfoProvider.SetMetaFileInfo(mfi); } File.Delete(imgPath); } } } catch (Exception ex) { evp.LogEvent("Upgrade to 5.5 R2", "Upgrade", ex); } #endregion // Clear hashtables CMSObjectHelper.ClearHashtables(); // Set the path to the upgrade package mUpgradePackagePath = HttpContext.Current.Server.MapPath("~/CMSSiteUtils/Import/upgrade_55_55R2.zip"); mWebsitePath = HttpContext.Current.Server.MapPath("~/"); // Set data version ObjectHelper.SetSettingsKeyValue("CMSDataVersion", "5.5R2"); CMSThread thread = new CMSThread(Upgrade55R2Import); thread.Start(); }
public static void Update50() { #region "Schemas and queries" DataClassInfo dci = DataClassInfoProvider.GetDataClass("ecommerce.customer"); if (dci != null) { SqlGenerator.GenerateDefaultQueries(dci, true, false); } dci = DataClassInfoProvider.GetDataClass("ecommerce.order"); if (dci != null) { SqlGenerator.GenerateDefaultQueries(dci, true, false); } dci = DataClassInfoProvider.GetDataClass("ecommerce.orderitem"); if (dci != null) { SqlGenerator.GenerateDefaultQueries(dci, true, false); } dci = DataClassInfoProvider.GetDataClass("ecommerce.shoppingcart"); if (dci != null) { SqlGenerator.GenerateDefaultQueries(dci, true, false); } dci = DataClassInfoProvider.GetDataClass("ecommerce.shoppingcartitem"); if (dci != null) { SqlGenerator.GenerateDefaultQueries(dci, true, false); } dci = DataClassInfoProvider.GetDataClass("cms.user"); if (dci != null) { SqlGenerator.GenerateDefaultQueries(dci, true, false); } dci = DataClassInfoProvider.GetDataClass("ecommerce.sku"); if (dci != null) { dci.ClassXmlSchema = CMS.DataEngine.TableManager.GetXmlSchema("COM_SKU"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); } #endregion try { dci = DataClassInfoProvider.GetDataClass("cms.usersettings"); if (dci != null) { CMS.FormEngine.FormInfo fi = FormHelper.GetFormInfo(dci.ClassName, true); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "UserUsedWebParts"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 1000; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = CMS.FormEngine.FormFieldControlTypeEnum.TextBoxControl; ffi.Visible = false; ffi.Caption = "UserUsedWebParts"; ffi.DefaultValue = String.Empty; ffi.Description = String.Empty; ffi.RegularExpression = String.Empty; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserUsedWidgets"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 1000; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = CMS.FormEngine.FormFieldControlTypeEnum.TextAreaControl; ffi.Visible = false; ffi.Caption = "UserUsedWidgets"; ffi.DefaultValue = String.Empty; ffi.Description = String.Empty; ffi.RegularExpression = String.Empty; fi.AddFormField(ffi); dci.ClassFormDefinition = fi.GetXmlDefinition(); dci.ClassXmlSchema = CMS.DataEngine.TableManager.GetXmlSchema("CMS_UserSettings"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); } } } catch (Exception ex) { EventLogProvider evp = new EventLogProvider(); evp.LogEvent("CMS.User - Update", "Update", ex); } // Clear hashtables CMSObjectHelper.ClearHashtables(); // Set data version ObjectHelper.SetSettingsKeyValue("CMSDataVersion", "5.0"); // Set the path to the upgrade package mUpgradePackagePath = HttpContext.Current.Server.MapPath("~/CMSSiteUtils/Import/upgrade_41_50.zip"); mWebsitePath = HttpContext.Current.Server.MapPath("~/"); CMSThread thread = new CMSThread(Update50Import); thread.Start(); }
public static void Update55() { DataClassInfo dci = null; #region "CMS.UserSettings" try { dci = DataClassInfoProvider.GetDataClass("cms.usersettings"); if (dci != null) { CMS.FormEngine.FormInfo fi = FormHelper.GetFormInfo(dci.ClassName, true); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "UserFacebookID"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 100; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = CMS.FormEngine.FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; ffi.Caption = "UserFacebookID"; ffi.DefaultValue = String.Empty; ffi.Description = String.Empty; ffi.RegularExpression = String.Empty; fi.AddFormField(ffi); dci.ClassFormDefinition = fi.GetXmlDefinition(); dci.ClassXmlSchema = CMS.DataEngine.TableManager.GetXmlSchema("CMS_UserSettings"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); } } } catch (Exception ex) { EventLogProvider evp = new EventLogProvider(); evp.LogEvent("CMS.UserSettings - Update", "Update", ex); } #endregion #region "CMS.User" try { dci = DataClassInfoProvider.GetDataClass("cms.user"); if (dci != null) { CMS.FormEngine.FormInfo fi = FormHelper.GetFormInfo(dci.ClassName, true); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "UserSiteManagerDisabled"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = CMS.FormEngine.FormFieldControlTypeEnum.CheckBoxControl; ffi.Visible = false; ffi.Caption = "Site manager disabled"; ffi.DefaultValue = "false"; ffi.Description = String.Empty; ffi.RegularExpression = String.Empty; fi.AddFormField(ffi); dci.ClassFormDefinition = fi.GetXmlDefinition(); dci.ClassXmlSchema = CMS.DataEngine.TableManager.GetXmlSchema("CMS_User"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); } } } catch (Exception ex) { EventLogProvider evp = new EventLogProvider(); evp.LogEvent("CMS.User - Update", "Update", ex); } #endregion #region "Ecommerce.SKU" // Change form definition of system tables try { dci = DataClassInfoProvider.GetDataClass("ecommerce.sku"); if (dci != null) { CMS.FormEngine.FormInfo fi = FormHelper.GetFormInfo(dci.ClassName, true); if (fi != null) { FormFieldInfo ffi = fi.GetFormField("SKUName"); if (ffi != null) { ffi.Size = 440; ffi.Visibility = "none"; ffi.IsMacro = false; fi.UpdateFormField("SKUName", ffi); } dci.ClassFormDefinition = fi.GetXmlDefinition(); dci.ClassXmlSchema = CMS.DataEngine.TableManager.GetXmlSchema("COM_SKU"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); } } } catch (Exception ex) { EventLogProvider evp = new EventLogProvider(); evp.LogEvent("COM.SKU - Update", "Update", ex); } #endregion // Clear hashtables CMSObjectHelper.ClearHashtables(); // Set the path to the upgrade package mUpgradePackagePath = HttpContext.Current.Server.MapPath("~/CMSSiteUtils/Import/upgrade_50_55.zip"); mWebsitePath = HttpContext.Current.Server.MapPath("~/"); // Set data version ObjectHelper.SetSettingsKeyValue("CMSDataVersion", "5.5"); CMSThread thread = new CMSThread(Update55Import); thread.Start(); }