public ActionResult Csv(ContentIdentifier cid, User user)
 {
     var helper = GetHelper(cid.PortletId.Value);
     DataTable dt;
     try
     {
         dt = GetData(helper, user.Username);
     }
     catch (Exception ex)
     {
         return View("Error",
                     new Error
                     {
                         ErrorMessage = "An error occurred while querying the database.",
                         Exception =
                             _userFacade.FindByUsername(user.Username).IsSiteAdmin
                                 ? ex.ToString().Replace("\n", "<br />")
                                 : String.Empty
                     });
     }
     var model = new SimpleQueryLiteral
                     {
                         Html = "<pre>" + OutputHelper.RenderCsv(dt,
                                                       helper.GetSetting("GOGridShowColumnHeadings", false).
                                                           BoolValue,
                                                       helper.GetSetting("ColumnLabels").Value) + "</pre>",
                         AllowExports = helper.GetSetting("GOAllowExports").BoolValue
                     };
     return View("Literal", model);
 }
Beispiel #2
0
        public ActionResult Literal(ContentIdentifier cid, User user)
        {
            var       helper = GetHelper(cid.PortletId.Value);
            DataTable dt;

            try
            {
                dt = GetData(helper);
            }
            catch (Exception ex)
            {
                return(View("Error",
                            new Error
                {
                    ErrorMessage = "An error occurred while querying the database.",
                    Exception =
                        _userFacade.FindByUsername(user.Username).IsSiteAdmin
                                        ? ex.ToString().Replace("\n", "<br />")
                                        : String.Empty
                }));
            }
            var model = new SimpleQueryLiteral
            {
                Html         = OutputHelper.RenderLiteral(dt, helper.GetSetting("ExportLiteralPattern", "{0}").Value),
                AllowExports = helper.GetSetting("GOAllowExports").BoolValue
            };

            return(View("Literal", model));
        }
        /// <summary>
        /// The cache item container is used to hold an internal entity in to the cache memory queue.
        /// </summary>
        /// <param name="id">The content identifier.</param>
        /// <param name="blob">The binary blob.</param>
        /// <param name="path">The relative file path.</param>
        /// <param name="hitCount">The historical hit count for the item.</param>
		public CacheItemContainer(ContentIdentifier id, byte[] blob, string path, long hitCount)
        {
            this.mID = id;
            this.mBlob = blob;
            this.mFilePath = path;
            this.mTotalHitCount = hitCount;
            mCreateDateTime = DateTime.Now;
        }
 public ActionResult Export(ContentIdentifier cid, User user)
 {
     var helper = GetHelper(cid.PortletId.Value);
     var model = new SimpleQueryExport
                     {
                         AllowExports = helper.GetSetting("GOAllowExports").BoolValue,
                         ExportTypes = AllowedExports(helper)
                     };
     return View(model);
 }
Beispiel #5
0
        public ActionResult Export(ContentIdentifier cid, User user)
        {
            var helper = GetHelper(cid.PortletId.Value);
            var model  = new SimpleQueryExport
            {
                AllowExports = helper.GetSetting("GOAllowExports").BoolValue,
                ExportTypes  = AllowedExports(helper)
            };

            return(View(model));
        }
Beispiel #6
0
    private bool connectToIgloo(ZoneId zoneId, ZoneDefinition zoneToJoin, Language language, string onJoinNotificationTag)
    {
        if (!startZoneTransition(zoneToJoin.SceneName, onJoinNotificationTag))
        {
            return(false);
        }
        ContentIdentifier contentIdentifier = generateContentIdentifier();

        targetWorldToJoin = null;
        Service.Get <INetworkServicesManager>().WorldService.JoinIgloo(zoneId, LocalizationLanguage.GetLanguageString(language), this);
        PreviousZone      = CurrentZone;
        CurrentZone       = zoneToJoin;
        CurrentInstanceId = zoneId.instanceId;
        return(IsConnecting);
    }
