Пример #1
0
        public static void LogGen(Dictionary<Visualizers.Types, Appender> loggers,
            Visualizers.Types typelog,
            Dictionary<Rules, string> rules,
            KeyValuePair<Activity, ActivityCont> dicitem)
        {
            var item = dicitem.Key;
            var action = "A";

            var logEvent = Visualizers.TypeLogEvent[typelog]
                .GetConstructor(Type.EmptyTypes)
                    .Invoke(Type.EmptyTypes) as LogEvent;

            var po = new PatternOption();

            po.Post = item;
            po.Type = TypePattern.post;
            po.Pattern = rules[Rules.NotShare];

            po.SharePath = ReplacePattern(po);

            po.Type = (TypePattern)Enum.Parse(typeof(TypePattern), item.Verb, true);
            po.Type = TypePattern.post;
            po.Pattern = rules[Rules.Post];

            var sharafile = po.PostFileName;

            po.PostFileName = ReplacePattern(po);
            logEvent.User = typelog == Visualizers.Types.Code_swarm ? curWord : GetActor(item.Actor, typelog);
            logEvent.Date = DateTime.Parse(item.Published);
            logEvent.Action = typelog == Visualizers.Types.Logstalgia ? "post" : action;
            logEvent.FileName = po.PostFileName;
            if (logEvent is LogstalgiaEvent)
                (logEvent as LogstalgiaEvent).Size = item.Object != null ? item.Object.Content.Length.ToString() : "100";
            if ((logEvent is GephiLogEvent)) {
                (logEvent as GephiLogEvent).From = curWord;
            }

            loggers[typelog].Append(logEvent);
        }
Пример #2
0
        private void Generate(string idProfile, StateControl sc, Visualizers.Types flags, Dictionary<Visualizers.Types, string> filenames)
        {
            var sett = new GeneratorSetting() {
                ProfileID = /*"101113754039426612780"*/idProfile,
                Rules = rules,
                VisLogs = (Visualizers.Types)flags,
                LogFiles = filenames,
                Methods = new Dictionary<Visualizers.Types, GeneratorLogsMeth> {
                    //UD
                    {Visualizers.Code_swarm, UDGenerator.LogGen},
                    {Visualizers.Gource, Generator.LogGen},
                    {Visualizers.Logstalgia, Generator.LogGen},
                    {Visualizers.Gephi, Generator.LogGen},
                },
                MaxResults = Convert.ToInt32(nudMaxRes.Value),
                MaxComments = Convert.ToInt32(nudMaxComment.Value),
                MaxPluses = Convert.ToInt32(nudMaxPlus.Value),
                MaxReshares = Convert.ToInt32(nudMaxReshare.Value),
                Deep = checkBox1.Checked ? Convert.ToInt32(nudDeep.Value) : 0
            };

            //UD
            if (checkBox2.Checked) {
                new FollowersGenerator(apikey.Text, sc).Run(sett);
            }
            else {
                if (checkBox1.Checked)
                    (Program.OAuth2 != null ? new RGenerator(Program.OAuth2, sc) : new RGenerator(apikey.Text, sc)).Run(sett);
                else
                    (Program.OAuth2 != null ? new RGenerator(Program.OAuth2, sc) : new Generator(apikey.Text, sc)).Run(sett);
            }
        }
Пример #3
0
 protected static string GetActor(Google.Apis.Plus.v1.Data.Person actor, Visualizers.Types logType)
 {
     return logType == Visualizers.Types.Code_swarm ? actor.Id : actor.DisplayName;
 }
