public static string Ekle(VMKullanicilar Data) { using (MMDB db = new MMDB()) { try { bool bul = db.Kullanicilar.Any(p => p.Email == Data.Email.Trim()); if (bul != true) { db.Kullanicilar.Add(new Kullanicilar() { Email = Data.Email.Trim(), Sifre = Data.Sifre.Trim(), Yetki = Data.Yetki.Trim() }); db.SaveChanges(); return("Kullanicilar Başarıyla Eklendi"); } else { return("Kullanicilar Daha Önceden Kaydedilmiş"); } } catch { return("Kullanicilar Kaydetme İşlemi Başarılı Olamadı."); } } }
public static bool Ekle(VMMArka Data) { using (MMDB db = new MMDB()) { try { bool bul = db.Marka.Any(p => p.MarkaAdi == Data.MarkaAdi.Trim()); if (bul != true) { db.Marka.Add(new Marka() { MarkaAdi = Data.MarkaAdi.Trim() }); db.SaveChanges(); return(true); } else { return(false); } } catch { return(false); } } }
public static bool Ekle(VMKampanya Data) { using (MMDB db = new MMDB()) { try { bool bul = db.Kampanya.Any(p => p.KampanyaAdi == Data.KampanyaAdi.Trim()); if (bul != true) { db.Kampanya.Add(new Kampanya() { KampanyaAdi = Data.KampanyaAdi.Trim(), IndirimOrani = Data.IndirimOrani }); db.SaveChanges(); return(true); } else { return(false); } } catch { return(false); } } }
static string AddOrUpdateLJPost(Int32 user, string title, string content) { // figger out if this watcher has a post because if so, then i update that string strCmd = string.Format("select radar_post_id from nameidmap where id={0};", user); MyNpgsqlCommand cmd = new MyNpgsqlCommand(strCmd, MMDB.DBConnection); NpgsqlDataReader myReader = null; myReader = cmd.ExecuteReader(); myReader.Read(); Int32?itemId = MMDB.MaybeNullInt32(myReader, 0); myReader.Close(); string url = ""; JUST_MAKE_ONE: if (itemId == null) { Int32 newItemId = 0; url = CreateLJPost(title, content, ref newItemId); // store this itemID for this watcher. MMDB.ExecuteNonQuery(string.Format("update nameidmap set radar_post_id={0} where id={1};", newItemId, user)); } else { url = UpdateLJPost(title, content, itemId); if (null == url) { itemId = null; goto JUST_MAKE_ONE; } } return(url); }
public static bool Ekle(VMKategori Data) { using (MMDB db = new MMDB()) { try { bool bul = db.Kategoriler.Any(p => p.KategoriAdi == Data.KategoriAdi.Trim()); if (bul != true) { db.Kategoriler.Add(new Kategoriler() { KategoriAdi = Data.KategoriAdi.Trim() }); db.SaveChanges(); return(true); } else { return(false); } } catch { return(false); } } }
public static bool Guncelle(VMUrun Data) { using (MMDB db = new MMDB()) { try { var kampanya = db.Kampanya.FirstOrDefault(p => p.KampanyaAdi == Data.Kampanya); var kategori = db.Kategoriler.FirstOrDefault(p => p.KategoriAdi == Data.Kategoriler); var marka = db.Marka.FirstOrDefault(p => p.MarkaAdi == Data.Marka); var bul = db.Urun.FirstOrDefault(p => p.Barkod == Data.Barkod.Trim()); //bul.Adet = Data.Adet; //bul.AlisFiyati = Data.AlisFiyati; bul.Barkod = Data.Barkod.Trim(); //bul.Gramaji = Data.Gramaji; bul.KampanyaID = kampanya.KampanyaID; bul.KategorilerID = kategori.KategorilerID; bul.MarkaID = marka.MarkaID; //bul.SatisFiyati = Data.SatisFiyati; bul.UrunAdi = Data.UrunAdi.Trim(); db.SaveChanges(); return(true); } catch { return(false); } } }
public static Kullanicilar OturumAcHizli(VMKullanicilar Data) { using (MMDB db = new MMDB()) { return(db.Kullanicilar.FirstOrDefault(p => p.Email == Data.Email && p.Sifre == Data.Sifre)); } }
public static VMKampanya Bul(int id) { using (MMDB db = new MMDB()) { return(db.Kampanya.Where(p => p.KampanyaID == id).Select(p => new VMKampanya { KampanyaAdi = p.KampanyaAdi, KampanyaID = p.KampanyaID, IndirimOrani = p.IndirimOrani }).FirstOrDefault()); } }
public static VMKategori Bul(int id) { using (MMDB db = new MMDB()) { return(db.Kategoriler.Where(p => p.KategorilerID == id).Select(p => new VMKategori { KategoriAdi = p.KategoriAdi, KategorilerID = p.KategorilerID }).FirstOrDefault()); } }
public static VMMArka Bul(int id) { using (MMDB db = new MMDB()) { return(db.Marka.Where(p => p.MarkaID == id).Select(p => new VMMArka { MarkaAdi = p.MarkaAdi, MarkaID = p.MarkaID }).FirstOrDefault()); } }
public static List <VMKategori> Liste() { using (MMDB db = new MMDB()) { return(db.Kategoriler.Select(p => new VMKategori { KategoriAdi = p.KategoriAdi, KategorilerID = p.KategorilerID }).ToList()); } }
public static List <VMKampanya> Liste() { using (MMDB db = new MMDB()) { return(db.Kampanya.Select(p => new VMKampanya { KampanyaAdi = p.KampanyaAdi, KampanyaID = p.KampanyaID, IndirimOrani = p.IndirimOrani }).ToList()); } }
public static VMKullanicilar KullaniciBul(string Benzersiz) { using (MMDB db = new MMDB()) { return(db.Kullanicilar.Where(p => p.Benzersiz.ToString() == Benzersiz).Select(n => new VMKullanicilar { Benzersiz = n.Benzersiz, Email = n.Email, Sifre = n.Sifre, Yetki = n.Yetki }).FirstOrDefault()); } }
public static List <VMMArka> Liste() { using (MMDB db = new MMDB()) { return(db.Marka.Select(p => new VMMArka { MarkaAdi = p.MarkaAdi, MarkaID = p.MarkaID }).ToList()); } }
public static string Sil(VMKullanicilar Data) { using (MMDB db = new MMDB()) { try { var bul = db.Kullanicilar.FirstOrDefault(p => p.Email == Data.Email.Trim()); db.Kullanicilar.Remove(bul); db.SaveChanges(); return("Kullanicilar Başarrıyla Silindi"); } catch { return("Kullanicilar Silme İşlemi Başarılı Olamadı."); } } }
public static bool Guncelle(VMKategori Data) { using (MMDB db = new MMDB()) { try { var bul = db.Kategoriler.FirstOrDefault(p => p.KategorilerID == Data.KategorilerID); bul.KategoriAdi = Data.KategoriAdi.Trim(); db.SaveChanges(); return(true); } catch { return(false); } } }
public static bool Sil(VMKategori Data) { using (MMDB db = new MMDB()) { try { var bul = db.Kategoriler.FirstOrDefault(p => p.KategorilerID == Data.KategorilerID); db.Kategoriler.Remove(bul); db.SaveChanges(); return(true); } catch { return(false); } } }
public static bool Sil(VMMArka Data) { using (MMDB db = new MMDB()) { try { var bul = db.Marka.FirstOrDefault(p => p.MarkaID == Data.MarkaID); db.Marka.Remove(bul); db.SaveChanges(); return(true); } catch { return(false); } } }
public static bool Sil(VMUrun data) { using (MMDB db = new MMDB()) { try { var bul = db.Urun.FirstOrDefault(p => p.Barkod == data.Barkod.Trim()); db.Urun.Remove(bul); db.SaveChanges(); return(true); } catch { return(false); } } }
public static bool Guncelle(VMMArka Data) { using (MMDB db = new MMDB()) { try { var bul = db.Marka.FirstOrDefault(p => p.MarkaID == Data.MarkaID); bul.MarkaAdi = Data.MarkaAdi.Trim(); db.SaveChanges(); return(true); } catch { return(false); } } }
public static bool Guncelle(VMKampanya Data) { using (MMDB db = new MMDB()) { try { var bul = db.Kampanya.FirstOrDefault(p => p.KampanyaID == Data.KampanyaID); bul.KampanyaAdi = Data.KampanyaAdi.Trim(); bul.IndirimOrani = Data.IndirimOrani; db.SaveChanges(); return(true); } catch { return(false); } } }
public static string Guncelle(VMKullanicilar Data) { using (MMDB db = new MMDB()) { try { var bul = db.Kullanicilar.FirstOrDefault(p => p.Email == Data.Email.Trim()); bul.Email = Data.Email.Trim(); bul.Sifre = Data.Sifre.Trim(); bul.Yetki = Data.Yetki.Trim(); db.SaveChanges(); return("Kullanicilar Başarrıyla Guncellendi"); } catch { return("Kullanicilar Guncelleme İşlemi Başarılı Olamadı."); } } }
static void NoteRecommendeds(Int32 userid, List <HashSet <Int32> > targets_recommended) { // i want one entry for each watcher-target combination, but i'll let the unique index assure it right? eventually. foreach (var t in targets_recommended) { foreach (var one in t) { try { MMDB.ExecuteNonQuery(string.Format("INSERT INTO radarpicks (userid, userid_recommended) Values({0}, {1});", userid, one)); } catch (NpgsqlException) { // ok i'm crazy but just move on it's probably a unique constraint failure which is by design } } } }
public static bool Ekle(VMUrun Data) { using (MMDB db = new MMDB()) { try { bool bul = db.Urun.Any(p => p.Barkod == Data.Barkod.Trim()); if (bul != true) { var kampanya = db.Kampanya.FirstOrDefault(p => p.KampanyaAdi == Data.Kampanya); var kategori = db.Kategoriler.FirstOrDefault(p => p.KategoriAdi == Data.Kategoriler); var marka = db.Marka.FirstOrDefault(p => p.MarkaAdi == Data.Marka); db.Urun.Add(new Urun() { //Adet = Data.Adet, //AlisFiyati = Data.AlisFiyati, Barkod = Data.Barkod.Trim(), //Gramaji = Data.Gramaji, KampanyaID = kampanya.KampanyaID, KategorilerID = kategori.KategorilerID, MarkaID = marka.MarkaID, //SatisFiyati = Data.SatisFiyati, UrunAdi = Data.UrunAdi.Trim() }); db.SaveChanges(); return(true); } else { return(false); } } catch { return(false); } } }
public static VMUrun Bul(string barkod) { using (MMDB db = new MMDB()) { return(db.Urun.Where(m => m.Barkod == barkod).Select(p => new VMUrun { //Adet = p.Adet, //AlisFiyati = p.AlisFiyati, Barkod = p.Barkod, //Gramaji = p.Gramaji, Kampanya = p.Kampanya.KampanyaAdi, //KampanyaID = p.KampanyaID, Kategoriler = p.Kategoriler.KategoriAdi, //KategorilerID = p.KategorilerID, Marka = p.Marka.MarkaAdi, //MarkaID = p.MarkaID, //SatisFiyati = p.SatisFiyati, UrunAdi = p.UrunAdi, UrunID = p.UrunID, //SonFiyat = p.SatisFiyati / p.Kampanya.IndirimOrani }).FirstOrDefault()); } }
public static List <VMUrun> Liste() { using (MMDB db = new MMDB()) { return(db.Urun.Select(p => new VMUrun { //Adet = p.Adet, //AlisFiyati = p.AlisFiyati, Barkod = p.Barkod, //Gramaji = p.Gramaji, Kampanya = p.Kampanya.KampanyaAdi, //KampanyaID = p.KampanyaID, Kategoriler = p.Kategoriler.KategoriAdi, //KategorilerID = p.KategorilerID, Marka = p.Marka.MarkaAdi, //MarkaID = p.MarkaID, //SatisFiyati = p.SatisFiyati, UrunAdi = p.UrunAdi, UrunID = p.UrunID, //SonFiyat = p.SatisFiyati / p.Kampanya.IndirimOrani }).ToList()); } }
public static List <List <int> > CustomGroupMain(Int32 iSeed, HashSet <Int32> members) { MMDB.MakeSureDBIsOpen(); if (false == members.Contains(iSeed)) { Console.WriteLine("I crammed the seed back into the set."); members.Add(iSeed); } List <int> everyone = new List <int>(members); Dictionary <int, HashSet <int> > master = new Dictionary <int, HashSet <int> >(); foreach (int iUserIRead in members) { string fd2 = FData.GetFData(IDMap.IDToName(iUserIRead)); if (fd2 == null) { continue; } HashSet <int> whoTheyRead = FData.IDsInIReadFData(fd2); // ReadArrayFromUserField(iUserIRead, "snapshot", whoIRead); if (null == whoTheyRead) { whoTheyRead = new HashSet <int> { } } ; // and for every unique id, we need to store their snapshot // so we can make the bitfield later master.Add(iUserIRead, whoTheyRead); } // i want to know every case where whoAllRead lacks a key that appears in everyone list. foreach (int i in everyone) { if (false == master.ContainsKey(i)) { Console.WriteLine("whoAllRead has no key: " + i); // these are offline and so no fdata is provided for them. they still could be in everyone. fix that. } } // POPULATE THE BITFIELDS, which are GRIDS of two-way readership realationships // RITE? // well i'm one of those bitfields // bit i think i am always in my own set of whoiRead (self) // i only include the set of those i read, i think. // DO I INCLUDE MYSELF???? i want a bitarray also!? // prep SortedList eachToOthers = new SortedList(); // the userid yields a bitarray foreach (int i in everyone) { eachToOthers.Add(i, new BitArray(everyone.Count())); } // that's the f*****g way to create the bit array! // what is the f*****g way to populate it? // per each bit array. foreach (int iKey in eachToOthers.Keys) { BitArray ba = (BitArray)eachToOthers[iKey]; // if whoALlRead[ikey] doesn't exist, emit a warning and skip it. can i f*****g do that? // somehow there's no entry for iKey in this whoAllRead, where do eachToOthers diverge in keys from whoAllRead? foreach (int iSomeUser in master[iKey]) // whoAllRead[stooge] is a way of saying "who stooge reads" { // if i have never associated with them, they don't get in. if (everyone.IndexOf(iSomeUser) != -1) { ba.Set(everyone.IndexOf(iSomeUser), true);// all sets } } } // IS THERE A REQUIREMENT THAT I ONLY OR OPTIMALLY POPULATE TWO-WAY ONLY? List <List <int> > sl = CliquesFromBits(eachToOthers, iSeed, everyone, null); // if i save this output, i can use it as hints later. could be valuable / essential. we shall see. // so this is a bit array of many groupings? everyone has a line in this bit array. return(sl); } }
static void NotifyViaLJInbox(Int32 toWhom, string content, string url) { XDocument xd = new XDocument(); xd.Add(new XElement("methodCall", new XElement("methodName", "LJ.XMLRPC.sendmessage"), new XElement("params", new XElement("param", new XElement("value", new XElement("struct", new XElement("member", new XElement("name", "username"), new XElement("value", new XElement("string", "ljfinder"))), // new XElement("value", new XElement("string", "mcfnord"))), new XElement("member", new XElement("name", "password"), new XElement("value", new XElement("string", Registry.GetValue("HKEY_CURRENT_USER\\Software\\MindMap", "LJFinderPwd", null).ToString()))), new XElement("member", new XElement("name", "subject"), new XElement("value", new XElement("string", "New LJs and your MindMap at " + url))), new XElement("member", new XElement("name", "body"), new XElement("value", new XElement("string", content))), new XElement("member", new XElement("name", "to"), new XElement("value", new XElement("string", IDMap.IDToName(toWhom)))))))))); ASCIIEncoding encoding = new ASCIIEncoding(); byte[] data = encoding.GetBytes("<?xml version=\"1.0\"?>" + xd.ToString()); xd = null; HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.livejournal.com/interface/xmlrpc"); request.UserAgent = "http://ljmindmap.com/; [email protected]"; request.Method = "POST"; request.ContentType = "text/xml"; // "application/x-www-form-urlencoded"; request.ContentLength = data.GetLength(0); Stream newStream = request.GetRequestStream(); newStream.Write(data, 0, data.GetLength(0)); newStream.Close(); WebResponse response = null; response = request.GetResponse(); Stream s = response.GetResponseStream(); StreamReader sr = new StreamReader(s); string fd = sr.ReadToEnd(); Console.WriteLine(fd); // System.Diagnostics.Debug.Assert(false == fd.Contains("ault")); if (fd.Contains("ault")) { if (false == fd.Contains("privacy options")) { System.Diagnostics.Debug.Assert(false);// i hate any other fault. } } // remember this day for this user //MMDB.ExecuteNonQuery(string.Format("update nameidmap set // do we have a week indicator? DateTime TwoK = new DateTime(0x7d0, 1, 1); int weeks = (int)(DateTime.Now.Subtract(TwoK).Days / 7.02); MMDB.ExecuteNonQuery(string.Format("update nameidmap set inbox_hit_week={1} where id={0};", toWhom, weeks)); }
public static void RefreshBasedOnRadarSignals_AndPublish(HashSet <Int32> considered) { // SendPostToLJ(); // SendPostToLJ("For <lj user=mcfnord>", "some kibble"); MMDB.MakeSureDBIsOpen(); // first trash watches entirely? so no need to drop people. // then populate watches entirely. build it up! readers of ljreader. not who ljreader reads! new MyNpgsqlCommand("delete from watches;", MMDB.DBConnection).ExecuteNonQuery(); // string fdataLJReader = FData.GetFData("ljfinder", true); // string fdataLJReader = FData.GetFData("mcfnord", true); // HashSet<Int32> whoReadsTheRobot = FData.IDsInTheyReadMeFData(fdataLJReader); considered.Remove(5731095); // no self! // ok, kill all adds that are oldder than 119 days. cuz i don't want to pblish offlines. or something. MMDB.ExecuteNonQuery(string.Format("delete from adds where daydetected < {0};", DateTime.Now.AddDays(-119).Subtract(Extras.TwoK).Days)); // MAYBE SOMEDAY I EXCLUDE SOME PEOPLE WHO READ THE ROBOT BECAUSE THEY SUCK ASS AND DON'T PICK UP THE SHIT. foreach (var jokerWhoReadsTheRobot in considered) { foreach (var someoneJokerReads in FData.IDsInIReadFData(FData.GetFData(IDMap.IDToName(jokerWhoReadsTheRobot)))) { MMDB.ExecuteNonQuery(string.Format("INSERT INTO watches (watcher, watched) Values({0}, {1});", jokerWhoReadsTheRobot, someoneJokerReads), false); } } // gather all actors in add events HashSet <Int32> watchers = new HashSet <int>(); NpgsqlCommand cmd = new NpgsqlCommand("select distinct(watcher) from watches where watched IN (select distinct(actor) from adds) ;", MMDB.DBConnection); cmd.CommandTimeout = 0; // forever! NpgsqlDataReader myReader = cmd.ExecuteReader(); while (myReader.Read()) { watchers.Add(myReader.GetInt32(0)); } myReader.Close(); HashSet <Int32> everyoneImmaUpdate = new HashSet <int>(); // I HATE RECOMMENDING RENAMES. I HATE IT SO MUCH THAT I WANT TO MAXIMALLY DETECT THEM IN A PRE-STEP. foreach (var watcher in watchers) { everyoneImmaUpdate.UnionWith(FData.IDsInIReadFData(FData.GetFData(IDMap.IDToName(watcher)))); } everyoneImmaUpdate.ExceptWith(watchers); foreach (var someParty in everyoneImmaUpdate) { if (false == FData.FDataConfirmedCurrentEnufOn(IDMap.IDToName(someParty))) { FData.GetFData(IDMap.IDToName(someParty)); } } everyoneImmaUpdate = null; // imma gonna order watchers into orderedWatchers, based on last-published-to date // but first it's ok i'll run this through... string sqlset = ""; foreach (var dude in watchers) { sqlset += dude.ToString() + ","; } sqlset = sqlset.Substring(0, sqlset.Length - 1); myReader = new NpgsqlCommand(string.Format("select id from nameidmap where id in ({0}) order by inbox_hit_week ;", sqlset), MMDB.DBConnection).ExecuteReader(); List <Int32> sortedWatchers = new List <int>(); while (myReader.Read()) { sortedWatchers.Add(myReader.GetInt32(0)); } myReader.Close(); watchers = null; foreach (var watcher in sortedWatchers) { if (watcher == 1179796) { Console.WriteLine("The bastardo."); } HashSet <Int32> whoWatcherReads = FData.IDsInIReadFData(FData.GetFData(IDMap.IDToName(watcher))); if (whoWatcherReads.Contains(watcher)) // ditch read-self! { whoWatcherReads.Remove(watcher); } // tell me who was added by all the parties we watch Dictionary <Int32, HashSet <Int32> > everyTarget = new Dictionary <Int32, HashSet <Int32> >(); string whoWatcherReadsInSQLSet = ""; foreach (var someone in whoWatcherReads) { whoWatcherReadsInSQLSet += someone.ToString() + ","; } whoWatcherReadsInSQLSet = whoWatcherReadsInSQLSet.Substring(0, whoWatcherReadsInSQLSet.Length - 1); // rule out anyone if i ever ever read them before. // my encyclopedic archive rules i guess! List <int> daysOfTheFData = FData.GetFDataDates(IDMap.IDToName(watcher)); HashSet <Int32> everyoneIEverRead = new HashSet <Int32>(); foreach (var day in daysOfTheFData) { string anFD = FData.FDataBy2kDay(IDMap.IDToName(watcher), day); everyoneIEverRead.UnionWith(FData.IDsInIReadFData(anFD)); } if (everyoneIEverRead.Contains(watcher)) { everyoneIEverRead.Remove(watcher); // remove watcher manually } if (watcher == 1) { if (everyoneIEverRead.Contains(578)) { Console.WriteLine("I read scribble before."); } } cmd = new NpgsqlCommand(string.Format("select target, actor from adds where actor IN ({0});", whoWatcherReadsInSQLSet), MMDB.DBConnection); myReader = cmd.ExecuteReader(); while (myReader.Read()) { Int32 iTarget = myReader.GetInt32(0); // skip self-whatevers. if (iTarget == watcher) { continue; } // skip ljfinder! if (iTarget == 5731095) { continue; } // detected as offline in last 120 days? NpgsqlDataReader innerReader = new MyNpgsqlCommand( string.Format("select offline_last_detected_on from nameidmap where id={0};", iTarget), MMDB.DBConnection).ExecuteReader(); innerReader.Read(); Int16?offline_detected_on = MMDB.MaybeNullInt16(innerReader, 0); // overload with a no-local-reader option! rolls royce db! innerReader.Close(); if (null != offline_detected_on) { if (offline_detected_on > DateTime.Now.AddDays(-120).Subtract(Extras.TwoK).Days) { continue; } } if (everyoneIEverRead.Contains(iTarget)) { continue; } // MORITORIUM ALSO ON ANYTHING THAT IS DEAD WTF // KILL IT WITH ANY F*****G FEATURE... UPDATEPPY? 404! // moritorium on any target that has been detected as a rename in the last 120 days innerReader = new MyNpgsqlCommand( string.Format("select made_by_rename_detected_on from nameidmap where id={0};", iTarget), MMDB.DBConnection).ExecuteReader(); innerReader.Read(); Int16?day_rename_detected = MMDB.MaybeNullInt16(innerReader, 0); // overload with a no-local-reader option! rolls royce db! innerReader.Close(); if (null != day_rename_detected) { if (day_rename_detected > DateTime.Now.AddDays(-120).Subtract(Extras.TwoK).Days) { continue; } } // create and add if (false == everyTarget.ContainsKey(iTarget)) { // if it's known offline i'm gonna hit this way too hard. i just need to remember somehow that i hit it. // Extras.CheckForRenameOrOffline(iTarget); everyTarget.Add(iTarget, new HashSet <Int32>()); } int iActor = myReader.GetInt32(1); ////////////////////// diagnose how actor == watcher, ever. // Console.WriteLine("Target: {0}, Actor: {1}, Watcher: {2}", IDMap.IDToName(iTarget), IDMap.IDToName(iActor), IDMap.IDToName(watcher)); ////////////////////// diagnose how actor == watcher, ever. System.Diagnostics.Debug.Assert(iActor != watcher); // watcher should not be in the IN set that does this query! everyTarget[iTarget].Add(iActor); // add the actor. this is why we can't just use a big IN sql statement. or can we? } myReader.Close(); // only publish if i've never published to this user, or barring that, at least one target must have more than one actor. cmd = new NpgsqlCommand(string.Format("select count(*) from radarpicks where userid={0} ;", watcher), MMDB.DBConnection); myReader = cmd.ExecuteReader(); myReader.Read(); Int64?any = MMDB.MaybeNullInt64(myReader, 0); myReader.Close(); if (everyTarget.Count > 0) // else we crash so f**k this situation. { if (any == 0 || everyTarget.Max(targ => targ.Value.Count) > 1) { List <HashSet <Int32> > actors = new List <HashSet <Int32> >(); List <HashSet <Int32> > targets = new List <HashSet <Int32> >(); var sortedGroups = (from g in everyTarget where g.Value.Count > ((any == 0) ? 0 : 1) // if we've never published anything, lower the standard to just 1 orderby g.Value.Count descending select g).Take(12); // fold the sorted groups into the two dictionaries. foreach (var thisG in sortedGroups) { // if these actors are already in my actor list, then we skip foreach (var existing in actors) { if (thisG.Value.SetEquals(existing)) // wha'ts the right way??? cuz it's not this. { goto ALREADY; } } // i know its key, so i can look for equal sets that aren't it. var sameActors = from x in everyTarget where (x.Key != thisG.Key && x.Value.SetEquals(thisG.Value)) // so same actors, different key, so excludes thisG! select x; // All of them are added as a same 'entry' slot into actors and targets sets. actors.Add(thisG.Value); System.Diagnostics.Debug.Assert(false == thisG.Value.Contains(watcher)); // watchers aren't actors in their deeds! HashSet <Int32> targs = new HashSet <int>(); targs.Add(thisG.Key); foreach (var same in sameActors) { targs.Add(same.Key); } targets.Add(targs); ALREADY: ; } // divide into two groups, based on whether i've published this name to this user before.] // builds a logic array of whether anyone in this set has been published before. List <bool> publishedBefore = new List <bool>(); foreach (var targSet in targets) { bool fPublishedBefore = true; foreach (var t in targSet) { cmd = new NpgsqlCommand(string.Format("select count(*) from radarpicks where userid={0} and userid_recommended={1};", watcher, t), MMDB.DBConnection); myReader = cmd.ExecuteReader(); myReader.Read(); try { fPublishedBefore = (myReader.GetInt64(0) > 0); if (false == fPublishedBefore) { break; // just one "news" in the set means NO, not published before! } } finally { myReader.Close(); } } publishedBefore.Add(fPublishedBefore); } //// TOTAL EXPERIMENT BEFORE THE PUBLISHED B4 CHECK. //// TOTAL EXPERIMENT BEFORE THE PUBLISHED B4 CHECK. /* * foreach (var set in actors) * { * List<List<Int32>> bunches = TCliquesClass.CustomGroupMain(watcher, set); // love this but need specialized "top set matters" timeout mode. * // that clique finder puts the watcher into the set. i take it out! * set.Remove(watcher); * * Console.WriteLine("Largest actor clique: "); * foreach (var party in bunches[0]) * { * Console.Write(IDMap.IDToName(party) + " "); * } * Console.WriteLine(); * } * */ //// TOTAL EXPERIMENT BEFORE THE PUBLISHED B4 CHECK. //// TOTAL EXPERIMENT BEFORE THE PUBLISHED B4 CHECK. // is there anything new to publish? if (any > 0) // if any == 0, then we publish cuz we never published b4 { if (false == publishedBefore.Contains(false)) { Console.WriteLine("Nothin new to publish, just stuff I already found."); continue; } } string title = "Hey <lj user="******">"; string archiveContent = ""; string newContent = ""; string names = ""; foreach (var t in targets) { foreach (var item in t) { names += IDMap.IDToName(item) + "|"; } } names = names.Substring(0, names.Length - 1); // in conclusion, a link to the visual // string content = "<ul><li><a href='http://ljmindmap.com/h.php?n=" + IDMap.IDToName(watcher) + "'>Тесен Мир / MindMap</a>"; string content = "<table><tr><td><center><a href='http://ljmindmap.com/h.php?n=" + IDMap.IDToName(watcher) + "'><img width='500' src='http://ljmindmap.com/s/?f=" + IDMap.IDToName(watcher) + ".gif'><br>Тесен Мир / MindMap</a></td></tr></table><br>"; /* * * * * <table><tr><td><center><a href="http://ljmindmap.com/h.php?n=micaturtle"><img width="500" src="http://ljmindmap.com/s/?f=micaturtle.gif"><br>Тесен Мир / MindMap</a></td></tr></table><br> */ // content += string.Format("<li><a href='http://ljmindmap.com/mass_add.php?a={0}'>Surf these LJs</a></ul>", names); content += "<table border='1'><tr><th><u>New LJs</u><th><u>Found by</u></tr>"; System.Diagnostics.Debug.Assert(actors.Count == targets.Count); for (int iPos = 0; iPos < actors.Count; iPos++) { string contentFragment = "<tr><td>"; foreach (var t in targets[iPos]) { contentFragment += "<lj user="******"> "; } contentFragment += "<td><b>"; foreach (var a in actors[iPos]) { System.Diagnostics.Debug.Assert(a != watcher); contentFragment += IDMap.IDToName(a) + " "; } contentFragment += "</b></tr>"; if (publishedBefore[iPos]) { archiveContent += contentFragment; } else { newContent += contentFragment; } } content += newContent; content += "</table>"; if (archiveContent.Length > 0) { content += "<br><h3>Archive</h3><table>"; content += archiveContent; content += "</table>"; } string url = AddOrUpdateLJPost(watcher, title, content); if (null == url) { // need to just re-post. } System.Diagnostics.Debug.Assert(url.Length > 0); Console.WriteLine(url); string emailcontent = "\r\nI've made your own custom MindMap and found some LJs your friends are adding. Yay!\r\n\r\n" + url + "\r\n\r\n- lil ljfinder"; NotifyViaLJInbox(watcher, emailcontent, url); NoteRecommendeds(watcher, targets); //NotifyViaLJBanner(watcher, emailcontent, url); } } } // still need to kill old events somewhere! at 110 days (rename prevention stops at 120) }
// ArrayList alAllLevels = ChurnAndBurnTribes(lju, twoWayReadership, seed); public static List <List <int> > TCliquesMain(string seed) { MMDB.MakeSureDBIsOpen(); int iUser = IDMap.NameToID(seed); string fd = FData.GetFData(seed, true); // absolutely new fdata. if (null == fd) { return(null); // f**k it } HashSet <int> whoIRead = FData.IDsInIReadFData(fd); if (false == whoIRead.Contains(iUser)) // i read my damn self ok { whoIRead.Add(iUser); } // what would i see if i scanned these for offlines? HashSet <int> whoIReadTrimmed = new HashSet <int>(); foreach (var v in whoIRead) { if (false == FData.KnownOffline(IDMap.IDToName(v))) { whoIReadTrimmed.Add(v); } } whoIRead = whoIReadTrimmed; // original list clobbered! whoIReadTrimmed = null; List <int> everyone = new List <int>(whoIRead); AGAIN_WITHOUT_THE_DINKS: // get an everyone List... by reading everyone's arrays? add-if-unique to a list of unique keys // HEY AM I IN THIS LIST??? Debug.Assert(everyone.IndexOf(iUser) != -1); // I WILL NEED TO ADD MYSELF TO THE EVERYONE LIST EVERY TIME OK? Dictionary <int, HashSet <int> > whoAllRead = new Dictionary <int, HashSet <int> >(); whoAllRead.Add(iUser, whoIRead); foreach (int iUserIRead in whoIRead) { // if i read myself, i was already added, skip if (iUserIRead == iUser) // meee! { continue; } string fd2 = FData.GetFData(IDMap.IDToName(iUserIRead)); if (fd2 == null) { continue; } HashSet <int> whoTheyRead = FData.IDsInIReadFData(fd2); // ReadArrayFromUserField(iUserIRead, "snapshot", whoIRead); if (null == whoTheyRead) { whoTheyRead = new HashSet <int> { } } ; // and for every unique id, we need to store their snapshot // so we can make the bitfield later whoAllRead.Add(iUserIRead, whoTheyRead); } // it's gonna blow my mind if core user is not in everyone set. Debug.Assert(-1 != everyone.IndexOf(iUser)); // i want to know every case where whoAllRead lacks a key that appears in everyone list. foreach (int i in everyone) { if (false == whoAllRead.ContainsKey(i)) { Console.WriteLine("whoAllRead has no key: " + i); // these are offline and so no fdata is provided for them. they still could be in everyone. fix that. } } // ATTENTION. EVERYONE I READ IS LOADED INTO whoAllRead. // For each, a sifted subset (containing only people I read) is constructed. // For too-large groups, I will now proceed to throw out parties who only read one other party in this set. // Maybe then I try throwing out two. // THIS INVOLVES CAREFUL WHATEVER... everyone is a slot-based scenario. // oh what the f***s please what the f***s ugh. // just cull the everyone list based on whoAllRead and GOTO up there to the whoAllRead. Console.WriteLine("of course i only want this for f*****g biggies not for me!"); if (whoAllRead.Count > 5000) { foreach (int iDude in whoAllRead.Keys) { HashSet <int> check = whoAllRead[iDude]; // two? this must iterate up until it's a confirmed manageable subset size! if (check.Count < 2) { everyone.Remove(iDude); } } Debug.Assert(false); //wtf is this? this is experimental two-wayer removal optimization that i never quite approved. goto AGAIN_WITHOUT_THE_DINKS; } // i better have a list who i read, right? // Debug.Assert(null != eachToOthers[iUser]); // POPULATE THE BITFIELDS, which are GRIDS of two-way readership realationships // RITE? // well i'm one of those bitfields // bit i think i am always in my own set of whoiRead (self) // i only include the set of those i read, i think. // DO I INCLUDE MYSELF???? i want a bitarray also!? // prep SortedList eachToOthers = new SortedList(); // the userid yields a bitarray foreach (int i in everyone) { eachToOthers.Add(i, new BitArray(everyone.Count())); } // that's the f*****g way to create the bit array! // what is the f*****g way to populate it? // per each bit array. foreach (int iKey in eachToOthers.Keys) { BitArray ba = (BitArray)eachToOthers[iKey]; // if whoALlRead[ikey] doesn't exist, emit a warning and skip it. can i f*****g do that? // somehow there's no entry for iKey in this whoAllRead, where do eachToOthers diverge in keys from whoAllRead? foreach (int iSomeUser in whoAllRead[iKey]) // whoAllRead[stooge] is a way of saying "who stooge reads" { // if i have never associated with them, they don't get in. if (everyone.IndexOf(iSomeUser) != -1) { ba.Set(everyone.IndexOf(iSomeUser), true);// all sets } } } // IS THERE A REQUIREMENT THAT I ONLY OR OPTIMALLY POPULATE TWO-WAY ONLY? List <List <int> > sl = CliquesFromBits(eachToOthers, iUser, everyone, null); // if i save this output, i can use it as hints later. could be valuable / essential. we shall see. // so this is a bit array of many groupings? everyone has a line in this bit array. return(sl); }