Пример #1
0
 public LogMessageEntry(LogMessageType messageCode, String message, RvsSavedProperties savedProperties)
     : this()
 {
     MessageCode     = messageCode;
     Message         = message;
     SavedProperties = savedProperties;
 }
 public bool DeleteSavedSettings(string id)
 {
     if (string.IsNullOrEmpty(id))
     {
         return(false);
     }
     //note: проверка прав внутри функции
     return(RvsSavedProperties.DeleteProperties(Convert.ToInt64(id)));
 }
Пример #3
0
        public static void SaveSettings(BaseJournalControl journal, string argument, ILogMonitor logMonitor, LogMessageType logMessageType)
        {
            var jss          = new JavaScriptSerializer();
            var saveArgument = jss.Deserialize <SaveArgument>(argument);
            var properties   = RvsSavedProperties.GetFromJournal(journal.ParentUserControl);

            logMonitor.Log(new LogMessageEntry(logMessageType, properties.NameRu, properties));
            properties.SaveWithViewSettings(saveArgument, "Cross:" + journal.GetType().FullName);
        }
Пример #4
0
        public Stream GetExcelByType(Type journalType, string format, long idProperties, StorageValues storageValues, string culture, ILogMonitor logMonitor, bool checkPermit, out string fileNameExtention)
        {
            var rvsProp = RvsSavedProperties.LoadFrom(idProperties, logMonitor);

            rvsProp.Format        = format;
            rvsProp.Culture       = culture;
            rvsProp.StorageValues = storageValues;
            return(GetExcelByType(journalType, rvsProp, logMonitor, checkPermit, out fileNameExtention));
        }
Пример #5
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            _chkSaveAsShared.Enabled = UserRoles.IsInRole(UserRoles.AllowSaveJournalSettingsAsShared);
            _tbSaveNameRu.Text       = "";
            _tbSaveNameKz.Text       = "";

            using (var db = new DB_RvsSettingsDataContext(SpecificInstances.DbFactory.CreateConnection()))
            {
                var sid             = User.GetSID();
                var journalTypeName = RvsSavedProperties.GetJournalTypeName(Journal.ParentUserControl);
                var data            = (IQueryable <RVS_SavedProperty>)
                                      db.RVS_SavedProperties.
                                      Where(r => r.JournalTypeName == journalTypeName &&
                                            (r.UserSID == sid || r.isSharedView)).
                                      OrderByDescending(r => r.dateTime);
                var result = data.Select(r =>
                                         new ListItem
                {
                    id          = r.id,
                    NameKz      = r.nameKz,
                    NameRu      = r.nameRu,
                    dateTime    = r.dateTime,
                    isShared    = r.isSharedView,
                    Sid         = r.UserSID,
                    SaveFilters = r.RVS_Property.Filter != null,
                }).ToList();
                _ddlLoadFilters.DataSource = result;
                _ddlLoadFilters.DataBind();
                _ddlLoadFilters.Attributes["onchange"] =
                    string.Format("changeSelectedLoadViewSettings(this, '{0}');", _hlDelSavedInOpen.ClientID);

                if (!UserRoles.IsInRole(UserRoles.AllowChangeOrDeleteJournalSettingsAsShared))
                {
                    _ddlSaveFilters.DataSource = result.Where(r => r.Sid == sid);
                }
                else
                {
                    _ddlSaveFilters.DataSource = result;
                }
                _ddlSaveFilters.DataBind();
                _ddlSaveFilters.Attributes["onchange"] =
                    string.Format("changeSelectedSaveViewSettings(this, '{0}', '{1}', '{2}', '{3}', '{4}');",
                                  _tbSaveNameRu.ClientID, _tbSaveNameKz.ClientID, _chkSaveAsShared.ClientID,
                                  _chkSaveFilters.ClientID, _hlDelSavedInSave.ClientID);
                if (_ddlLoadFilters.SelectedValue == null || _ddlLoadFilters.SelectedValue == "")
                {
                    _hlDelSavedInOpen.Style[HtmlTextWriterStyle.Display] = "none";
                }
                if (_ddlSaveFilters.SelectedValue == null || _ddlSaveFilters.SelectedValue == "")
                {
                    _hlDelSavedInSave.Style[HtmlTextWriterStyle.Display] = "none";
                }
            }
        }
        protected override void OnPreRender(EventArgs e)
        {
            if (!IsPostBack)
            {
                EnsureChildControls();
                LogMonitor.Log(new LogMessageEntry(ViewLog, HeaderRu, RvsSavedProperties.GetFromJournal(this)));
            }

            base.OnPreRender(e);
            ScriptManager.RegisterScriptControl(this);
        }
