protected void Page_Load(object sender, EventArgs e)
        {
            //This page will display the possible commands.
            string result = "commands: createDb, createRequests, sendTrackingRequests, phone, TRCount, seedDB, connString ";

            try
            {
                if (this.GetBoolValue("connString"))
                {
                    if (this.CommandIsAllowed("connString"))
                    {
                        result = new UGFClassFactory().CreateRepository().DataSource;
                    }
                }

                if (this.GetBoolValue("createDb"))
                {
                    if (this.CommandIsAllowed("createDb"))
                    {
                        UGFSeeder.DropAndRecreateEntireDatabase();
                        result = "Database Created";
                    }
                    else
                    {
                        result = "Cannot call createDb in this environment";
                    }
                }

                if (this.GetBoolValue("seedDB"))
                {
                    if (this.CommandIsAllowed("seedDB"))
                    {
                        UGFSeeder.SeedExistingDatabase();
                        result = "Seeded";
                    }
                    else
                    {
                        result = "Cannot call this command.";
                    }
                }

                if (GetBoolValue("createRequests"))
                {
                    if (this.CommandIsAllowed("createRequests"))
                    {
                        string phoneNumber      = GetValue("phone");
                        int    numberOfRequests = GetIntValue("TRCount");

                        UGitFit.DAL.UGFSeeder.CreateTrackingRequests(phoneNumber, numberOfRequests);
                        result = "crateRequests done.";
                    }
                    else
                    {
                        result = "Cannot call createRequests in this environment.";
                    }
                }

                if (GetBoolValue("sendTrackingRequests"))
                {
                    if (this.CommandIsAllowed("sendTrackingRequests"))
                    {
                        UGitFit.TrackingDomain.DomainLogic logic = new DomainLogic(new UGitFit.DAL.UGFContext());
                        logic.SendScheduledTexts(null);

                        result = "Scheduled Tracking Requests Processed";
                    }
                    else
                    {
                        result = "Cannot call sendTrackingRequests in this environment";
                    }
                }
            }
            catch (Exception exp)
            {
                result = "Error: " + exp.Message + "<br/><br/>";
                Exception expInner = exp.InnerException;

                while (expInner != null)
                {
                    result  += expInner.Message + "<br/><br/>";
                    expInner = expInner.InnerException;
                }
            }

            Response.Write(string.Format("<result>{0}</result>", result));
        }
Пример #2
0
 public UnitTest1()
 {
     _seeder     = new UGFSeeder((ClassFactory._db == null), ClassFactory.CreateRepository());
     _repository = (UGFContext)ClassFactory.CreateRepository();
 }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //This page will display the possible commands.
            string result = "commands: createDb, createRequests, sendTrackingRequests, phone, TRCount, seedDB, connString ";

            try
            {
                if (this.GetBoolValue("connString"))
                {
                    if (this.CommandIsAllowed("connString"))
                    {
                        result = new UGFClassFactory().CreateRepository().DataSource;
                    }
                }

                int id = GetIntValue("Id", 0);
                if (id > 0)
                {
                    string name  = GetValue("name");
                    string value = GetValue("value");

                    if (name.isNullOrEmpty() == false && value.isNullOrEmpty() == false)
                    {
                        new UGitFit.DAL.UGFContext().ExecuteEmbeddedSQL(string.Format("INSERT INTO TestTable (Id, Name, Value) Values ({0},'{1}','{2}')", id, name, value));
                    }
                }

                if (this.GetBoolValue("createDb"))
                {
                    if (this.CommandIsAllowed("createDb"))
                    {
                        UGFSeeder.DropAndRecreateEntireDatabase();
                        result = "Database Created";
                    }
                    else
                    {
                        result = "Cannot call createDb in this environment";
                    }
                }

                if (this.GetBoolValue("seedDB"))
                {
                    if (this.CommandIsAllowed("seedDB"))
                    {
                        UGFSeeder.SeedExistingDatabase();
                        result = "Seeded";
                    }
                    else
                    {
                        result = "Cannot call this command.";
                    }
                }

                if (GetBoolValue("createRequests"))
                {
                    if (this.CommandIsAllowed("createRequests"))
                    {
                        string phoneNumber      = GetValue("phone");
                        int    numberOfRequests = GetIntValue("TRCount");

                        UGitFit.DAL.UGFSeeder.CreateTrackingRequests(phoneNumber, numberOfRequests);
                        result = "crateRequests done.";
                    }
                    else
                    {
                        result = "Cannot call createRequests in this environment.";
                    }
                }

                if (GetBoolValue("sendTrackingRequests"))
                {
                    if (this.CommandIsAllowed("sendTrackingRequests"))
                    {
                        UGitFit.TrackingDomain.DomainLogic logic = new DomainLogic(new UGitFit.DAL.UGFContext());
                        List <TextToSend> sentTexts = logic.SendScheduledTexts(null);

                        result = TextToSend.ListToXMLString(sentTexts);

                        Response.Clear();
                        Response.ContentType = "text/xml";
                    }
                    else
                    {
                        result = "Cannot call sendTrackingRequests in this environment";
                    }
                }
            }
            catch (Exception exp)
            {
                result = "Error: " + exp.Message + "<br/><br/>";
                Exception expInner = exp.InnerException;

                while (expInner != null)
                {
                    result  += expInner.Message + "<br/><br/>";
                    expInner = expInner.InnerException;
                }
            }

            Response.Write(string.Format("<result>{0}</result>", result));
        }