Example #1
0
 public ChangeUserText(Gate g, string oldtext, string newtext, SetName snf)
 {
     this.g       = g;
     this.oldtext = oldtext;
     this.newtext = newtext;
     this.snf     = snf;
 }
 // Use this for initialization
 void Start()
 {
     ingameQuitMenu.SetActive(false);
     healthText = GameObject.Find("healthText").GetComponent <UnityEngine.UI.Text>();
     playerName = SetName.getCharacterName();
     isPaused   = false;
 }
Example #3
0
        private void RefreshFromMetadata(MovieMetadata metadata)
        {
            Certification   = metadata.Certification;
            FileInformation = metadata.FileInformation;
            Id               = metadata.Id;
            OriginalTitle    = metadata.OriginalTitle;
            Outline          = metadata.Outline;
            PlayCount        = metadata.PlayCount;
            Plot             = metadata.Plot;
            PremieredDate    = metadata.Premiered;
            Rating           = metadata.Rating;
            RuntimeInMinutes = metadata.RuntimeInMinutes;
            Country          = metadata.Country;
            SetName.Value    = metadata.SetName;
            SetName.Save();
            Studio      = metadata.Studio;
            Tagline     = metadata.Tagline;
            Title.Value = metadata.Title;
            Title.Save();
            Year = metadata.Year;
            Poster.RefreshImage(metadata.ImagePosterPath);
            Fanart.RefreshImage(metadata.ImageFanartPath);

            Credits.ReplaceWith(metadata.Credits);
            Directors.ReplaceWith(metadata.Directors);
            Genres.ReplaceWith(metadata.Genres);
            ActorManager.Initialize(TransformActors(metadata.Actors));
        }
Example #4
0
 public ChangeUserText(Gate g, string oldtext, string newtext, SetName snf)
 {
     this.g = g;
     this.oldtext = oldtext;
     this.newtext = newtext;
     this.snf = snf;
 }
Example #5
0
 public override string Print(int depth)
 {
     if (!string.IsNullOrEmpty(Operation))
     {
         return("filter " + SetName.Print(depth) + " " + RuleInput.Print(depth) + " " + Operation);
     }
     return("filter " + SetName.Print(depth) + " " + TempVar.Print(depth) + " " + Expression.Print(depth));
 }
Example #6
0
        protected override async Task SaveInternal()
        {
            Title.Save();
            SetName.Save();
            await ActorManager.Save();

            MovieMetadata metadata = CreateMetadata();
            await _metadataService.Save(Path, metadata);
        }
Example #7
0
 public void SetName(Furniture_Recepteur recepteur, string oldName, string newName)
 {
     if (oldName != newName)
     {
         Commande commande = new SetName(recepteur.getGameObject(), oldName, newName);
         commande.Do();
         commandeList.Push(commande);
         editManager.RefreshInfos();
     }
 }
Example #8
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (SetName != null ? SetName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (RoomDescriptionName != null ? RoomDescriptionName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Scale.GetHashCode();
         return(hashCode);
     }
 }
Example #9
0
        public IEnumerator <ITask> SetNameHandler(SetName req)
        {
            yield return(Arbiter.Choice(_scribblerPort.SetName(new brick.SetNameBody()
            {
                NewName = req.Body.Value
            }),
                                        delegate(DefaultUpdateResponseType r) { req.ResponsePort.Post(r); },
                                        delegate(Fault f) { req.ResponsePort.Post(f); }));

            yield break;
        }
Example #10
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #11
0
        /// <summary>
        /// Creates a gameset for given gamefield
        /// </summary>
        /// <param name="pCurrent">Set name to identify</param>
        /// <param name="pGameID">Game ID in the tournament</param>
        public GameSet(SetName pCurrent, string pGameID)
        {
            Name = pCurrent;

            _scoreBoard = new int[] { 0, 0 };
            _advsDeuce  = new bool[] { false, false };

            ScoreStatus = StatusName.Scheduled;

            GameID = pGameID;

            Winner = null;
        }
