コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        threadGuid = QueryHelper.GetGuid("threadguid", Guid.Empty);

        thread = CMSThread.GetThread(threadGuid);
        ctlAsync.OnRequestLog += new EventHandler(ctlAsync_OnRequestLog);

        if (!IsCallback)
        {
            // Set the title
            CurrentMaster.Title.TitleText = GetString("ViewLog.Title");
            CurrentMaster.Title.TitleImage = GetImageUrl("Objects/__GLOBAL__/Object.png");
            Page.Title = GetString("ViewLog.Title");

            if ((thread != null) && (thread.Log != null))
            {
                pnlLog.Visible = true;
                btnCancel.Text = GetString("general.cancel");
                btnCancel.OnClientClick = "return confirm('" + GetString("ViewLog.CancelPrompt") + "')";

                ctlAsync.RunAsync();
            }
            else
            {
                pnlLog.Visible = false;
                ShowError(GetString("ViewLog.ThreadNotRunning"));
            }
        }
    }
コード例 #2
0
    protected void btnRunDummy_Click(object sender, EventArgs e)
    {
        LogContext.EnsureLog(Guid.NewGuid());

        CMSThread dummy = new CMSThread(RunTest);
        dummy.Start();

        Thread.Sleep(100);
        ReloadData();
    }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        PageTitle.IsDialog = true;

        threadGuid = QueryHelper.GetGuid("threadGuid", Guid.Empty);
        string requestedServerName = QueryHelper.GetString("serverName", "");

        if (!RequestHelper.IsCallback())
        {
            // Set the title
            PageTitle.TitleText = GetString("ViewLog.Title");
            Page.Title = GetString("ViewLog.Title");

            if (WebFarmHelper.WebFarmEnabled && !String.IsNullOrEmpty(requestedServerName))
            {
                if (WebFarmHelper.ServerName.ToLowerCSafe() != requestedServerName.ToLowerCSafe())
                {
                    string loadMsg = ScriptHelper.GetLoaderInlineHtml(Page, GetString("debug.contactrequestedserver"));
                    litMessage.Text = loadMsg;
                    litMessage.Visible = true;

                    RegisterRefreshScript();
                    return;
                }
            }
        }

        thread = CMSThread.GetThread(threadGuid);
        ctlAsync.ProcessGUID = threadGuid;
        ctlAsync.OnRequestLog += ctlAsync_OnRequestLog;
        ctlAsync.OnFinished += ctlAsync_OnFinished;
        ctlAsync.OnCancel += ctlAsync_OnCancel;

        if (!RequestHelper.IsCallback() && !RequestHelper.IsPostBack())
        {
            if ((thread != null) && (thread.Log != null))
            {
                pnlLog.Visible = pnlCancel.Visible = true;

                btnCancel.Text = GetString("general.cancel");
                btnCancel.OnClientClick = "if(confirm(" + ScriptHelper.GetLocalizedString("ViewLog.CancelPrompt") + ")) { " + ctlAsync.GetCancelScript(true) + "} " + "return false;";

                ctlAsync.AttachToThread(thread);
            }
            else
            {
                pnlLog.Visible = false;

                ShowError(GetString("ViewLog.ThreadNotRunning"));
            }

            ScriptHelper.RegisterModule(Page, "CMS/HeaderShadow");
        }
    }
コード例 #4
0
    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();
    }
コード例 #5
0
    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();
    }