Beispiel #7
0
    private void onPostRoomPlayersResponse(PostRoomPlayersOperation operation, HttpResponse httpResponse)
    {
        signedJoinRoomData = operation.SignedJoinRoomData;
        string subContentVersion = new ContentIdentifier(signedJoinRoomData.Data.room).subContentVersion;

        if (subContentVersion != clubPenguinClient.ContentVersionDate.ToString("yyyy-MM-dd"))
        {
            DateTime dateTime = DateTime.Parse(subContentVersion);
            clubPenguinClient.ContentVersionDate = dateTime;
            Service.Get <EventDispatcher>().DispatchEvent(new WorldServiceEvents.ContentDateChanged(dateTime));
        }
        clubPenguinClient.GameServer.AddEventListener(GameServerEvent.ROOM_JOIN, onRoomJoin);
        clubPenguinClient.GameServer.AddEventListener(GameServerEvent.ROOM_JOIN_ERROR, onRoomJoinError);
        clubPenguinClient.GameServer.AddEventListener(GameServerEvent.ROOM_FULL, onRoomFull);
        clubPenguinClient.GameServer.JoinRoom(signedJoinRoomData);
    }
Beispiel #8
0
        public void ContainsURL_withValidURLString_returnsTrue()
        {
            Dictionary <String, Boolean> sampleStrings = new Dictionary <String, Boolean>();

            sampleStrings.Add("019avd23asvad8\nee www.g.com", true);
            sampleStrings.Add("https://a.a", false);
            sampleStrings.Add("https://example.me", false);
            sampleStrings.Add("http://www.example.com", true);
            sampleStrings.Add("w3.example.com", false);

            foreach (String sampleString in sampleStrings.Keys)
            {
                Assert.AreEqual(ContentIdentifier.ContainsURL(sampleString),
                                sampleStrings[sampleString]);
            }
        }
Beispiel #9
0
        public Task <CompilationResult> Compile(IFileInfo file, ITrace tracer)
        {
            Requires.NotNull(file, "file");
            Requires.NotNull(tracer, "tracer");

            // Generate a content id
            string contentId = ContentIdentifier.GenerateContentId(file);

            tracer.WriteLine("CompilationManager - Content ID: {0}", contentId);

            WeakReference <Type> cacheEntry;

            if (Cache.TryGetValue(contentId, out cacheEntry))
            {
                Type cached;
                if (cacheEntry.TryGetTarget(out cached))
                {
                    return(Task.FromResult(CompilationResult.FromCache(cached)));
                }
                else
                {
                    tracer.WriteLine("CompilationManager - Expired: {0}", contentId);
                    Cache.Remove(contentId);
                }
            }

            foreach (var compiler in _compilers)
            {
                if (compiler.CanCompile(file))
                {
                    tracer.WriteLine("CompilationManager - Selected compiler: '{0}'", compiler.GetType().Name);
                    return(CompileWith(compiler, contentId, file));
                }
            }

            return(Task.FromResult(CompilationResult.Failed(null, new[]
            {
                new CompilationMessage(
                    MessageLevel.Error,
                    Resources.DefaultCompilationManager_CannotFindCompiler,
                    new FileLocation(file.PhysicalPath ?? file.Name))
            })));
        }