Example #12
0
 private void RenameItemToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (SelectedItem != null)
     {
         this.setNameDialog = new SetName();
         setNameDialog.form = this;
         this.setNameDialog.Show();
     }
     else
     {
         MessageBox.Show("Please, select an item.");
     }
 }
 public Task Handle(object command)
 {
     return(command switch
     {
         Create cmd => HandleCreate(cmd),
         Update cmd => HandleFullUpdate(cmd),
         SetName cmd => HandleUpdate(cmd.Id, (a) => a.SetName(cmd.Name),
                                     (a) => Repository.Update(a)),
         SetLogoPath cmd => HandleUpdate(cmd.Id, (a) => a.SetLogoPath(cmd.LogoPath),
                                         (a) => Repository.Update(a)),
         SetDescription cmd => HandleUpdate(cmd.Id, (a) => a.SetDescription(cmd.Description),
                                            (a) => Repository.Update(a)),
         DeletePublisher cmd => HandleUpdate(cmd.Id, _ => Repository.RemoveAsync(cmd.Id)),
         _ => Task.CompletedTask
     });
Example #14
0
        public Kingdom(SetName setName = 0, int?players = 2, bool colonyDay = false)
        {
            Trash           = new Deck(Deck.State.inTrash, "KINGDOM");
            KingdomSupply   = new List <Deck>();
            this.maxCurses  = 10;
            this.maxVictory = 8;

            if (players == 3)
            {
                this.maxCurses  = 20;
                this.maxVictory = 12;
            }
            else if (players == 4)
            {
                this.maxCurses  = 30;
                this.maxVictory = 12;
            }

            populateBasicCards(KingdomSupply, colonyDay);
            populateNonBasicCards(KingdomSupply, setName);

            //Sort by cost for easier reading
            KingdomSupply = KingdomSupply.OrderBy(o => o.Cards[0].cost).ToList();
        }
Example #15
0
        public ActionResult UploadFile(UploadFileVM upload)
        {
            if (string.IsNullOrEmpty(upload.SetName) || string.IsNullOrEmpty(upload.UserName))
            {
                upload.ErrorMessage = "Please provide both a name for the data set and your name.";
                return(RedirectToAction("Index", new { model = upload }));
            }
            HttpPostedFileBase file = upload.UploadFile;

            if (file != null && file.ContentLength > 0)
            {
                string fileName     = Path.GetFileName(file.FileName);
                string folderGUID   = Guid.NewGuid().ToString();
                string path         = Server.MapPath("~/App_Data/Uploads/" + folderGUID + "/");
                string pathFileName = Path.Combine(path, fileName);
                try
                {
                    Directory.CreateDirectory(path);
                    upload.UploadFile.SaveAs(pathFileName);
                }
                catch (Exception)
                {
                    Directory.Delete(path, recursive: true);
                    upload.ErrorMessage = "Sorry, we were unable to upload your file.";
                    return(RedirectToAction("Index", new { model = upload }));
                }
                var importSets = new List <ImportSetExcelRow>();
                try
                {
                    importSets = ImportFileXML(path, pathFileName, upload);
                }
                catch (Exception)
                {
                    Directory.Delete(path, recursive: true);
                    upload.ErrorMessage = "Sorry, we were unable to import your file.";
                    return(RedirectToAction("Index", new { model = upload }));
                }
                Directory.Delete(path, recursive: true);
                int numErrorFreeLines = 0;
                foreach (ImportSetExcelRow item in importSets)
                {
                    if (!item.HasError)
                    {
                        numErrorFreeLines++;
                    }
                }
                if (numErrorFreeLines > 0)
                {
                    SetName setName = new SetName();
                    try
                    {
                        List <SetName> setNames = db.SetNames.Where(x => x.Name.StartsWith(upload.SetName)).ToList();
                        if (setNames.Count > 0) //look at existing names to ensure uniqueness
                        {
                            bool exactMatch = false;
                            int  n          = int.MinValue; //highest number that has been appended to the current name
                            foreach (SetName item in setNames)
                            {
                                if (item.Name == upload.SetName)
                                {
                                    exactMatch = true;
                                }
                                string temp = item.Name.Replace(upload.SetName, ""); //remove current name from string
                                int    len  = temp.Length;
                                //check to see if an integer has been appended to the current name such as "example(3)"
                                if (len > 2 && temp.Substring(0, 1) == "(" && temp.Substring(len - 1, 1) == ")")
                                {
                                    string temp2 = temp.Substring(1, len - 2);
                                    if (int.TryParse(temp2, out int nn))
                                    {
                                        if (nn > n)
                                        {
                                            n = nn;
                                        }
                                    }
                                }
                            }
                            if (exactMatch)
                            {
                                if (n > int.MinValue)
                                {
                                    upload.SetName += "(" + (++n) + ")";
                                }
                                else
                                {
                                    upload.SetName += "(1)";
                                }
                            }
                        }
                        setName = new SetName
                        {
                            DateUploaded = DateTime.Now,
                            HasErrors    = (importSets.Count > numErrorFreeLines ? true : false),
                            Name         = upload.SetName,
                            UserName     = upload.UserName
                        };
                        db.SetNames.Add(setName);
                        _ = db.SaveChanges();
                    }
                    catch (Exception)
                    {
                        upload.ErrorMessage = "Sorry, something went wrong. Please try again later.";
                        return(RedirectToAction("Index", new { model = upload }));
                    }
                    foreach (ImportSetExcelRow row in importSets)
                    {
                        if (!row.HasError)
                        {
                            row.ImportSet.SetID = setName.ID;
                            db.ImportSets.Add(row.ImportSet);
                        }
                    }
                    _ = db.SaveChanges();
                }
                return(View("Results", importSets));
            }
            else
            {
                upload.ErrorMessage = "The file is empty. Please try again.";
                return(RedirectToAction("Index", new { model = upload }));
            }
        }
Example #16
0
 public void levelEnd()
 {
     trapdoorSound.Play();
     Scoreboard.writeToScoreboard(SetName.getCharacterName(), Player.currentScore);
     Invoke("loadHighScoreScene", 1.5f);
 }
Example #17
0
        private IEnumerator<ITask> SetNameHandler(SetName command)
        {
            if (command.Body == null || string.IsNullOrEmpty(command.Body.NewName))
            {
                command.ResponsePort.Post(new Fault());
                yield break;
            }

            string shortenedname;
            if (command.Body.NewName.Length > 8)
                shortenedname = command.Body.NewName.Substring(0, 8);
            else
                shortenedname = command.Body.NewName;

            _state.RobotName = shortenedname;

            ScribblerCommand cmd = new ScribblerCommand((byte)ScribblerHelper.Commands.SET_NAME, shortenedname);
            SendScribblerCommand sendcmd = new SendScribblerCommand(cmd);
            _scribblerComPort.Post(sendcmd);

            yield return Arbiter.Receive<ScribblerResponse>(false, sendcmd.ResponsePort,
                delegate(ScribblerResponse response)
                {
                    SaveState(_state);
                }
            );

            //reply to sender
            command.ResponsePort.Post(DefaultUpdateResponseType.Instance);

            yield break;
        }
Example #18
0
        private void populateNonBasicCards(List <Deck> KingdomSupply, SetName setName)
        {
            Sets.BaseSet baseSet = new Sets.BaseSet();
            List <Card>  KingdomSupplyTemplate = new List <Card>();

            switch (setName)
            {
            case SetName.Random:
                for (int i = 0; i < 10; i++)
                {
                    //Uncomment to test a specific card
                    if (i == 0)
                    {
                        KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Spy));
                    }
                    else
                    {
                        KingdomSupplyTemplate.Add(baseSet.getBaseSetCard());
                    }
                }
                break;

            case SetName.FirstGame:
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Cellar));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Market));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Merchant));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Militia));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Mine));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Moat));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Remodel));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Smithy));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Village));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Workshop));
                break;

            case SetName.SizeDistortion:
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Artisan));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Bandit));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Bureaucrat));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Chapel));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Festival));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Gardens));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Sentry));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.ThroneRoom));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Witch));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Workshop));
                break;

            case SetName.DeckTop:
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Artisan));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Bureaucrat));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.CouncilRoom));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Festival));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Harbinger));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Laboratory));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Moneylender));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Sentry));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Vassal));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Village));
                break;

            case SetName.SleightOfHand:
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Cellar));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.CouncilRoom));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Festival));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Gardens));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Library));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Harbinger));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Militia));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Poacher));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Smithy));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.ThroneRoom));
                break;

            case SetName.Improvements:
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Artisan));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Cellar));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Market));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Merchant));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Mine));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Moat));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Moneylender));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Poacher));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Remodel));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Witch));
                break;

            case SetName.SilverAndGold:
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Bandit));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Bureaucrat));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Chapel));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Harbinger));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Laboratory));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Merchant));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Mine));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Moneylender));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.ThroneRoom));
                KingdomSupplyTemplate.Add(baseSet.getBaseSetCard(Sets.BaseSet.BaseSetCards.Vassal));
                break;
            }

            foreach (Card card in KingdomSupplyTemplate)
            {
                Deck KingdomPile = new Deck(Deck.State.inKingdom, "");
                KingdomSupply.Add(KingdomPile);
                fillKingdomPile(card, KingdomPile);
            }
        }