コード例 #6
0
    /// <summary>
    /// Archives document(s).
    /// </summary>
    private void ArchiveAll(object parameter)
    {
        if (parameter == null)
        {
            return;
        }

        TreeProvider tree = new TreeProvider(currentUser);

        tree.AllowAsyncActions = false;

        try
        {
            AddLog(ResHelper.GetString("content.archivingdocuments", currentCulture));

            string[] parameters = ((string)parameter).Split(';');
            string   siteName   = parameters[1];
            int[]    workNodes  = nodeIds.ToArray();
            string where = new WhereCondition().WhereIn("NodeID", workNodes).ToString(true);
            string columns     = SqlHelper.MergeColumns(DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS, "NodeAliasPath, ClassName, DocumentCulture");
            string cultureCode = chkAllCultures.Checked ? TreeProvider.ALL_CULTURES : parameters[0];

            // Get the documents
            var documents = tree.SelectNodes(siteName, "/%", cultureCode, false, null, where, "NodeAliasPath DESC", TreeProvider.ALL_LEVELS, false, 0, columns);
            if (!DataHelper.DataSourceIsEmpty(documents))
            {
                foreach (DataRow nodeRow in documents.Tables[0].Rows)
                {
                    if (PerformArchive(tree, nodeRow, cultureCode))
                    {
                        return;
                    }
                }
            }
            else
            {
                AddError(ResHelper.GetString("content.nothingtoarchive", currentCulture));
            }
        }
        catch (ThreadAbortException ex)
        {
            if (!CMSThread.Stopped(ex))
            {
                // Log error
                LogExceptionToEventLog(ResHelper.GetString("content.archivefailed", currentCulture), ex);
            }
        }
        catch (Exception ex)
        {
            // Log error
            LogExceptionToEventLog(ResHelper.GetString("content.archivefailed", currentCulture), ex);
        }
    }
コード例 #7
0
        internal static void Delete(IDataStore dataStore, CMSThread thread, IUserBasic userBasic)
        {
            CMSThreadRatingManager manager = new CMSThreadRatingManager(dataStore);

            CMSThreadRating threadRating = manager.GetThreadRating(thread, userBasic);

            BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Delete(threadRating);

            Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status);
            Assert.IsNull(manager.GetThreadRating(thread, userBasic));

            Trace.WriteLine("Successfully deleted threadRating " + threadRating.CMSThreadId + " -> " + threadRating.CMSUserId);
        }
コード例 #8
0
        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();
        }
コード例 #9
0
        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();
        }
コード例 #10
0
    /// <summary>
    /// Deletes selected tasks.
    /// </summary>
    protected void DeleteSelected(List <String> list)
    {
        CanceledString = GetString("Tasks.DeletionCanceled");
        eventCode      = "DELETESELECTEDTASKS";
        try
        {
            AddLog(GetString("Synchronization.DeletingTasks"));

            list.Sort();
            foreach (string synchronizationIdString in list)
            {
                int synchronizationId = ValidationHelper.GetInteger(synchronizationIdString, 0);
                if (synchronizationId > 0)
                {
                    IntegrationSynchronizationInfo synchronization = IntegrationSynchronizationInfo.Provider.Get(synchronizationId);

                    if (synchronization != null)
                    {
                        IntegrationTaskInfo task = IntegrationTaskInfo.Provider.Get(synchronization.SynchronizationTaskID);

                        if (task != null)
                        {
                            DeleteSynchronization(synchronizationId, task.TaskTitle);
                        }
                    }
                }
            }

            CurrentInfo = GetString("tasks.deletionok");
            AddLog(CurrentInfo);
        }
        catch (ThreadAbortException ex)
        {
            if (CMSThread.Stopped(ex))
            {
                // Canceled by user
                CurrentInfo = CanceledString;
                AddLog(CurrentInfo);
            }
            else
            {
                CurrentError = GetString("Tasks.DeletionFailed");
                AddErrorLog(CurrentError);
            }
        }
        catch (Exception ex)
        {
            CurrentError = GetString("Tasks.DeletionFailed") + ": " + ex.Message;
            AddErrorLog(CurrentError);
        }
    }
