예제 #1
0
        public FI.Common.Data.FIDataTable GetUsersWithChildReports(Report ParentReport)
        {
            FI.Common.Data.FIDataTable table = null;


            if (ParentReport.GetType() == typeof(OlapReport))
            {
                FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();
                table = dacObj.ReadUsersWithChildReports(ParentReport.ID, this.GetReportTypeCode(ParentReport.GetType()));
            }
            else if (ParentReport.GetType() == typeof(StorecheckReport))
            {
                FI.Common.DataAccess.IStorecheckReportsDA dacObj = DataAccessFactory.Instance.GetStorecheckReportsDA();
                table = dacObj.ReadUsersWithChildReports(ParentReport.ID, this.GetReportTypeCode(ParentReport.GetType()));
            }
            else if (ParentReport.GetType() == typeof(CustomSqlReport))
            {
                FI.Common.DataAccess.ICustomSqlReportsDA dacObj = DataAccessFactory.Instance.GetCustomSqlReportsDA();
                table = dacObj.ReadUsersWithChildReports(ParentReport.ID, this.GetReportTypeCode(ParentReport.GetType()));
            }
            else if (ParentReport.GetType() == typeof(CustomMdxReport))
            {
                FI.Common.DataAccess.ICustomMdxReportsDA dacObj = DataAccessFactory.Instance.GetCustomMdxReportsDA();
                table = dacObj.ReadUsersWithChildReports(ParentReport.ID, this.GetReportTypeCode(ParentReport.GetType()));
            }
            else
            {
                throw new NotSupportedException();
            }

            return(table);
        }
예제 #2
0
        public decimal CreateAsSharedFrom(Report parentReport, Report.SharingEnum subscriberSharing)
        {
            if (this.Owner == parentReport.Owner)
            {
                throw new Exception("Cannot share to same user");
            }

            parentReport.LoadHeader();

            if (subscriberSharing == Report.SharingEnum.None)
            {
                throw new Exception("Wrong sharing option");
            }

            if (parentReport.SharingStatus != Report.SharingEnum.None)
            {
                throw new Exception("Shared report cannot be source of other shared report");
            }


            decimal newReportId = 0;

            System.Type reportType = parentReport.GetType();
            // ----------------------------------------
            if (reportType == typeof(OlapReport))
            {
                FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();
                newReportId = dacObj.CreateSharedReport(parentReport.ID, this.Owner.ID, (int)subscriberSharing);
            }
            else if (reportType == typeof(StorecheckReport))
            {
                FI.Common.DataAccess.IStorecheckReportsDA dacObj = DataAccessFactory.Instance.GetStorecheckReportsDA();
                newReportId = dacObj.CreateSharedReport(parentReport.ID, this.Owner.ID, (int)subscriberSharing);
            }
            else if (reportType == typeof(CustomSqlReport))
            {
                FI.Common.DataAccess.ICustomSqlReportsDA dacObj = DataAccessFactory.Instance.GetCustomSqlReportsDA();
                newReportId = dacObj.CreateSharedReport(parentReport.ID, this.Owner.ID, (int)subscriberSharing);
            }
            else if (reportType == typeof(CustomMdxReport))
            {
                FI.Common.DataAccess.ICustomMdxReportsDA dacObj = DataAccessFactory.Instance.GetCustomMdxReportsDA();
                newReportId = dacObj.CreateSharedReport(parentReport.ID, this.Owner.ID, (int)subscriberSharing);
            }
            // ----------------------------------------


            // update max
            if (((int)parentReport._maxSubscriberSharing) < ((int)subscriberSharing))
            {
                parentReport._maxSubscriberSharing = subscriberSharing;
            }

            return(newReportId);
        }
예제 #3
0
        private void UpdateButton_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (_report.State == Report.StateEnum.Closed)
                {
                    _report.Open();
                }
                if (_report.State == Report.StateEnum.Open)
                {
                    _report.Execute();
                }

                string path       = "";
                string reportName = "";
                if (radioExcel.Checked)
                {
                    reportName = _report.GetType().Name + _report.ID.ToString() + ".XLS";
                    path       = FI.Common.AppConfig.TempDir + @"\" + reportName;
                    _report.Export(path, Report.ExportFormat.CSV);
                    hrefExcel.Text        = reportName;
                    hrefExcel.NavigateUrl = Request.ApplicationPath + "/" + FI.Common.AppConfig.TempVirtualDir + "/" + reportName;
                    Session["Report"]     = _report;
                }
                else if (radioHtml.Checked)
                {
                    reportName = _report.GetType().Name + _report.ID.ToString() + ".HTML";
                    path       = FI.Common.AppConfig.TempDir + @"\" + reportName;
                    _report.Export(path, Report.ExportFormat.HTML);
                    hrefHtml.Text        = reportName;
                    hrefHtml.NavigateUrl = Request.ApplicationPath + "/" + FI.Common.AppConfig.TempVirtualDir + "/" + reportName;
                    Session["Report"]    = _report;
                }
            }
            catch (Exception exc)
            {
                this.ShowException(exc);
            }
        }
