public static Qustions AddNewSmile(Qustions Qustion)
        {
            int    Id            = AddQustionInDataBase(Qustion);
            Smiles SmileQuestion = (Smiles)Qustion;

            if (Id != -1)
            {
                try
                {
                    using (SqlConnection Connection = new SqlConnection(DataBaseConnections.connectionString))
                    {
                        SqlCommand CommandForInsertSmile = new SqlCommand(InsertInSmile, Connection);
                        CommandForInsertSmile.Parameters.AddWithValue(NewNumberOfSmily, SmileQuestion.NumberOfSmiles);
                        CommandForInsertSmile.Parameters.AddWithValue(QustionIdDataBase, Id);
                        CommandForInsertSmile.Connection.Open();
                        CommandForInsertSmile.ExecuteNonQuery();
                        CommandForInsertSmile.Parameters.Clear();
                        SmileQuestion.Id         = Id;
                        StaticObjects.SuccOfFail = 1;
                        return(SmileQuestion);
                    }
                }
                catch (Exception ex)
                {
                    StaticObjects.Erros.Log(ex);
                    StaticObjects.SuccOfFail = 0;
                    return(SmileQuestion);
                }
            }
            return(SmileQuestion);
        }
Beispiel #2
0
        //Populate DetectionInfo with face recognition Attributes
        public DetectionInfo(Image <Bgr, byte> image, ICollection <Rectangle> rectangles, ICollection <Face> faces)
        {
            InitData();
            Image      = image;
            Rectangles = rectangles;
            Faces      = faces;

            if (faces.Any())
            {
                PersonCount = Faces.Count;
                //Gestion des genres
                Genders     = faces.Select(gender => gender.FaceAttributes.Gender).ToList();
                MaleCount   = Genders.Where(g => g == "male").Count();
                FemaleCount = Genders.Where(g => g == "female").Count();
                //Calcul de l'age moyen
                AgeAverage = faces.Select(age => age.FaceAttributes.Age).ToList().Average();
                //Calcul du nombre de sourire
                Smiles     = faces.Select(age => age.FaceAttributes.Smile).ToList();
                SmileCount = Smiles.Where(s => s >= 0.5).Count();
                //Calcul du nombre de "poilus" (moustache ou barbe)
                FacialHair = faces.Select(age => age.FaceAttributes.FacialHair).ToList();
                foreach (var f in FacialHair)
                {
                    if (f.Beard > 0.3 || f.Moustache > 0.3)
                    {
                        HearyCount++;
                    }
                }
                //calcul du nombre de porteur de lunettes de vue et solaire
                Glasses             = faces.Select(g => g.FaceAttributes.Glasses).ToList();
                SunGlassesCount     = Glasses.Where(g => g == Microsoft.ProjectOxford.Face.Contract.Glasses.Sunglasses).Count();
                ReadingGlassesCount = Glasses.Where(g => g == Microsoft.ProjectOxford.Face.Contract.Glasses.ReadingGlasses).Count();
                //Accessoires : non gérés
                Accessories = faces.Select(age => age.FaceAttributes.Accessories).ToList();
                //Ventilation des emotions selon les 4 grandes tendances
                Emotions = faces.Select(age => age.FaceAttributes.Emotion).ToList();
                foreach (var e in Emotions)
                {
                    if (GetEmotion(e) == "Happiness")
                    {
                        EmotionHappyCount++;
                    }
                    if (GetEmotion(e) == "Anger")
                    {
                        EmotionAngerCount++;
                    }
                    if (GetEmotion(e) == "Disgust")
                    {
                        EmotionDisgustCount++;
                    }
                    if (GetEmotion(e) == "Neutral")
                    {
                        EmotionNeutralCount++;
                    }
                }
                //Calcul du ratio de "happy" par rapport au nombre de personnes
                HappyRatio = Math.Round((((double)EmotionHappyCount / (double)faces.Count)) * 100, 2);
            }
        }