コード例 #11
0
    /// <summary>
    /// Restores objects selected in UniGrid.
    /// </summary>
    private void Restore(BinSettingsContainer settings, Action action)
    {
        try
        {
            // Begin log
            AddLog(ResHelper.GetString("objectversioning.recyclebin.restoringobjects", mCurrentCulture));

            if (settings.User.IsAuthorizedPerResource("cms.globalpermissions", "RestoreObjects"))
            {
                DataSet recycleBin = GetRecycleBinSeletedItems(settings, "VersionID, VersionObjectDisplayName, VersionObjectType, VersionObjectID");

                if (!DataHelper.DataSourceIsEmpty(recycleBin))
                {
                    RestoreDataSet(recycleBin, action);
                }
            }
            else
            {
                CurrentError = ResHelper.GetString("objectversioning.recyclebin.restorationfailedpermissions");
                AddLog(CurrentError);
            }
        }
        catch (ThreadAbortException ex)
        {
            if (CMSThread.Stopped(ex))
            {
                // When canceled
                CurrentInfo = ResHelper.GetString("Recyclebin.RestorationCanceled", mCurrentCulture);
                AddLog(CurrentInfo);
            }
            else
            {
                // Log error
                CurrentError = ResHelper.GetString("objectversioning.recyclebin.restorationfailed", mCurrentCulture) + ": " + ResHelper.GetString("general.seeeventlog", mCurrentCulture);
                AddLog(CurrentError);

                // Log to event log
                LogException("OBJECTRESTORE", ex);
            }
        }
        catch (Exception ex)
        {
            // Log error
            CurrentError = ResHelper.GetString("objectversioning.recyclebin.restorationfailed", mCurrentCulture) + ": " + ResHelper.GetString("general.seeeventlog", mCurrentCulture);
            AddLog(CurrentError);

            // Log to event log
            LogException("OBJECTRESTORE", ex);
        }
    }
コード例 #12
0
    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();
    }
コード例 #13
0
        public void Test_Delete_Section()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            CMSSection section   = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random);
            CMSThread  thread    = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random);
            CMSContent content   = Test_CMSContents.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random);

            Test_CMSSections.Delete(this.DataStore, section);

            CMSThreadManager  threadManager  = new CMSThreadManager(this.DataStore);
            CMSContentManager contentManager = new CMSContentManager(this.DataStore);

            Assert.IsNull(threadManager.GetThread(section.CMSSectionType, thread.CMSThreadId));
            Assert.IsNull(contentManager.GetContent(content.CMSContentId));
        }
コード例 #14
0
    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();
    }
コード例 #15
0
 internal CMSThreadRating GetThreadRating(CMSThread thread, IUserBasic userBasic)
 {
     try
     {
         using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
         {
             return(dataStoreContext.cms_ThreadRatings_Get(userBasic.UserId, thread.CMSThreadId));
         }
     }
     catch (Exception ex)
     {
         _Log.Error("Error at cms_ThreadRatings_Get", ex);
         throw new DataStoreException(ex, true);
     }
 }
コード例 #16
0
 internal List <CMSThreadRating> GetRatingsForThread(CMSThread thread)
 {
     try
     {
         using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
         {
             return(dataStoreContext.cms_ThreadRatings_Get(thread.CMSThreadId).ToList());
         }
     }
     catch (Exception ex)
     {
         _Log.Error("Error at cms_ThreadRatings_Get", ex);
         throw new DataStoreException(ex, true);
     }
 }
コード例 #17
0
    /// <summary>
    /// Deletes all tasks.
    /// </summary>
    protected void DeleteAll(object parameter)
    {
        eventCode      = "DELETEALLTASKS";
        CanceledString = GetString("Tasks.DeletionCanceled");
        try
        {
            AddLog(GetString("Synchronization.DeletingTasks"));

            // Get synchronizations
            DataSet ds = IntegrationTaskInfoProvider.GetIntegrationTasksView(gridElem.CompleteWhereCondition, "SynchronizationID ASC", -1, "SynchronizationID, TaskTitle");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    // Get synchronization id
                    int synchronizationId = ValidationHelper.GetInteger(row["SynchronizationID"], 0);
                    if (synchronizationId > 0)
                    {
                        string taskTitle = ValidationHelper.GetString(row["TaskTitle"], String.Empty);
                        DeleteSynchronization(synchronizationId, taskTitle);
                    }
                }
            }

            CurrentInfo = GetString("tasks.deletionok");
            AddLog(CurrentInfo);
        }
        catch (ThreadAbortException ex)
        {
            if (CMSThread.Stopped(ex))
            {
                // Canceled by user
                CurrentInfo = CanceledString;
                AddLog(CurrentInfo);
            }
            else
            {
                CurrentError = GetString("Tasks.DeletionFailed");
                AddErrorLog(CurrentError);
            }
        }
        catch (Exception ex)
        {
            CurrentError = GetString("Tasks.DeletionFailed") + ": " + ex.Message;
            AddErrorLog(CurrentError);
        }
    }
