示例#1
0
        public override void Patch(OlxPatcher patcher, Config config, Profile profile, EdxCourse edxCourse)
        {
            var videoJson = string.Format("{0}/{1}", Dir, config.Video);
            var video     = File.Exists(videoJson)
                                ? JsonConvert.DeserializeObject <Video>(File.ReadAllText(videoJson))
                                : new Video {
                Records = new Record[0]
            };

            VideoHistory.UpdateHistory(Dir, video);
            var guids = Guids == null ? null : Guids.Split(',').Select(Utils.GetNormalizedGuid).ToList();

            if (config.Video != null && File.Exists(string.Format("{0}/{1}", Dir, config.Video)))
            {
                var videoComponents = video
                                      .Records
                                      .Where(x => guids == null || guids.Contains(Utils.GetNormalizedGuid(x.Guid)))
                                      .Select(x => new VideoComponent(Utils.GetNormalizedGuid(x.Guid), x.Data.Name, x.Data.Id));

                patcher.PatchComponents(
                    edxCourse,
                    videoComponents,
                    guids != null || !SkipExistingGuids
                    );
            }
        }
示例#2
0
        public async Task OnPostAsync()
        {
            await Task.Delay(500);

            Guids.Add(PostGuid);
            PostGuid = Guid.NewGuid().ToString();
        }
示例#3
0
        /// <summary>
        ///     Adds a <see cref="NamedPropertyTag" />
        /// </summary>
        /// <remarks>
        ///     Only support for properties by ID for now.
        /// </remarks>
        /// <param name="mapiTag"></param>
        /// <param name="obj"></param>
        internal void AddProperty(NamedPropertyTag mapiTag, object obj)
        {
            // Named property field 0000. 0x8000 + property offset
            //_topLevelProperties.AddProperty(new PropertyTag((ushort)(0x8000 + _namedPropertyIndex++), mapiTag.Type), obj);

            var propertyIndex = (ushort)(0x8000 + this.Count);
            var kind          = mapiTag.Name.StartsWith("PidName") ? PropertyKind.Name : PropertyKind.Lid;
            var namedProperty = new NamedProperty
            {
                NameIdentifier = kind == PropertyKind.Lid ? mapiTag.Id : propertyIndex,
                Guid           = mapiTag.Guid,
                Kind           = kind,
                Name           = mapiTag.Name.Replace("PidName", "").Replace("PidLid", ""),
                NameSize       = (uint)(kind == PropertyKind.Name ? mapiTag.Name.Length : 0)
            };

            if (mapiTag.Guid != PropertySets.PS_MAPI &&
                mapiTag.Guid != PropertySets.PS_PUBLIC_STRINGS &&
                !Guids.Contains(mapiTag.Guid))
            {
                Guids.Add(mapiTag.Guid);
            }

            _topLevelProperties.AddProperty(new PropertyTag(propertyIndex, mapiTag.Type), obj);

            Add(namedProperty);
        }
        public override void Publish(TextWriter writer)
        {
            Console.WriteLine();
            if (Guids == null || !Guids.Any())
            {
                writer.WriteLine("No guids to analyze");
                return;
            }

            writer.WriteLine("Generated GUIDs:");

            foreach (var guid in Guids)
            {
                writer.WriteLine(guid);
            }

            Console.WriteLine();
            if (CommonSequences == null || !CommonSequences.Any())
            {
                writer.WriteLine("No matching substrings");
                return;
            }

            writer.WriteLine("Max common strings for 3 and more GUIDs:");
            foreach (var value in CommonSequences)
            {
                writer.WriteLine(value);
            }
            Console.WriteLine();
        }
示例#5
0
        private async Task RefreshGuids()
        {
            tbx_tip.Text = "正在初始化验证码";
            HttpMessage resp = await LoginHelper.GetGuids();

            switch (resp.statusCode)
            {
            case HttpStatusCode.OK:
                Guids guids = resp.data as Guids;
                if (guids != null)
                {
                    tbx_tip.Text        = "正在加载验证码";
                    this.guids          = guids;
                    this.url_login_vali = LoginHelper.GetLoginValiPicUrl(guids.ImgGuid);
                    var image = await HttpHelper.GetPicAsync(this.url_login_vali);

                    if (image != null)
                    {
                        img_vali.Source    = image;
                        tbx_tip.Visibility = Visibility.Hidden;
                    }
                    else
                    {
                        tbx_tip.Text = "验证码加载失败,点击刷新";
                    }
                }
                break;

            default:
                tbx_tip.Text = "异常错误,点击刷新";
                Debug.WriteLine(resp.data.ToString(), "异常错误!");
                break;
            }
        }