Beispiel #3
0
        /// <summary>
        /// This Listener for delete button when press add button
        /// </summary>
        private void Delete_Click(object sender, EventArgs e)
        {
            try
            {
                Qustion QuestionForDelete = GetObjectSelect();
                int     Check             = 0;
                if (QuestionForDelete == null)
                {
                    MessageBox.Show(Survey.Properties.Messages.NoSelectItem, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    DialogResult dialogResult = MessageBox.Show(Survey.Properties.Messages.SureToDeleteMessage, GenralVariables.DELETE, MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        switch (QuestionForDelete.TypeOfQuestion)
                        {
                        case TypeOfQuestion.Slider:
                            Slider SliderWillDelete = (Slider)QuestionForDelete;
                            Check = Operation.DeleteQustion(SliderWillDelete);
                            if (CheckMessageError(Check))
                            {
                                Operation.ListOfAllQuestion.Remove(SliderWillDelete);
                                ShowData(Operation.ListOfAllQuestion);
                            }
                            break;

                        case TypeOfQuestion.Smily:
                            Smiles SmileWillDelete = (Smiles)QuestionForDelete;
                            Check = Operation.DeleteQustion(SmileWillDelete);
                            if (CheckMessageError(Check))
                            {
                                Operation.ListOfAllQuestion.Remove(SmileWillDelete);
                                ShowData(Operation.ListOfAllQuestion);
                            }
                            break;

                        case TypeOfQuestion.Stars:
                            Stars StarWillDelete = (Stars)QuestionForDelete;
                            Check = Operation.DeleteQustion(StarWillDelete);
                            if (CheckMessageError(Check))
                            {
                                Operation.ListOfAllQuestion.Remove(StarWillDelete);
                                ShowData(Operation.ListOfAllQuestion);
                            }
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GenralVariables.Errors.Log(ex.Message);
                MessageBox.Show(Survey.Properties.Messages.MessageError);
            }
        }
Beispiel #4
0
 public static Qustion SpecifyTheTypeAndCreateTheQuestion(QuestionModel NewQustion)
 {
     try
     {
         if (NewQustion.StartValue > 0)
         {
             Slider NewQuestion = new Slider();
             if (NewQustion.Id > 0 && NewQustion.IdForType > 0)
             {
                 NewQuestion.Id        = NewQustion.Id;
                 NewQuestion.IdForType = NewQustion.IdForType;
             }
             NewQuestion.TypeOfQuestion = TypeOfQuestion.Slider;
             NewQuestion.NewText        = NewQustion.NewText;
             NewQuestion.Order          = NewQustion.Order;
             NewQuestion.StartValue     = NewQustion.StartValue;
             NewQuestion.EndValue       = NewQustion.EndValue;
             NewQuestion.StartCaption   = NewQustion.StartCaption;
             NewQuestion.EndCaption     = NewQustion.EndCaption;
             return(NewQuestion);
         }
         else if (NewQustion.NumberOfSmiles > 0)
         {
             Smiles NewQuestion = new Smiles();
             if (NewQustion.Id > 0 && NewQustion.IdForType > 0)
             {
                 NewQuestion.Id        = NewQustion.Id;
                 NewQuestion.IdForType = NewQustion.IdForType;
             }
             NewQuestion.TypeOfQuestion = TypeOfQuestion.Smily;
             NewQuestion.NewText        = NewQustion.NewText;
             NewQuestion.Order          = NewQustion.Order;
             NewQuestion.NumberOfSmiles = NewQustion.NumberOfSmiles;
             return(NewQuestion);
         }
         else
         {
             Stars NewQuestion = new Stars();
             if (NewQustion.Id > 0 && NewQustion.IdForType > 0)
             {
                 NewQuestion.Id        = NewQustion.Id;
                 NewQuestion.IdForType = NewQustion.IdForType;
             }
             NewQuestion.TypeOfQuestion = TypeOfQuestion.Stars;
             NewQuestion.NewText        = NewQustion.NewText;
             NewQuestion.Order          = NewQustion.Order;
             NewQuestion.NumberOfStars  = NewQustion.NumberOfStars;
             return(NewQuestion);
         }
     }
     catch (Exception ex)
     {
         Logger.Log(ex.Message);
         return(null);
     }
 }
Beispiel #5
0
 /// <summary>
 /// This Listener for delete button when press add button
 /// </summary>
 private void Delete_Click(object sender, EventArgs e)
 {
     try
     {
         QuestionWillDeleteOrEdit = GetObjectSelect();
         int Check = 0;
         if (QuestionWillDeleteOrEdit == null)
         {
             MessageBox.Show(Survey.Properties.Resource1.NoSelectItem, Global.Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
             StaticObjects.SuccOfFail = 0;
         }
         else
         {
             DialogResult dialogResult = MessageBox.Show(Survey.Properties.Resource1.SureToDeleteMessage, Global.Constant.DELETE, MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.Yes)
             {
                 if (QuestionWillDeleteOrEdit.TypeOfQuestion == Global.TypeOfQuestion.Slider.ToString())
                 {
                     Slider SliderWillDelete = (Slider)QuestionWillDeleteOrEdit;
                     Check = Operation.DeleteQustion(SliderWillDelete);
                     ListOfAllQuestion.Remove(SliderWillDelete);
                 }
                 else if (QuestionWillDeleteOrEdit.TypeOfQuestion == Global.TypeOfQuestion.Smily.ToString())
                 {
                     Smiles SmileWillDelete = (Smiles)QuestionWillDeleteOrEdit;
                     Check = Operation.DeleteQustion(SmileWillDelete);
                     ListOfAllQuestion.Remove(SmileWillDelete);
                 }
                 else if (QuestionWillDeleteOrEdit.TypeOfQuestion == Global.TypeOfQuestion.Stars.ToString())
                 {
                     Stars StarWillDelete = (Stars)QuestionWillDeleteOrEdit;
                     Check = Operation.DeleteQustion(StarWillDelete);
                     ListOfAllQuestion.Remove(StarWillDelete);
                 }
                 if (Check == 1)
                 {
                     MessageBox.Show(Survey.Properties.Resource1.TheQuestionDeleted);
                     ShowData();
                     StaticObjects.SuccOfFail = 1;
                 }
                 else
                 {
                     MessageBox.Show(Survey.Properties.Resource1.TheQuestionNotDeleted);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         StaticObjects.Erros.Log(ex);
         StaticObjects.SuccOfFail = 0;
         MessageBox.Show(Survey.Properties.Resource1.MessageError);
     }
 }
 public static int AddNewSmile(Qustion NewQuestion)
 {
     try
     {
         if (IsServerConnected())
         {
             int ResultOfBulid = BuildConnectionString();
             if (ResultOfBulid == GenralVariables.Succeeded)
             {
                 Smiles SmileQuestion = (Smiles)NewQuestion;
                 int    Id;
                 int    ResultOfAdd = AddQustionInDataBase(NewQuestion, out Id);
                 if (ResultOfAdd == GenralVariables.Succeeded)
                 {
                     using (SqlConnection Connection = new SqlConnection(GenralVariables.ConnectionString))
                     {
                         SqlCommand CommandForInsertSmile = new SqlCommand(GenralVariables.InsertInSmile, Connection);
                         CommandForInsertSmile.Parameters.AddWithValue(GenralVariables.NewNumberOfSmily, SmileQuestion.NumberOfSmiles);
                         CommandForInsertSmile.Parameters.AddWithValue(GenralVariables.QustionIdDataBase, Id);
                         SmileQuestion.Id = Id;
                         CommandForInsertSmile.Connection.Open();
                         int NumberOfRowsaffected = CommandForInsertSmile.ExecuteNonQuery();
                         if (NumberOfRowsaffected >= 1)
                         {
                             if (SelectIdType(TypeOfQuestion.Smily, ref Id) == GenralVariables.Succeeded)
                             {
                                 SmileQuestion.IdForType = Id;
                                 NewQuestion             = SmileQuestion;
                                 return(GenralVariables.Succeeded);
                             }
                         }
                         else
                         {
                             GenralVariables.Errors.Log(GenralVariables.ErrorAddSliderInLog);
                             return(GenralVariables.ErrorInOperation);
                         }
                     }
                     return(GenralVariables.ErrorInDataBase);
                 }
                 return(ResultOfAdd);
             }
             return(ResultOfBulid);
         }
         return(GenralVariables.ErrorWhileConnectiong);
     }
     catch (Exception ex)
     {
         GenralVariables.Errors.Log(ex.Message);
         return(GenralVariables.ErrorInAddQuestion);
     }
 }
        /// <summary>
        /// This get method take id the question to show the data
        /// </summary>
        public ActionResult EditQuestion(int Id)
        {
            try
            {
                var           QuestionWillEdit = Operation.SelectById(Id);
                QuestionModel NewQustionModel  = new QuestionModel();
                switch (QuestionWillEdit.TypeOfQuestion)
                {
                case TypeOfQuestion.Slider:
                    NewQustionModel.TypeOfQuestion = TypeOfQuestion.Slider;
                    Slider QuestionSlider = (Slider)QuestionWillEdit;
                    NewQustionModel.Id           = QuestionSlider.Id;
                    NewQustionModel.IdForType    = QuestionSlider.IdForType;
                    NewQustionModel.NewText      = QuestionSlider.NewText;
                    NewQustionModel.Order        = QuestionSlider.Order;
                    NewQustionModel.StartValue   = QuestionSlider.StartValue;
                    NewQustionModel.EndValue     = QuestionSlider.EndValue;
                    NewQustionModel.StartCaption = QuestionSlider.StartCaption;
                    NewQustionModel.EndCaption   = QuestionSlider.EndCaption;
                    break;

                case TypeOfQuestion.Smily:
                    NewQustionModel.TypeOfQuestion = TypeOfQuestion.Smily;
                    Smiles QuestionSmile = (Smiles)QuestionWillEdit;
                    NewQustionModel.Id             = QuestionSmile.Id;
                    NewQustionModel.IdForType      = QuestionSmile.IdForType;
                    NewQustionModel.NewText        = QuestionSmile.NewText;
                    NewQustionModel.Order          = QuestionSmile.Order;
                    NewQustionModel.NumberOfSmiles = QuestionSmile.NumberOfSmiles;
                    break;

                case TypeOfQuestion.Stars:
                    NewQustionModel.TypeOfQuestion = TypeOfQuestion.Stars;
                    Stars QuestionStar = (Stars)QuestionWillEdit;
                    NewQustionModel.Id            = QuestionStar.Id;
                    NewQustionModel.IdForType     = QuestionStar.IdForType;
                    NewQustionModel.NewText       = QuestionStar.NewText;
                    NewQustionModel.Order         = QuestionStar.Order;
                    NewQustionModel.NumberOfStars = QuestionStar.NumberOfStars;
                    break;
                }
                return(View(NewQustionModel));
            }
            catch (Exception ex)
            {
                Logger.Log(ex.Message);
                return(RedirectToAction(SurveyWebSite.Resources.Constants.ErrorView, new { ErrorMessage = SurveyWebSite.Resources.Messages.ErrorEdit }));
            }
        }
Beispiel #8
0
 /// <summary>
 /// This function for add Attrubites for type Star
 /// </summary>
 private int AddQuestionFromOperation()
 {
     try
     {
         if (SliderRadio.Checked)
         {
             Slider NewQuestion = new Slider();
             NewQuestion = (Slider)AddAttrubitesForQuestion(NewQuestion);
             if (NewQuestion != null && AddAttrubitesForSlider(ref NewQuestion) == GenralVariables.Succeeded && CheckAndAddQuestion(NewQuestion) == GenralVariables.Succeeded)
             {
                 return(GenralVariables.Succeeded);
             }
             return(GenralVariables.NoData);
         }
         else if (SmilyRadio.Checked)
         {
             Smiles NewQuestion = new Smiles();
             NewQuestion = (Smiles)AddAttrubitesForQuestion(NewQuestion);
             if (NewQuestion != null && AddAttrubitesForSmile(ref NewQuestion) == GenralVariables.Succeeded && CheckAndAddQuestion(NewQuestion) == GenralVariables.Succeeded)
             {
                 return(GenralVariables.Succeeded);
             }
             return(GenralVariables.NoData);
         }
         else if (StarsRadio.Checked)
         {
             Stars NewQuestion = new Stars();
             NewQuestion = (Stars)AddAttrubitesForQuestion(NewQuestion);
             if (NewQuestion != null && AddAttrubitesForStar(ref NewQuestion) == GenralVariables.Succeeded && CheckAndAddQuestion(NewQuestion) == GenralVariables.Succeeded)
             {
                 return(GenralVariables.Succeeded);
             }
             return(GenralVariables.NoData);
         }
         else
         {
             this.DialogResult = DialogResult.Cancel;
             MessageBox.Show(Survey.Properties.Messages.NotChooseTheType, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
             return(GenralVariables.NoData);
         }
     }catch (Exception ex)
     {
         this.DialogResult = DialogResult.Cancel;
         GenralVariables.Errors.Log(ex.Message);
         MessageBox.Show(Survey.Properties.Messages.MessageError);
         return(GenralVariables.Error);
     }
 }
Beispiel #9
0
    public void AddMessage(string nick, string message)
    {
        GameObject go;

        if (items.Count == historySize)         // первое сообщение ставим в конец
        {
            go = items[0];
            go.transform.SetParent(null);
            items.RemoveAt(0);
            //Destroy(i);
            print("reuse chat item");
        }
        else             // если не достигли истории, то создаём
        {
            go = Instantiate(Prefabs.Me.MsgItem) as GameObject;
        }

        var v           = scrollRect.verticalNormalizedPosition;
        var scrollToEnd = (v < 0.01f);

        items.Add(go);
        go.transform.SetParent(chatArea);
        go.transform.localScale    = Vector3.one;
        go.transform.localRotation = Quaternion.identity;
        go.transform.localPosition = Vector3.zero;

        var txt = go.transform.Find("Text").GetComponent <Text>();

        message  = Smiles.Replace(message);
        txt.text = message;

        txt = go.transform.Find("Nick").GetComponent <Text>();
        if (nick != null)
        {
            txt.text = nick;
        }
        else
        {
            txt.gameObject.SetActive(false);
        }

        if (scrollToEnd)
        {
            // если скроллим сразу после добавления элемента, то ничего не происходит
            // нужно подождать немного
            Invoke("ScrollChatToEnd", 0.1f);
        }
    }
Beispiel #10
0
 /// <summary>
 /// This function for add Attrubites for type Slider
 /// </summary>
 private int AddAttrubitesForSmile(ref Smiles NewQuestion)
 {
     try
     {
         NewQuestion.TypeOfQuestion = TypeOfQuestion.Smily;
         NewQuestion.NumberOfSmiles = Convert.ToInt32(NewNumberOfSmiles.Text);
         return(GenralVariables.Succeeded);
     }
     catch (Exception ex)
     {
         this.DialogResult = DialogResult.Cancel;
         GenralVariables.Errors.Log(ex.Message);
         MessageBox.Show(Survey.Properties.Messages.MessageError);
         return(GenralVariables.Error);
     }
 }
 public static int EditSmile(Qustion Qustion)
 {
     try
     {
         if (IsServerConnected())
         {
             int ResultOfBulid = BuildConnectionString();
             if (ResultOfBulid == GenralVariables.Succeeded)
             {
                 Smiles SmileForEdit = (Smiles)Qustion;
                 using (SqlConnection Connection = new SqlConnection(GenralVariables.ConnectionString))
                 {
                     int ResultOfEdit = EditQuestion(SmileForEdit);
                     if (ResultOfEdit == GenralVariables.Succeeded)
                     {
                         SqlCommand CommandForUpdateSmile = new SqlCommand(GenralVariables.UpdateSmile, Connection);
                         CommandForUpdateSmile.Parameters.AddWithValue(GenralVariables.NewNumberOfSmily, SmileForEdit.NumberOfSmiles);
                         CommandForUpdateSmile.Parameters.AddWithValue(GenralVariables.IdQuestion, SmileForEdit.Id);
                         CommandForUpdateSmile.Connection.Open();
                         int NumberOfRowsaffected = CommandForUpdateSmile.ExecuteNonQuery();
                         CommandForUpdateSmile.Parameters.Clear();
                         if (NumberOfRowsaffected >= 1)
                         {
                             return(GenralVariables.Succeeded);
                         }
                         else
                         {
                             GenralVariables.Errors.Log(GenralVariables.ErrorEditSmileInLog);
                             return(GenralVariables.ErrorInOperation);
                         }
                     }
                     return(ResultOfEdit);
                 }
             }
             return(ResultOfBulid);
         }
         return(GenralVariables.ErrorWhileConnectiong);
     }
     catch (Exception ex)
     {
         GenralVariables.Errors.Log(ex.Message);
         return(GenralVariables.ErrorInEditQuestion);
     }
 }
 public static int DeleteSmile(Qustion Question)
 {
     try
     {
         if (IsServerConnected())
         {
             int ResultOfBulid = BuildConnectionString();
             if (ResultOfBulid == GenralVariables.Succeeded)
             {
                 using (SqlConnection Connection = new SqlConnection(GenralVariables.ConnectionString))
                 {
                     Smiles     QustionWillDeleteSmile  = (Smiles)Question;
                     SqlCommand CommandForDeleteQustion = null;
                     CommandForDeleteQustion = new SqlCommand(GenralVariables.DeleteSmilyString, Connection);
                     CommandForDeleteQustion.Parameters.AddWithValue(GenralVariables.IdQuestionWithAt, QustionWillDeleteSmile.IdForType);
                     CommandForDeleteQustion.Connection.Open();
                     int NumberOfRowsaffected = CommandForDeleteQustion.ExecuteNonQuery();
                     CommandForDeleteQustion.Parameters.Clear();
                     int ResultOfDelete = DeleteQustion(Question.Id);
                     if (NumberOfRowsaffected >= 1)
                     {
                         if (ResultOfDelete == GenralVariables.Succeeded)
                         {
                             return(GenralVariables.Succeeded);
                         }
                     }
                     else
                     {
                         GenralVariables.Errors.Log(GenralVariables.ErrorDeleteSmileInLog);
                         return(GenralVariables.ErrorInOperation);
                     }
                     return(ResultOfDelete);
                 }
             }
             return(ResultOfBulid);
         }
         return(GenralVariables.ErrorWhileConnectiong);;
     }
     catch (Exception ex)
     {
         GenralVariables.Errors.Log(ex.Message);
         return(GenralVariables.ErrorInDeleteQuestion);
     }
 }
Beispiel #13
0
 /// <summary>
 /// This old data in object and appear when press edit question
 /// </summary>
 private void ShowDataForEdit()
 {
     try
     {
         GroupOfTypes.Visible = true;
         GroupOfTypes.Enabled = false;
         if (TypeOfQuestion.Slider.ToString() == QuestionWillDeleteOrEdit.TypeOfQuestion)
         {
             Slider EditSlider = (Slider)QuestionWillDeleteOrEdit;
             NewText.Text              = EditSlider.NewText;
             NewOrder.Value            = EditSlider.Order;
             NewStartValue.Value       = EditSlider.StartValue;
             NewEndValue.Value         = EditSlider.EndValue;
             NewStartValueCaption.Text = EditSlider.StartCaption;
             NewEndValueCaption.Text   = EditSlider.EndCaption;
             SliderRadio.Checked       = true;
             SliderForEdit             = (Slider)QuestionWillDeleteOrEdit;
         }
         else if (TypeOfQuestion.Stars.ToString() == QuestionWillDeleteOrEdit.TypeOfQuestion)
         {
             Stars EditStar = (Stars)QuestionWillDeleteOrEdit;
             NewText.Text           = EditStar.NewText;
             NewOrder.Value         = EditStar.Order;
             NewNumberOfStars.Value = EditStar.NumberOfStars;
             StarsRadio.Checked     = true;
             StarForEdit            = (Stars)QuestionWillDeleteOrEdit;
         }
         else if (TypeOfQuestion.Smily.ToString() == QuestionWillDeleteOrEdit.TypeOfQuestion)
         {
             Smiles EditSmile = (Smiles)QuestionWillDeleteOrEdit;
             NewText.Text            = EditSmile.NewText;
             NewOrder.Value          = EditSmile.Order;
             NewNumberOfSmiles.Value = EditSmile.NumberOfSmiles;
             SmilyRadio.Checked      = true;
             SmileForEdit            = (Smiles)QuestionWillDeleteOrEdit;
         }
     }catch (Exception ex)
     {
         StaticObjects.Erros.Log(ex);
         MessageBox.Show(Survey.Properties.Resource1.MessageError);
     }
 }
Beispiel #14
0
        /// <summary>
        /// This old data in object and appear when press edit question
        /// </summary>
        private void ShowDataForEdit()
        {
            try
            {
                GroupOfTypes.Visible = true;
                GroupOfTypes.Enabled = false;
                switch (ReturnNewQuestion.TypeOfQuestion)
                {
                case TypeOfQuestion.Slider:
                    Slider EditSlider = (Slider)ReturnNewQuestion;
                    NewText.Text              = EditSlider.NewText;
                    NewOrder.Value            = EditSlider.Order;
                    NewStartValue.Value       = EditSlider.StartValue;
                    NewEndValue.Value         = EditSlider.EndValue;
                    NewStartValueCaption.Text = EditSlider.StartCaption;
                    NewEndValueCaption.Text   = EditSlider.EndCaption;
                    SliderRadio.Checked       = true;
                    break;

                case TypeOfQuestion.Stars:
                    Stars EditStar = (Stars)ReturnNewQuestion;
                    NewText.Text           = EditStar.NewText;
                    NewOrder.Value         = EditStar.Order;
                    NewNumberOfStars.Value = EditStar.NumberOfStars;
                    StarsRadio.Checked     = true;
                    break;

                case TypeOfQuestion.Smily:
                    Smiles EditSmile = (Smiles)ReturnNewQuestion;
                    NewText.Text            = EditSmile.NewText;
                    NewOrder.Value          = EditSmile.Order;
                    NewNumberOfSmiles.Value = EditSmile.NumberOfSmiles;
                    SmilyRadio.Checked      = true;
                    break;
                }
            }catch (Exception ex)
            {
                GenralVariables.Errors.Log(ex.Message);
                MessageBox.Show(Survey.Properties.Messages.MessageError);
            }
        }
 public static int DeleteSmile(Qustions Question)
 {
     try
     {
         using (SqlConnection Connection = new SqlConnection(DataBaseConnections.connectionString))
         {
             Smiles     QustionWillDeleteSmile  = (Smiles)Question;
             SqlCommand CommandForDeleteQustion = null;
             CommandForDeleteQustion = new SqlCommand(DeleteSmilyString, Connection);
             CommandForDeleteQustion.Parameters.AddWithValue(IdQuestionWithAt, QustionWillDeleteSmile.IdForType);
             CommandForDeleteQustion.Connection.Open();
             CommandForDeleteQustion.ExecuteNonQuery();
             CommandForDeleteQustion.Parameters.Clear();
             DeleteQustion(Question.Id);
             return(1);
         }
     }catch (Exception ex)
     {
         StaticObjects.Erros.Log(ex);
         return(0);
     }
 }
Beispiel #16
0
 /// <summary>
 /// Turn off all effects from selected mode
 /// </summary>
 public static void offLightAlgs()
 {
     if (effects)
     {
         if (Equalizer.getState())
         {
             Equalizer.stop();
         }
         else if (Volume.getState())
         {
             Volume.stop();
         }
         else if (Effects.Random.getState())
         {
             Effects.Random.stop();
         }
     }
     else if (animations)
     {
         if (Animations.Timer.getState())
         {
             Animations.Timer.stop();
         }
         else if (Smiles.getState())
         {
             Smiles.stop();
         }
         else if (Waterfall.getState())
         {
             Waterfall.stop();
         }
         else if (NyanCat.getState())
         {
             NyanCat.stop();
         }
     }
     Thread.Sleep(100);
 }
 public static Qustions EditSmile(Qustions Qustion)
 {
     try
     {
         Smiles SmileForEdit = (Smiles)Qustion;
         using (SqlConnection Connection = new SqlConnection(DataBaseConnections.connectionString))
         {
             SqlCommand CommandForUpdateSmile = new SqlCommand(UpdateSmile, Connection);
             CommandForUpdateSmile.Parameters.AddWithValue(NewNumberOfSmily, SmileForEdit.NumberOfSmiles);
             CommandForUpdateSmile.Parameters.AddWithValue(IdQuestion, SmileForEdit.Id);
             CommandForUpdateSmile.Connection.Open();
             CommandForUpdateSmile.ExecuteNonQuery();
             CommandForUpdateSmile.Parameters.Clear();
             EditQuestion(SmileForEdit);
             return(SmileForEdit);
         }
     }
     catch (Exception ex)
     {
         StaticObjects.Erros.Log(ex);
         return(Qustion);
     }
 }
Beispiel #18
0
 /// <summary>
 /// Turn on specified effect from selected mode
 /// </summary>
 public static void onLightAlg()
 {
     if (effects)
     {
         if (ei == 0)
         {
             Equalizer.start();
         }
         else if (ei == 1)
         {
             Volume.start();
         }
         else if (ei == 2)
         {
             Effects.Random.start();
         }
     }
     else if (animations)
     {
         if (ai == 0)
         {
             Animations.Timer.start();
         }
         else if (ai == 1)
         {
             Smiles.start();
         }
         else if (ai == 2)
         {
             Waterfall.start();
         }
         else if (ai == 3)
         {
             NyanCat.start();
         }
     }
 }
Beispiel #19
0
 /// <summary>
 /// На сервере кто-то улыбнулся
 /// </summary>
 /// <param name="smileType"></param>
 /// <param name="userName"></param>
 void OnServerSmile(Smiles.SmileTypes smileType, string userName)
 {
     ServerPlayer serverPlayer = serverPlayers.GetPlayer(userName);
     if (serverPlayer == null)
     {
         Debug.LogWarning("Игрок " + userName + " не найден");
         return;
     }
     serverPlayer.Smile(smileType);
 }
        public static int CheckTheData(Qustion NewQuestion)
        {
            try
            {
                if (NewQuestion.NewText == "")
                {
                    return(GenralVariables.TextIsEmpty);
                }
                else if (IsNumber(NewQuestion.NewText))
                {
                    return(GenralVariables.TextIsNumber);
                }

                else if (NewQuestion.Order <= 0)
                {
                    return(GenralVariables.OrderLessThanZero);
                }

                if (NewQuestion.TypeOfQuestion == TypeOfQuestion.Slider)
                {
                    Slider TempNewQuestion = (Slider)NewQuestion;
                    if (TempNewQuestion.StartValue <= 0)
                    {
                        return(GenralVariables.StartValueLessThanZero);
                    }
                    else if (TempNewQuestion.EndValue <= 0)
                    {
                        return(GenralVariables.EndValueLessThanZero);
                    }
                    else if (TempNewQuestion.StartValue > 100)
                    {
                        return(GenralVariables.StartValueGreaterThanOneHundered);
                    }
                    else if (TempNewQuestion.EndValue > 100)
                    {
                        return(GenralVariables.EndValueGreaterThanOneHundered);
                    }
                    else if (TempNewQuestion.StartValue >= TempNewQuestion.EndValue)
                    {
                        return(GenralVariables.StartValueGreaterThanEndValue);
                    }
                    else if (TempNewQuestion.StartCaption == "")
                    {
                        return(GenralVariables.StartCaptionIsEmtpty);
                    }
                    else if (IsNumber(TempNewQuestion.StartCaption))
                    {
                        return(GenralVariables.StartCaptionJustNumbers);
                    }
                    else if (TempNewQuestion.EndCaption == "")
                    {
                        return(GenralVariables.EndCaptionIsEmtpty);
                    }
                    else if (IsNumber(TempNewQuestion.EndCaption))
                    {
                        return(GenralVariables.EndCaptionJustNumbers);
                    }
                }
                else if (NewQuestion.TypeOfQuestion == TypeOfQuestion.Smily)
                {
                    Smiles TempNewQuestion = (Smiles)NewQuestion;
                    if (TempNewQuestion.NumberOfSmiles <= 1 || TempNewQuestion.NumberOfSmiles > 5)
                    {
                        return(GenralVariables.NumberOfSmileInvalid);
                    }
                }
                else if (NewQuestion.TypeOfQuestion == TypeOfQuestion.Stars)
                {
                    Stars TempNewQuestion = (Stars)NewQuestion;
                    if (TempNewQuestion.NumberOfStars <= 0 || TempNewQuestion.NumberOfStars > 10)
                    {
                        return(GenralVariables.NumberOfStarsInvalid);
                    }
                }
            }
            catch (Exception ex)
            {
                GenralVariables.Errors.Log(ex.Message);
                return(GenralVariables.ErrorInManger);
            }
            return(GenralVariables.Succeeded);
        }
Beispiel #21
0
        /// <summary>
        /// when i press save button go to this function and from AddOrEdit var will know i edit or add the question
        /// </summary>
        private void Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (AddOrEdirChoice == TypeOfChoice.Add.ToString())
                {
                    if (SliderRadio.Checked)
                    {
                        Slider NewQuestion = new Slider();
                        NewQuestion.NewText        = NewText.Text;
                        NewQuestion.Order          = Convert.ToInt32(NewOrder.Value);
                        NewQuestion.TypeOfQuestion = TypeOfQuestion.Slider.ToString();
                        NewQuestion.StartValue     = Convert.ToInt32(NewStartValue.Text);
                        NewQuestion.EndValue       = Convert.ToInt32(NewEndValue.Text);
                        NewQuestion.StartCaption   = NewStartValueCaption.Text;
                        NewQuestion.EndCaption     = NewEndValueCaption.Text;
                        if (CheckTheData(NewQuestion))
                        {
                            ReturnNewQuestion = (Slider)Operation.AddQustion(NewQuestion);
                            if (StaticObjects.SuccOfFail == 1)
                            {
                                DataEnter();
                            }
                        }
                    }
                    else if (SmilyRadio.Checked)
                    {
                        Smiles NewQuestion = new Smiles();
                        NewQuestion.NewText        = NewText.Text;
                        NewQuestion.Order          = Convert.ToInt32(NewOrder.Value);
                        NewQuestion.TypeOfQuestion = TypeOfQuestion.Smily.ToString();
                        NewQuestion.NumberOfSmiles = Convert.ToInt32(NewNumberOfSmiles.Text);
                        if (CheckTheData(NewQuestion))
                        {
                            ReturnNewQuestion = (Smiles)Operation.AddQustion(NewQuestion);
                            if (StaticObjects.SuccOfFail == 1)
                            {
                                DataEnter();
                            }
                        }
                    }
                    else if (StarsRadio.Checked)
                    {
                        Stars NewQuestion = new Stars();
                        NewQuestion.NewText        = NewText.Text;
                        NewQuestion.Order          = Convert.ToInt32(NewOrder.Value);
                        NewQuestion.TypeOfQuestion = TypeOfQuestion.Stars.ToString();
                        NewQuestion.NumberOfStars  = Convert.ToInt32(NewNumberOfStars.Text);
                        if (CheckTheData(NewQuestion))
                        {
                            ReturnNewQuestion = (Stars)Operation.AddQustion(NewQuestion);
                            if (StaticObjects.SuccOfFail == 1)
                            {
                                DataEnter();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(Survey.Properties.Resource1.NotChooseTheType, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }catch (Exception ex)
            {
                StaticObjects.Erros.Log(ex);
                MessageBox.Show(Survey.Properties.Resource1.MessageError);
            }
            try {
                if (AddOrEdirChoice == TypeOfChoice.Edit.ToString())
                {
                    if (SliderForEdit != null)
                    {
                        SliderForEdit.NewText      = NewText.Text;
                        SliderForEdit.Order        = Convert.ToInt32(NewOrder.Value);
                        SliderForEdit.StartValue   = Convert.ToInt32(NewStartValue.Value);
                        SliderForEdit.EndValue     = Convert.ToInt32(NewEndValue.Value);
                        SliderForEdit.StartCaption = NewStartValueCaption.Text;
                        SliderForEdit.EndCaption   = NewEndValueCaption.Text;
                        if (CheckTheData(SliderForEdit))
                        {
                            ReturnNewQuestion = (Slider)Operation.EditQustion(SliderForEdit);
                            MessageBox.Show(Properties.Resource1.TheEditMessage);
                            StaticObjects.SuccOfFail = 1;
                            this.Close();
                        }
                    }
                    else if (SmileForEdit != null)
                    {
                        SmileForEdit.NewText        = NewText.Text;
                        SmileForEdit.Order          = Convert.ToInt32(NewOrder.Value);
                        SmileForEdit.NumberOfSmiles = Convert.ToInt32(NewNumberOfSmiles.Value);
                        if (CheckTheData(SmileForEdit))
                        {
                            ReturnNewQuestion = (Smiles)Operation.EditQustion(SmileForEdit);
                            MessageBox.Show(Properties.Resource1.TheEditMessage);
                            StaticObjects.SuccOfFail = 1;
                            this.Close();
                        }
                    }
                    else if (StarForEdit != null)
                    {
                        StarForEdit.NewText       = NewText.Text;
                        StarForEdit.Order         = Convert.ToInt32(NewOrder.Value);
                        StarForEdit.NumberOfStars = Convert.ToInt32(NewNumberOfStars.Value);
                        if (CheckTheData(StarForEdit))
                        {
                            ReturnNewQuestion = (Stars)Operation.EditQustion(StarForEdit);
                            MessageBox.Show(Properties.Resource1.TheEditMessage);
                            StaticObjects.SuccOfFail = 1;
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                StaticObjects.Erros.Log(ex);

                MessageBox.Show(Survey.Properties.Resource1.MessageError);
            }
        }
Beispiel #22
0
        /// <summary>
        /// This Function to Check validation of data
        /// </summary>
        private bool CheckTheData(Qustions TypeQuestion)
        {
            try
            {
                if (TypeQuestion.NewText == Constant.Empty)
                {
                    MessageBox.Show(Survey.Properties.Resource1.QuestionIsEmptyMessage, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);;
                    return(false);
                }
                else if (IsNumber(TypeQuestion.NewText))
                {
                    MessageBox.Show(Survey.Properties.Resource1.QuestionIsJustANumberMessage, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                else if (TypeQuestion.Order <= 0)
                {
                    MessageBox.Show(Survey.Properties.Resource1.NewOrderLessThanZeroMessage, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                if (TypeQuestion is Slider)
                {
                    Slider SliderCheck = (Slider)TypeQuestion;
                    if (SliderCheck.StartValue <= 0)
                    {
                        MessageBox.Show(Survey.Properties.Resource1.StartValueLessThanZeroMessage, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (SliderCheck.EndValue <= 0)
                    {
                        MessageBox.Show(Survey.Properties.Resource1.EndValueLessThanZeroMessage, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (SliderCheck.StartValue > 100)
                    {
                        MessageBox.Show(Survey.Properties.Resource1.StartValueGreaterThanOneHundredMessage, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (SliderCheck.EndValue > 100)
                    {
                        MessageBox.Show(Survey.Properties.Resource1.EndValueGreaterThanOneHundredMessage, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (SliderCheck.StartValue >= SliderCheck.EndValue)
                    {
                        MessageBox.Show(Survey.Properties.Resource1.TheEndValueSholudGreaterThanStartValueMessage, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (SliderCheck.StartCaption == Constant.Empty)
                    {
                        MessageBox.Show(Survey.Properties.Resource1.StartCaptionEmptyMessage, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (IsNumber(SliderCheck.StartCaption))
                    {
                        MessageBox.Show(Survey.Properties.Resource1.StartCaptionJustNumberMessage, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (SliderCheck.EndCaption == Constant.Empty)
                    {
                        MessageBox.Show(Survey.Properties.Resource1.EndCaptionEmptyMessage, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (IsNumber(SliderCheck.EndCaption))
                    {
                        MessageBox.Show(Survey.Properties.Resource1.EndCaptionJustNumberMessage, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }
                else if (TypeQuestion is Smiles)
                {
                    Smiles SmilesCheck = (Smiles)TypeQuestion;
                    if (SmilesCheck.NumberOfSmiles <= 1 || SmilesCheck.NumberOfSmiles > 5)
                    {
                        MessageBox.Show(Survey.Properties.Resource1.NumberOfSmileBetweenFiveAndTow, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }
                else if (TypeQuestion is Stars)
                {
                    Stars StarCheck = (Stars)TypeQuestion;
                    if (StarCheck.NumberOfStars <= 0 || StarCheck.NumberOfStars > 10)
                    {
                        MessageBox.Show(Survey.Properties.Resource1.NumberOfStrasBetweenTenAndOne, Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                StaticObjects.Erros.Log(ex);
                MessageBox.Show(Survey.Properties.Resource1.MessageError);

                return(false);
            }
            return(true);
        }
        /// <summary>
        /// Return list of question from database
        /// </summary>
        public static List <Qustions> GetQuestionFromDataBase()
        {
            List <Qustions> TempListOfQustion = new List <Qustions>();
            SqlDataReader   DataReader        = null;
            Smiles          NewSmile          = null;
            Slider          NewSlider         = null;
            Stars           NewStars          = null;

            try
            {
                using (SqlConnection Connection = new SqlConnection(DataBaseConnections.connectionString))
                {
                    SqlCommand CommandForJoinQustion = new SqlCommand(JoinSmileAndQustion, Connection);
                    CommandForJoinQustion.Connection.Open();
                    DataReader = CommandForJoinQustion.ExecuteReader();
                    while (DataReader.Read())
                    {
                        NewSmile                = new Smiles();
                        NewSmile.Id             = Convert.ToInt32(DataReader.GetValue(0));
                        NewSmile.IdForType      = Convert.ToInt32(DataReader.GetValue(1));
                        NewSmile.NewText        = DataReader.GetValue(2) + Constant.Empty;
                        NewSmile.Order          = Convert.ToInt32(DataReader.GetValue(3));
                        NewSmile.NumberOfSmiles = Convert.ToInt32(DataReader.GetValue(4));
                        NewSmile.TypeOfQuestion = TypeOfQuestion.Smily.ToString();
                        TempListOfQustion.Add(NewSmile);
                    }
                    DataReader.Close();
                    CommandForJoinQustion.CommandText = JoinSliderAndQuestion;
                    DataReader = CommandForJoinQustion.ExecuteReader();
                    while (DataReader.Read())
                    {
                        NewSlider                = new Slider();
                        NewSlider.Id             = Convert.ToInt32(DataReader.GetValue(0));
                        NewSlider.IdForType      = Convert.ToInt32(DataReader.GetValue(1));
                        NewSlider.NewText        = DataReader.GetValue(2) + Constant.Empty;
                        NewSlider.Order          = Convert.ToInt32(DataReader.GetValue(3));
                        NewSlider.TypeOfQuestion = TypeOfQuestion.Slider.ToString();
                        NewSlider.StartValue     = Convert.ToInt32(DataReader.GetValue(4));
                        NewSlider.EndValue       = Convert.ToInt32(DataReader.GetValue(5));
                        NewSlider.StartCaption   = DataReader.GetValue(6) + Constant.Empty;
                        NewSlider.EndCaption     = DataReader.GetValue(7) + Constant.Empty;
                        TempListOfQustion.Add(NewSlider);
                    }
                    DataReader.Close();
                    CommandForJoinQustion.CommandText = JoinStarsAndQuestion;
                    DataReader = CommandForJoinQustion.ExecuteReader();
                    while (DataReader.Read())
                    {
                        NewStars                = new Stars();
                        NewStars.Id             = Convert.ToInt32(DataReader.GetValue(0));
                        NewStars.IdForType      = Convert.ToInt32(DataReader.GetValue(1));
                        NewStars.NewText        = DataReader.GetValue(2) + Constant.Empty;
                        NewStars.Order          = Convert.ToInt32(DataReader.GetValue(3));
                        NewStars.NumberOfStars  = Convert.ToInt32(DataReader.GetValue(4));
                        NewStars.TypeOfQuestion = TypeOfQuestion.Stars.ToString();
                        TempListOfQustion.Add(NewStars);
                    }
                }
                return(TempListOfQustion);
            }
            catch (Exception ex)
            {
                StaticObjects.Erros.Log(ex);
                return(TempListOfQustion);
            }
        }
Beispiel #24
0
        /// <summary>
        /// This for bind the object and return to create or edit
        /// </summary>
        /// <returns></returns>
        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            try {
                if (bindingContext.ModelType == typeof(Qustion))
                {
                    HttpRequestBase request = controllerContext.HttpContext.Request;
                    string          text    = request.Form.Get(SurveyWebSite.Resources.Constants.NewText);
                    string          order   = request.Form.Get(SurveyWebSite.Resources.Constants.Order);
                    if (request.Form.Get(SurveyWebSite.Resources.Constants.StartValue) != null)
                    {
                        string StartValue  = request.Form.Get(SurveyWebSite.Resources.Constants.StartValue);
                        string EndValue    = request.Form.Get(SurveyWebSite.Resources.Constants.EndValue);
                        string StarCaption = request.Form.Get(SurveyWebSite.Resources.Constants.StartCaption);
                        string EndCaption  = request.Form.Get(SurveyWebSite.Resources.Constants.EndCaption);

                        Slider NewSlider = new Slider();
                        NewSlider.NewText = text;
                        if (!String.IsNullOrEmpty(order))
                        {
                            NewSlider.Order = Convert.ToInt32(order);
                        }
                        NewSlider.TypeOfQuestion = TypeOfQuestion.Slider;
                        if (!String.IsNullOrEmpty(StartValue))
                        {
                            NewSlider.StartValue = Convert.ToInt32(StartValue);
                        }
                        if (!String.IsNullOrEmpty(EndValue))
                        {
                            NewSlider.EndValue = Convert.ToInt32(EndValue);
                        }
                        NewSlider.StartCaption = StarCaption;
                        NewSlider.EndCaption   = EndCaption;
                        return(NewSlider);
                    }
                    else if (request.Form.Get(SurveyWebSite.Resources.Constants.NumberOfSmiles) != null)
                    {
                        string NumberOfSmile = request.Form.Get(SurveyWebSite.Resources.Constants.NumberOfSmiles);
                        Smiles NewSmile      = new Smiles();
                        NewSmile.NewText = text;
                        if (!String.IsNullOrEmpty(order))
                        {
                            NewSmile.Order = Convert.ToInt32(order);
                        }
                        if (!String.IsNullOrEmpty(order))
                        {
                            NewSmile.NumberOfSmiles = Convert.ToInt32(NumberOfSmile);
                        }
                        NewSmile.TypeOfQuestion = TypeOfQuestion.Smily;
                        return(NewSmile);
                    }
                    else if (request.Form.Get(SurveyWebSite.Resources.Constants.NumberOfStar) != null)
                    {
                        string NumberOfStar = request.Form.Get(SurveyWebSite.Resources.Constants.NumberOfStar);
                        Stars  NewStar      = new Stars();
                        NewStar.NewText = text;
                        if (!String.IsNullOrEmpty(order))
                        {
                            NewStar.Order = Convert.ToInt32(order);
                        }
                        if (!String.IsNullOrEmpty(order))
                        {
                            NewStar.NumberOfStars = Convert.ToInt32(NumberOfStar);
                        }
                        NewStar.TypeOfQuestion = TypeOfQuestion.Stars;
                        return(NewStar);
                    }
                }
                return(base.BindModel(controllerContext, bindingContext));
            }catch (Exception ex)
            {
                Logger.Log(ex.Message);
                return(base.BindModel(controllerContext, bindingContext));
            }
        }
Beispiel #25
0
    void Start()
    {
        if (IOL.Instance == null)
        {
            Debug.LogWarning("Не найден главный инстанс игры");
            return;
        }

        serverRequests = IOL.Instance.ServerRequests;
        serverPlayers = GetComponent<ServerPlayers>();
        smiles = GetComponent<Smiles>();
        state = GameStates.WaitForPlayers;
        times = new GameTimes();

        IOL.Instance.ServerResponses.OnCurrentTimeUpdate += OnServerTimeUpdate;
        IOL.Instance.ServerResponses.OnGameStateUpdate += OnGameStateUpdate;
        IOL.Instance.ServerResponses.OnPlayersInfo += OnPlayersInfo;
        IOL.Instance.ServerResponses.OnCirclesInfo += OnCirclesInfo;
        IOL.Instance.ServerResponses.OnCircleAndPlayer += OnCircleAndPlayer;
        IOL.Instance.ServerResponses.OnSmile += OnServerSmile;
        IOL.Instance.Connection.OnRoomLeave += OnRoomLeave;
        IOL.Instance.Connection.OnConnectClosed += OnConnectClosed;

        serverRequests.ReadyForGame();
    }
Beispiel #26
0
 /// <summary>
 /// Игрок выбрал смайл
 /// </summary>
 /// <param name="smileType"></param>
 public void SmileSelected(Smiles.SmileTypes smileType)
 {
     serverRequests.Smile(smileType);
 }
 /// <summary>
 /// Get all my question from database as list and return the list to manger
 /// </summary>
 public static int GetQuestionFromDataBase(ref List <Qustion> TempListOfQustion)
 {
     try
     {
         if (IsServerConnected())
         {
             int ResultInBulid = BuildConnectionString();
             if (ResultInBulid == GenralVariables.Succeeded)
             {
                 SqlDataReader DataReader = null;
                 Smiles        NewSmile   = null;
                 Slider        NewSlider  = null;
                 Stars         NewStars   = null;
                 using (SqlConnection Connection = new SqlConnection(GenralVariables.ConnectionString))
                 {
                     SqlCommand CommandForJoinQustion = new SqlCommand(GenralVariables.JoinSmileAndQustion, Connection);
                     CommandForJoinQustion.Connection.Open();
                     DataReader = CommandForJoinQustion.ExecuteReader();
                     while (DataReader.Read())
                     {
                         NewSmile                = new Smiles();
                         NewSmile.Id             = Convert.ToInt32(DataReader.GetValue(0));
                         NewSmile.IdForType      = Convert.ToInt32(DataReader.GetValue(1));
                         NewSmile.NewText        = DataReader.GetValue(2).ToString();
                         NewSmile.Order          = Convert.ToInt32(DataReader.GetValue(3));
                         NewSmile.NumberOfSmiles = Convert.ToInt32(DataReader.GetValue(4));
                         NewSmile.TypeOfQuestion = TypeOfQuestion.Smily;
                         TempListOfQustion.Add(NewSmile);
                     }
                     DataReader.Close();
                     CommandForJoinQustion.CommandText = GenralVariables.JoinSliderAndQuestion;
                     DataReader = CommandForJoinQustion.ExecuteReader();
                     while (DataReader.Read())
                     {
                         NewSlider                = new Slider();
                         NewSlider.Id             = Convert.ToInt32(DataReader.GetValue(0));
                         NewSlider.IdForType      = Convert.ToInt32(DataReader.GetValue(1));
                         NewSlider.NewText        = DataReader.GetValue(2).ToString();
                         NewSlider.Order          = Convert.ToInt32(DataReader.GetValue(3));
                         NewSlider.TypeOfQuestion = TypeOfQuestion.Slider;
                         NewSlider.StartValue     = Convert.ToInt32(DataReader.GetValue(4));
                         NewSlider.EndValue       = Convert.ToInt32(DataReader.GetValue(5));
                         NewSlider.StartCaption   = DataReader.GetValue(6).ToString();
                         NewSlider.EndCaption     = DataReader.GetValue(7).ToString();
                         TempListOfQustion.Add(NewSlider);
                     }
                     DataReader.Close();
                     CommandForJoinQustion.CommandText = GenralVariables.JoinStarsAndQuestion;
                     DataReader = CommandForJoinQustion.ExecuteReader();
                     while (DataReader.Read())
                     {
                         NewStars                = new Stars();
                         NewStars.Id             = Convert.ToInt32(DataReader.GetValue(0));
                         NewStars.IdForType      = Convert.ToInt32(DataReader.GetValue(1));
                         NewStars.NewText        = DataReader.GetValue(2).ToString();
                         NewStars.Order          = Convert.ToInt32(DataReader.GetValue(3));
                         NewStars.NumberOfStars  = Convert.ToInt32(DataReader.GetValue(4));
                         NewStars.TypeOfQuestion = TypeOfQuestion.Stars;
                         TempListOfQustion.Add(NewStars);
                     }
                 }
                 return(GenralVariables.Succeeded);
             }
             return(ResultInBulid);
         }
         else
         {
             return(GenralVariables.ErrorWhileConnectiong);
         }
     }
     catch (Exception ex)
     {
         GenralVariables.Errors.Log(ex.Message);
         return(GenralVariables.ErrorInGetQuestion);
     }
 }
Beispiel #28
0
 /// <summary>
 /// Начинаем улыбаться
 /// </summary>
 /// <param name="smileType"></param>
 /// <param name="userName"></param>
 void OnSmile(Smiles.SmileTypes smileType, string userName)
 {
     smileQueue.Add(Game.Instance.Smiles.GetSmileSprite(smileType));
 }
Beispiel #29
0
 public void Smile(Smiles.SmileTypes smileType)
 {
     if (OnSmile != null)
         OnSmile(smileType, userName);
 }
Beispiel #30
0
 /// <summary>
 /// Выбрали смайлик
 /// </summary>
 /// <param name="smileType"></param>
 public void Smile(Smiles.SmileTypes smileType)
 {
     ISFSObject data = new SFSObject();
     data.PutUtfString("smileType", Util.EnumToStr(smileType));
     SendToLastJoinedRoom(Reqeusts.Smile, data);
 }
Beispiel #31
0
        /// <summary>
        /// This function call functions for any type of question for ADD
        /// and call this function in SaveClick function and call anthor function for ADD
        /// </summary>
        private int EditQuestionFromOpertion()
        {
            try {
                switch (ReturnNewQuestion.TypeOfQuestion)
                {
                case TypeOfQuestion.Slider:
                    if (CheckTheData(TypeOfQuestion.Slider))
                    {
                        Slider SliderForEdit = (Slider)ReturnNewQuestion;
                        SliderForEdit = (Slider)AddAttrubitesForQuestion(SliderForEdit);
                        if (AddAttrubitesForSlider(ref SliderForEdit) == GenralVariables.Succeeded)
                        {
                            if (CheckMessageError(Operation.EditQustion(SliderForEdit)))
                            {
                                ReturnNewQuestion = SliderForEdit;
                                this.DialogResult = DialogResult.OK;
                                MessageBox.Show(Properties.Messages.TheEditMessage);
                                this.Close();
                                return(GenralVariables.Succeeded);
                            }
                        }
                    }
                    return(GenralVariables.NoData);

                case TypeOfQuestion.Smily:
                    if (CheckTheData(TypeOfQuestion.Smily))
                    {
                        Smiles SmileForEdit = (Smiles)ReturnNewQuestion;
                        SmileForEdit = (Smiles)AddAttrubitesForQuestion(SmileForEdit);
                        AddAttrubitesForSmile(ref SmileForEdit);
                        if (CheckMessageError(Operation.EditQustion(SmileForEdit)))
                        {
                            ReturnNewQuestion = SmileForEdit;
                            this.DialogResult = DialogResult.OK;
                            MessageBox.Show(Properties.Messages.TheEditMessage);
                            this.Close();
                            return(GenralVariables.Succeeded);
                        }
                    }
                    return(GenralVariables.NoData);

                case TypeOfQuestion.Stars:
                    if (CheckTheData(TypeOfQuestion.Stars))
                    {
                        Stars StarForEdit = (Stars)ReturnNewQuestion;
                        StarForEdit = (Stars)AddAttrubitesForQuestion(StarForEdit);
                        AddAttrubitesForStar(ref StarForEdit);
                        if (CheckMessageError(Operation.EditQustion(StarForEdit)))
                        {
                            ReturnNewQuestion = StarForEdit;
                            MessageBox.Show(Properties.Messages.TheEditMessage);
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                            return(GenralVariables.Succeeded);
                        }
                    }

                    return(GenralVariables.NoData);

                default:
                    this.DialogResult = DialogResult.Cancel;
                    return(GenralVariables.NoData);
                }
            }catch (Exception ex)
            {
                GenralVariables.Errors.Log(ex.Message);
                Save.DialogResult = DialogResult.Cancel;
                MessageBox.Show(Survey.Properties.Messages.MessageError);
                return(GenralVariables.Error);
            }
        }