コード例 #18
0
        /// <summary>
        /// Add metrics to submission.
        /// </summary>
        public void SendSubmission(MultipartFormDataContent submission)
        {
            var contextRequestServerVariables = CMSHttpContext.Current.Request.ServerVariables;

            var dataCollection = new ConcurrentBag <Tuple <string, string, IEnumerable <KeyValuePair <string, string> > > >();

            // Generate metrics data based on selected metrics
            Parallel.For(0, Rows.Count, CMSThread.Wrap <int>(i =>
            {
                var metric = Rows[i] as Metric;

                // Skip row if disabled
                if (!metric.MetricSelected)
                {
                    return;
                }

                metric.MetricServerVariables = contextRequestServerVariables;

                var data = metric.MetricData;

                if (data != null)
                {
                    dataCollection.Add(Tuple.Create(metric.MetricCodeName, metric.MetricParent.MetricCodeName, data));
                }
            }, true));

            // Add all to submission
            foreach (var metricData in dataCollection)
            {
                submission.AddSubmissionItem(metricData.Item1, metricData.Item2, metricData.Item3);
            }

            LogSubmission(submission);

            // Send using HttpClient
            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage response = client.PostAsync(Endpoint, submission).Result;

                if (!response.IsSuccessStatusCode)
                {
                    EventLogProvider.LogEvent(EventType.ERROR, "Support helper", "SEND", response.ReasonPhrase);
                    throw new IOException(response.ReasonPhrase);
                }
            }
        }
コード例 #19
0
ファイル: CMSThreadManager.cs プロジェクト: tm011064/Luputa
        internal BusinessObjectActionReport <DataRepositoryActionStatus> Create(CMSThread cmsThread)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsThread);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num = -1;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                    {
                        num = dataStoreContext.cms_Threads_Insert(
                            cmsThread.CMSSectionId
                            , cmsThread.CMSName
                            , cmsThread.CMSStickyDateUtc
                            , cmsThread.IsLocked
                            , cmsThread.CMSIsSticky
                            , cmsThread.IsApproved
                            , cmsThread.CMSThreadStatus);
                    }
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at cms_Threads_Insert", ex);
                    throw new DataStoreException(ex, true);
                }
                if (num > 0)
                {
                    cmsThread.CMSThreadId    = num;
                    cmsThread.DateCreatedUtc = DateTime.UtcNow;
                }
                else
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.NoRecordRowAffected;
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("CMSThread {0} was not inserted at the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(cmsThread)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
コード例 #20
0
        public void Test_SelfRatingConstraint()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            CMSSection section   = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random);
            CMSThread  thread    = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random);
            CMSContent content   = Test_CMSContents.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random);

            CMSContentRatingManager manager = new CMSContentRatingManager(this.DataStore);

            CMSContentRating record = new CMSContentRating(userBasic, content, 1);
            BaseRatingInfo   baseRatingInfo;

            BusinessObjectActionReport <RatingDataRepositoryActionStatus> report = manager.Create(record, true, false, out baseRatingInfo);

            Assert.AreEqual(RatingDataRepositoryActionStatus.SelfRatingNotAllowed, report.Status);

            Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file
        }
コード例 #21
0
        public void Test_CreateUpdateDeleteContentUser()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            CMSSection section   = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random);
            CMSThread  thread    = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random);
            CMSContent content   = Test_CMSContents.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random);

            CMSContentUserManager manager = new CMSContentUserManager(this.DataStore);

            CMSContentUser record = new CMSContentUser(userBasic, content);

            BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(record);

            Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status);

            Delete(this.DataStore, content, userBasic);
            Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file
        }
コード例 #22
0
        public ContentBlock GetContentBlock(int contentBlockId)
        {
            CMSContent content = _CMSContentManager.GetContent(contentBlockId);

            ContentBlock record = null;

            if (content != null)
            {
                CMSThread  thread  = null;
                CMSSection section = null;

                thread  = _CMSThreadManager.GetThread(CMSSectionType.Content, content.CMSThreadId);
                section = _CMSSectionManager.GetSection(CMSSectionType.Content, thread.CMSSectionId);

                record = new ContentBlock(content, thread, section);
            }

            return(record);
        }