Пример #4
0
        public static void LogGen(Dictionary<Visualizers.Types, Appender> loggers, 
            Visualizers.Types typelog,
            Dictionary<Rules, string> rules,
            KeyValuePair<Activity, ActivityCont> dicitem)
        {
            var item = dicitem.Key;
            var action = "A";

            var logEvent = Visualizers.TypeLogEvent[typelog]
                .GetConstructor(Type.EmptyTypes)
                    .Invoke(Type.EmptyTypes) as LogEvent;

            var po = new PatternOption();

            var share = dicitem.Value.Share;
            if (share != null) {
                po.Post = item;
                po.Share = share;
                po.Pattern = rules[Rules.SharePath];
                po.Type = TypePattern.share;

                po.SharePath = ReplacePattern(po);

                po.Pattern = rules[Rules.ShareName];
                po.PostFileName = po.SharePath + ReplacePattern(po);
                po.PostFileName = po.PostFileName.Replace("//", "/");

                logEvent.User = GetActor(share.Actor, typelog);
                logEvent.Date = DateTime.Parse(share.Published);
                logEvent.Action = typelog == Visualizers.Types.Logstalgia ? "share" : action;
                logEvent.FileName = po.PostFileName;
                if (logEvent is LogstalgiaEvent)
                    (logEvent as LogstalgiaEvent).Size =
                        !string.IsNullOrWhiteSpace(share.Title) ?
                            share.Title.Length.ToString() :
                                string.IsNullOrWhiteSpace(item.Title) ?
                                    item.Title.Length.ToString() : "200";
                loggers[typelog].Append(logEvent);

                action = "M";
            }
            else {
                po.Post = item;
                po.Type = TypePattern.post;
                po.Pattern = rules[Rules.NotShare];

                po.SharePath = ReplacePattern(po);
            }

            po.Type = (TypePattern)Enum.Parse(typeof(TypePattern), item.Verb, true);
            if (po.Type == TypePattern.share && share == null)
                po.Type = TypePattern.post;
            po.Pattern = rules[Rules.Post];

            var sharafile = po.PostFileName;

            po.PostFileName = ReplacePattern(po);
            logEvent.User = GetActor(item.Actor, typelog);
            logEvent.Date = DateTime.Parse(item.Published);
            logEvent.Action = typelog == Visualizers.Types.Logstalgia ? "post" : action;
            logEvent.FileName = po.PostFileName;
            if (logEvent is LogstalgiaEvent)
                (logEvent as LogstalgiaEvent).Size = item.Object != null ? item.Object.Content.Length.ToString() : "100";
            if (share != null && (logEvent is GephiLogEvent)) {
                (logEvent as GephiLogEvent).From = sharafile;
            }

            loggers[typelog].Append(logEvent);

            if (item.Object != null) {

                if (item.Object.Replies.TotalItems > 0) {
                    try {
                        var listpl = dicitem.Value.Comments;

                        po.Pattern = rules[Rules.Comment];
                        po.Type = TypePattern.comment;

                        foreach (var pl in listpl) {
                            po.Comment = pl;
                            po.Type = TypePattern.comment;
                            var fnp = ReplacePattern(po);

                            logEvent.User = GetActor(pl.Actor, typelog);
                            logEvent.Date = DateTime.Parse(pl.Published);
                            logEvent.Action = typelog == Visualizers.Types.Logstalgia ? "comment" : "A";
                            logEvent.FileName = fnp;
                            if (logEvent is LogstalgiaEvent)
                                (logEvent as LogstalgiaEvent).Size = pl.Object != null ? pl.Object.Content.Length.ToString() : "1";
                            if (logEvent is GephiLogEvent)
                                (logEvent as GephiLogEvent).From = po.PostFileName;

                            loggers[typelog].Append(logEvent);
                        }
                    }
                    catch (Exception e) {
                        WriteLog(e, "Generator.LogGen");
                    }
                }

                long ticks = 0;

                if (item.Object.Plusoners.TotalItems > 0) {
                    try {
                        var listpl = dicitem.Value.Plusers;

                        po.Pattern = rules[Rules.Plus];

                        foreach (var pl in listpl) {
                            po.Person = pl;
                            po.Type = TypePattern.plus;
                            var fnp = ReplacePattern(po);

                            logEvent.User = GetActor(pl, typelog);
                            logEvent.Date = DateTime.Parse(item.Published).AddMinutes(ticks);
                            logEvent.Action = typelog == Visualizers.Types.Logstalgia ? "plus" : "A";
                            logEvent.FileName = fnp;
                            if (logEvent is LogstalgiaEvent)
                                (logEvent as LogstalgiaEvent).Size = "5";
                            if (logEvent is GephiLogEvent)
                                (logEvent as GephiLogEvent).From = po.PostFileName;

                            loggers[typelog].Append(logEvent);

                            ticks += 5;
                        }
                    }
                    catch (Exception e) {
                        WriteLog(e, "Generator.LogGen");
                    }
                }

                ticks = 0;

                if (item.Object.Resharers.TotalItems > 0) {
                    try {
                        var listpl = dicitem.Value.Sharers;

                        po.Pattern = rules[Rules.Plus];

                        foreach (var pl in listpl) {
                            po.Person = pl;
                            po.Type = TypePattern.reshare;
                            var fnp = ReplacePattern(po);

                            logEvent.User = GetActor(pl, typelog);
                            logEvent.Date = DateTime.Parse(item.Published).AddMinutes(ticks);
                            logEvent.Action = typelog == Visualizers.Types.Logstalgia ? "reshare" : "A";
                            logEvent.FileName = fnp;
                            if (logEvent is LogstalgiaEvent)
                                (logEvent as LogstalgiaEvent).Size = "5";
                            if (logEvent is GephiLogEvent)
                                (logEvent as GephiLogEvent).From = po.PostFileName;

                            loggers[typelog].Append(logEvent);

                            ticks += 5;
                        }
                    }
                    catch (Exception e) {
                        WriteLog(e, "Generator.LogGen");
                    }
                }
            }
        }
