Пример #1
0
        public FI.Common.Data.FIDataTable GetReportHeaders(System.Type ReportType)
        {
            FI.Common.Data.FIDataTable table = null;


            if (ReportType == typeof(OlapReport))
            {
                FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();
                table = dacObj.ReadReportHeaders(_owner.ID);
            }
            else if (ReportType == typeof(StorecheckReport))
            {
                FI.Common.DataAccess.IStorecheckReportsDA dacObj = DataAccessFactory.Instance.GetStorecheckReportsDA();
                table = dacObj.ReadReportHeaders(_owner.ID);
            }
            else if (ReportType == typeof(CustomSqlReport))
            {
                FI.Common.DataAccess.ICustomSqlReportsDA dacObj = DataAccessFactory.Instance.GetCustomSqlReportsDA();
                table = dacObj.ReadReportHeaders(_owner.ID);
            }
            else if (ReportType == typeof(CustomMdxReport))
            {
                FI.Common.DataAccess.ICustomMdxReportsDA dacObj = DataAccessFactory.Instance.GetCustomMdxReportsDA();
                table = dacObj.ReadReportHeaders(_owner.ID);
            }
            else
            {
                throw new NotSupportedException();
            }

            return(table);
        }
Пример #2
0
        override protected internal void _LoadState(short StateCode)
        {
            FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();
            string reportXml = dacObj.LoadState(this.ID, StateCode, ref this._undoStateCount, ref this._redoStateCount);

            LoadFromXml(reportXml);
        }
Пример #3
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);
        }
Пример #4
0
        internal OlapReport(decimal ID, User Owner) : base(ID, Owner)
        {
            _schema = new Schema();
            _axes   = new Olap.Axes(this.Schema);

            this.Axes.BeforeChangeItem += new EventHandler(OnBeforeChangeAxesItem);

            if (ID == 0)          //if new
            {
                FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();

                string ReportXml    = "<R></R>";
                string OpenNodesXml = "<NODES></NODES>";
                _graphOptions = GraphOptionsEnum.Pivot; // graph pivot option on by default

                _id = dacObj.InsertReport(
                    _owner.ID, 0, 0, "New Report", "", this.IsSelected,
                    (byte)this.GraphType, this.GraphTheme, (int)this.GraphOptions, this.GraphWidth, this.GraphHeight, this.GraphNum1,
                    ReportXml, OpenNodesXml);

                // flags
                _isProxy = false;
                _isDirty = false;
            }
        }
Пример #5
0
 override protected internal void _SaveHeader()
 {
     FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();
     dacObj.UpdateReportHeader(
         this.Owner.ID, this.ID, this._parentReportId, (byte)this.SharingStatus, this.Name, this.Description, this.IsSelected,
         this.Schema.OpenNodesToXml(),
         (byte)this.GraphType, this.GraphTheme, (int)this.GraphOptions, this.GraphWidth, this.GraphHeight);
 }
Пример #6
0
        override protected internal void _Save()
        {
            FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();
            dacObj.SaveReport(_owner.ID, this._id, SaveToXml(), this.Schema.OpenNodesToXml());

//			// always save on close, cause open nodes could've been changed
//			dacObj.SaveReport(_owner.ID , this._id  , SaveToXml(), this.SaveOpenNodesToXml() );
        }
Пример #7
0
        override protected internal Report _Clone(string Name, string Description)
        {
            FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();
            string ReportXml    = this.SaveToXml();
            string OpenNodesXml = this.SaveOpenNodesToXml();

            decimal newId = dacObj.InsertReport(_owner.ID, 0, 0, Name, Description, false, (byte)this.GraphType, (int)this.GraphOptions, ReportXml, OpenNodesXml);

            return(_owner.ReportSystem.GetReport(newId, typeof(OlapReport), false));
        }
Пример #8
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);
        }
Пример #9
0
        override protected internal void _Close(bool SaveFromState)
        {
            FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();

            //dacObj.UpdateReportHeader(_owner.ID , this._id , _parentReportId, (byte)this._sharing , _name , _description , _isSelected , (byte)_graphType , _graphOptions.ToString() );

            if (SaveFromState)
            {
                dacObj.SaveReport(_owner.ID, this._id, SaveToXml(), this.Schema.OpenNodesToXml());
            }

//			// always save on close, cause open nodes could've been changed
//			dacObj.SaveReport(_owner.ID , this._id  , SaveToXml(), this.SaveOpenNodesToXml() );
        }
