Ejemplo n.º 1
0
        private DispatchedMessageInfo BuildDispatchMessageInfo(MessageItem message, PlanData planData, VisitData visitData)
        {
            MessageStateInfo      info  = new MessageStateInfo(message);
            DispatchedMessageInfo info3 = new DispatchedMessageInfo();

            info3.ID          = info.ID;
            info3.Name        = info.Name;
            info3.MessageType = info.Type;
            info3.Date        = info.StartDate;
            info3.State       = info.Status;
            DispatchedMessageInfo info2 = info3;

            if (planData != null)
            {
                DateTime       time;
                DateTime       time2;
                PlanStatistics planStatistics = AnalyticsFactory.Instance.GetPlanStatistics(planData);
                AnalyticsHelper.TryGetCampaignDates(message.CampaignId.ToGuid(), out time, out time2);
                info2.Sent      = (time != time2) ? planStatistics.GetTotal() : 0;
                info2.OpenRate  = planStatistics.GetOpenRate();
                info2.ClickRate = planStatistics.GetClickRate();
            }
            if (visitData != null)
            {
                info2.ValuePerVisit = visitData.ValuePerVisit;
                info2.Value         = visitData.Value;
            }
            return(info2);
        }
Ejemplo n.º 2
0
 private void ExecutorProgress(PlanStatistics statistics, string results)
 {
     if (!IsDisposed)
     {
         AppendResultPanel(results);
     }
 }
        private DispatchedMessageInfo GetDispatchedInfo(MessageItem message, VisitData visitData, PlanData planData)
        {
            MessageStateInfo      messageStateInfo = this.GetMessageStateInfo(message);
            DispatchedMessageInfo info3            = new DispatchedMessageInfo();

            info3.ID             = messageStateInfo.ID;
            info3.Name           = messageStateInfo.Name;
            info3.State          = messageStateInfo.Status;
            info3.Date           = messageStateInfo.Updated;
            info3.Sent           = messageStateInfo.Sent;
            info3.NumSubscribers = messageStateInfo.NumSubscribers;
            info3.MessageState   = messageStateInfo.MessageState;
            DispatchedMessageInfo info2 = info3;
            int emailCount = -1;

            if (planData != null)
            {
                PlanStatistics planStatistics = AnalyticsFactory.Instance.GetPlanStatistics(planData);
                info2.OpenRate  = planStatistics.GetOpenRate();
                info2.ClickRate = planStatistics.GetClickRate();
                emailCount      = planStatistics.GetActual();
            }
            if (visitData != null)
            {
                info2.ValuePerVisit = visitData.ValuePerVisit;
                if (emailCount > -1)
                {
                    VisitStatistics visitStatistics = AnalyticsFactory.Instance.GetVisitStatistics(visitData);
                    info2.ValuePerEmail  = visitStatistics.GetValuePerEmail(emailCount);
                    info2.VisitsPerEmail = visitStatistics.GetVisitPerEmail(emailCount);
                }
            }
            return(info2);
        }
