Exemple #1
0
        protected void Application_Start(object sender, EventArgs args)
        {
            GlobalConfiguration.Configure(config =>
            {
                var configuration = new TerrificNetHostConfiguration
                {
                    Applications = new Dictionary <string, TerrificNetApplicationConfiguration>
                    {
                        { "administration", new TerrificNetApplicationConfiguration
                          {
                              BasePath        = "zip://Web.zip/Web",
                              ApplicationName = "administration",
                              Section         = "web/"
                          } },
                        { "application", new TerrificNetApplicationConfiguration
                          {
                              BasePath        = "",
                              ApplicationName = "application",
                              Section         = ""
                          } }
                    }
                };

                var serverConfiguration = ServerConfiguration.LoadConfiguration(this.Server.MapPath("/server.json"));
                var container           = WebInitializer.Initialize(this.Server.MapPath("/"), configuration, serverConfiguration);

                container.RegisterType <IModelTypeProvider, DummyModelTypeProvider>();

                new Startup().Configuration(container, config);
            });
            RouteTable.Routes.RouteExistingFiles = true;
        }
 private static DBFilterValuesDataContext GetDB()
 {
     if (WebSpecificInstances.DbFactory == null)
     {
         WebInitializer.Initialize();
     }
     return(new DBFilterValuesDataContext(WebSpecificInstances.DbFactory.CreateConnection()));
 }