Пример #10
0
        override public void LoadHeader()
        {
            FI.Common.DataAccess.IOlapReportsDA dacObj    = DataAccessFactory.Instance.GetOlapReportsDA();
            FI.Common.Data.FIDataTable          dataTable = dacObj.ReadReportHeader(this.Owner.ID, this.ID);

            this._parentReportId       = (decimal)dataTable.Rows[0]["parent_report_id"];
            this._name                 = (string)dataTable.Rows[0]["name"];
            this._description          = (string)dataTable.Rows[0]["description"];
            this._isSelected           = (bool)dataTable.Rows[0]["is_selected"];
            this._sharing              = (Report.SharingEnum)((byte)dataTable.Rows[0]["sharing_status"]);
            this._maxSubscriberSharing = (Report.SharingEnum)((byte)dataTable.Rows[0]["max_subscriber_sharing_status"]);

            string openNodesXml = (string)dataTable.Rows[0]["open_nodes"];
        }
        public void RefreshCachedReports(string CompanyNameShort)
        {
            Common.LogWriter.Instance.WriteEventLogEntry("Start RefreshCachedReports: " + CompanyNameShort);

            lock (this)
            {
                // check if already being handled
                if (_refreshCachedRequests.Contains(CompanyNameShort))
                {
                    return;
                }
                _refreshCachedRequests.Add(CompanyNameShort);
            }

            int count = 0;

            try
            {
                FI.Common.DataAccess.IUsersDA       userDao = DataAccessFactory.Instance.GetUsersDA();
                FI.Common.DataAccess.IOlapReportsDA rptDao  = DataAccessFactory.Instance.GetOlapReportsDA();

                decimal companyId = userDao.GetCompanyIdByShortName(CompanyNameShort);
                if (companyId <= 0)
                {
                    return;
                }

                Common.Data.FIDataTable tbl = rptDao.GetCashedReportsToRefresh(companyId);
                if (tbl != null)
                {
                    foreach (DataRow row in tbl.Rows)
                    {
                        User       usr = new User((decimal)row["user_id"], false);
                        OlapReport rpt = usr.ReportSystem.GetReport((decimal)row["rpt_id"], typeof(OlapReport), true) as OlapReport;
                        rpt.Execute();
                        count++;
                    }
                }
            }
            catch (Exception exc)
            {
                Common.LogWriter.Instance.WriteEventLogEntry(exc);
                throw exc;
            }
            finally
            {
                _refreshCachedRequests.Remove(CompanyNameShort);
                Common.LogWriter.Instance.WriteEventLogEntry(string.Format("End RefreshCachedReports: Company={0}, Count={1}", CompanyNameShort, count));
            }
        }
Пример #12
0
        override protected internal void _Open()
        {
            short  sharing = 0;
            short  maxSubscriberSharing = 0;
            string reportXml            = "";
            string openNodesXml         = "";
            string schemaXml            = "";
            byte   graphType            = 0;
            int    graphOptions         = 0;

            //bool fakeIsSelected=false;

            FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();
            dacObj.ReadReport(_owner.ID, this.ID,
                              ref this._parentReportId,
                              ref this._name,
                              ref this._description,
                              ref sharing,
                              ref maxSubscriberSharing,
                              ref this._isSelected,   //ref fakeIsSelected,
                              ref graphType,
                              ref _graphTheme,
                              ref graphOptions,
                              ref _graphWidth,
                              ref _graphHeight,
                              ref _graphNum1,
                              ref Schema.Server,
                              ref Schema.Database,
                              ref Schema.Cube,
                              ref reportXml,
                              ref schemaXml,
                              ref openNodesXml,
                              ref _undoStateCount,
                              ref _redoStateCount);

            this._sharing = (Report.SharingEnum)sharing;
            this._maxSubscriberSharing = (Report.SharingEnum)maxSubscriberSharing;
            this._graphType            = (GraphTypeEnum)graphType;
            this._graphOptions         = (GraphOptionsEnum)graphOptions;

            //dacObj.UpdateReportHeader(_owner.ID , this.ID, this._parentReportId , (byte)this.SharingStatus , this.Name , this.Description , this.IsSelected , 0, "");

            this.Schema.OpenNodesFromXml(openNodesXml);             // before other loads, cause then other loads will fetch members depending on open nodes
            LoadFromXmlSchema(schemaXml);
            LoadFromXml(reportXml);
        }
Пример #13
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;
        }
Пример #14
0
 override protected internal void _Delete(bool DenyShared)
 {
     FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();
     dacObj.DeleteReport(_owner.ID, this.ID, DenyShared);
 }
Пример #15
0
 override protected internal void _DeleteStates()
 {
     FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();
     dacObj.DeleteReportStates(this.ID);
 }
Пример #16
0
 override protected internal void _SaveState()
 {
     FI.Common.DataAccess.IOlapReportsDA dacObj = DataAccessFactory.Instance.GetOlapReportsDA();
     dacObj.SaveState(this.ID, this.MaxStateCount, SaveToXml(), ref this._undoStateCount);
 }