示例#6
0
        public UrlGenerator(Uri uri, int number)
        {
            Uri = uri;

            for (var i = 0; i < number; i++)
            {
                Guids.Add(Guid.NewGuid());
            }
        }
示例#7
0
        public UrlGenerator(Uri uri, int number, Guid guidToCopy)
        {
            Uri = uri;

            for (var i = 0; i < number; i++)
            {
                Guids.Add(guidToCopy);
            }
        }
示例#8
0
        public void TestShouldCreateTimestamp_Validate_Invalid()
        {
            // Given
            var now    = new DateTime(1850, 12, 21, 7, 7, 7);
            var origin = Origin.Create(Guids.Two(), nameof(TimestampTests), nameof(TestShouldCreateTimestamp_Validate_Invalid));

            // When
            var result = Timestamp.Create(now, origin);

            // Then
            Assert.IsTrue(result.IsInvalid());
        }
示例#9
0
        public void TestShouldCreateText_Validate_Invalid()
        {
            // Given
            var    origin = Origin.Create(Guids.One(), nameof(TimestampTests), nameof(TestShouldCreateText_Validate_Valid));
            string str    = "  ";

            // When
            var result = Text.Create(str, origin);

            // Then
            Assert.IsTrue(result.IsInvalid());
        }
        /// <summary>
        /// Configures the host to use app center
        /// </summary>
        /// <param name="hostBuilder">The host builder</param>
        /// <returns>The host builder</returns>
        public static IHostBuilder UseAppCenter(this IHostBuilder hostBuilder)
        {
            return(hostBuilder
                   .ConfigureServices((hostContext, services) =>
            {
#if !DEBUG
                var sp = services.BuildServiceProvider();
                var deviceProvider = sp.GetService <IDeviceProvider>();

                AppCenter.Start(Guids.GetSecureGuid($"ChromaControl.{deviceProvider.Name}.AppCenter").ToString(), typeof(Analytics), typeof(Crashes));
#endif
            }));
        }
示例#11
0
        public void TestShouldCreateTimestamp_Validate_Func_Invalid()
        {
            // Given
            Func <DateTime> now() => () => new DateTime(1899, 12, 21, 7, 7, 7);

            var origin = Origin.Create(Guids.Four(), nameof(TimestampTests), nameof(TestShouldCreateTimestamp_Validate_Func_Invalid));

            // When
            var result = Timestamp.Create(now(), origin);

            // Then
            Assert.IsTrue(result.IsInvalid());
        }
示例#12
0
        public void TestShouldCreateText_Validate_Valid()
        {
            // Given
            var    origin = Origin.Create(Guids.One(), nameof(TimestampTests), nameof(TestShouldCreateText_Validate_Valid));
            string str    = "Test";

            // When
            var result = Text.Create(str, origin);

            // Then
            Assert.IsTrue(result.IsValid);
            Assert.AreEqual(str, result.GetOrException().ToString());
        }
示例#13
0
        public void TestShouldCreateAdd_Update()
        {
            // Given
            var add = Adds.Create();

            // When
            var result = add.Create(Guids.Nine());

            // Then
            var updated = (Add)result;

            Assert.AreEqual(Guids.Nine(), updated.MessageId);
            Assert.AreEqual(add.Name, updated.Name);
        }
示例#14
0
        public void TestShouldCreateRequest_None()
        {
            // Given
            var message = (Message.Create(Guids.Two(),
                                          "{\"name\": \"Jane Doe\"}",
                                          new DateTime(2021, 1, 1),
                                          MessageTypes.Unknown));

            // When
            var result = message.CreateRequest();

            // Then
            Assert.IsTrue(result.IsNone);
        }
示例#15
0
        public void TestShouldCreateTimestamp_Validate_Valid()
        {
            // Given
            var now    = new DateTime(2020, 12, 21, 7, 7, 7);
            var origin = Origin.Create(Guids.One(), nameof(TimestampTests), nameof(TestShouldCreateTimestamp_Validate_Valid));

            // When
            var result = Timestamp.Create(now, origin);

            // Then
            Assert.IsTrue(result.IsValid);
            DateTime actual = result.GetOrException();

            Assert.AreEqual(now, actual);
        }
示例#16
0
        private static void CreateTempDir()
        {
            Directory.CreateDirectory(_TempDir);

            FSW = new FileSystemWatcher(_TempDir);

            FSW.Deleted += (sender, e) =>
            {
                if (Guids.Contains(e.Name))
                {
                    Guids.Remove(e.Name);
                }
            };

            FSW.EnableRaisingEvents = true;
        }