예제 #4
0
 protected void BackButton_Click(object sender, System.EventArgs e)
 {
     if (_report.GetType() == typeof(FI.BusinessObjects.OlapReport))
     {
         Response.Redirect("OlapReport/Design.aspx", true);
     }
     else if (_report.GetType() == typeof(FI.BusinessObjects.CustomSqlReport))
     {
         Response.Redirect("SqlReport/Design.aspx", true);
     }
     else if (_report.GetType() == typeof(FI.BusinessObjects.CustomMdxReport))
     {
         Response.Redirect("MdxReport/Design.aspx", true);
     }
     else if (_report.GetType() == typeof(FI.BusinessObjects.StorecheckReport))
     {
         Response.Redirect("StorecheckReport/Design.aspx", true);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
예제 #5
0
        private void UpdateButton_Click(object sender, System.EventArgs e)
        {
            Report.SharingEnum sharing = Report.SharingEnum.None;

            if (radioNone.Checked == true)
            {
                sharing = Report.SharingEnum.None;
            }
            else if (radioSnapshot.Checked == true)
            {
                sharing = Report.SharingEnum.SnapshotSubscriber;
            }
            else if (radioInherite.Checked == true)
            {
                sharing = Report.SharingEnum.InheriteSubscriber;
            }
            else
            {
                return;                 //none of radios is checked
            }
            System.Collections.ArrayList pks = _gr.SelectedPrimaryKeys;

            foreach (string[] keys in pks)
            {
                decimal user_id   = decimal.Parse(keys[0]);
                decimal report_id = decimal.Parse(keys[1]);

                try
                {
                    User user = _user.GetUser(user_id, true);

                    if (report_id != 0)
                    {
                        Report childReport = user.ReportSystem.GetReport(report_id, _reportProxy.GetType(), false);
                        user.ReportSystem.DeleteSharedReport(_reportProxy, childReport);
                    }

                    if (sharing != Report.SharingEnum.None)
                    {
                        user.ReportSystem.CreateAsSharedFrom(_reportProxy, sharing);
                    }
                }
                catch (Exception exc)
                {
                    ShowException(exc);
                }
            }

            LoadSharingPanel();
        }
예제 #6
0
        public void DeleteSharedReport(Report parentReport, Report childReport)
        {
            System.Type reportType = childReport.GetType();

            if (parentReport.GetType() != reportType)
            {
                throw new Exception("Parent and child report type mismatch");
            }

            short maxSurscriberSharing = 0;

            // delete child report states
            childReport._DeleteStates();


            // ----------------------------------------
            if (reportType == typeof(OlapReport))
            {
                FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();
                dacObj.DeleteSharedReport(parentReport.ID, childReport.ID, ref maxSurscriberSharing);
            }
            else if (reportType == typeof(StorecheckReport))
            {
                FI.Common.DataAccess.IStorecheckReportsDA dacObj = DataAccessFactory.Instance.GetStorecheckReportsDA();
                dacObj.DeleteSharedReport(parentReport.ID, childReport.ID, ref maxSurscriberSharing);
            }
            else if (reportType == typeof(CustomSqlReport))
            {
                FI.Common.DataAccess.ICustomSqlReportsDA dacObj = DataAccessFactory.Instance.GetCustomSqlReportsDA();
                dacObj.DeleteSharedReport(parentReport.ID, childReport.ID, ref maxSurscriberSharing);
            }
            else if (reportType == typeof(CustomMdxReport))
            {
                FI.Common.DataAccess.ICustomMdxReportsDA dacObj = DataAccessFactory.Instance.GetCustomMdxReportsDA();
                dacObj.DeleteSharedReport(parentReport.ID, childReport.ID, ref maxSurscriberSharing);
            }
            else
            {
                throw new NotSupportedException();
            }
            // ----------------------------------------

            childReport._sharing = Report.SharingEnum.None;
            parentReport._maxSubscriberSharing = (Report.SharingEnum)maxSurscriberSharing;
        }
        public void SendReport(Report report, Contact[] contacts, Report.ExportFormat Format, DateTime getCachedFrom, out bool isFromCache)
        {
            isFromCache = false;

            if (report.IsProxy)
            {
                throw new Exception("Report cannot be Proxy");
            }

            if (contacts.Length == 0)
            {
                return;
            }

            string fileNamePattern     = report.GetType().Name + "_" + report.ID.ToString() + "_";
            string fileName            = fileNamePattern + DateTime.Now.ToString("yyyyMMddHHmmss") + "." + Format.ToString();
            string cacheLookupFileName = fileNamePattern + getCachedFrom.ToString("yyyyMMddHHmmss") + "." + Format.ToString();
            string filePath            = null;
            string reportString        = null;

            // lookup cached report
            string[] lookupPaths = Directory.GetFiles(FI.Common.AppConfig.TempDir, fileNamePattern + "*." + Format.ToString());
            if (lookupPaths != null)
            {
                foreach (string path in lookupPaths)
                {
                    string file = Path.GetFileName(path);
                    if (file.Length == cacheLookupFileName.Length && file.CompareTo(cacheLookupFileName) > 0)
                    {
                        filePath    = FI.Common.AppConfig.TempDir + @"\" + file;
                        isFromCache = true;
                        break;
                    }
                }
            }
            if (filePath == null)
            {
                filePath = FI.Common.AppConfig.TempDir + @"\" + fileName;
                report.Export(filePath, Format);
            }


            foreach (Contact cnt in contacts)
            {
                if (Format == Report.ExportFormat.HTML && reportString == null)
                {
                    if (cnt.DistributionFormat == Contact.DistributionFormatEnum.MessageBody || cnt.DistributionFormat == Contact.DistributionFormatEnum.Body_And_Attachment)
                    {
                        StreamReader sr = new StreamReader(filePath, System.Text.Encoding.Unicode, true);
                        if (sr != null)
                        {
                            reportString = sr.ReadToEnd();
                            sr.Close();
                        }
                    }
                }

                //send via email
                try
                {
                    if (cnt.IsProxy)
                    {
                        cnt.Fetch();
                    }

                    // message object
                    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(cnt.EMail));
                    msg.Subject = report.Name + " (" + report.Description + ")";

                    // attachment if ordered or report is not html
                    if (cnt.DistributionFormat == Contact.DistributionFormatEnum.Attachment ||
                        cnt.DistributionFormat == Contact.DistributionFormatEnum.Body_And_Attachment ||
                        Format != Report.ExportFormat.HTML)
                    {
                        OpenSmtp.Mail.Attachment att = new OpenSmtp.Mail.Attachment(filePath);
                        //att.Encoding=System.Web.Mail.MailEncoding.UUEncode;
                        msg.Attachments.Add(att);
                    }

                    // message body (if retport is html)
                    if (Format == Report.ExportFormat.HTML &&
                        (cnt.DistributionFormat == Contact.DistributionFormatEnum.MessageBody ||
                         cnt.DistributionFormat == Contact.DistributionFormatEnum.Body_And_Attachment))
                    {
                        msg.HtmlBody = reportString;
                    }

//					msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "0"); //This is crucial. put 0 there
//					msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 90);

                    OpenSmtp.Mail.SmtpConfig.LogToText = false;

                    OpenSmtp.Mail.Smtp smtp = new OpenSmtp.Mail.Smtp();
                    smtp.SendTimeout = 600;
                    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);
//					System.Web.Mail.SmtpMail.SmtpServer=FI.Common.AppConfig.SmtpServer;
//					System.Web.Mail.SmtpMail.Send(msg);
                }
                catch (Exception exc)
                {
                    // because real exception is inside:
                    while (exc.InnerException != null)
                    {
                        exc = exc.InnerException;
                    }

                    Common.LogWriter.Instance.WriteEventLogEntry(exc);
                    throw exc;
                }
            }
        }
        public void SendReport(Report report, Guid olapTaskGuid, Contact[] contacts, Report.ExportFormat Format, DateTime minCacheTimestamp, DateTime currentTimestamp, out bool isFromCache)
        {
            isFromCache = false;

            if (contacts.Length == 0)
            {
                return;
            }

            if (report.IsProxy)
            {
                report.Open();
            }

            string fileNamePattern     = report.GetType().Name + "_" + report.ID.ToString() + "_";
            string newFileName         = fileNamePattern + currentTimestamp.ToString("yyyyMMddHHmmssfff") + "." + Format.ToString();
            string cacheLookupFileName = fileNamePattern + minCacheTimestamp.ToString("yyyyMMddHHmmssfff") + "." + Format.ToString();
            string filePath            = null;
            string reportString        = null;

            // lookup cached report
            if (minCacheTimestamp != DateTime.MinValue && minCacheTimestamp != DateTime.MaxValue)
            {
                string[] lookupPaths = Directory.GetFiles(FI.Common.AppConfig.TempDir, fileNamePattern + "*." + Format.ToString());
                if (lookupPaths != null)
                {
                    foreach (string path in lookupPaths)
                    {
                        string file = Path.GetFileName(path);
                        if (file.Length == cacheLookupFileName.Length && file.CompareTo(cacheLookupFileName) > 0)
                        {
                            filePath    = FI.Common.AppConfig.TempDir + @"\" + file;
                            isFromCache = true;
                            break;
                        }
                    }
                }
            }

            // no cache, execute
            if (filePath == null)
            {
                if (report.State == Report.StateEnum.Open)
                {
                    OlapReport olapRpt = report as OlapReport;
                    if (olapRpt != null)
                    {
                        olapRpt.Execute(olapTaskGuid);
                    }
                    else
                    {
                        report.Execute();
                    }
                }

                filePath = FI.Common.AppConfig.TempDir + @"\" + newFileName;
                report.Export(filePath, Format);
            }


            // send to contacts
            foreach (Contact cnt in contacts)
            {
                if (Format == Report.ExportFormat.HTML && reportString == null)
                {
                    if (cnt.DistributionFormat == Contact.DistributionFormatEnum.MessageBody || cnt.DistributionFormat == Contact.DistributionFormatEnum.Body_And_Attachment)
                    {
                        StreamReader sr = new StreamReader(filePath, System.Text.Encoding.Unicode, true);
                        if (sr != null)
                        {
                            reportString = sr.ReadToEnd();
                            sr.Close();
                        }
                    }
                }

                //send via email
                try
                {
                    if (cnt.IsProxy)
                    {
                        cnt.Fetch();
                    }

                    // message object
                    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                    msg.From = new System.Net.Mail.MailAddress(FI.Common.AppConfig.SmtpSender);
                    msg.To.Add(cnt.EMail);
                    msg.Subject = report.Name + " (" + report.Description + ")";
                    //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(cnt.EMail));
                    //msg.Subject=report.Name + " (" + report.Description + ")";

                    // attachment if ordered or report is not html
                    if (cnt.DistributionFormat == Contact.DistributionFormatEnum.Attachment ||
                        cnt.DistributionFormat == Contact.DistributionFormatEnum.Body_And_Attachment ||
                        Format != Report.ExportFormat.HTML)
                    {
                        //OpenSmtp.Mail.Attachment att=new OpenSmtp.Mail.Attachment(filePath);
                        //att.Encoding=System.Web.Mail.MailEncoding.UUEncode;
                        System.Net.Mail.Attachment att = new System.Net.Mail.Attachment(filePath);
                        msg.Attachments.Add(att);
                    }

                    // message body (if retport is html)
                    if (Format == Report.ExportFormat.HTML &&
                        (cnt.DistributionFormat == Contact.DistributionFormatEnum.MessageBody ||
                         cnt.DistributionFormat == Contact.DistributionFormatEnum.Body_And_Attachment))
                    {
                        //msg.HtmlBody=reportString;
                        msg.Body       = reportString;
                        msg.IsBodyHtml = true;
                    }

//					msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "0"); //This is crucial. put 0 there
//					msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 90);

                    //OpenSmtp.Mail.SmtpConfig.LogToText=false;

                    System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
                    smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                    smtp.Host           = FI.Common.AppConfig.SmtpServer;
                    smtp.Timeout        = 600000; // 10 minutes
                    if (FI.Common.AppConfig.SmtpPort > 0)
                    {
                        smtp.Port = FI.Common.AppConfig.SmtpPort;
                    }

                    //OpenSmtp.Mail.Smtp smtp=new OpenSmtp.Mail.Smtp();
                    //smtp.SendTimeout=600;
                    //smtp.Host=FI.Common.AppConfig.SmtpServer;
                    if (FI.Common.AppConfig.SmtpUserName != null && FI.Common.AppConfig.SmtpUserName != "")
                    {
                        smtp.Credentials = new System.Net.NetworkCredential(FI.Common.AppConfig.SmtpUserName, FI.Common.AppConfig.SmtpPassword);
                        //smtp.Username=FI.Common.AppConfig.SmtpUserName;
                        //smtp.Password=FI.Common.AppConfig.SmtpPassword;
                    }
                    smtp.Send(msg);
                    //smtp.SendMail(msg);
//					System.Web.Mail.SmtpMail.SmtpServer=FI.Common.AppConfig.SmtpServer;
//					System.Web.Mail.SmtpMail.Send(msg);
                }
                catch (Exception exc)
                {
                    // because real exception is inside:
                    while (exc.InnerException != null)
                    {
                        exc = exc.InnerException;
                    }

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