Пример #7
0
        private static void LoadSettings(BaseJournalControl control, string argument, ILogMonitor logMonitor, LogMessageType logMessageType)
        {
            var jss          = new JavaScriptSerializer();
            var loadArgument = jss.Deserialize <LoadArgument>(argument);

            if (loadArgument.id.HasValue)
            {
                var properties = RvsSavedProperties.LoadBySavedViewSettings(loadArgument.id.Value, null);
                properties.StorageValues = null;
                logMonitor.Log(new LogMessageEntry(logMessageType, properties.NameRu, properties));
                properties.SetToJournal(control.ParentUserControl, !loadArgument.loadFilters, true);
            }
        }
Пример #8
0
        /* public Stream GetExcelByTypeName(string journalType, string format, long idProperties, ILogMonitor logMonitor, bool checkPermit)
         * {
         *  var properties = RvsSavedProperties.LoadFrom(idProperties);
         *  return GetExcelByTypeName(journalType, properties, logMonitor, checkPermit);
         * }
         *
         * public Stream GetExcelByTypeName(string journalType, RvsSavedProperties properties, ILogMonitor logMonitor, bool checkPermit)
         * {
         *  var type = Type.GetType(journalType) ?? BuildManager.GetType(journalType, false, true);
         *  return GetExcelByType(type, properties, logMonitor, checkPermit);
         * }
         */

        public Stream GetExcelByType(Type journalType, RvsSavedProperties properties, ILogMonitor logMonitor, bool checkPermit, out string fileNameExtention)
        {
            var oldCulture = Thread.CurrentThread.CurrentUICulture;

            if (!string.IsNullOrEmpty(properties.Culture))
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(properties.Culture);
            }
            try
            {
                var    obj        = Activator.CreateInstance(journalType);
                var    methodInfo = typeof(Exporter).GetMethod("GetExcel");
                Type[] gTypes     = null;
                if (journalType.IsGenericType)
                {
                    gTypes = journalType.GetGenericArguments();
                }
                else if (journalType.BaseType.IsGenericType)
                {
                    gTypes = journalType.BaseType.GetGenericArguments();
                }
                else if (journalType.BaseType.BaseType.IsGenericType)
                {
                    gTypes = journalType.BaseType.BaseType.GetGenericArguments();
                }

                methodInfo        = methodInfo.MakeGenericMethod(gTypes);
                fileNameExtention = GetFileNameExtension(properties.Format);
                return((Stream)methodInfo.Invoke(null, new[] { obj, properties, logMonitor, checkPermit }));
            }
            finally
            {
                if (!string.IsNullOrEmpty(properties.Culture))
                {
                    Thread.CurrentThread.CurrentUICulture = oldCulture;
                }
            }
        }
Пример #9
0
        //// ReSharper restore InconsistentNaming

        public Stream GetExcel(BaseJournalUserControl <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal, TNavigatorControl, TNavigatorValues, TFilter> journalControl, RvsSavedProperties properties)
        {
            if (HttpContext.Current != null)
            {
                foreach (var key in HttpContext.Current.Items.Keys.OfType <string>().ToList().Where(r => r.EndsWith(".FiltersCache")))
                {
                    HttpContext.Current.Items.Remove(key);
                }
            }

            var page = new Page();

            _journalControl = journalControl;
            _journalControl.StorageValues = properties.StorageValues;
            _journalControl.InitializeControls(properties);
            page.TemplateControl.Controls.Add(_journalControl);
            return(GetExcel());
        }