コード例 #23
0
        public Message GetMessage(int messageId)
        {
            CMSContent content = _CMSContentManager.GetContent(messageId);

            Message record = null;

            if (content != null)
            {
                CMSThread  thread  = null;
                CMSSection section = null;

                thread  = _CMSThreadManager.GetThread(CMSSectionType.MessageBoard, content.CMSThreadId);
                section = _CMSSectionManager.GetSection(CMSSectionType.MessageBoard, thread.CMSSectionId);

                record = new Message(content, thread, section);
            }

            return(record);
        }
コード例 #24
0
    /// <summary>
    /// Check links contained in document
    /// </summary>
    /// <param name="parameter">Parameter containing data to resolve relative URLs to absolute</param>
    private void CheckLinks(object parameter)
    {
        try
        {
            AddLog(ResHelper.GetString("validation.link.checkingurls", currentCulture));
            List <string> urls = GetUrls();

            // Ensure thread doesn't finish to early in special situations
            if ((urls == null) || urls.Count == 0)
            {
                Thread.Sleep(200);
            }

            if (urls != null)
            {
                CheckUrls(urls, ValidationHelper.GetString(parameter, null));
            }
            else
            {
                CurrentError = GetString("validation.diffdomainorprotocol");
            }
            pnlLog.Visible = false;
        }
        catch (ThreadAbortException ex)
        {
            if (CMSThread.Stopped(ex))
            {
                // When canceled
                AddLog(ResHelper.GetString("validation.link.abort", currentCulture));
                ctlAsyncLog.RaiseError(null, null);
            }
            else
            {
                // Log error
                mErrorText = ex.Message;
            }
        }
        catch (Exception ex)
        {
            // Log error
            mErrorText = ex.Message;
        }
    }
コード例 #25
0
        public PrivateMessage GetPrivateMessage(int privateMessageId)
        {
            CMSContent content = _CMSContentManager.GetContent(privateMessageId);

            PrivateMessage record = null;

            if (content != null)
            {
                CMSThread  thread  = null;
                CMSSection section = null;

                thread  = _CMSThreadManager.GetThread(CMSSectionType.PrivateMessageInbox, content.CMSThreadId);
                section = _CMSSectionManager.GetSection(CMSSectionType.PrivateMessageInbox, thread.CMSSectionId);

                record = new PrivateMessage(content, thread, section);
            }

            return(record);
        }
コード例 #26
0
    /// <summary>
    /// Deletes document(s).
    /// </summary>
    private void Delete(object parameter)
    {
        if ((parameter == null) || (ds.Tables[0].Rows.Count < 1))
        {
            return;
        }

        try
        {
            // Begin log
            AddLog(GetString("om.contact.deleting"));
            AddLog(string.Empty);

            // Mass delete without logging items
            if (chkChildren.Checked && !chkMoveRelations.Checked && (ds.Tables[0].Rows.Count > 1))
            {
                BatchDeleteOnSql();
            }
            // Delete items
            else
            {
                DeleteItems();
            }
        }
        catch (ThreadAbortException ex)
        {
            if (CMSThread.Stopped(ex))
            {
                // When canceled
                AddError(GetString("om.deletioncanceled"));
            }
            else
            {
                // Log error
                LogExceptionToEventLog(ex);
            }
        }
        catch (Exception ex)
        {
            // Log error
            LogExceptionToEventLog(ex);
        }
    }
コード例 #27
0
    /// <summary>
    /// Check document CSS
    /// </summary>
    /// <param name="parameter">Parameter containing data to resolve relative links to absolute</param>
    private void CheckCss(object parameter)
    {
        try
        {
            AddLog(ResHelper.GetString("validation.css.checkingcss", currentCulture));
            Dictionary <string, string> requests = GetValidationRequests(ValidationHelper.GetString(parameter, null));

            // Ensure thread doesn't finish to early in special situations
            if ((requests == null) || (requests.Count <= 1))
            {
                Thread.Sleep(200);
            }

            if (requests != null)
            {
                GetValidationResults(requests, ValidationHelper.GetString(parameter, null));
                Data.PostProcessingRequired = true;
            }
            else
            {
                CurrentError = GetString("validation.diffdomainorprotocol");
            }
            pnlLog.Visible = false;
        }
        catch (ThreadAbortException ex)
        {
            if (CMSThread.Stopped(ex))
            {
                // When canceled
                AddLog(ResHelper.GetString("validation.css.abort", currentCulture));
                ctlAsyncLog.RaiseError(null, null);
            }
            else
            {
                mErrorText = ex.Message;
            }
        }
        catch (Exception ex)
        {
            mErrorText = ex.Message;
        }
    }
