public LlcTlliSessionStaging() { mongo_LlcTlliSessionStaging = new MongoCrud<LlcTlliSessionStagingDocument>(mongo_conn, mongo_db, mongo_collection); gb.CommandTimeout = 0; gb.ContextOptions.LazyLoadingEnabled = true; gb.Gb_LLC_ReTransmission.MergeOption = MergeOption.NoTracking; }
public override void Execute(string[] args) { if (args.Length < 2) { Write(0, "delete <hwid|key>"); return; } bool b = new MongoCrud().DeleteLicenseByHwid(args[1]) || new MongoCrud().DeleteLicenseByKey(args[1]); Write(0, $"Deleted: {b.ToString()}"); }
public int State(string key) { var licenses = new MongoCrud().RetrieveRecords <License>("Licenses"); foreach (var license in licenses) { if (license.Key == key) { return(license.Hwid == "" ? 0 : 1); } } return(-1); }
// example static void Main(string[] args) { var customer = new Customer { Name = "Harun", CreatedOn = DateTime.UtcNow }; MongoCrud mongo = new MongoCrud(); mongo.Insert(customer); Console.ReadLine(); }
public static Dictionary <Tuple <string, string>, int> BuildDistancesMatrix(string strCity, List <CompanySubType> lstCompanyTypes, List <Constraint> lstConstraints) { MongoCrud <Company> _mongoCrud = new MongoCrud <Company>(); List <Company> lstAllCompanies = _mongoCrud.GetAllEntities().ToList <Company>(); List <Company> lstRelevantCompanies = lstAllCompanies.Where( c => c.Location.Contains(strCity) && lstCompanyTypes.Contains(c.SubType)).ToList <Company>(); var matrixDictionary = DistancesMatrixReader.Read(strCity); var filteredMatrix = DistancesMatrixHandler.FilterMatrixBySpecificCompanies(matrixDictionary, lstRelevantCompanies); if (lstConstraints.Count > 0) { filteredMatrix = DistancesMatrixHandler.AddConstraintsToDistancesMatrix(filteredMatrix, lstRelevantCompanies, lstConstraints); } return(filteredMatrix); }
public static Dictionary<Tuple<string, string>, int> BuildDistancesMatrix(string strCity, List<CompanySubType> lstCompanyTypes, List<Constraint> lstConstraints) { MongoCrud<Company> _mongoCrud = new MongoCrud<Company>(); List<Company> lstAllCompanies = _mongoCrud.GetAllEntities().ToList<Company>(); List<Company> lstRelevantCompanies = lstAllCompanies.Where( c => c.Location.Contains(strCity) && lstCompanyTypes.Contains(c.SubType)).ToList<Company>(); var matrixDictionary = DistancesMatrixReader.Read(strCity); var filteredMatrix = DistancesMatrixHandler.FilterMatrixBySpecificCompanies(matrixDictionary, lstRelevantCompanies); if (lstConstraints.Count > 0) { filteredMatrix = DistancesMatrixHandler.AddConstraintsToDistancesMatrix(filteredMatrix, lstRelevantCompanies, lstConstraints); } return (filteredMatrix); }
private static Dictionary <Tuple <string, string>, int> FilterMatrixBySpecificCompanies( Dictionary <Tuple <string, string>, int> dictMatrix, List <Company> lstRelevantCompanies) { MongoCrud <Company> _mongoCrud = new MongoCrud <Company>(); List <Company> listAllCompanies = _mongoCrud.GetAllEntities().ToList <Company>(); List <string> lstFilteredCompanies = lstRelevantCompanies.Select(s => s.Id).ToList <string>(); Dictionary <Tuple <string, string>, int> dictFilteredMatrix = new Dictionary <Tuple <string, string>, int>(); foreach (Tuple <string, string> curr in dictMatrix.Keys) { if (lstFilteredCompanies.Contains(curr.Item1) && lstFilteredCompanies.Contains(curr.Item2)) { dictFilteredMatrix.Add(curr, dictMatrix[curr]); } } return(dictFilteredMatrix); }
public bool Whitelisted(string hwid) { var licenses = new MongoCrud().RetrieveRecords <License>("Licenses"); if (!licenses.Any(license => license.Hwid == hwid)) { return(false); } var target = licenses.First(license => license.Hwid == hwid); var valid = target.Issued.AddDays(target.ExpireAfterDays) > DateTime.Now; if (!valid) { Logger.Log($"[!] license expired - {target.Key}", LogType.Warning); new MongoCrud().DeleteLicenseByKey(target.Key); } return(valid); }
public void ClearLicense(string key) { License target = null; var licenses = new MongoCrud().RetrieveRecords <License>("Licenses"); foreach (var license in licenses) { if (license.Key == key) { target = license; } } if (target == null) { return; } target.Hwid = ""; target.Issued = DateTime.Now; new MongoCrud().UpdateLicense(target.Key, target); }
public bool IsBanned(string ip) { var bans = new MongoCrud().RetrieveRecords <Ban>("Bans"); foreach (var ban in bans) { if (ban.IpAddress != ip) { continue; } if ((DateTime.Now - ban.Issued).Days > ban.Days) { Logger.Log($"[!] Ban revoked -> {ban.IpAddress}"); new MongoCrud().RevokeBan(ban); } else { return(true); } } return(false); }
public PostOfficeController() { _mongoCrud = new MongoCrud<DbAppointmentCompany>(); }
public PostOfficeController() { _mongoCrud = new MongoCrud <DbAppointmentCompany>(); }
public CompanyController() { _mongoCrud = new MongoCrud<Company>(); }
public BankController() { _mongoCrud = new MongoCrud <DbAppointmentCompany>(); }
public GwGETRateMap() { mongo_get = new MongoCrud<GiGETRateMap>(mongo_conn, mongo_db, mongo_collection); }
public HistoryDataCalculate() { mongo_HistoryDataCalculateDocument = new MongoCrud<HistoryDataCalculateDocument>(mongo_conn, mongo_db, mongo_collection); }
public UserController() { _mongoCrud = new MongoCrud<User>(); }
public MedicalClinicController() { _mongoCrud = new MongoCrud <DbAppointmentCompany>(); }
public bool Valid(string key, string hwid) { var licenses = new MongoCrud().RetrieveRecords <License>("Licenses"); return(licenses.Any(license => license.Hwid == hwid && license.Key == key)); }
public static void Run() { // Get all the companies from the DB MongoCrud <Company> _mongoCrud = new MongoCrud <Company>(); List <Company> listAllCompanies = _mongoCrud.GetAllEntities().ToList <Company>(); //ComapanyQueryHandler query = new ComapanyQueryHandler(); //List<Company> listAllCompanies = query.GetCompaniesByTypeAndLocation(null, "ראשון לציון"); BsonArray bsonItems = new BsonArray(); int nBulkSize = 10; // Run over all the companies for (int i = 0; i < listAllCompanies.Count; i++) { int nIterationsNumber = Convert.ToInt32(Math.Ceiling(listAllCompanies.Count / 10.0)); //int nIterationsNumber = Convert.ToInt32(Math.Round(listAllCompanies.Count / 25.0, MidpointRounding.AwayFromZero)); for (int j = 0; j < nIterationsNumber; j++) { string strRequestUrl = "https://maps.googleapis.com/maps/api/distancematrix/xml?origins=" + listAllCompanies[i].Location + "&destinations="; for (int k = 0; (k < nBulkSize) && (((j * nBulkSize) + k) < listAllCompanies.Count); k++) { strRequestUrl += listAllCompanies[(j * nBulkSize) + k].Location + "|"; } strRequestUrl = strRequestUrl.Remove(strRequestUrl.Length - 1, 1); strRequestUrl += "&key=AIzaSyCOnipZ0p4Khy5BhgtWhmLdkO9j4Du1-iw"; // Send request to google and get the response var request = WebRequest.Create(strRequestUrl); var response = request.GetResponse(); // Convert the data to xml document var xdoc = XDocument.Load(response.GetResponseStream()); IEnumerable <XElement> lstElements = xdoc.Element("DistanceMatrixResponse").Element("row").Elements(); // Run over all the results elements for (int k = 0; k < lstElements.Count(); k++) { // Build the current way distance (id1->id2) and add it to the items array BsonDocument currentDis = new BsonDocument { { "id1", listAllCompanies[i].Id }, { "id2", listAllCompanies[(j * nBulkSize) + k].Id }, { "distance", int.Parse(lstElements.ElementAt(k).Element("duration").Element("value").Value) } }; bsonItems.Add(currentDis); } Thread.Sleep(12000); } // Build the request url for google /*string strRequestUrl = "https://maps.googleapis.com/maps/api/distancematrix/xml?origins=" + listAllCompanies[i].Location + "&destinations="; * for (int j = 0; j < listAllCompanies.Count; j++) * { * strRequestUrl += listAllCompanies[j].Location + "|"; * } * strRequestUrl = strRequestUrl.Remove(strRequestUrl.Length - 1, 1); * * // Send request to google and get the response * var request = WebRequest.Create(strRequestUrl); * var response = request.GetResponse(); * * // Convert the data to xml document * var xdoc = XDocument.Load(response.GetResponseStream()); * IEnumerable<XElement> lstElements = xdoc.Element("DistanceMatrixResponse").Element("row").Elements(); * * // Run over all the results elements * for (int j = 0; j < lstElements.Count(); j++) * { * // Build the current way distance (id1->id2) and add it to the items array * BsonDocument currentDis = new BsonDocument * { * { "id1", listAllCompanies[i].Id }, * { "id2", listAllCompanies[j].Id }, * { "distance", int.Parse(lstElements.ElementAt(j).Element("duration").Element("value").Value) } * }; * bsonItems.Add(currentDis); * }*/ } // Connecting to the DBd MongoClient client = new MongoClient(@"mongodb://localhost:27017/SaveMayDay"); var server = client.GetServer(); var database = server.GetDatabase("SaveMayDay"); MongoCollection distancesCollection = database.GetCollection("distances"); BsonDocument bsonDocToSave = new BsonDocument { { "content", bsonItems } }; // Save all the distances to the DB distancesCollection.Save(bsonDocToSave); }
public MedicalClinicController() { _mongoCrud = new MongoCrud<DbAppointmentCompany>(); }
public SimulinkMatchNow() { mongocrud = new MongoCrud<SimulinkMatchNowDocument>(mongo_conn, mongo_db, mongo_collection); }
public LiveDataETLs() { mongo_LiveDataETL = new MongoCrud<LiveDataETLsDocument>(mongo_conn, mongo_db, mongo_collection); }
public HistoryDataTopDetail() { mongo_HistoryDataTopHostDocument = new MongoCrud<HistoryDataTopHostDocument>(mongo_conn, mongo_db1, mongo_collection_host); mongo_HistoryDataTopAwayDocument = new MongoCrud<HistoryDataTopAwayDocument>(mongo_conn, mongo_db2, mongo_collection_away); mongo_HistoryDataTopJzDocument = new MongoCrud<HistoryDataTopJzDocument>(mongo_conn, mongo_db3, mongo_collection_jz); }
public LacCellBvciETL() { mongo_LacCellBvciETL = new MongoCrud<LacCellBvciETLDocument>(mongo_conn, mongo_db, mongo_collection); }
public UnitTest1() { _db = new MongoCrud("Library"); }
public StagingETLs() { mongo_StagingETLs = new MongoCrud<StagingETLsDocument>(mongo_conn, mongo_db, mongo_collection); }
public ScorePredictForCn() { mongo_ScorePredictForCn = new MongoCrud<ScorePredictForCnDocument>(mongo_conn, mongo_db, mongo_collection); }
private static Dictionary<Tuple<string, string>, int> FilterMatrixBySpecificCompanies( Dictionary<Tuple<string, string>, int> dictMatrix, List<Company> lstRelevantCompanies) { MongoCrud<Company> _mongoCrud = new MongoCrud<Company>(); List<Company> listAllCompanies = _mongoCrud.GetAllEntities().ToList<Company>(); List<string> lstFilteredCompanies = lstRelevantCompanies.Select(s => s.Id).ToList<string>(); Dictionary<Tuple<string, string>, int> dictFilteredMatrix = new Dictionary<Tuple<string, string>, int>(); foreach (Tuple<string, string> curr in dictMatrix.Keys) { if (lstFilteredCompanies.Contains(curr.Item1) && lstFilteredCompanies.Contains(curr.Item2)) { dictFilteredMatrix.Add(curr, dictMatrix[curr]); } } return (dictFilteredMatrix); }
public static void Run() { // Get all the companies from the DB MongoCrud<Company> _mongoCrud = new MongoCrud<Company>(); List<Company> listAllCompanies = _mongoCrud.GetAllEntities().ToList<Company>(); //ComapanyQueryHandler query = new ComapanyQueryHandler(); //List<Company> listAllCompanies = query.GetCompaniesByTypeAndLocation(null, "ראשון לציון"); BsonArray bsonItems = new BsonArray(); int nBulkSize = 10; // Run over all the companies for (int i = 0; i < listAllCompanies.Count; i++) { int nIterationsNumber = Convert.ToInt32(Math.Ceiling(listAllCompanies.Count / 10.0)); //int nIterationsNumber = Convert.ToInt32(Math.Round(listAllCompanies.Count / 25.0, MidpointRounding.AwayFromZero)); for (int j = 0; j < nIterationsNumber; j++) { string strRequestUrl = "https://maps.googleapis.com/maps/api/distancematrix/xml?origins=" + listAllCompanies[i].Location + "&destinations="; for (int k = 0; (k < nBulkSize) && (((j * nBulkSize) + k) < listAllCompanies.Count); k++) { strRequestUrl += listAllCompanies[(j * nBulkSize) + k].Location + "|"; } strRequestUrl = strRequestUrl.Remove(strRequestUrl.Length - 1, 1); strRequestUrl += "&key=AIzaSyCOnipZ0p4Khy5BhgtWhmLdkO9j4Du1-iw"; // Send request to google and get the response var request = WebRequest.Create(strRequestUrl); var response = request.GetResponse(); // Convert the data to xml document var xdoc = XDocument.Load(response.GetResponseStream()); IEnumerable<XElement> lstElements = xdoc.Element("DistanceMatrixResponse").Element("row").Elements(); // Run over all the results elements for (int k = 0; k < lstElements.Count(); k++) { // Build the current way distance (id1->id2) and add it to the items array BsonDocument currentDis = new BsonDocument { { "id1", listAllCompanies[i].Id }, { "id2", listAllCompanies[(j * nBulkSize) + k].Id }, { "distance", int.Parse(lstElements.ElementAt(k).Element("duration").Element("value").Value) } }; bsonItems.Add(currentDis); } Thread.Sleep(12000); } // Build the request url for google /*string strRequestUrl = "https://maps.googleapis.com/maps/api/distancematrix/xml?origins=" + listAllCompanies[i].Location + "&destinations="; for (int j = 0; j < listAllCompanies.Count; j++) { strRequestUrl += listAllCompanies[j].Location + "|"; } strRequestUrl = strRequestUrl.Remove(strRequestUrl.Length - 1, 1); // Send request to google and get the response var request = WebRequest.Create(strRequestUrl); var response = request.GetResponse(); // Convert the data to xml document var xdoc = XDocument.Load(response.GetResponseStream()); IEnumerable<XElement> lstElements = xdoc.Element("DistanceMatrixResponse").Element("row").Elements(); // Run over all the results elements for (int j = 0; j < lstElements.Count(); j++) { // Build the current way distance (id1->id2) and add it to the items array BsonDocument currentDis = new BsonDocument { { "id1", listAllCompanies[i].Id }, { "id2", listAllCompanies[j].Id }, { "distance", int.Parse(lstElements.ElementAt(j).Element("duration").Element("value").Value) } }; bsonItems.Add(currentDis); }*/ } // Connecting to the DBd MongoClient client = new MongoClient(@"mongodb://localhost:27017/SaveMayDay"); var server = client.GetServer(); var database = server.GetDatabase("SaveMayDay"); MongoCollection distancesCollection = database.GetCollection("distances"); BsonDocument bsonDocToSave = new BsonDocument { { "content", bsonItems } }; // Save all the distances to the DB distancesCollection.Save(bsonDocToSave); }
public FreeAppointmentTesterController() { _mongoCrud = new MongoCrud<DbAppointmentCompany>(); _mongoCrudCompany = new MongoCrud<Company>(); _mongoCrudFA = new MongoCrud<DbAppointment>(); }
public FreeAppointmentTesterController() { _mongoCrud = new MongoCrud <DbAppointmentCompany>(); _mongoCrudCompany = new MongoCrud <Company>(); _mongoCrudFA = new MongoCrud <DbAppointment>(); }
public N201UXIDStatics() { mongo_fcmr = new MongoCrud<N201UXIDStaticsDocument>(mongo_conn, mongo_db, mongo_collection); }
public AppointmentController() { _mongoCrud = new MongoCrud <Appointment>(); }
public TcpPortSessionETL() { mongo_TcpPortSessionETL = new MongoCrud<TcpPortSessionETLDocument>(mongo_conn, mongo_db, mongo_collection); }
public AppointmentController() { _mongoCrud = new MongoCrud<Appointment>(); }
public BankController() { _mongoCrud = new MongoCrud<DbAppointmentCompany>(); }
public LacCellBvciStaging() { mongo_LacCellBvciStaging = new MongoCrud<LacCellBvciStagingDocument>(mongo_conn, mongo_db, mongo_collection); }
public UserController() { _mongoCrud = new MongoCrud <User>(); }
public CompanyController() { _mongoCrud = new MongoCrud <Company>(); }
//private GuangZhou_Gb_TCP_ReTransmission gb; public TcpPortSessionStaging() { mongo_TcpPortSessionStaging = new MongoCrud<TcpPortSessionStagingDocument>(mongo_conn, mongo_db, mongo_collection); //gb = new GuangZhou_Gb_TCP_ReTransmission(); }
public N201UXIDBeforeMessage() { mongo_fcbm = new MongoCrud<N201UXIDBeforeMessageDocument>(mongo_conn, mongo_db, mongo_collection); }