Пример #10
0
        public static Stream GetExcel <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal, TNavigatorControl, TNavigatorValues, TFilter>(
            BaseJournalUserControl <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal, TNavigatorControl, TNavigatorValues, TFilter>
            journalControl,
            RvsSavedProperties properties,
            ILogMonitor logMonitor,
            bool checkPermit)

            where TDataContext : DataContext, new()
            where TKey : struct
            where TTable : class
            where TFilterControl : BaseFilterControl <TKey, TTable>, new()
            where TDataSource : BaseDataSource <TKey, TTable, TDataContext, TRow>
            where TRow : BaseRow, new()
            where TJournal : BaseJournalControl <TKey, TTable, TRow, TDataContext>
            where TNavigatorControl : BaseNavigatorControl <TNavigatorValues>
            where TNavigatorValues : BaseNavigatorValues, new()
            where TFilter : BaseFilter <TKey, TTable, TDataContext>, new()
        {
            Stream stream;

            journalControl.LogMonitor = logMonitor;
            journalControl.Url        = MainPageUrlBuilder.Current.Clone();
            if (checkPermit)
            {
                journalControl.CheckExportPermit();
            }
            if ("xml".Equals(properties.Format, StringComparison.OrdinalIgnoreCase))
            {
                var exporterXml = new ExporterXml <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal,
                                                   TNavigatorControl, TNavigatorValues, TFilter> {
                    LogMonitor = logMonitor
                };
                stream = exporterXml.GetExcel(journalControl, properties);
            }
            else
            {
                var exporterXslx = new ExporterXslx <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal,
                                                     TNavigatorControl, TNavigatorValues, TFilter> {
                    LogMonitor = logMonitor
                };
                stream = exporterXslx.GetExcel(journalControl, properties);
            }

            DBDataContext.AddViewReports(
                User.GetSID(),
                HttpContext.Current.User.Identity.Name,
                HttpContext.Current.User.Identity.Name,
                HttpContext.Current.Request.Url.PathAndQuery,
                HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority),
                Environment.MachineName,
                true,
                BuildManager.GetType(properties.ReportPluginName, false, true) ?? GetTypeByReportManager(properties.ReportPluginName));

            logMonitor.Log(
                new LogMessageEntry(
                    User.GetSID(),
                    journalControl.ExportLog,
                    properties.NameRu,
                    journalControl.OnExportNewSavedProperties ? RvsSavedProperties.GetFromJournal(journalControl) : properties));

            return(stream);
        }
Пример #11
0
        public Stream GetExcel(BaseJournalUserControl <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal, TNavigatorControl, TNavigatorValues, TFilter> journalControl, RvsSavedProperties properties)
        {
            var page = new Page();

            _journalControl = journalControl;
            _journalControl.StorageValues = properties.StorageValues;
            _journalControl.InitializeControls(properties);
            page.TemplateControl.Controls.Add(_journalControl);
            var stream       = new MemoryStream();
            var streamWriter = new StreamWriter(stream);

            _writer = new XmlTextWriter(streamWriter)
            {
                Formatting = Formatting.Indented
            };
            _writer.WriteProcessingInstruction("xml", "version=\"1.0\"");
            _writer.WriteProcessingInstruction("mso-application", "progid=\"Excel.Sheet\"");
            _writer.WriteStartElement("Workbook");
            _writer.WriteAttributeString("xmlns", "urn:schemas-microsoft-com:office:spreadsheet");
            _writer.WriteAttributeString("xmlns:o", "urn:schemas-microsoft-com:office:office");
            _writer.WriteAttributeString("xmlns:x", "urn:schemas-microsoft-com:office:excel");
            _writer.WriteAttributeString("xmlns:ss", "urn:schemas-microsoft-com:office:spreadsheet");
            _writer.WriteAttributeString("xmlns:html", "http://www.w3.org/TR/REC-html40");

            RenderDocumentProperties();
            RenderStyles();
            RenderWorksheet();

            _writer.WriteEndElement();
            _writer.Flush();
            streamWriter.Flush();
            stream.Position = 0;
            return(stream);
        }