コード例 #28
0
    /// <summary>
    /// Deletes document(s).
    /// </summary>
    private void Delete(object parameter)
    {
        if (parameter == null || accountIds.Count < 1)
        {
            return;
        }

        try
        {
            // Begin log
            AddLog(GetString("om.account.deleting"));
            AddLog(string.Empty);

            // When deleting children and not removing relations then we can run
            if (numberOfDeletedAccounts > 1)
            {
                BatchDeleteOnSql();
            }
            else
            {
                DeleteItems();
            }
        }
        catch (ThreadAbortException ex)
        {
            if (CMSThread.Stopped(ex))
            {
                // When canceled
                AddError(GetString("om.deletioncanceled"));
            }
            else
            {
                // Log error
                LogExceptionToEventLog(ex);
            }
        }
        catch (Exception ex)
        {
            // Log error
            LogExceptionToEventLog(ex);
        }
    }
コード例 #29
0
ファイル: Test_CMSThreads.cs プロジェクト: tm011064/Luputa
        internal static CMSThread Create(IDataStore dataStore, IApplicationSettings applicationSettings, IApplication application, CMSSection section, Random random)
        {
            CMSThreadManager manager = new CMSThreadManager(dataStore);

            CMSThread thread = new CMSThread(
                section
                , true
                , -1);

            BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(thread);

            Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status);
            Assert.Greater(thread.CMSThreadId, 0);

            CMSThread dsThread = manager.GetThread(section.CMSSectionType, thread.CMSThreadId);

            Assert.IsNotNull(dsThread);

            return(dsThread);
        }
コード例 #30
0
 /// <summary>
 /// Deletes activities.
 /// </summary>
 private void Delete()
 {
     var whereCondition = new WhereCondition(WhereCondition);
     try
     {
         var restrictedSitesCondition = CheckSitePermissions(whereCondition);
         DeleteActivities(whereCondition.Where(restrictedSitesCondition));
     }
     catch (ThreadAbortException ex)
     {
         if (!CMSThread.Stopped(ex))
         {
             LogExceptionToEventLog(ex);
         }
     }
     catch (Exception ex)
     {
         LogExceptionToEventLog(ex);
     }
 }
コード例 #31
0
        public int cms_Threads_Insert(int sectionId, string name, DateTime?stickyDateUtc, bool isLocked, bool isSticky
                                      , bool isApproved, int threadStatus)
        {
            CMSThread record = new CMSThread(
                _Threads.Count == 0 ? 1000 : _Threads.Last().CMSThreadId + 1
                , sectionId
                , name
                , DateTime.UtcNow
                , stickyDateUtc
                , 0
                , 0
                , isLocked
                , isSticky
                , isApproved
                , 0
                , 0
                , 0
                , DateTime.UtcNow);

            _Threads.Add(record);

            return(record.CMSThreadId);
        }
コード例 #32
0
        public void Test_CreateUpdateDeleteContentRating()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            CMSSection section   = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random);
            CMSThread  thread    = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random);
            CMSContent content   = Test_CMSContents.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random);

            CMSContentRatingManager manager = new CMSContentRatingManager(this.DataStore);

            CMSContentRating record = new CMSContentRating(userBasic, content, 1);
            BaseRatingInfo   baseRatingInfo;

            BusinessObjectActionReport <RatingDataRepositoryActionStatus> report = manager.Create(record, true, true, out baseRatingInfo);

            Assert.AreEqual(RatingDataRepositoryActionStatus.Success, report.Status);
            Assert.AreEqual(1, baseRatingInfo.RatingSum);
            Assert.AreEqual(1, baseRatingInfo.TotalRatings);

            CMSContentRating recordToCompare;

            for (int i = 0; i < this.DefaultUpdateTestIterations; i++)
            {
                PopulateWithRandomValues(record, this.DummyDataManager, this.Random);
                recordToCompare = record;

                manager.Update(record);
                record = manager.GetContentRating(content, userBasic);

                string errors = string.Empty;
                // TODO (Roman): relax datetime comparisons
                Assert.IsTrue(DebugUtility.ArePropertyValuesEqual(record, recordToCompare, out errors), errors);
                Trace.WriteLine("Update test successfull.");
            }

            Delete(this.DataStore, content, userBasic);
            Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file
        }
