override protected internal void _Execute()
        {
            try
            {
                string taskGuid        = Guid.NewGuid().ToString();
                string taskDescription = string.Format("User: {0} ({1}), CustomMdxReport: {2} ({3})",
                                                       this._owner.Name, this._owner.ID, this.Name, this.ID);

                FI.Common.DataAccess.IOlapSystemDA dacOlapSystem = DataAccessFactory.Instance.GetOlapSystemDA();
                string data = dacOlapSystem.BuildCellset(this.SchemaServer, this.SchemaDatabase, null, this.Mdx, taskGuid, taskDescription, "CustomMdx", this.ID);

                this._cellset.LoadCellset(data);

                _error = "";
            }
            catch (Exception exc)
            {
                _error = exc.Message;
                throw exc;
            }
        }
        public void PingOlapSystem(string Mdx, string MailTo)
        {
            bool failure = false;

            System.IO.StringWriter sw = new System.IO.StringWriter();

            // get all companies
            FI.Common.DataAccess.IUsersDA usersDac = DataAccessFactory.Instance.GetUsersDA();
            System.Data.DataTable         table    = usersDac.ReadCompanies();
            if (table == null || table.Rows.Count == 0)
            {
                return;
            }

            sw.WriteLine("<html>");
            sw.WriteLine("Failed Ping Queries (" + System.DateTime.Today.ToShortDateString() + " " + System.DateTime.Now.ToShortTimeString() + ")");
            sw.WriteLine("<br><br>");
            sw.WriteLine("<table border=1 width=100%>");

            try
            {
                foreach (System.Data.DataRow row in table.Rows)
                {
                    if ((bool)row["Ping"] == true)
                    {
                        string company  = row["ShortName"].ToString();
                        string server   = row["OlapServer"].ToString();
                        string database = row["OlapDatabase"].ToString();

                        try
                        {
                            string taskGuid = Guid.NewGuid().ToString();
                            string taskTag  = string.Format("Ping");

                            FI.Common.DataAccess.IOlapSystemDA olapDac = DataAccessFactory.Instance.GetOlapSystemDA();
                            olapDac.BuildCellset(Mdx, server, database, taskGuid, taskTag);
                        }
                        catch (Exception exc)
                        {
                            failure = true;

                            sw.Write("<tr>");
                            sw.Write("<td>");
                            sw.Write(company);
                            sw.Write("</td><td>");
                            sw.Write(exc.Message);
                            sw.Write("</td>");
                            sw.WriteLine("</tr>");

                            Common.LogWriter.Instance.WriteEventLogEntry(exc);
                        }
                    }
                }
            }
            catch (Exception exc)            //more common exception
            {
                failure = true;

                sw.Write("<tr>");
                sw.Write(exc.Message);
                sw.Write("</td>");
                sw.WriteLine("</tr>");

                Common.LogWriter.Instance.WriteEventLogEntry(exc);
            }

            sw.WriteLine("</table></html>");


            //send via email
            if (failure)
            {
                try
                {
                    // message
                    OpenSmtp.Mail.MailMessage msg = new OpenSmtp.Mail.MailMessage();
                    msg.From = new OpenSmtp.Mail.EmailAddress(FI.Common.AppConfig.SmtpSender);
                    msg.To.Add(new OpenSmtp.Mail.EmailAddress(MailTo));
                    msg.Subject  = "Failed Ping Queries";
                    msg.Priority = "High";
                    msg.HtmlBody = sw.ToString();

                    // smtp host
                    OpenSmtp.Mail.Smtp smtp = new OpenSmtp.Mail.Smtp();
                    smtp.Host = FI.Common.AppConfig.SmtpServer;
                    if (FI.Common.AppConfig.SmtpUserName != null && FI.Common.AppConfig.SmtpUserName != "")
                    {
                        smtp.Username = FI.Common.AppConfig.SmtpUserName;
                        smtp.Password = FI.Common.AppConfig.SmtpPassword;
                    }
                    smtp.SendMail(msg);
                }
                catch (Exception exc)
                {
                    // because real exception is inside:
                    while (exc.InnerException != null)
                    {
                        exc = exc.InnerException;
                    }

                    throw exc;
                }
            }
        }