示例#17
0
        internal string MakeNameUnique(string name)
        {
            if (!Guids.ContainsKey(name))
            {
                return(name);
            }

            string result;
            int    count = 1;

            do
            {
                result = string.Format("{0}({1})", name, count);
                count++;
            } while (Guids.ContainsKey(result));

            return(result);
        }
示例#18
0
        public void TestShouldCreateRequest_Remove()
        {
            // Given
            var message = (Message.Create(Guids.Two(),
                                          "{\"id\": \"5998b4d5-ff78-415f-9ffa-62df1e27dfe8\",\"name\": \"Jane Doe\"}",
                                          new DateTime(2021, 1, 1),
                                          MessageTypes.ThingRemoved));

            // When
            var result = message.CreateRequest();

            // Then
            Assert.IsTrue(result.IsSome);

            var remove = (Remove)result.GetOrException();

            Assert.AreEqual("5998b4d5-ff78-415f-9ffa-62df1e27dfe8", remove.Id.ToString());
            Assert.AreEqual(Guids.Two(), remove.MessageId);
        }
示例#19
0
        public void TestShouldCreateRequest_Add()
        {
            // Given
            var message = (Message.Create(Guids.Two(),
                                          "{\"name\": \"Jane Doe\"}",
                                          new DateTime(2021, 1, 1),
                                          MessageTypes.NewThing));

            // When
            var result = message.CreateRequest();

            // Then
            Assert.IsTrue(result.IsSome);

            var add = (Add)result.GetOrException();

            Assert.AreEqual("Jane Doe", add.Name);
            Assert.AreEqual(Guids.Two(), add.MessageId);
        }
示例#20
0
        public void SaveAndLoad()
        {
            Guid start = new Guid("5f346a0d-a38b-40c2-9289-44c5ffe40752");
            Guid end   = new Guid("4ea3a3fd-8892-46b5-8dca-370e64f6c4f9");

            Guids guids = new Guids {
                Start = start
            };

            JsonConvert.SerializeObject(guids, new GuidLowerNoDashJsonConverter()).ShouldBe(@"{""Start"":""5f346a0da38b40c2928944c5ffe40752"",""End"":null}");
            guids.End = end;
            JsonConvert.SerializeObject(guids, new GuidLowerNoDashJsonConverter()).ShouldBe(@"{""Start"":""5f346a0da38b40c2928944c5ffe40752"",""End"":""4ea3a3fd889246b58dca370e64f6c4f9""}");

            guids = JsonConvert.DeserializeObject <Guids>(@"{""Start"":""5f346a0da38b40c2928944c5ffe40752"",""End"":null}", new GuidLowerNoDashJsonConverter());
            guids.Start.ShouldBe(start);
            guids.End.ShouldBe(null);
            guids = JsonConvert.DeserializeObject <Guids>(@"{""Start"":""5f346a0da38b40c2928944c5ffe40752"",""End"":""4ea3a3fd889246b58dca370e64f6c4f9""}", new GuidLowerNoDashJsonConverter());
            guids.Start.ShouldBe(start);
            guids.End.ShouldBe(end);
        }
        public override void Patch(OlxPatcher patcher, Config config, Profile profile, EdxCourse edxCourse)
        {
            var ulearnDir = new DirectoryInfo(string.Format("{0}/{1}", Dir, config.ULearnCourseId));

            Console.WriteLine("Loading Ulearn course from {0}", ulearnDir.Name);
            var ulearnCourse = new CourseLoader().Load(ulearnDir);

            Console.WriteLine("Patching");
            var videoJson = string.Format("{0}/{1}", Dir, config.Video);
            var video     = File.Exists(videoJson)
                                ? JsonConvert.DeserializeObject <Video>(File.ReadAllText(videoJson))
                                : new Video {
                Records = new Record[0]
            };
            var videoHistory = VideoHistory.UpdateHistory(Dir, video);
            var videoGuids   = videoHistory.Records
                               .SelectMany(x => x.Data.Select(y => Tuple.Create(y.Id, x.Guid.GetNormalizedGuid())))
                               .ToDictionary(x => x.Item1, x => x.Item2);

            var guids = Guids?.Split(',').Select(Utils.GetNormalizedGuid).ToList();

            patcher.PatchVerticals(
                edxCourse,
                ulearnCourse.Slides
                .Where(s => !config.IgnoredUlearnSlides.Select(Guid.Parse).Contains(s.Id))
                .Where(s => guids == null || guids.Contains(s.NormalizedGuid))
                .Select(s => s.ToVerticals(
                            ulearnCourse.Id,
                            profile.UlearnUrl,
                            videoGuids,
                            config.LtiId,
                            CoursePackageRoot
                            ).ToArray()),
                guids != null || !SkipExistingGuids
                );
            if (Config.EmitSequentialsForInstructorNotes)
            {
                PatchInstructorsNotes(edxCourse, ulearnCourse, patcher.OlxPath);
            }
        }