コード例 #33
0
ファイル: CMSThreadManager.cs プロジェクト: tm011064/Luputa
        internal BusinessObjectActionReport <DataRepositoryActionStatus> Delete(CMSThread cmsThread, bool deleteLinkedThreads)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsThread);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num = 0;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                    {
                        num = dataStoreContext.cms_Threads_Delete(cmsThread.CMSThreadId, deleteLinkedThreads);
                    }
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at XXX", ex);
                    throw new DataStoreException(ex, true);
                }

                if (num <= 0)
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.NoRecordRowAffected;
                    _Log.WarnFormat("CMSThread {0} was not deleted from the database (ErrorCode: {1})."
                                    , DebugUtility.GetObjectString(cmsThread)
                                    , num);
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("CMSThread {0} was not deleted from the database because the validation failed.\nReport: {1}", DebugUtility.GetObjectString(cmsThread), businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
コード例 #34
0
    /// <summary>
    /// Performs contact group recalculation.
    /// Fires, when recalculate button is clicked.
    /// </summary>
    private void RecalculateContactGroup(object sender, EventArgs e)
    {
        if (ContactGroup == null || ContactGroup.ContactGroupStatus == ContactGroupStatusEnum.Rebuilding)
        {
            return;
        }

        if (ContactGroupHelper.AuthorizedModifyContactGroup(ContactGroup.ContactGroupSiteID, true))
        {
            RebuildHeaderAction.Text    = ResHelper.GetString("om.contactgroup.rebuilding");
            RebuildHeaderAction.Enabled = false;
            StatusLabel.Visible         = false;

            // Set status that the contact group is being rebuilt
            ContactGroup.ContactGroupStatus = ContactGroupStatusEnum.Rebuilding;
            ContactGroupInfoProvider.SetContactGroupInfo(ContactGroup);

            // Evaluate the membership of the contact group
            ContactGroupEvaluator evaluator = new ContactGroupEvaluator();
            evaluator.ContactGroup = ContactGroup;

            Task.Factory.StartNew(CMSThread.Wrap(evaluator.Run), TaskCreationOptions.LongRunning);
        }
    }
コード例 #35
0
        internal Article(CMSContent cmsContent, CMSThread cmsThread, CMSSection cmsSection, List <string> tags, List <string> contentLevelNodeNames)
        {
            this._CMSContent = cmsContent;

            if (cmsThread != null)
            {
                this.ArticleGroupThread = new ArticleGroupThread(cmsThread, cmsSection);
            }

            if (cmsContent.CMSExtraInfo == null)
            {
                cmsContent.CMSExtraInfo = new XElement("i");
            }

            this.ContentLevelNodeNames = (contentLevelNodeNames ?? new List <string>());
            this.Tags = (tags ?? new List <string>());
            List <KeyValuePair <string, string> > tripleTags = new List <KeyValuePair <string, string> >();
            List <string> tags2 = new List <string>();

            TagHelper.FormatTags(this.Tags, out tags2, out tripleTags);
            this.Tags        = tags2;
            this._TripleTags = tripleTags;
            this.AddTripleTagsToTagCollection(this._TripleTags);
        }
コード例 #36
0
    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;
    }
コード例 #37
0
ファイル: UpgradeProcedure.cs プロジェクト: KuduApps/Kentico
    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();
    }
コード例 #38
0
ファイル: UpgradeProcedure.cs プロジェクト: KuduApps/Kentico
    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();
    }
コード例 #39
0
ファイル: UpgradeProcedure.cs プロジェクト: KuduApps/Kentico
    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();
    }
コード例 #40
0
    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;
            }
        }
    }
コード例 #41
0
    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();
    }
コード例 #42
0
    /// <summary>
    /// Attaches to the given asynchronous process.
    /// </summary>
    public void AttachToThread(CMSThread thread)
    {
        RenderScripts(true);

        Worker.AttachToThread(thread);
    }