Exemple #3
0
 public static void SetUserActivityTime(string sid, DateTime time)
 {
     WebInitializer.Initialize();
     using (var db = new DBDataContext(SpecificInstances.DbFactory.CreateConnection()))
     {
         db.ADM_P_SetUserActivityTime(sid, time);
     }
 }
        public static Component GetTableAdapterToHistoricalData(Component adapter, string endDateField, string StartDateField, DateTime?HistolicalPoint, Type typeTableAdapter, int commandIndex)
        {
            WebInitializer.Initialize();
            QueryConditionList queryConditions = GetHistoricalCondition(endDateField, StartDateField, HistolicalPoint);
            var queryGenerator = new QueryGenerator(adapter, commandIndex);

            return(queryGenerator.GetTableAdapter(queryConditions));
        }
        public void ProcessRequest(HttpContext context)
        {
            WebInitializer.Initialize();
            var excelExport = "excel".Equals(context.Request["export"], StringComparison.OrdinalIgnoreCase);

            context.Response.ContentType = excelExport ? ExcelContentType : "text/json";
            int total;
            var data = GetData(context, excelExport, out total);

            context.Response.Write(string.Format("{{Total:{1},'Data':{0}}}", JSON.Serialize(data), total));
        }
        private void TraceRequest(XElement traceXml)
        {
            var parametersXml = new XElement("Root");

            this.WriteParameters(parametersXml);

            WebInitializer.Initialize();
            using (var db = new DBTraceTimingRequestsDataContext(SpecificInstances.DbFactory.CreateConnection()))
            {
                var page      = string.Empty;
                var tableName = string.Empty;
                var pageType  = string.Empty;
                var traceKey  = (Guid?)HttpContext.Current.Items["TraceTimingRegeusts.TraceKey"];
                if (traceKey == null)
                {
                    traceKey = Guid.NewGuid();
                }
                long?id    = null;
                var  match = pageRegex.Match(HttpContext.Current.Request.Url.AbsolutePath);
                if (match.Success)
                {
                    page = match.Value;
                }
                match = tableNameAndPageTypeRegex.Match(HttpContext.Current.Request.Url.AbsolutePath);
                if (match.Success)
                {
                    if (match.Groups["TableName"].Success)
                    {
                        tableName = match.Groups["TableName"].Value;
                    }
                    if (match.Groups["PageType"].Success)
                    {
                        pageType = match.Groups["PageType"].Value;
                    }
                }

                var personInfo = User.GetPersonInfo();
                db.P_LOG_InsertTraceTimingRequest(
                    page,
                    HttpContext.Current.Request.Url.ToString(),
                    HttpContext.Current.Timestamp,
                    (DateTime.Now.Ticks - HttpContext.Current.Timestamp.Ticks) / 10000,
                    User.GetSID(),
                    personInfo?.refRegion,
                    tableName,
                    HttpContext.Current.Request.QueryString["mode"],
                    pageType,
                    parametersXml,
                    traceXml,
                    traceKey,
                    ref id);
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            WebInitializer.Initialize();
            context.Response.ContentType = "text/json";
            IDataSourceView3 ds3;
            int countRows;
            var data = GetCompletionList(context, out ds3, out countRows);

            if (data == null)
            {
                return;
            }

            var dataRows = data.ToList()
                           .Select(
                r => new
            {
                id               = r.Value,
                RowName          = r.Name,
                Row              = r,
                AdditionalValues = JSON.Serialize(r.GetAdditionalValues(ds3.SelectParameters)),
            })
                           .ToList();

            var store = new Store();

            store.Model.Add(new Model());
            store.Model.Primary.Fields.Add(new ModelField("id", ModelFieldType.String)
            {
                ServerMapping = "id"
            });
            store.Model.Primary.Fields.Add(new ModelField("RowName", ModelFieldType.String)
            {
                ServerMapping = "RowName"
            });
            store.Model.Primary.Fields.Add(new ModelField("AdditionalValues", ModelFieldType.String)
            {
                ServerMapping = "AdditionalValues"
            });

            var comboBoxView = GetComboBoxView(context);

            if (comboBoxView != null)
            {
                comboBoxView.ServerMappingPerfix = "Row.";
                store.InitializeListConfig(comboBoxView);
            }

            store.DataSource = dataRows;
            store.DataBind();
            context.Response.Write(string.Format("{{Total:{1},'Data':{0}}}", store.JsonData, countRows));
        }
Exemple #8
0
        private static TResult GetPersonInfoInternal <TResult>(string sid)
        {
            if (string.IsNullOrEmpty(sid))
            {
                return(default(TResult));
            }

            try
            {
                if (InitializerSection.GetSection().IsConvertToSSDL)
                {
                    if (!sid.StartsWith("S-") && !"anonymous".Equals(sid))
                    {
                        var base64   = Convert.FromBase64String(sid);
                        var sidValue = new SecurityIdentifier(base64, 0);
                        sid = sidValue.Value;
                    }
                }
            }
            catch (FormatException)
            {
            }

            var     key = PersonInfoBySid + typeof(TResult).FullName + ">:" + sid;
            TResult value;

            if (HttpContext.Current != null && HttpContext.Current.Cache[key] != null)
            {
                value = (TResult)HttpContext.Current.Cache[key];
            }
            else
            {
                WebInitializer.Initialize();
                using (var db = new DBDataContext(SpecificInstances.DbFactory.CreateConnection()))
                {
                    value = db.GetPersonInfoBySid <TResult>(sid).FirstOrDefault();
                    if (value != null && HttpContext.Current != null)
                    {
                        HttpContext.Current.Cache.Add(
                            key,
                            value,
                            null,
                            DateTime.Now.AddMinutes(2),
                            Cache.NoSlidingExpiration,
                            CacheItemPriority.Normal,
                            null);
                    }
                }
            }

            return(value);
        }
 public void DeleteUploadedFile(long id)
 {
     WebInitializer.Initialize();
     using (var db = new DBUploadFilesDataContext(WebSpecificInstances.DbFactory.CreateConnection()))
     {
         var row = db.SYS_FileUploads.FirstOrDefault(r => r.id == id && r.PersonSID == Tools.Security.User.GetSID());
         if (row != null)
         {
             db.SYS_FileUploads.DeleteOnSubmit(row);
             db.SubmitChanges();
         }
     }
 }
        public string StillEditCrossData(string journalName, string rowID)
        {
            WebInitializer.Initialize();
            var db     = new CrossJournalDataContext(SpecificInstances.DbFactory.CreateConnection());
            var rusult = db.SYS_UpdateCrossJournalEdits(Tools.Security.User.GetSID(), journalName, rowID).FirstOrDefault();

            LocalizationHelper.SetThreadCulture();
            if (!rusult.Result.Value)
            {
                return(Resources.SEndCrossDataEdit);
            }
            return("");
        }
Exemple #11
0
            private void ReloadData(DbTransaction transaction)
            {
                WebInitializer.Initialize();
                DbConnection connection;
                var          command = SpecificInstances.DbFactory.CreateCommand();
                var          adapter = SpecificInstances.DbFactory.CreateDataAdapter();

                if (command == null)
                {
                    throw new NullReferenceException("Method 'SpecificInstances.DbFactory.CreateCommand()' return null");
                }
                if (adapter == null)
                {
                    throw new NullReferenceException("Method 'SpecificInstances.DbFactory.CreateDataAdapter()' return null");
                }
                if (transaction == null)
                {
                    connection = SpecificInstances.DbFactory.CreateConnection();
                    if (connection == null)
                    {
                        throw new NullReferenceException("Method 'SpecificInstances.DbFactory.CreateConnection()' return null");
                    }
                }
                else
                {
                    connection          = transaction.Connection;
                    command.Transaction = transaction;
                }
                command.Connection    = connection;
                command.CommandText   = "select code, enabled from DIC_LOG_MESSAGE_SOURCE_TO_TYPE";
                adapter.SelectCommand = command;
                if (transaction == null)
                {
                    connection.Open();
                }
                try
                {
                    Clear();
                    adapter.Fill(this);
                    _needReload = false;
                }
                finally
                {
                    if (transaction == null)
                    {
                        connection.Close();
                    }
                }
            }
 protected override void InitInsertValues(System.Collections.IDictionary values, ListControlItem item)
 {
     base.InitInsertValues(values, item);
     WebInitializer.Initialize();
     using (var db = new DBUploadFilesDataContext(SpecificInstances.DbFactory.CreateConnection()))
     {
         var row = db.SYS_FileUploads.
                   FirstOrDefault(r => r.id == Convert.ToInt64(item.Value) && r.PersonSID == User.GetSID());
         if (row != null)
         {
             values[FileDataFieldName] = row.data;
             values[FileFieldName]     = row.dataFileName;
         }
     }
 }
Exemple #13
0
 public static FileData GetSysFileUpload(long id, string subsystem)
 {
     WebInitializer.Initialize();
     using (var db = new DBUploadFilesDataContext(SpecificInstances.DbFactory.CreateConnection()))
     {
         return(CacheQueries.ExecuteFunction <SYS_FileUpload, Triplet <long, string, string>, FileData>(
                    db, new Triplet <long, string, string>(id, User.GetSID(), subsystem),
                    (r, value) =>
                    r.id == value.First && r.PersonSID == value.Second && r.SubSystemName == value.Third,
                    r => new FileData
         {
             FileName = r.dataFileName,
             Binary = r.data,
         }));
     }
 }
        public void TraceDestination(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                return;
            }
            var guid = new Guid(key);

            if (HttpContext.Current.Session[guid.ToString("N")] == null)
            {
                return;
            }
            var dateTime = (DateTime)HttpContext.Current.Session[guid.ToString("N")];

            WebInitializer.Initialize();
            using (var db = new DBTraceTimingRequestsDataContext(SpecificInstances.DbFactory.CreateConnection()))
                db.P_LOG_UpdateTraceTimingRequest(guid, (DateTime.Now.Ticks - dateTime.Ticks) / 10000);
            HttpContext.Current.Session.Remove(guid.ToString("N"));
        }
 private string UploadFile(byte[] buffer, string fileName, string subsystem, string tableId)
 {
     WebInitializer.Initialize();
     using (var db = new DBUploadFilesDataContext(WebSpecificInstances.DbFactory.CreateConnection()))
     {
         var sfu = new SYS_FileUpload
         {
             data          = buffer,
             UploadDate    = DateTime.Now,
             PersonSID     = Tools.Security.User.GetSID(),
             SubSystemName = subsystem,
             dataFileName  = fileName,
         };
         db.SYS_FileUploads.InsertOnSubmit(sfu);
         db.SubmitChanges();
         var result = GetResult(fileName, tableId, sfu);
         return(new JavaScriptSerializer().Serialize(result));
     }
 }