Beispiel #10
0
    public bool ConnectToZone(string sceneName, string worldName = null, string onJoinNotificationTag = null)
    {
        ZoneDefinition zoneBySceneName = GetZoneBySceneName(sceneName);

        if (zoneBySceneName == null)
        {
            Log.LogError(this, "Attempting to join a zone that doesn't exist");
            return(false);
        }
        if (!startZoneTransition(sceneName, onJoinNotificationTag))
        {
            return(false);
        }
        PresenceData      component         = dataEntityCollection.GetComponent <PresenceData>(dataEntityCollection.LocalPlayerHandle);
        ContentIdentifier contentIdentifier = generateContentIdentifier();

        if (!string.IsNullOrEmpty(worldName))
        {
            targetWorldToJoin = worldName;
            ZoneId zoneId = new ZoneId();
            zoneId.name = zoneBySceneName.ZoneName;
            Service.Get <INetworkServicesManager>().WorldService.JoinRoomInWorld(new RoomIdentifier(worldName, Service.Get <Localizer>().Language, zoneId, contentIdentifier.ToString()), this);
        }
        else if (component != null && !string.IsNullOrEmpty(component.World))
        {
            targetWorldToJoin = component.World;
            ZoneId zoneId = new ZoneId();
            zoneId.name = zoneBySceneName.ZoneName;
            Service.Get <INetworkServicesManager>().WorldService.JoinRoomInWorld(new RoomIdentifier(component.World, Service.Get <Localizer>().Language, zoneId, contentIdentifier.ToString()), this);
        }
        else
        {
            targetWorldToJoin = null;
            Service.Get <INetworkServicesManager>().WorldService.JoinRoom(zoneBySceneName.ZoneName, contentIdentifier.ToString(), Service.Get <Localizer>().LanguageString, this);
        }
        PreviousZone      = CurrentZone;
        CurrentZone       = zoneBySceneName;
        CurrentInstanceId = "";
        return(IsConnecting);
    }
        /// <summary>
        /// The cache item container is used to hold an internal entity in to the cache memory queue.
        /// </summary>
        /// <param name="id">The content identifier.</param>
        /// <param name="path">The relative file path.</param>
        /// <param name="hitCount">The historical hit count for the item.</param>
		public CacheItemContainer(ContentIdentifier id, string path, long hitCount)
            : this(id, null, path, hitCount){}