Example #19
0
 /// <summary>
 /// Creates a gameset and change status for given gamefield
 /// </summary>
 /// <param name="pCurrent">Set name to identify</param>
 /// <param name="pGameID">Game ID in the tournament</param>
 /// <param name="pStatus">Status of the gameset</param>
 public GameSet(SetName pCurrent, string pGameID, StatusName pStatus) : this(pCurrent, pGameID)
 {
     ScoreStatus = pStatus;
 }
Example #20
0
        private void Insert_Click(object sender, EventArgs e) // inserts set into database and then updates cloud
        {
            Querey getSetId = new Querey();
            bool   used;

            using (getSetId.connection = getSetId.NewConn)
            {
                using (getSetId.command = getSetId.NewComm)
                {
                    SetIdCommand(getSetId);
                    using (getSetId.reader = getSetId.command.ExecuteReader())
                    {
                        used = getSetId.reader.Read();
                    }
                }
            }

            if (SetName.Text == "")
            {
                MessageForm errorForm = new MessageForm("Please enter a set name.");
                errorForm.Show();
            }
            else if (!used)
            {
                if (Title1.Text == "" || Title2.Text == "")
                {
                    MessageForm errorForm = new MessageForm("Please enter titles for your sets.");
                    errorForm.Show();
                }
                else
                {
                    Querey insert = new Querey();
                    using (insert.connection = insert.NewConn)
                    {
                        using (insert.command = insert.NewComm)
                        {
                            insert.command.CommandText = "INSERT INTO Sets (OwnerId, SetName, Title1, Title2) VALUES (@owner, @name, @title1, @title2);";
                            insert.AddParameter("@owner", _userId);
                            insert.AddParameter("@name", SetName.Text);
                            insert.AddParameter("@title1", Title1.Text);
                            insert.AddParameter("@title2", Title2.Text);
                            if (insert.connection.State != ConnectionState.Open)
                            {
                                insert.connection.Open();
                            }
                            insert.command.ExecuteNonQuery();
                            insert.Close();
                        }
                    }

                    getSetId = new Querey();
                    int setId;
                    using (getSetId.connection = getSetId.NewConn)
                    {
                        using (getSetId.command = getSetId.NewComm)
                        {
                            SetIdCommand(getSetId);
                            using (getSetId.reader = getSetId.command.ExecuteReader())
                            {
                                getSetId.reader.Read();
                                setId = getSetId.reader.GetInt32(0);
                            }
                        }
                    }

                    insert = new Querey();
                    using (insert.connection = insert.NewConn)
                    {
                        int count = 0;
                        while (count < 64 && _data[count, 0] != null)
                        {
                            using (insert.command = insert.NewComm)
                            {
                                insert.command.CommandText = "INSERT INTO Flashcards (SetId, Text1, Text2) VALUES (@setId, @text1, @text2);";
                                insert.AddParameter("@setId", setId);
                                insert.AddParameter("@text1", _data[count, 0]);
                                insert.AddParameter("@text2", _data[count, 1]);
                                insert.command.ExecuteNonQuery();
                                count++;
                            }
                        }

                        string[] tables = { "Permissions", "SetProgress" }; // done this way to allow easier error checking and make queries more readable
                        for (int i = 0; i < tables.Length; i++)
                        {
                            using (insert.command = insert.NewComm)
                            {
                                if (_student != null)
                                {
                                    insert.command.CommandText = "INSERT INTO " + tables[i] + " (UserId, SetId) SELECT Users.Id, Sets.Id FROM Users, Sets, Friends WHERE Student1 = @id AND Sets.Id = @setId AND Sets.OwnerId = Student1 AND Users.Id = Student2 OR Student2 = @id AND Sets.Id = @setId AND Sets.OwnerId = Student2 AND Users.Id = Student1;";
                                }
                                else
                                {
                                    insert.command.CommandText = "INSERT INTO " + tables[i] + " (UserId, SetId) SELECT Users.Id, Sets.Id FROM Users, Sets, TeacherStudent WHERE TeacherId = @id AND Sets.Id = @setId AND Sets.OwnerId = TeacherId AND Users.Id = StudentId;";
                                }
                                insert.AddParameter("@id", _userId);
                                insert.AddParameter("@setId", setId);
                                insert.command.ExecuteNonQuery();
                                new MessageForm("inserted").Show();
                            }
                        }

                        using (insert.command = insert.NewComm)
                        {
                            insert.command.CommandText = "INSERT INTO SetProgress (UserId, SetId) SELECT OwnerId, Id FROM Sets WHERE id = @setId;";
                            insert.AddParameter("setId", setId);
                            insert.command.ExecuteNonQuery();
                        }

                        using (insert.command = insert.NewComm)
                        {
                            double initialStrength = 2.10;
                            insert.command.CommandText = "UPDATE SetProgress SET LastReview = @now, Strength = @strength WHERE SetId = @set;";
                            insert.AddParameter("@now", DateTime.Now.ToString());
                            insert.AddParameter("@strength", initialStrength);
                            insert.AddParameter("@set", setId);

                            insert.command.ExecuteNonQuery();
                        }
                    }

                    GDrive drive = new GDrive();
                    drive.UploadDatabase();

                    ConfirmMsg.Enabled = false;
                    OpenFile.Reset();
                    SetName.Clear();
                    Title1.Clear();
                    Title2.Clear();
                    OpenFile.Reset();
                    FileName.Text = "";
                }
            }
            else
            {
                MessageForm errorForm = new MessageForm("This set name has already been used. Please choose a different one.");
                errorForm.Show();
            }
        }
