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;
 }
예제 #2
0
        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()}");
        }
예제 #3
0
        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);
        }
예제 #4
0
        // example

        static void Main(string[] args)
        {
            var customer = new Customer
            {
                Name      = "Harun",
                CreatedOn = DateTime.UtcNow
            };

            MongoCrud mongo = new MongoCrud();

            mongo.Insert(customer);

            Console.ReadLine();
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
 public PostOfficeController()
 {
     _mongoCrud = new MongoCrud<DbAppointmentCompany>();
 }
예제 #12
0
 public PostOfficeController()
 {
     _mongoCrud = new MongoCrud <DbAppointmentCompany>();
 }
예제 #13
0
 public CompanyController()
 {
     _mongoCrud = new MongoCrud<Company>();
 }
예제 #14
0
 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);
 }
예제 #17
0
 public UserController()
 {
     _mongoCrud = new MongoCrud<User>();
 }
예제 #18
0
 public MedicalClinicController()
 {
     _mongoCrud = new MongoCrud <DbAppointmentCompany>();
 }
예제 #19
0
        public bool Valid(string key, string hwid)
        {
            var licenses = new MongoCrud().RetrieveRecords <License>("Licenses");

            return(licenses.Any(license => license.Hwid == hwid && license.Key == key));
        }
예제 #20
0
        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);
        }
예제 #21
0
 public MedicalClinicController()
 {
     _mongoCrud = new MongoCrud<DbAppointmentCompany>();
 }
 public SimulinkMatchNow()
 {
     mongocrud = new MongoCrud<SimulinkMatchNowDocument>(mongo_conn, mongo_db, mongo_collection);
 }
예제 #23
0
 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);
 }
예제 #26
0
 public UnitTest1()
 {
     _db = new MongoCrud("Library");
 }
예제 #27
0
 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);
 }
예제 #29
0
        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);
        }
예제 #30
0
        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);
 }
예제 #34
0
 public AppointmentController()
 {
     _mongoCrud = new MongoCrud <Appointment>();
 }
 public TcpPortSessionETL()
 {
     mongo_TcpPortSessionETL = new MongoCrud<TcpPortSessionETLDocument>(mongo_conn, mongo_db, mongo_collection);
 }
예제 #36
0
 public AppointmentController()
 {
     _mongoCrud = new MongoCrud<Appointment>();
 }
예제 #37
0
 public BankController()
 {
     _mongoCrud = new MongoCrud<DbAppointmentCompany>();
 }
 public LacCellBvciStaging()
 {
     mongo_LacCellBvciStaging = new MongoCrud<LacCellBvciStagingDocument>(mongo_conn, mongo_db, mongo_collection);
 }
예제 #39
0
 public UserController()
 {
     _mongoCrud = new MongoCrud <User>();
 }
예제 #40
0
 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);
 }