예제 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string purgeResult = "";
            string destroyKey  = "";

            try
            {
                if (uint.TryParse(MinimumAcceptedMatchScore, out _minimumAcceptedMatchScore) == false)
                {
                    _minimumAcceptedMatchScore = 30;
                }

                foreach (String key in context.Request.QueryString.AllKeys)
                {
                    if (key == "destroykey")
                    {
                        destroyKey = context.Request.QueryString[key];
                        break;
                    }
                }
                if (destroyKey == DestroyKey)
                {
                    MongoDBWrapper dbwrapper = new MongoDBWrapper(NoIDMongoDBAddress, SparkMongoDBAddress);
                    if (dbwrapper.DeleteMongoDBs() == true)
                    {
                        FingerPrintMatchDatabase dbMinutia = new FingerPrintMatchDatabase(DatabaseLocation, BackupLocation, _minimumAcceptedMatchScore);
                        if (dbMinutia.DeleteMatchDatabase())
                        {
                            purgeResult = "Successful.";
                        }
                        else
                        {
                            purgeResult = "Error in PurgeAllDatabases::ProcessRequest: Unable to delete all databases.";
                        }
                    }
                }
                else
                {
                    //TODO: log this event as an invalid attempt due to mismatched keys.
                }
            }
            catch (Exception ex)
            {
                purgeResult = "Error in PurgeAllDatabases::ProcessRequest: " + ex.Message;
            }
            context.Response.Write(purgeResult);
        }