Ejemplo n.º 4
0
        private TrickleInfo GetTrickleInfo(MessageItem message, VisitData visitData, PlanData planData)
        {
            MessageStateInfo messageStateInfo = this.GetMessageStateInfo(message);
            TrickleInfo      info3            = new TrickleInfo();

            info3.ID     = messageStateInfo.ID;
            info3.Name   = messageStateInfo.Name;
            info3.HasAbn = messageStateInfo.HasAbn;
            TrickleInfo info2      = info3;
            int         emailCount = -1;

            if (planData != null)
            {
                PlanStatistics planStatistics = this.analyticsFactory.GetPlanStatistics(planData);
                info2.OpenRate   = planStatistics.GetOpenRate();
                info2.Recipients = planStatistics.GetTotal();
                emailCount       = planStatistics.GetActual();
            }
            if (visitData != null)
            {
                info2.ValuePerVisit = visitData.ValuePerVisit;
                if (emailCount > -1)
                {
                    info2.ValuePerEmail = this.analyticsFactory.GetVisitStatistics(visitData).GetValuePerEmail(emailCount);
                }
            }
            return(info2);
        }
        public static void ExecuteScript(IServerProcess process, string script, ScriptExecuteOption options, out ErrorList errors, out TimeSpan timeElapsed, ReportScriptProgressHandler reportScriptProgress, DebugLocator locator)
        {
            StringBuilder result = new StringBuilder();

            errors      = new ErrorList();
            timeElapsed = TimeSpan.Zero;

            bool     attemptExecute = true;
            DateTime startTime      = DateTime.Now;

            try
            {
                IServerScript localScript = process.PrepareScript(script, locator);
                try
                {
                    if (ConvertParserErrors(localScript.Messages, errors))
                    {
                        foreach (IServerBatch batch in localScript.Batches)
                        {
                            PlanStatistics statistics = null;
                            try
                            {
                                if (batch.IsExpression())
                                {
                                    IServerExpressionPlan plan = batch.PrepareExpression(null);
                                    try
                                    {
                                        attemptExecute &= ConvertCompilerErrors(plan.Messages, errors);
                                        if (attemptExecute)
                                        {
                                            int rowCount = ReadResult(result, plan);

                                            AppendStatistics(result, options, plan.PlanStatistics, plan.ProgramStatistics, rowCount);
                                            statistics = plan.PlanStatistics;
                                        }
                                    }
                                    finally
                                    {
                                        batch.UnprepareExpression(plan);
                                    }
                                }
                                else
                                {
                                    IServerStatementPlan plan = batch.PrepareStatement(null);
                                    try
                                    {
                                        attemptExecute &= ConvertCompilerErrors(plan.Messages, errors);
                                        if (attemptExecute)
                                        {
                                            plan.Execute(null);

                                            AppendStatistics(result, options, plan.PlanStatistics, plan.ProgramStatistics, -1);
                                            statistics = plan.PlanStatistics;
                                        }
                                    }
                                    finally
                                    {
                                        batch.UnprepareStatement(plan);
                                    }
                                }
                            }
                            finally
                            {
                                if (reportScriptProgress != null)
                                {
                                    reportScriptProgress(statistics, result.ToString());
                                }
                                result.Length = 0;
                            }
                        }                       // foreach batch...
                    }                           // if (no parser errors)...
                }
                finally
                {
                    process.UnprepareScript(localScript);
                }
            }
            catch (Exception exception)
            {
                errors.Add(exception);
            }
            timeElapsed = DateTime.Now - startTime;
        }
 private static void AppendStatistics(StringBuilder result, ScriptExecuteOption options, PlanStatistics statistics, ProgramStatistics programStatistics, int rowCount)
 {
     if ((options & ScriptExecuteOption.ShowSuccessStatus) != 0)
     {
         result.Append(Strings.Get("ExecuteSuccess"));
         if (rowCount != -1)
         {
             if (rowCount == 1)
             {
                 result.Append(Strings.Get("ExecuteSuccessRowCountSingular"));
             }
             else
             {
                 result.AppendFormat(Strings.Get("ExecuteSuccessRowCountPlural"), rowCount.ToString("#,##0"));
             }
         }
         result.Append("\r\n");
     }
     if ((options & ScriptExecuteOption.ShowPrepareTime) != 0)
     {
         result.AppendFormat(Strings.Get("PrepareTime"), statistics.PrepareTime.ToString(), statistics.CompileTime.ToString(), statistics.OptimizeTime.ToString(), statistics.BindingTime.ToString());
         result.Append("\r\n");
     }
     if ((options & ScriptExecuteOption.ShowExecutionTime) != 0)
     {
         result.AppendFormat(Strings.Get("ExecuteTime"), programStatistics.ExecuteTime.ToString(), programStatistics.DeviceExecuteTime.ToString(), programStatistics.ExecuteTime == TimeSpan.Zero ? "N/A" : String.Format("{0}%", ((Convert.ToDecimal(programStatistics.DeviceExecuteTime.Ticks) / programStatistics.ExecuteTime.Ticks) * 100).ToString("F6")));
         result.Append("\r\n");
     }
 }
Ejemplo n.º 7
0
 private void AsyncProgress(PlanStatistics statistics, string results)
 {
     // Return what results we got even if stopped.
     _executeProgress(statistics, results);
 }