Пример #5
0
        public static void LogGen(Dictionary<Visualizers.Types, Appender> loggers, Visualizers.Types typelog, Dictionary<Rules, string> rules, KeyValuePair<Activity, ActivityCont> dicitem)
        {
            var item = dicitem.Key;

            var action = "A";

            var po = new PatternOption();

            var share = dicitem.Value.Share;
            if (share != null) {
                po.Post = item;
                po.Share = share;
                po.Pattern = rules[Rules.SharePath];
                po.Type = TypePattern.share;

                po.SharePath = ReplacePattern(po);

                po.Pattern = rules[Rules.ShareName];
                po.PostFileName = po.SharePath + ReplacePattern(po);
                po.PostFileName = po.PostFileName.Replace("//", "/");

                loggers[typelog].Append(new LogEvent() {
                    User = item.Object.Id,
                    Date = DateTime.Parse(item.Published),
                    Action = action,
                    FileName = po.PostFileName
                });

                action = "M";
            }
            else {
                po.Post = item;
                po.Type = TypePattern.post;
                po.Pattern = rules[Rules.NotShare];

                po.SharePath = ReplacePattern(po);
            }

            po.Type = TypePattern.post;
            po.Pattern = rules[Rules.Post];

            po.PostFileName = ReplacePattern(po);

            loggers[typelog].Append(new LogEvent() {
                User = item.Id,
                Date = DateTime.Parse(item.Published),
                Action = action,
                FileName = po.PostFileName
            });

            if (item.Object != null) {

                if (item.Object.Resharers.TotalItems > 0) {
                    try {
                        var listpl = dicitem.Value.Comments;
                        po.Pattern = rules[Rules.Comment];
                        po.Type = TypePattern.comment;
                        foreach (var pl in listpl) {
                            po.Comment = pl;
                            var fnp = ReplacePattern(po);

                            loggers[typelog].Append(new LogEvent() {
                                User = item.Id,
                                Date = DateTime.Parse(item.Published),
                                Action = "A",
                                FileName = fnp
                            });
                        }
                    }
                    catch (Exception e) {
                        WriteLog(e, "UDGenerator.LogGen");
                    }
                }

                long ticks = 0;

                if (item.Object.Plusoners.TotalItems > 0) {
                    try {
                        var listpl = dicitem.Value.Plusers;

                        po.Pattern = rules[Rules.Plus];
                        po.Type = TypePattern.plus;

                        foreach (var pl in listpl) {
                            po.Person = pl;
                            var fnp = ReplacePattern(po);

                            loggers[typelog].Append(new LogEvent() {
                                User = item.Id,
                                Date = DateTime.Parse(item.Published).AddMinutes(ticks),
                                Action = "A",
                                FileName = fnp
                            });

                            ticks += 5;
                        }
                    }
                    catch (Exception e) {
                        WriteLog(e, "UDGenerator.LogGen");
                    }
                }

                ticks = 0;

                if (item.Object.Resharers.TotalItems > 0) {
                    try {
                        var listpl = dicitem.Value.Sharers;

                        po.Pattern = rules[Rules.Plus];
                        po.Type = TypePattern.reshare;

                        foreach (var pl in listpl) {
                            po.Person = pl;
                            var fnp = ReplacePattern(po);

                            loggers[typelog].Append(new LogEvent() {
                                User = item.Id,
                                Date = DateTime.Parse(item.Published).AddMinutes(ticks),
                                Action = "A",
                                FileName = fnp
                            });

                            ticks += 5;
                        }
                    }
                    catch (Exception e) {
                        WriteLog(e, "UDGenerator.LogGen");
                    }
                }
            }
        }