Example #21
0
        /// <summary>
        /// Http Post Handler.  Handles http form inputs
        /// </summary>
        //[ServiceHandler(ServiceHandlerBehavior.Concurrent)]
        public IEnumerator<ITask> HttpPostHandler(HttpPost httpPost)
        {
            // Use helper to read form data
            ReadFormData readForm = new ReadFormData(httpPost);
            _httpUtilities.Post(readForm);

            // Read form data
            NameValueCollection parameters = null;
            yield return Arbiter.Choice(readForm.ResultPort,
                delegate(NameValueCollection p) { parameters = p; },
                delegate(Exception e) { throw new Exception("Error reading form data", e); });

            // Act on form data
            if (!string.IsNullOrEmpty(parameters["Action"])
                  && parameters["Action"] == "ScribblerConfig")
            {
                if (parameters["buttonOk"] == "Change" && _state.Connected)
                {
                    SetNameBody newname = new SetNameBody(parameters["Name"]);
                    SetName newnamemessage = new SetName(newname);
                    _mainPort.PostUnknownType(newnamemessage);
                    Activate(
                        Arbiter.Choice(
                            Arbiter.Receive<DefaultUpdateResponseType>(false, newnamemessage.ResponsePort,
                                delegate(DefaultUpdateResponseType response)
                                {
                                    HttpPostSuccess(httpPost);
                                }),
                            Arbiter.Receive<Fault>(false, newnamemessage.ResponsePort,
                                delegate(Fault f)
                                {
                                    HttpPostFailure(httpPost, f.Reason[0].Value);
                                })
                        )
                    );

                }
                else if (parameters["buttonOk"] == "Connect" && _state.Connected)
                {
                    //close down this connection to make a new connection below

                    PollTimer.Close();

                    System.Threading.Thread.Sleep(100);

                    _scribblerCom.Close();

                    _state.Connected = false;

                    //HttpPostSuccess(httpPost);
                }

                if (parameters["buttonOk"] == "Connect" && !_state.Connected)
                {
                    int port = 0;
                    int.TryParse(parameters["ComPort"], out port);
                    string name = parameters["Name"];
                    if (!string.IsNullOrEmpty(name) && name.Length > 8)
                        name = name.Substring(0, 8);

                    _state.ComPort = port;
                    _state.RobotName = name;

                    //open Scribbler Communications port
                    LogInfo("connecting to scribbler...");
                    Reconnect rec = new Reconnect();
                    _mainPort.PostUnknownType(rec);
                    yield return Arbiter.Choice(rec.ResponsePort,
                        delegate(DefaultUpdateResponseType r)
                        {
                            LogInfo("connected, sending http reply");
                            HttpPostSuccess(httpPost);
                            LogInfo("http reply sent");
                        },
                        delegate(Fault f)
                        {
                            httpPost.ResponsePort.Post(f);
                        });
                }
            }
            else if (!string.IsNullOrEmpty(parameters["Action"])
                  && parameters["Action"] == "ScribblerSensors")
            {
                if (parameters["buttonOk"] == "Poll" && _state.Connected)
                {
                    ScribblerCommand cmd = new ScribblerCommand(ScribblerHelper.Commands.GET_ALL);
                    SendScribblerCommand sendcmd = new SendScribblerCommand(cmd);
                    _scribblerComPort.Post(sendcmd);
                    Activate(
                        Arbiter.Choice(
                            Arbiter.Receive<ScribblerResponse>(false, sendcmd.ResponsePort,
                                delegate(ScribblerResponse response)
                                {
                                    HttpPostSuccess(httpPost);
                                }),
                            Arbiter.Receive<Fault>(false, sendcmd.ResponsePort,
                                delegate(Fault f)
                                {
                                    HttpPostFailure(httpPost, f.Reason[0].Value);
                                })
                        )
                    );
                }
            }
            else if (!string.IsNullOrEmpty(parameters["Action"])
                && parameters["Action"] == "ScribblerMotors")
            {
                if (parameters["buttonOk"] == "Set" && _state.Connected)
                {
                    int left = _state.MotorLeft;
                    int right = _state.MotorRight;
                    int.TryParse(parameters["LeftMotor"], out left);
                    int.TryParse(parameters["RightMotor"], out right);

                    SetMotorsBody setMotorsBody = new SetMotorsBody(left, right);
                    SetMotors setMotorsRequest = new SetMotors(setMotorsBody);

                    _mainPort.PostUnknownType(setMotorsRequest);

                    Activate(
                        Arbiter.Choice(
                            Arbiter.Receive<DefaultUpdateResponseType>(false, setMotorsRequest.ResponsePort,
                                delegate(DefaultUpdateResponseType response)
                                {
                                    HttpPostSuccess(httpPost);
                                }),
                            Arbiter.Receive<Fault>(false, setMotorsRequest.ResponsePort,
                                delegate(Fault f)
                                {
                                    HttpPostFailure(httpPost, f.Reason[0].Value);
                                })
                        )
                    );
                }
                else if (parameters["buttonOk"] == "All Stop" && _state.Connected)
                {
                    SetMotorsBody setMotorsBody = new SetMotorsBody(100, 100);
                    SetMotors setMotorsRequest = new SetMotors(setMotorsBody);

                    _mainPort.PostUnknownType(setMotorsRequest);

                    Activate(
                        Arbiter.Choice(
                            Arbiter.Receive<DefaultUpdateResponseType>(false, setMotorsRequest.ResponsePort,
                                delegate(DefaultUpdateResponseType response)
                                {
                                    HttpPostSuccess(httpPost);
                                }),
                            Arbiter.Receive<Fault>(false, setMotorsRequest.ResponsePort,
                                delegate(Fault f)
                                {
                                    HttpPostFailure(httpPost, f.Reason[0].Value);
                                })
                        )
                    );
                }
            }
            else if (!string.IsNullOrEmpty(parameters["Action"])
                && parameters["Action"] == "ScribblerLEDs")
            {
                if (parameters["buttonOk"] == "Set" && _state.Connected)
                {
                    bool left = ((parameters["LeftLED"] ?? "off") == "on");
                    bool center = ((parameters["CenterLED"] ?? "off") == "on");
                    bool right = ((parameters["RightLED"] ?? "off") == "on");

                    SetAllLedsBody leds = new SetAllLedsBody(left, center, right);
                    SetAllLEDs setAllLeds = new SetAllLEDs(leds);
                    _mainPort.PostUnknownType(setAllLeds);

                    Activate(
                        Arbiter.Choice(
                            Arbiter.Receive<DefaultUpdateResponseType>(false, setAllLeds.ResponsePort,
                                delegate(DefaultUpdateResponseType response)
                                {
                                    HttpPostSuccess(httpPost);
                                }),
                            Arbiter.Receive<Fault>(false, setAllLeds.ResponsePort,
                                delegate(Fault f)
                                {
                                    HttpPostFailure(httpPost, f.Reason[0].Value);
                                })
                        )
                    );

                }
            }
            else if (!string.IsNullOrEmpty(parameters["Action"])
                && parameters["Action"] == "ScribblerSpeaker")
            {
                if (parameters["buttonOk"] == "Play" && _state.Connected)
                {
                    int tone1 = 0;
                    int tone2 = 0;
                    int duration = 0;
                    int.TryParse(parameters["Tone1"], out tone1);
                    int.TryParse(parameters["Tone2"], out tone2);
                    int.TryParse(parameters["Duration"], out duration);

                    PlayToneBody playTone = new PlayToneBody(duration, tone1, tone2);
                    PlayTone playToneMessage = new PlayTone(playTone);
                    _mainPort.PostUnknownType(playToneMessage);

                    Activate(
                        Arbiter.Choice(
                            Arbiter.Receive<DefaultUpdateResponseType>(false, playToneMessage.ResponsePort,
                                delegate(DefaultUpdateResponseType response)
                                {
                                    HttpPostSuccess(httpPost);
                                }),
                            Arbiter.Receive<Fault>(false, playToneMessage.ResponsePort,
                                delegate(Fault f)
                                {
                                    HttpPostFailure(httpPost, f.Reason[0].Value);
                                })
                        )
                    );
                }
            }
            else
            {
                HttpPostFailure(httpPost, "Unknown Http Post");
            }
            yield break;
        }