Beispiel #12
0
        public ActionResult ExportFile(String fileType, ContentIdentifier cid, User user)
        {
            var           helper       = GetHelper(cid.PortletId.Value);
            List <String> allowedTypes = AllowedExports(helper);

            if (allowedTypes.Contains(fileType))
            {
                DataTable dt;
                try
                {
                    dt = GetData(helper);
                }
                catch (Exception ex)
                {
                    return(View("Error",
                                new Error
                    {
                        ErrorMessage = "An error occurred while querying the database.",
                        Exception =
                            _userFacade.FindByUsername(user.Username).IsSiteAdmin
                                                ? ex.ToString().Replace("\n", "<br />")
                                                : String.Empty
                    }));
                }
                var    strContentType = "text/plain"; // these defaults will be overwritten if we're successful
                var    strFilename    = "ErrorOutput.txt";
                byte[] byteArray;
                using (var mstream = new MemoryStream())
                {
                    using (var sw = new StreamWriter(mstream))
                    {
                        string fileName;
                        if (helper.GetSetting("QueryTitle").Value.Trim().Length > 0)
                        {
                            fileName = Regex.Replace(helper.GetSetting("QueryTitle").Value.Trim(), @"\W", "");
                        }
                        //remove non-alphanumeric characters from filename
                        else
                        {
                            fileName = "ExportedData";
                        }

                        switch (fileType)
                        {
                        case "Xls":
                            var dgResults = OutputHelper.CreateDataGrid();

                            OutputHelper.ConfigureDataGrid(ref dgResults,
                                                           dt,
                                                           helper.GetSetting("GOGridShowColumnHeadings", false).
                                                           BoolValue,
                                                           helper.GetSetting("GOGridAltRowColors", false).BoolValue,
                                                           helper.GetSetting("GOGridShowGridlines", false).BoolValue,
                                                           Convert.ToInt16(
                                                               helper.GetSetting("GOGridCellPadding", 5).Value),
                                                           helper.GetSetting("ColumnLabels").Value);


                            dgResults.DataSource = dt;
                            dgResults.DataBind();

                            var stringWrite = new StringWriter();
                            var htmlWrite   = new HtmlTextWriter(stringWrite);
                            dgResults.RenderControl(htmlWrite);

                            htmlWrite.Flush();

                            sw.WriteLine(stringWrite.ToString().Replace("\n", "").Replace("\r", "").Replace("  ", ""));
                            strContentType = "application/vnd.ms-excel";
                            strFilename    = fileName + ".xls";
                            break;

                        case "Xml":
                            sw.WriteLine(OutputHelper.RenderXml(dt));
                            strContentType = "text/xml";
                            strFilename    = fileName + ".xml";
                            break;

                        case "Csv":
                            sw.WriteLine(OutputHelper.RenderCsv(dt,
                                                                helper.GetSetting("GOGridShowColumnHeadings", false)
                                                                .
                                                                BoolValue,
                                                                helper.GetSetting("ColumnLabels").Value));
                            strContentType = "text/csv";
                            strFilename    = fileName + ".csv";
                            break;

                        case "Literal":
                            sw.WriteLine(OutputHelper.RenderLiteral(dt,
                                                                    helper.GetSetting("ExportLiteralPattern", "{0}")
                                                                    .
                                                                    Value));
                            strContentType = "text/plain";
                            strFilename    = fileName + ".txt";
                            break;
                        }

                        sw.Flush();
                        sw.Close();

                        byteArray = mstream.ToArray();

                        mstream.Flush();
                        mstream.Close();
                    }
                }
                return(File(byteArray, strContentType, strFilename));
            }

            return(View("Error", new Error {
                ErrorMessage = "File Export Type Not Allowed"
            }));
        }
        public ActionResult ExportFile(String fileType, ContentIdentifier cid, User user)
        {
            var helper = GetHelper(cid.PortletId.Value);
            List<String> allowedTypes = AllowedExports(helper);
            if (allowedTypes.Contains(fileType))
            {
                DataTable dt;
                try
                {
                    dt = GetData(helper, user.Username);
                }
                catch (Exception ex)
                {
                    return View("Error",
                                new Error
                                    {
                                        ErrorMessage = "An error occurred while querying the database.",
                                        Exception =
                                            _userFacade.FindByUsername(user.Username).IsSiteAdmin
                                                ? ex.ToString().Replace("\n", "<br />")
                                                : String.Empty
                                    });
                }
                var strContentType = "text/plain"; // these defaults will be overwritten if we're successful
                var strFilename = "ErrorOutput.txt";
                byte[] byteArray;
                using (var mstream = new MemoryStream())
                {

                    using (var sw = new StreamWriter(mstream))
                    {
                        string fileName;
                        if (helper.GetSetting("QueryTitle").Value.Trim().Length > 0)
                            fileName = Regex.Replace(helper.GetSetting("QueryTitle").Value.Trim(), @"\W", "");
                            //remove non-alphanumeric characters from filename
                        else
                            fileName = "ExportedData";

                        switch (fileType)
                        {
                            case "Xls":
                                var dgResults = OutputHelper.CreateDataGrid();

                                OutputHelper.ConfigureDataGrid(ref dgResults,
                                                               dt,
                                                               helper.GetSetting("GOGridShowColumnHeadings", false).
                                                                   BoolValue,
                                                               helper.GetSetting("GOGridAltRowColors", false).BoolValue,
                                                               helper.GetSetting("GOGridShowGridlines", false).BoolValue,
                                                               Convert.ToInt16(
                                                                   helper.GetSetting("GOGridCellPadding", 5).Value),
                                                               helper.GetSetting("ColumnLabels").Value);

                                dgResults.DataSource = dt;
                                dgResults.DataBind();

                                var stringWrite = new StringWriter();
                                var htmlWrite = new HtmlTextWriter(stringWrite);
                                dgResults.RenderControl(htmlWrite);

                                htmlWrite.Flush();

                                sw.WriteLine(stringWrite.ToString().Replace("\n", "").Replace("\r", "").Replace("  ", ""));
                                strContentType = "application/vnd.ms-excel";
                                strFilename = fileName + ".xls";
                                break;
                            case "Xml":
                                sw.WriteLine(OutputHelper.RenderXml(dt));
                                strContentType = "text/xml";
                                strFilename = fileName + ".xml";
                                break;
                            case "Csv":
                                sw.WriteLine(OutputHelper.RenderCsv(dt,
                                                                    helper.GetSetting("GOGridShowColumnHeadings", false)
                                                                        .
                                                                        BoolValue,
                                                                    helper.GetSetting("ColumnLabels").Value));
                                strContentType = "text/csv";
                                strFilename = fileName + ".csv";
                                break;
                            case "Literal":
                                sw.WriteLine(OutputHelper.RenderLiteral(dt,
                                                                        helper.GetSetting("ExportLiteralPattern", "{0}")
                                                                            .
                                                                            Value));
                                strContentType = "text/plain";
                                strFilename = fileName + ".txt";
                                break;

                        }

                        sw.Flush();
                        sw.Close();

                        byteArray = mstream.ToArray();

                        mstream.Flush();
                        mstream.Close();
                    }
                }
                return File(byteArray, strContentType, strFilename);
            }

            return View("Error", new Error { ErrorMessage = "File Export Type Not Allowed" });
        }