Exemple #16
0
        static void Main(string[] args)
        {
            const string baseAddress = "http://+:9000/";

            var bind = args.FirstOrDefault(i => i.StartsWith(BindingArgumentPrefix));

            bind = !string.IsNullOrEmpty(bind) ? bind.Substring(PathArgumentPrefix.Length) : baseAddress;

            var path = args.FirstOrDefault(i => i.StartsWith(PathArgumentPrefix));

            path = !string.IsNullOrEmpty(path) ? path.Substring(PathArgumentPrefix.Length) : ".";

            var container = WebInitializer.Initialize(Path.GetFullPath(path));

            container.RegisterType <IModelTypeProvider, DummyModelTypeProvider>();


            // Start OWIN host
            using (WebApp.Start(bind, builder => Initialize(builder, container)))
            {
                Console.WriteLine("Started on " + bind);
                Console.ReadLine();
            }
        }
//        public Hashtable Values
//        {
//            get { return _values; }
//            set { _values = value; }
//        }
//
//        public List<Hashtable> ValuesCircle
//        {
//            get { return _valuesCircle; }
//            set { _valuesCircle = value; }
//        }
//
        public static StorageValues GetStorageValues(string key, byte[] sid)
        {
            WebInitializer.Initialize();
            return(GetStorageValues(SpecificInstances.DbFactory.CreateConnection(), SpecificInstances.DbConstants.SqlParameterPrefix, key, sid));
        }
 static BaseSPWebPart()
 {
     WebInitializer.Initialize();
 }
 protected virtual void Initialize()
 {
     WebInitializer.Initialize();
 }
        protected void Application_Error(object sender, EventArgs e)
        {
            OnCustomEndRequest(sender, e);
            try
            {
                if (Context != null && Context.AllErrors != null)
                {
                    WebInitializer.Initialize();
                    var monitor = new LogMonitor();
                    monitor.Init();
                    var str2 = Tools.Security.User.GetSID();
                    var db   = new DBFilterValuesDataContext(SpecificInstances.DbFactory.CreateConnection());

                    // присвоение выбранного фильтра, для его пометки, как опасного
                    long?refUserFilter = null;
                    if (MainPageUrlBuilder.Current.IsDataControl &&
                        MainPageUrlBuilder.Current.UserControl != null &&
                        MainPageUrlBuilder.Current.UserControl.EndsWith("Journal"))
                    {
                        var tableName    = MainPageUrlBuilder.Current.UserControl.Substring(0, MainPageUrlBuilder.Current.UserControl.Length - 7);
                        var filterValues = MainPageUrlBuilder.Current.GetFilterItemsDic(tableName);
                        if (filterValues != null && filterValues.ContainsKey("__refUserFilterValues") &&
                            filterValues["__refUserFilterValues"].Count > 0 &&
                            !string.IsNullOrEmpty(filterValues["__refUserFilterValues"][0].Value1))
                        {
                            refUserFilter = Convert.ToInt64(filterValues["__refUserFilterValues"][0].Value1);
                        }
                    }

                    foreach (var exception in Context.AllErrors)
                    {
                        var message = string.Format("{0}: {1}", Context.Request.Url.PathAndQuery, exception);
                        var entry2  = new LogMessageEntry(LogMessageType.SystemErrorInApp, message)
                        {
                            Sid = str2
                        };
                        var logMessageEntry = entry2;
                        var refLog          = monitor.WriteLog(logMessageEntry);
                        // для ошибок дополнительно залогируем агрументы
                        if (Context.Request.HttpMethod.ToLower() == "post" && refLog != null)
                        {
                            foreach (string key in Context.Request.Form.Keys)
                            {
                                monitor.WriteFieldChanged(refLog.Value, "", key, Context.Request.Form[key], null);
                            }
                        }

                        var sqlException = exception as SqlException ?? exception.InnerException as SqlException;
                        if (sqlException != null && refUserFilter != null)
                        {
                            foreach (SqlError sqlError in sqlException.Errors)
                            {
                                if (sqlError.Number == -2)
                                {
                                    db.SYS_SetIsDangerousUserFilter(refUserFilter);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #21
0
        public static void SyncSidAndNames()
        {
            WebInitializer.Initialize();
            #region Create connections, commands

            var connectionSelect = SpecificInstances.DbFactory.CreateConnection();
            var connectionUpdate = SpecificInstances.DbFactory.CreateConnection();
            var cSelect          = SpecificInstances.DbFactory.CreateCommand();
            var cUpdate          = SpecificInstances.DbFactory.CreateCommand();
            var nameParameter    = SpecificInstances.DbFactory.CreateParameter();
            var idParameter      = SpecificInstances.DbFactory.CreateParameter();

            if (cSelect == null || cUpdate == null)
            {
                throw new NullReferenceException("Method 'SpecificInstances.DbFactory.CreateCommand()' return null");
            }
            if (connectionSelect == null || connectionUpdate == null)
            {
                throw new NullReferenceException("Method 'SpecificInstances.DbFactory.CreateConnection()' return null");
            }
            if (nameParameter == null || idParameter == null)
            {
                throw new NullReferenceException("Method 'SpecificInstances.DbFactory.CreateParameter()' return null");
            }

            #endregion

            cSelect.CommandType = CommandType.Text;
            cSelect.CommandText = "select id, sid from LOG_SidIdentification";
            cSelect.Connection  = connectionSelect;

            cUpdate.CommandType         = CommandType.Text;
            cUpdate.CommandText         = "update LOG_SidIdentification set name = @name where id = @id";
            cUpdate.Connection          = connectionUpdate;
            nameParameter.DbType        = DbType.String;
            nameParameter.ParameterName = "name";
            idParameter.DbType          = DbType.Int64;
            idParameter.ParameterName   = "id";
            cUpdate.Parameters.Add(idParameter);
            cUpdate.Parameters.Add(nameParameter);

            var provider = Membership.Providers["LogMonitorADProvider"];
            if (provider == null)
            {
                throw new NullReferenceException("LogMonitorADProvider is not set");
            }
            try
            {
                connectionSelect.Open();
                connectionUpdate.Open();
                var reader = cSelect.ExecuteReader();
                while (reader.Read())
                {
                    var sid  = reader.GetString(1);
                    var user = provider.GetUser(new SecurityIdentifier(sid), false);
                    if (user != null)
                    {
                        nameParameter.Value = user.UserName;
                        idParameter.Value   = reader.GetInt64(0);
                        cUpdate.ExecuteNonQuery();
                    }
                }
            }
            finally
            {
                connectionSelect.Close();
                connectionUpdate.Close();
            }
        }
Exemple #22
0
 static ReportViewer()
 {
     WebInitializer.Initialize();
 }
Exemple #23
0
        public static Stream GetReport(bool useReturnStream, string pluginName, string guid,
                                       StorageValues storageValues, string culture, Page page, string format, string command,
                                       LogMonitor logMonitor, bool expToWord, Dictionary <string, object> constants, StiWebViewer report, out string fileNameExtention, bool RoleCheck)
        {
            var originalUICulture = Thread.CurrentThread.CurrentUICulture;
            var originalCulture   = Thread.CurrentThread.CurrentCulture;

            try
            {
                if (string.IsNullOrEmpty(culture))
                {
                    culture = "ru-ru";
                }
                Thread.CurrentThread.CurrentUICulture   =
                    Thread.CurrentThread.CurrentCulture =
                        new CultureInfo(culture == "ru" ? "ru-ru" : (culture == "kz" ? "kk-kz" : culture));

                fileNameExtention = "";
                WebInitializer.Initialize();
                var webReportManager = new WebReportManager(new TreeView());
                if (string.IsNullOrEmpty(pluginName))
                {
                    return(null);
                }
                webReportManager.RoleCheck = RoleCheck;
                webReportManager.Plugin    = webReportManager.GetPlugins()[pluginName];
                if (webReportManager.Plugin != null)
                {
                    webReportManager.Plugin.InitializeReportCulture(culture);
                    var values          = storageValues;
                    var webReportPlugin = (IWebReportPlugin)webReportManager.Plugin;
                    var stiPlugin       = (IStimulsoftReportPlugin)webReportPlugin;
                    webReportPlugin.Page = page;

                    webReportManager.CreateView();

                    if (!string.IsNullOrEmpty(webReportManager.Plugin.CultureParameter))
                    {
                        values.SetStorageValues(
                            webReportManager.Plugin.CultureParameter, webReportManager.Plugin.InitializedKzCulture);
                    }

                    webReportManager.InitValues(values, webReportPlugin.InitSavedValuesInvisibleConditions);
                    webReportPlugin.Constants = constants;
                    if (!string.IsNullOrEmpty(webReportManager.Plugin.CultureParameter) &&
                        stiPlugin.Report.Dictionary.Variables.Contains(webReportManager.Plugin.CultureParameter))
                    {
                        if (webReportManager.Plugin.SupportRuKz)
                        {
                            stiPlugin.Report[webReportManager.Plugin.CultureParameter] =
                                webReportManager.Plugin.InitializedKzCulture;
                        }
                        else
                        {
                            stiPlugin.Report[webReportManager.Plugin.CultureParameter] =
                                webReportManager.Plugin.InitializedCulture;
                        }
                    }

                    try
                    {
                        webReportManager.ShowReport();
                    }
                    catch (ConstraintException e)
                    {
                        var allErrors = webReportManager.Plugin.Table.DataSet?.GetAllErrors();
                        if (!string.IsNullOrEmpty(allErrors))
                        {
                            throw new Exception(allErrors, e);
                        }
                        var errors = webReportManager.Plugin.Table.GetErrors();
                        if (errors.Length > 0)
                        {
                            throw new Exception(errors.Select(r => r.RowError).Aggregate((v1, v2) => v1 + "; " + v2), e);
                        }
                        throw;
                    }

                    var section = ReportInitializerSection.GetReportInitializerSection();
                    if (section != null && !string.IsNullOrEmpty(section.PropSaveDataFile))
                    {
                        if (webReportManager.Plugin.Table.DataSet != null)
                        {
                            webReportManager.Plugin.Table.DataSet.WriteXml(section.PropSaveDataFile);
                        }
                        else
                        {
                            webReportManager.Plugin.Table.WriteXml(section.PropSaveDataFile);
                        }
                    }

                    if (HttpContext.Current != null && HttpContext.Current.Request.QueryString["GetDataSet"] == "on" && UserRoles.IsInRole(UserRoles.ADMIN))
                    {
                        using (var stream = new MemoryStream())
                        {
                            if (webReportManager.Plugin.Table.DataSet != null)
                            {
                                webReportManager.Plugin.Table.DataSet.WriteXml(stream);
                            }
                            else
                            {
                                webReportManager.Plugin.Table.WriteXml(stream);
                            }

                            stream.Position = 0;
                            PageHelper.DownloadFile(stream, "data.xml", HttpContext.Current.Response);
                        }
                    }

                    var autoExport = webReportPlugin as IReportAutoExport;

                    DBDataContext.AddViewReports(
                        Tools.Security.User.GetSID(),
                        HttpContext.Current?.User.Identity.Name ?? "anonymous",
                        HttpContext.Current?.User.Identity.Name ?? "anonymous",
                        ReportInitializerSection.GetReportInitializerSection().ReportPageViewer + "?ClassName=" + pluginName,
                        HttpContext.Current?.Request.Url.GetLeftPart(UriPartial.Authority) ?? "https://maxat",
                        Environment.MachineName,
                        useReturnStream || autoExport != null || expToWord || stiPlugin.AutoExportTo != null,
                        webReportManager.Plugin.GetType());

                    Log(logMonitor, guid, webReportManager);
                    if (useReturnStream)
                    {
                        StiExportFormat stiExportFormat;
                        try
                        {
                            stiExportFormat = (StiExportFormat)Enum.Parse(typeof(StiExportFormat), format);
                        }
                        catch (Exception)
                        {
                            var stiCustomExportType = (CustomExportType)Enum.Parse(typeof(CustomExportType), format);

                            return(ExportWithoutShow(
                                       webReportManager.Report,
                                       stiCustomExportType,
                                       true,
                                       out fileNameExtention));
                        }

                        fileNameExtention = WebReportManager.GetFileExtension(stiExportFormat);
                        return(ExportWithoutShow(webReportManager.Report, stiExportFormat, true));
                    }

                    //webReportManager.Report.EndRender += (sender, args) => LogMessages(webReportManager.Report, logMonitor);
                    if (autoExport != null)
                    {
                        autoExport.Export();
                    }

                    if (!expToWord && stiPlugin.AutoExportTo == null)
                    {
                        report.Report = webReportManager.Report;
                        page.Cache.Insert(report.Report.ReportName,
                                          report.Report,
                                          null,
                                          Cache.NoAbsoluteExpiration,
                                          new TimeSpan(0, 10, 0),
                                          CacheItemPriority.NotRemovable,
                                          null);
                        report.ResetCurrentPage();
                    }
                    else if (webReportPlugin.CustomExportType != CustomExportType.None)
                    {
                        return(ExportWithoutShow(
                                   webReportManager.Report,
                                   webReportPlugin.CustomExportType,
                                   false,
                                   out fileNameExtention));
                    }
                    else if (stiPlugin.AutoExportTo != null)
                    {
                        return(ExportWithoutShow(webReportManager.Report, stiPlugin.AutoExportTo.Value, false));
                    }
                    else
                    {
                        return(ExportWithoutShow(webReportManager.Report, StiExportFormat.Word2007, false));
                    }
                }
            }
            finally
            {
                Thread.CurrentThread.CurrentUICulture = originalUICulture;
                Thread.CurrentThread.CurrentCulture   = originalCulture;
            }

            return(null);
        }
Exemple #24
0
        static ReportResultPage()
        {
            WebInitializer.Initialize();
//            StiWebViewer.ExportNameRtf = "Microsoft Word";
//            StiWebViewer.ExportNameWord2007 = "Microsoft Word 2007";
        }
Exemple #25
0
 static ReportingServicesViewer()
 {
     WebInitializer.Initialize();
 }
Exemple #26
0
 static WebSpecificInstances()
 {
     WebInitializer.Initialize();
 }
        private void LoadFiltersState()
        {
            var sid = GetSidBytes();
            // Loading user dependend filters state settings
            // In case there is no user setting apply default settings
            StorageValues storageValues = StorageValues.GetStorageValues(string.Format("{0}_{1}", Page.AppRelativeVirtualPath, ClientID), sid);

            if (storageValues != null)
            {
                foreach (ColumnFilterStorage storage in ColumnFilterStorages)
                {
                    storageValues.SetStorage(storage);
                }
            }
            else
            {
                WebInitializer.Initialize();
                foreach (ColumnFilterStorage storage in ColumnFilterStorages)
                {
                    ColumnFilterType columnFilterType = (ColumnFilterType)(DataSetResourceManager.GetColumnExtProperty(
                                                                               dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_CONDITION) ?? ColumnFilterType.None);
                    if (columnFilterType != ColumnFilterType.None)
                    {
                        if (!dataTable.Columns.Contains(storage.Name))
                        {
                            continue;
                        }
                        object[] values = new object[2];
                        values[0] = DataSetResourceManager.GetColumnExtProperty(dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_VALUE_1) ?? null;
                        values[1] = DataSetResourceManager.GetColumnExtProperty(dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_VALUE_2) ?? null;

                        string codeField = (String)DataSetResourceManager.GetColumnExtProperty(dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_VALUE_CODE_FIELD);

                        if (storage.IsRefBound && !string.IsNullOrEmpty(codeField))
                        {
                            for (int i = 0; i < values.Length; i++)
                            {
                                if (values[i] != null)
                                {
                                    DataTable table = (DataTable)storage.RefDataSource;

                                    QueryConditionList queryConditionList = new QueryConditionList();
                                    QueryCondition     queryCondition     = new QueryCondition(codeField, ColumnFilterType.Equal, values[i], null);
                                    queryConditionList.Add(queryCondition);
                                    Type tableAdapterType = TableAdapterTools.GetTableAdapterType(table.GetType());

                                    QueryGenerator queryGenerator;

                                    if (table.Columns.IndexOf("dateEnd") != -1 && table.Columns.IndexOf("dateStart") != -1)
                                    {
                                        Component adapter = HistoricalData.GetTableAdapterToHistoricalData("dateEnd", "dateStart", DateTime.Now, tableAdapterType, 0);
                                        queryGenerator = new QueryGenerator(adapter);
                                    }
                                    else
                                    {
                                        queryGenerator = new QueryGenerator(table);
                                    }

                                    queryGenerator.TopCount = 1;
                                    queryGenerator.Fill(table, queryConditionList);
                                    if (table.Rows.Count != 0)
                                    {
                                        values[i] = table.Rows[0][storage.ValueColumn];
                                    }
                                }
                            }
                        }
                        storage.FilterType = columnFilterType;
                        try
                        {
                            for (int i = 0; i != 2; i++)
                            {
                                if (values[i] != null)
                                {
                                    storage.SetValue(i, Convert.ChangeType(values[i], storage.DataType));
                                }
                            }
                        }
                        catch (InvalidCastException)
                        {
                        }
                    }
                }
            }
        }
 public static void SetStorageValues(string key, byte[] sid, StorageValues values)
 {
     WebInitializer.Initialize();
     SetStorageValues(SpecificInstances.DbFactory.CreateConnection(), SpecificInstances.DbConstants.SqlParameterPrefix, key, sid, values);
 }
Exemple #29
0
 protected override void OnPreInit(EventArgs e)
 {
     WebInitializer.Initialize();
     base.OnPreInit(e);
     HttpContext.Current.Items["CurrentPage"] = this;
 }
Exemple #30
0
        public static Stream GetReport(bool useReturnStream, string pluginName, string guid,
                                       StorageValues storageValues, string culture, Page page, string format, string command,
                                       LogMonitor logMonitor, ServerReport report, out string fileNameExtention, bool RoleCheck)
        {
            fileNameExtention = "";
            WebInitializer.Initialize();
            report = ReportViewerInitializer(report);
            var webReportManager = new WebReportManager(new TreeView());

            if (string.IsNullOrEmpty(pluginName))
            {
                return(null);
            }
            webReportManager.RoleCheck = RoleCheck;
            webReportManager.Plugin    = webReportManager.GetPlugins()[pluginName];
            webReportManager.Plugin.InitializeReportCulture(culture);
            var webReportPlugin = (IWebReportPlugin)webReportManager.Plugin;

            webReportPlugin.Page = page;
            webReportManager.CreateView();
            webReportManager.InitValues(storageValues, true);
            var list = new List <ReportParameter>();

            foreach (var reportCondition in webReportManager.Plugin.Conditions)
            {
                var conditions = reportCondition.GetQueryConditions().ToList();
                if (conditions.Count == 0)
                {
                    list.Add(new ReportParameter(reportCondition.ColumnFilter.GetStorage().Name, (string)null, false));
                }
                else
                {
                    foreach (var condition in conditions)
                    {
                        if (condition.Parameters.Length == 0)
                        {
                            throw new Exception("Условие без значения не поддерживаются при формировании отчета");
                        }
                        var values = condition.GetParamValues().Select(r => r.ToString()).ToArray();
                        list.Add(new ReportParameter(condition.ColumnName, values, false));
                    }
                }
            }

            if (!string.IsNullOrEmpty(webReportManager.Plugin.CultureParameter))
            {
                if (webReportManager.Plugin.SupportRuKz)
                {
                    list.Add(new ReportParameter(webReportManager.Plugin.CultureParameter, webReportManager.Plugin.InitializedKzCulture.ToString(), false));
                }
                else
                {
                    list.Add(new ReportParameter(webReportManager.Plugin.CultureParameter, webReportManager.Plugin.InitializedCulture, false));
                }
            }
            //+= потому что инициализируется папка в которой лежат отчеты
            report.ReportPath += ((ISqlReportingServicesPlugin)webReportManager.Plugin).ReportUrl;
            report.SetParameters(list);

            Log(logMonitor, guid, webReportManager);

            var export = !string.IsNullOrEmpty(format) && "render".Equals(command, StringComparison.OrdinalIgnoreCase);

            DBDataContext.AddViewReports(
                Tools.Security.User.GetSID(),
                HttpContext.Current?.User.Identity.Name ?? "anonymous",
                HttpContext.Current?.User.Identity.Name ?? "anonymous",
                ReportInitializerSection.GetReportInitializerSection().ReportPageViewer + "?ClassName=" + webReportManager.Plugin.GetType().FullName,
                HttpContext.Current?.Request.Url.GetLeftPart(UriPartial.Authority) ?? "https://maxat",
                Environment.MachineName,
                export,
                webReportManager.Plugin.GetType());

            if (export)
            {
                string mimeType;
                if (useReturnStream)
                {
                    return(report.Render(format, "", null, out mimeType, out fileNameExtention));
                }

                PageHelper.DownloadFile(
                    report.Render(format, "", null, out mimeType, out fileNameExtention),
                    webReportManager.Plugin.Description + "." + fileNameExtention, HttpContext.Current.Response);
            }

            return(null);
        }