示例#22
0
        static void Main(string[] args)
        {
            List <String> contactPoints = new List <String>();

            contactPoints.Add("127.0.0.1");
            IVideoDbDAO vdb = new VideoDbBasicImpl(contactPoints, "videodb");
            // Basic get of a user. This is using the string method of executing CQL
            User user = vdb.GetUserByUserNameUsingString("tcodd");

            Console.WriteLine("Get user by using CQL string: " + user);
            // Get the same user but with a prepared statement
            user = vdb.GetUserByUserNameUsingPreparedStatement("tcodd");
            Console.WriteLine("Get user by using prepared statement: " + user);
            // Add a new user
            User newUser = new User("cdate",
                                    "Chris",
                                    "Date",
                                    "*****@*****.**",
                                    "6cb75f65-2a9b-5279-8eb6-cf2201057c73",
                                    DateTime.Now,
                                    0,
                                    Guids.GenerateTimeBasedGuid());

            vdb.SetUserByPreparedStatement(newUser);

            // Get a list of videos. This uses the simple Async Read feature.
            List <Video> videosByTag = vdb.GetVideosByTagUsingAsyncRead("lol");

            foreach (Video video in videosByTag)
            {
                Console.WriteLine("Video by AsyncRead" + video);
            }
            // Get a list of videos. This uses a threaded Async Read feature.
            // This method will take a list of tags to query.
            List <String> tags = new List <String>();

            tags.Add("lol");
            tags.Add("cat");
            // We'll use the videoID to set a rating of 4
            vdb.SetRatingForVideo(new Guid("99051fe9-6a9c-46c2-b949-38ef78858dd0"), 4);
            // Iterate over the same list and get the overall rating
            foreach (Video video in videosByTag)
            {
                Console.Write("Video " + video.VideoName
                              + " had an average of ");
                // We'll use the videoID of each to get a rating
                Console.WriteLine(vdb.GetRatingForVideo(video.VideoId));
            }

            /*
             *      List<Video> videosByTagList = vdb.GetVideosByTagsUsingAsyncReadThreads(tags);
             *      for (Video video : videosByTagList) {
             *              Console.WriteLine("Video by AsyncRead Threads" + video);
             *      }
             *
             *      // Set a comment for one video. The underlying method will set on two
             *      // tables at the same time.
             *      vdb.GetCommentForVideo(
             *                      new Guid("99051fe9-6a9c-46c2-b949-38ef78858dd0"),
             *                      "tcodd", "Worst. Video. Ever.");
             */

            // Get a list of comments by VideoID, a UUID.
            List <Comment> comments = vdb.GetCommentsByVideoIdUsingPreparedStatement(
                new Guid("99051fe9-6a9c-46c2-b949-38ef78858dd0"));

            foreach (Comment comment in comments)
            {
                Console.WriteLine("Get comments by VideoID: " + comment);
            }

            // Get a list of comments by UserName
            comments = vdb.GetCommentsByUserNameUsingPreparedStatement("tcodd");
            foreach (Comment comment in comments)
            {
                Console.WriteLine("Get comments by UserName: "******"99051fe9-6a9c-46c2-b949-38ef78858dd0"),
                "tcodd");

            Console.WriteLine("Video timestamp of last stop event: " + videoTimestamp);


            // Close our connection and exit. Exit is required since we are running
            // threads.
            vdb.Close();
            return;
        }
示例#23
0
 private ushort GetGuidIndex(NamedProperty namedProperty)
 {
     return((ushort)(namedProperty.Guid == PropertySets.PS_MAPI ? 1
                     : namedProperty.Guid == PropertySets.PS_PUBLIC_STRINGS ? 2
                     : (Guids.IndexOf(namedProperty.Guid) + 3)));
 }
示例#24
0
 public override Guid Generate()
 {
     return(Guids.GetGuid());
 }
示例#25
0
 private static Guid?GetGuid(this SpecialFolders specialFolder) => Guids.ContainsKey(specialFolder) ? (Guid?)Guids[specialFolder] : null;
示例#26
0
 public static Add Create() => new Add
 {
     MessageId = Guids.Eight(), Name = "John Doe"
 };