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, MaxResults = Convert.ToInt32(nudMaxRes.Value), MaxComments = Convert.ToInt32(nudMaxComment.Value), MaxPluses = Convert.ToInt32(nudMaxPlus.Value), MaxReshares = Convert.ToInt32(nudMaxReshare.Value), Deep = cbDeep.Checked ? Convert.ToInt32(nudDeep.Value) : 0, UseDateRange = cbDateRange.Checked, DateFrom = Convert.ToDateTime(dtpFrom.Value.Date), DateTo = Convert.ToDateTime(dtpTo.Value.AddDays(1).Date) }; if (tcGooglePlus.SelectedTab == tpGPUsers) { sett.Methods = new Dictionary <Visualizers.Types, GeneratorLogsMeth> { //UD { Visualizers.Code_swarm, UDGenerator.LogGen }, { Visualizers.Gource, Generator.LogGen }, { Visualizers.Logstalgia, Generator.LogGen }, { Visualizers.Gephi, Generator.LogGen }, }; if (cbFGraph.Checked) { new FollowersGenerator(apikey.Text, sc).Run(sett); } else { (Program.OAuth2 != null ? new Generator(Program.OAuth2, sc) : new Generator(apikey.Text, sc)).Run(sett); } } else { sett.Methods = new Dictionary <Visualizers.Types, GeneratorLogsMeth> { //UD { Visualizers.Code_swarm, WordsSearchGenerator.LogGen }, { Visualizers.Gource, WordsSearchGenerator.LogGen }, { Visualizers.Logstalgia, WordsSearchGenerator.LogGen }, { Visualizers.Gephi, WordsSearchGenerator.LogGen }, }; (Program.OAuth2 != null ? new WordsSearchGenerator(Program.OAuth2, sc) : new WordsSearchGenerator(apikey.Text, sc)).Run(sett); } }
static public 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); }
static public 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"); } } } }
static public 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"); } } } }
static protected string GetActor(Google.Apis.Plus.v1.Data.Person actor, Visualizers.Types logType) { return(logType == Visualizers.Types.Code_swarm ? actor.Id : actor.DisplayName); }
private void btGen_Click(object sender, EventArgs e) { if (tbID.Text.IsEmpty()) { new Exception("Enter Profile ID").ShowError(this); tbID.Focus(); return; } if (apikey.Text.IsEmpty() && Program.OAuth2 == null) { new Exception("Enter your simple API key").ShowError(this); return; } using (var sc = new StateControl()) { sc.Dock = DockStyle.Fill; //tableLayoutPanel1.Controls.Remove(apip); tlpGooglePlus.Controls.Add(sc, 1, 6); Application.DoEvents(); btGen.Enabled = false; try { Visualizers.Types flags = Visualizers.Types.None; var filenames = new Dictionary <Visualizers.Types, string>(); var controls = groupBox1.Controls.OfType <OutFilePanel>().Where(x => x.Checked); foreach (var cont in controls) { if (cont.Tag is Visualizers.Types) { var key = (Visualizers.Types)cont.Tag; if (cont.Checked) { flags = flags | key; filenames[key] = cont.FileName; if (File.Exists(cont.FileName)) { File.Delete(cont.FileName); } } } } if (filenames.Count < 1) { return; } Generate(tbID.Text, sc, flags, filenames); } finally { btGen.Enabled = true; tlpGooglePlus.Controls.Remove(sc); //tableLayoutPanel1.Controls.Add(apip, 1, 3); } } }