Beispiel #14
0
        public ActionResult Index(ContentIdentifier cid, User user)
        {
            var helper = GetHelper(cid.PortletId.Value);

            ViewBag.Title = helper.GetSetting("QueryTitle").Value;

            switch (helper.GetSetting("GOOutput").Value)
            {
            case "grid":
                DataTable dt;
                try
                {
                    dt = GetData(helper);

                    if (Convert.ToInt32(helper.GetSetting("RowLimit", 0).Value) > 0)
                    {
                        dt = dt.AsEnumerable().Take(Convert.ToInt32(helper.GetSetting("RowLimit", 0).Value)).CopyToDataTable();
                    }
                }
                catch (Exception ex)
                {
                    return(View("Error",
                                new Error
                    {
                        ErrorMessage = "An error occurred while querying the database.",
                        Exception =
                            _userFacade.FindByUsername(user.Username).IsSiteAdmin
                                                    ? ex.ToString().Replace("\n", "<br />")
                                                    : String.Empty
                    }));
                }
                var gridmodel = new SimpleQueryDataGrid
                {
                    CellPadding       = Convert.ToInt16(helper.GetSetting("GOSGridCellPadding", 5).Value),
                    ShowAltColors     = helper.GetSetting("GOGridAltRowColors", false).BoolValue,
                    ShowColumnHeaders =
                        helper.GetSetting("GOGridShowColumnHeadings", false).BoolValue,
                    ShowGridlines = helper.GetSetting("GOGridShowGridlines", false).BoolValue,
                    AllowExports  = helper.GetSetting("GOAllowExports").BoolValue,
                    Data          = dt
                };
                return(View("DataGrid", gridmodel));

            case "masterdetail":
                List <SimpleQueryDataRow> dataRows;
                try
                {
                    dataRows = GetMasterDetailData(helper, user.Username);
                }
                catch (Exception ex)
                {
                    return(View("Error",
                                new Error
                    {
                        ErrorMessage = "An error occurred while querying the database.",
                        Exception =
                            _userFacade.FindByUsername(user.Username).IsSiteAdmin
                                                    ? ex.ToString().Replace("\n", "<br />")
                                                    : String.Empty
                    }));
                }
                var mdmodel = new SimpleQueryMasterDetail
                {
                    AllowExports     = helper.GetSetting("GOAllowExports").BoolValue,
                    MasterDetailData = dataRows
                };
                return(View("MasterDetail", mdmodel));

            case "xml":
                return(Xml(cid, user));

            case "csv":
                return(Csv(cid, user));

            case "literal":
                return(Literal(cid, user));

            case "none":
                return(View("Error", new Error {
                    ErrorMessage = "Results for this portlet are not enabled for JICS Go"
                }));

            default:
                return(View("Error", new Error {
                    ErrorMessage = "This portlet has not yet been configured."
                }));
            }
        }
        public ActionResult Index(ContentIdentifier cid, User user)
        {
            var helper = GetHelper(cid.PortletId.Value);

            ViewBag.Title = helper.GetSetting("QueryTitle").Value;

            switch (helper.GetSetting("GOOutput").Value)
            {
                case "grid":
                    DataTable dt;
                    try
                    {
                        dt = GetData(helper, user.Username);

                        if (Convert.ToInt32(helper.GetSetting("RowLimit", 0).Value) > 0)
                            dt = dt.AsEnumerable().Take(Convert.ToInt32(helper.GetSetting("RowLimit", 0).Value)).CopyToDataTable();
                    }
                    catch (Exception ex)
                    {
                        return View("Error",
                                    new Error
                                        {
                                            ErrorMessage = "An error occurred while querying the database.",
                                            Exception =
                                                _userFacade.FindByUsername(user.Username).IsSiteAdmin
                                                    ? ex.ToString().Replace("\n", "<br />")
                                                    : String.Empty
                                        });
                    }
                    var gridmodel = new SimpleQueryDataGrid
                                    {
                                        CellPadding = Convert.ToInt16(helper.GetSetting("GOSGridCellPadding", 5).Value),
                                        ShowAltColors = helper.GetSetting("GOGridAltRowColors", false).BoolValue,
                                        ShowColumnHeaders =
                                            helper.GetSetting("GOGridShowColumnHeadings", false).BoolValue,
                                        ShowGridlines = helper.GetSetting("GOGridShowGridlines", false).BoolValue,
                                        AllowExports = helper.GetSetting("GOAllowExports").BoolValue,
                                        Data = dt
                                    };
                    return View("DataGrid", gridmodel);
                case "masterdetail":
                    List<SimpleQueryDataRow> dataRows;
                    try
                    {
                        dataRows = GetMasterDetailData(helper, user.Username);
                    }
                    catch (Exception ex)
                    {
                        return View("Error",
                                    new Error
                                        {
                                            ErrorMessage = "An error occurred while querying the database.",
                                            Exception =
                                                _userFacade.FindByUsername(user.Username).IsSiteAdmin
                                                    ? ex.ToString().Replace("\n","<br />")
                                                    : String.Empty
                                        });
                    }
                    var mdmodel = new SimpleQueryMasterDetail
                                      {
                                          AllowExports = helper.GetSetting("GOAllowExports").BoolValue,
                                          MasterDetailData = dataRows
                                      };
                    return View("MasterDetail", mdmodel);
                case "xml":
                    return Xml(cid, user);
                case "csv":
                    return Csv(cid, user);
                case "literal":
                    return Literal(cid, user);
                case "none":
                    return View("Error", new Error { ErrorMessage = "Results for this portlet are not enabled for JICS Go" });
                default:
                    return View("Error", new Error { ErrorMessage = "This portlet has not yet been configured." });
            }
        }
        public static byte[] Deserialize(ContentIdentifier Identifier, Guid ApplicationID, DirectoryInfo dInfo)
        {
            Rfc2898DeriveBytes pwdGen =
                new Rfc2898DeriveBytes(Identifier.CombinedID, ApplicationID.ToByteArray(), 1000);

            RijndaelManaged rjn = new RijndaelManaged();

            string dir = dInfo.FullName;

            using (ICryptoTransform eTransform = rjn.CreateDecryptor(pwdGen.GetBytes(32), pwdGen.GetBytes(16)))
            {
                using (FileStream ms = new FileStream(Path.Combine(dir, Identifier.CreateItemIDString()), FileMode.Open))
                {
                    using (CryptoStream cs = new CryptoStream(ms, eTransform, CryptoStreamMode.Read))
                    {
                        int len = (((cs.ReadByte() | (cs.ReadByte() << 8)) | (cs.ReadByte() << 0x10)) | (cs.ReadByte() << 0x18));

                        byte[] data = new byte[len];
                        cs.Read(data, 0, data.Length);

                        return data;
                    }
                }
            }
        }
 /// <summary>
 /// The cache item container is used to hold an internal entity in to the cache memory queue.
 /// </summary>
 /// <param name="id">The content identifier.</param>
 /// <param name="blob">The binary blob.</param>
 /// <param name="hitCount">The historical hit count for the item.</param>
 public CacheItemContainer(ContentIdentifier id, byte[] blob, long hitCount)
     : this(id, blob, null, hitCount){}