Example #1
0
        public void MainTest()
        {
//            var input = @"6
//1
//3
//46
//1
//3
//9
//47";

            var input            = @"7
6
12
3
9
3
5
1
12";
            var inputString      = new StringReader(input);
            int roktCouponsCount = Convert.ToInt32(inputString.ReadLine().Trim());

            List <int> roktCoupons = new List <int>();

            for (int i = 0; i < roktCouponsCount; i++)
            {
                int roktCouponsItem = Convert.ToInt32(inputString.ReadLine().Trim());
                roktCoupons.Add(roktCouponsItem);
            }

            long k = Convert.ToInt64(inputString.ReadLine().Trim());

            Question2.numberOfPayment(roktCoupons, k);
        }
 public static void Add(Question2 question)
 {
     lock (_syncRoot)
     {
         Questions.Add(question);
     }
 }
Example #3
0
 static void Main(string[] args)
 {
     Question1.ParseLocSegments();
     Question2.FindNodeXML();
     Console.WriteLine("Hello World!");
     Console.ReadLine();
 }
Example #4
0
 //Fontionc en chager de changer la question ou de finir le quiz
 void changerQuestion()
 {
     if (Question1.activeSelf)
     {
         Question1.SetActive(false);
         Question2.SetActive(true);
     }
     else if (Question2.activeSelf)
     {
         Question2.SetActive(false);
         Question3.SetActive(true);
     }
     else if (Question3.activeSelf)
     {
         Question3.SetActive(false);
         FinQuiz.SetActive(true);
     }
     else if (FinQuiz.activeSelf)
     {
         if (Input.GetKeyDown("z"))
         {
             CompleterNiveau();
         }
     }
 }
Example #5
0
 static void Main(string[] args)
 {
     Question2.Run();
     Question3.Run();
     Question10.Run();
     ThoughtQuestion1.Run();
     Console.ReadKey();
 }
Example #6
0
        public void Check_Positive_Divisors_For_42()
        {
            uint num    = 42;
            var  q2     = new Question2();
            var  result = q2.GetPostiveDivisors(num);

            Assert.That(new uint[] { 1, 2, 3, 6, 7, 14, 21, 42 }, Is.EquivalentTo(result));
        }
Example #7
0
        public void Check_Positive_Divisors_For_60()
        {
            uint num    = 60;
            var  q2     = new Question2();
            var  result = q2.GetPostiveDivisors(num);

            Assert.That(new uint[] { 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60 }, Is.EquivalentTo(result));
        }
Example #8
0
        public void Check_Positive_Divisors_For_1()
        {
            uint num    = 1;
            var  q2     = new Question2();
            var  result = q2.GetPostiveDivisors(num);

            Assert.That(new uint[] { 1 }, Is.EquivalentTo(result));
        }
Example #9
0
        public void CheckForZero()
        {
            uint num = 0;
            var  q2  = new Question2();
            var  ex  = Assert.Throws <ArgumentException>(() => q2.GetPostiveDivisors(num));

            Assert.AreEqual("value of num must be greater than 0", ex.Message);
        }
Example #10
0
        public void Q2Test2()
        {
            Question2 question2 = new Question2();

            int[] testTwo = new int[] { 3, 2, 2, 3 };

            Assert.Equal(4, question2.InitialLength(testTwo, 3));
            Assert.Equal(2, question2.NewLength(testTwo, 3));
        }
Example #11
0
        public void Test1()
        {
            var testCase = new TestCases();

            Question2.Logic(testCase);


            Assert.True(testCase.Output == "-111101110");
        }
 public static void Run()
 {
     // warms up the methods
     Question1.Answer(0.0, 0.0, 0.0);
     Question2.Answer(new int[] { 0 }, new int[] { 0 }, new int[] { 0 });
     Question3.Answer(new int[] { 0 }, new int[] { 0 });
     Question4.Answer(new int[] { 0 }, new int[] { 0 }, 0);
     Question5.Answer(new int[] { 0 });
     Question6.Answer(new string[] { "AA", "AA" });
 }
Example #13
0
        //CRUD Create / Red / Unreaad / Delete(+Read All)

        public static List <Question2> FindAll()
        {
            List <Question2> questions = new List <Question2>();

            //1.Connexion à une base de données

            string          chaineDeConnexion = Properties.Settings.Default.ConnexionString;
            MySqlConnection connexion         = new MySqlConnection(chaineDeConnexion);
            MySqlCommand    commande          = null;
            MySqlDataReader dataReader        = null;

            try
            {
                connexion.Open();

                //2.Préparer envoie d'une commande Mysql
                string requete = "SELECT id, enonce, multipleChoice, ordre FROM t_question";
                commande = new MySqlCommand(requete, connexion);;

                //3.Envoyer la commande
                dataReader = commande.ExecuteReader();

                while (dataReader.Read())
                {
                    //5.Construir l'objet à reenvoyer
                    Question2 quest = new Question2()
                    {
                        Enonce           = dataReader["enonce"].ToString(),    //ToString para convertir el resultado en chaîne de caracter
                        EstChoixMultiple = (bool)dataReader["multipleChoice"], //cast= conversion en este caso el "multiple choice" en entero y verificamos que la conversion sea igual a 1
                        Id    = (int)dataReader["id"],
                        Ordre = (int)dataReader["ordre"]
                    };


                    questions.Add(quest); // para agregarlo en la lista
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }

            finally
            {
                //Fermer la connexion
                dataReader?.Close();
                connexion?.Dispose();
                connexion.Close();
            }



            return(questions);
        }
        protected override void OnDisappearing()
        {
            base.OnDisappearing();

            Question1.RemoveBehaviors();
            Question2.RemoveBehaviors();
            Question3.RemoveBehaviors();
            Question4.RemoveBehaviors();
            Question5.RemoveBehaviors();
            Question6.RemoveBehaviors();
            Question7.RemoveBehaviors();
        }
Example #15
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello PTG world!");

            Question1 questionOne = new Question1();

            int[] testOne      = new int[] { 2, 7, 11, 15 };
            int[] resultOne    = questionOne.TwoSumIterative(testOne, 9);
            int[] resultOnePT2 = questionOne.TwoSumEfficient(testOne, 9);
            Console.WriteLine("[{0}]", string.Join(", ", resultOne));
            Console.WriteLine("[{0}]", string.Join(", ", resultOnePT2));

            Question2 questionTwo = new Question2();

            int[] testTwo = new int[] { 3, 2, 2, 3, 3, 4, 5, 6, 9, 3 };
            Console.WriteLine($"Initial Lenght: {questionTwo.InitialLength(testTwo, 3)}");
            Console.WriteLine($"Final Lenght: {questionTwo.NewLength(testTwo, 3)}");

            Question3 question3 = new Question3();

            int[] test3Arr1       = new int[] { 1, 2, 3, 0, 0, 0 };
            int[] test3Arr2       = new int[] { 2, 5, 6 };
            int[] question3Result = question3.MergeSort(test3Arr1, test3Arr2);
            Console.WriteLine("Question 3");
            Console.WriteLine("[{0}]", string.Join(", ", question3Result));

            Question4 question4 = new Question4();

            Question5 question5 = new Question5();

            Console.WriteLine("Question 5:");
            string q5InTrue  = "A man,!  -  a plAn, a canal: Panama";
            string q5InFasle = "race a car";

            Console.WriteLine($"Q5 Should be TRUE:  {question5.ValidPalindrome(q5InTrue)}");
            Console.WriteLine($"Q5 Should be FALSE:  {question5.ValidPalindrome(q5InFasle)}");

            Question6 question6 = new Question6();

            Console.WriteLine("");
            Console.WriteLine("QUESTION 6");
            string simple     = "(([[{{";
            string test6True  = "(){}[]";
            string test6True2 = "}}))(({{[]";
            string test6False = "{{{{((()(){{{{}}{{[[]{{{{{";

            Console.WriteLine($"Q6 false should be: {question6.HashMapCharacterValidation(simple)}");
            Console.WriteLine($"Q6 True should be: {question6.HashMapCharacterValidation(test6True)}");
            Console.WriteLine($"True should be for starting with close: {question6.HashMapCharacterValidation(test6True2)}");
            Console.WriteLine($"False should be: {question6.HashMapCharacterValidation(test6False)}");

            Console.ReadLine();
        }
        public void CreateCycle()
        {
            Question2 q = new Question2(new string[]
            {
                "pushed first",
                "pushed second",
                "pushed third",
            });

            Assert.AreEqual(q.DetectCycle, false);
            q.Run();
            Assert.AreEqual(q.DetectCycle, true);
        }
    internal void Prediction()
    {
        Question2 obj1 = new Question2();

        Console.Write("Enter the number of wins: ");
        int wins = Int16.Parse(Console.ReadLine());

        Console.Write("Enter the number of draws: ");
        int draws = Int16.Parse(Console.ReadLine());

        Console.Write("Enter the number of losses: ");
        int losses = Int16.Parse(Console.ReadLine());
        int result = obj1.CalculateTeamPoint(wins, draws, losses);

        Console.WriteLine($"Team earned {result} point in entire season");
    }
Example #18
0
        TimedAnswer <int> getSecondAnwser(Test <Cashflows> test)
        {
            var timer = new Stopwatch();

            Cashflows cashflows = test.GetInput();

            timer.Start();

            var answer = Question2.Answer(cashflows.cashFlowIn, cashflows.cashFlowOut);

            timer.Stop();

            var timeTaken = ((double)timer.ElapsedTicks / Stopwatch.Frequency) * 1000000000;

            return(new TimedAnswer <int>(answer, timeTaken));
        }
    static void Main()
    {
        Question1 answer1 = new Question1();

        answer1.Sum();


        Question2 answer2 = new Question2();

        answer2.Prediction();


        Question3 answer3 = new Question3();

        answer3.Initials();
    }
        Answer getSecondAnswer(Cashflows input, TestCase test)
        {
            var timer = new Stopwatch();

            timer.Start();

            var answer = Question2.Answer(input.cashFlowIn, input.cashFlowOut);

            timer.Stop();

            var timeTaken = ((double)timer.ElapsedTicks / Stopwatch.Frequency) * 1000000000;

            return new Answer()
            {
                questionNumber = 2,
                testNumber = test.testNumber,
                correct = answer == test.output ? "CORRECT" : "INCORRECT",
                speed = timeTaken
            };
        }
Example #21
0
        Answer getSecondAnswer(Q2Object input, TestCase test)
        {
            var timer = new Stopwatch();

            timer.Start();

            var answer = Question2.Answer(input.risk, input.bonus, input.trader);

            timer.Stop();

            var timeTaken = ((double)timer.ElapsedTicks / Stopwatch.Frequency) * 1000000000;

            return(new Answer()
            {
                questionNumber = 2,
                testNumber = test.testNumber,
                correct = answer == test.output ? "CORRECT" : "INCORRECT",
                speed = timeTaken
            });
        }
Example #22
0
        /*       public static void Insert(Question nouvelleQuestion)
         *     {
         *
         *         //Ouvrir la connexion
         *         string chaineDeConnexion = Properties.Settings.Default.ConnexionString;
         *         try
         *         {
         *             using (MySqlConnection connexion = new MySqlConnection(chaineDeConnexion)) //se pone using porque va a llamar automaticamente "dispose" asi que este se cerrara SOLO SIRVE SI TENEMOS EL DISPOSE EN NUESTRA VARIABLE
         *             {
         *                 //ouvrir la conexion
         *                 connexion.Open();
         *
         *                 //Préparer la commande
         *                 string requete = "INSERT INTO t_question(enonce, multipleChoice, ordre, quizid)" + " VALUES ('{0}', {1}, {2}, {3})";
         *                 using (MySqlCommand commande = new MySqlCommand(requete, connexion))
         *                 {
         *                     //Format de la requete
         *                     commande.CommandText = string.Format(requete, nouvelleQuestion.Enonce.Replace("'", ("''")), nouvelleQuestion.EstChoixMultiple, nouvelleQuestion.Ordre, 1); ; /*TODO: quizid à remplacer BOUCHON TEMPORAIRE est 1 cara sur Mysql on a id=1*/
/*
 *                      //Exécuter la commande
 *                      //ExecuteNonQuery: insert/delete/update no se puede usar con un select
 *                      commande.ExecuteNonQuery();
 *
 *
 *                      //MYSQL
 *                      nouvelleQuestion.Id = (int)commande.LastInsertedId;
 *                      //nouvelleQuestion.Id = (int)commande.ExecuteScalar(); A VOIR PLUS TARD
 *                  }//Appele commande Dipose
 *              } //Fermer la connexion
 *          }
 *          catch (Exception ex)
 *          {
 *              // TODO: faire quelque chose
 *
 *          }
 *      }
 */
        public static void Update(Question2 questionMaj)
        {
            //Ouvrir la connexion
            string chaineDeConnexion = Properties.Settings.Default.ConnexionString;

            using (MySqlConnection connexion = new MySqlConnection(chaineDeConnexion)) //se pone using porque va a llamar automaticamente "dispose" asi que este se cerrara SOLO SIRVE SI TENEMOS EL DISPOSE EN NUESTRA VARIABLE
            {
                //ouvrir la conexion
                connexion.Open();

                //Préparer la commande
                string requete = "UPDATE t_question SET enonce = '{0}', multipleChoice = {1}, ordre = {2}, quizid={3} WHERE id={4} "; // es importante el WHERE porque nos permite decir que operacion queremos actualizar
                using (MySqlCommand commande = new MySqlCommand(requete, connexion))
                {
                    //Format de la requete
                    commande.CommandText = string.Format(requete, questionMaj.Enonce.Replace("'", ("''")), questionMaj.EstChoixMultiple, questionMaj.Ordre, questionMaj.Ordre, 1, questionMaj.Id); /*TODO: quizid à remplacer BOUCHON TEMPORAIRE est 1 cara sur Mysql on a id=1*/

                    //Exécuter la commande
                    commande.ExecuteNonQuery();
                } //Appele commande Dipose
            }     //Fermer la connexion
        }
        public ActionResult AddQuestionnaire(QuestionnairesViewModel Model, string[] BlankOptions, string[] AnswerOptions)
        {
            try
            {
                VTSDBEntities objDB = new VTSDBEntities();

                if (Model.QuestionType == DAL.Model.QuestionType.SingleLine)
                {
                    Question1 question1 = new Question1();
                    question1.QuestionSentence = Model.QuestionText;
                    question1.OriginalSentence = "";
                    List <Option1> QuesOptions = new List <Option1>();
                    foreach (string OptionText in BlankOptions)
                    {
                        Option1 EachOption = new Option1();
                        EachOption.OptionText = OptionText;
                        EachOption.Question1  = question1;
                        QuesOptions.Add(EachOption);
                    }

                    List <Answer1> AllAnswers = new List <Answer1>();
                    foreach (string AnswerText in AnswerOptions)
                    {
                        Answer1 EachAnswer = new Answer1();
                        EachAnswer.AnswerText = AnswerText;
                        EachAnswer.Question1  = question1;
                        AllAnswers.Add(EachAnswer);
                    }

                    question1.Answer1 = AllAnswers;
                    question1.Option1 = QuesOptions;
                    objDB.Question1.Add(question1);
                    objDB.SaveChanges();
                    ViewBag.SuccessMsg = "Questionnaire added successfully.";
                }
                else if (Model.QuestionType == DAL.Model.QuestionType.MultiLine)
                {
                    Question2 question2 = new Question2();
                    question2.QuestionText = Model.QuestionText;

                    List <Option2> QuesOptions = new List <Option2>();
                    foreach (string OptionText in BlankOptions)
                    {
                        Option2 EachOption = new Option2();
                        EachOption.OptionText = OptionText;
                        EachOption.Question2  = question2;
                        QuesOptions.Add(EachOption);
                    }

                    List <Answer2> AllAnswers = new List <Answer2>();
                    Answer2        EachAnswer = new Answer2();
                    EachAnswer.Answer    = Model.AnswerText;
                    EachAnswer.Question2 = question2;
                    AllAnswers.Add(EachAnswer);


                    question2.Answer2 = AllAnswers;
                    question2.Option2 = QuesOptions;
                    objDB.Question2.Add(question2);
                    objDB.SaveChanges();
                    ViewBag.SuccessMsg = "Questionnaire added successfully.";
                }
                else if (Model.QuestionType == DAL.Model.QuestionType.SingleOption)
                {
                    Question3 question3 = new Question3();
                    question3.QuestionText = Model.QuestionText;

                    List <Answer3> AllAnswers = new List <Answer3>();
                    foreach (string AnswerText in AnswerOptions)
                    {
                        Answer3 EachAnswer = new Answer3();
                        EachAnswer.Answer    = AnswerText;
                        EachAnswer.Question3 = question3;
                        AllAnswers.Add(EachAnswer);
                    }


                    question3.Answer3 = AllAnswers;
                    objDB.Question3.Add(question3);
                    objDB.SaveChanges();
                    ViewBag.SuccessMsg = "Questionnaire added successfully.";
                }
                else if (Model.QuestionType == DAL.Model.QuestionType.MultiOption)
                {
                    Question4 question4 = new Question4();
                    question4.QuestionText = Model.QuestionText;

                    List <Answer4> AllAnswers = new List <Answer4>();
                    foreach (string AnswerText in AnswerOptions)
                    {
                        Answer4 EachAnswer = new Answer4();
                        EachAnswer.Answer    = AnswerText;
                        EachAnswer.Question4 = question4;
                        AllAnswers.Add(EachAnswer);
                    }

                    question4.Answer4 = AllAnswers;
                    objDB.Question4.Add(question4);
                    objDB.SaveChanges();
                    ViewBag.SuccessMsg = "Questionnaire added successfully.";
                }
                else if (Model.QuestionType == DAL.Model.QuestionType.Date)
                {
                    Question5 question5 = new Question5();
                    question5.QuestionText = Model.QuestionText;

                    List <Answer5> AllAnswers = new List <Answer5>();
                    foreach (string AnswerText in AnswerOptions)
                    {
                        Answer5 EachAnswer = new Answer5();
                        EachAnswer.Answer    = AnswerText;
                        EachAnswer.Question5 = question5;
                        AllAnswers.Add(EachAnswer);
                    }

                    question5.Answer5 = AllAnswers;
                    objDB.Question5.Add(question5);
                    objDB.SaveChanges();
                    ViewBag.SuccessMsg = "Questionnaire added successfully.";
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                //throw raise;
                ViewBag.ErrorMsg = "An error occurred while saving the questionnaire.";
            }

            ModelState.Clear();
            return(View());
        }
Example #24
0
 public void Run()
 {
     Question2.Run();
 }
Example #25
0
        static void Main(string[] args)
        {
            while (true)
            {
                Question1 q1 = null;
                Question2 q2 = null;
                Question3 q3 = null;

                Console.WriteLine("===============================================================");
                Console.WriteLine("ECE457-ASSIGNMENT 2");
                Console.WriteLine("Shweta Aladi, Bilal Arshad, Pooja Sardesai");
                Console.WriteLine("===============================================================\n");
                Console.WriteLine("Select the assignment question:");
                Console.WriteLine("[A] Vehicle Routing Problem");
                Console.WriteLine("[B] QAP Assignment");
                Console.WriteLine("[C] PID Controller");
                Console.WriteLine("[Q] Quit");
                char a = Console.ReadLine().ToLower().ToCharArray()[0];

                switch (a)
                {
                    case 'a':
                        Console.WriteLine("Run with constraint? Y/N");
                        char b = Console.ReadLine().ToLower().ToCharArray()[0];
                        if (b == 'y')
                        {
                            q1 = new Question1(6, 100, 200, 0.9, 50); //constraint
                        }
                        else if (b == 'n')
                        {
                            q1 = new Question1(6, 100, 200, 0.9); // no constraint
                        }
                        else
                        {
                            break;
                        }

                        q1.RunPartA();
                        break;
                    case 'b':
                        q2 = new Question2();
                        q2.RunPartB();
                        break;
                    case 'c':
                        Console.WriteLine("Use default values? Y/N [No. of Generations: 50, Population: 150, Mutation Prob.: 0.25, Crossover Prob.: 0.6 ]");
                        char i = Console.ReadLine().ToLower().ToCharArray()[0];
                        String filename = "";
                        if (i == 'y')
                        {
                            Console.WriteLine("Enter File Name to save results: [Leave Blank To NOT Save the Results]");
                            filename = Console.ReadLine();

                            q3 = new Question3();
                        }
                        else if (i == 'n')
                        {
                            Console.WriteLine("Enter File Name to save results: [Leave Blank To NOT Save the Results]");
                            filename = Console.ReadLine();

                            try
                            {
                                int generations = 0;
                                while (generations <= 0)
                                {
                                    Console.WriteLine("Enter No. of Generations: [>0]");
                                    generations = int.Parse(Console.ReadLine());
                                }

                                int population = 0;
                                while (population <= 2)
                                {
                                    Console.WriteLine("Enter Population Size: [>2]");
                                    population = int.Parse(Console.ReadLine());
                                }

                                double mutationProb = -1;
                                while ( !(mutationProb >= 0 && mutationProb <= 1) )
                                {
                                    Console.WriteLine("Enter Mutation Prob.: [0 - 1]");
                                    mutationProb = double.Parse(Console.ReadLine());
                                }

                                double crossoverProb = -1;
                                while ( !(crossoverProb >= 0 && crossoverProb <= 1) )
                                {
                                    Console.WriteLine("Enter Crossover Prob.: [0 - 1]");
                                    crossoverProb = double.Parse(Console.ReadLine());
                                }

                                q3 = new Question3(generations, population, mutationProb, crossoverProb);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine("Error Occured: " + e.ToString());
                                break;
                            }

                        } else {
                            break;
                        }
                        q3.Run();
                        if (!filename.Equals(""))
                        {
                            Question3.generateCSV(filename,q3.GetBestPopulation(),q3.GetAllFitness());
                        }
                        break;
                    case 'q':
                        Console.WriteLine("Exiting...");
                        return;
                    default:
                        Console.WriteLine("Invalid selection");
                        break;
                }

            }
        }
Example #26
0
        private async void FadeAnimations()
        {
            if (correct)
            {
                return;
            }

            ToggleButtonSet1(true);

            await Task.Delay(5000);

            if (correct)
            {
                return;
            }

            Question1.Fade(value: 0f, duration: 1100, delay: 0, easingType: EasingType.Default).Start();
            ToggleButtonSet1(false);

            if (correct)
            {
                return;
            }

            Question2.Fade(value: 1f, duration: 1100, delay: 0, easingType: EasingType.Default).Start();
            ToggleButtonSet2(true);

            await Task.Delay(5000);

            if (correct)
            {
                return;
            }

            Question2.Fade(value: 0f, duration: 1100, delay: 0, easingType: EasingType.Default).Start();
            ToggleButtonSet2(false);
            if (correct)
            {
                return;
            }

            Question3.Fade(value: 1f, duration: 1100, delay: 0, easingType: EasingType.Default).Start();
            ToggleButtonSet3(true);
            await Task.Delay(5000);

            if (correct)
            {
                return;
            }

            Question3.Fade(value: 0f, duration: 1100, delay: 0, easingType: EasingType.Default).Start();
            ToggleButtonSet3(false);
            if (correct)
            {
                return;
            }

            Question1.Fade(value: 1f, duration: 1100, delay: 0, easingType: EasingType.Default).Start();
            if (correct)
            {
                return;
            }

            FadeAnimations();
        }
Example #27
0
 public void Question2Test()
 {
     Assert.AreEqual(Question2.PrintNumber(),
                     "20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1"
                     );
 }
Example #28
0
        public void PDFGeneration()
        {
            MySqlConnection con1 = new MySqlConnection();

            //SqlConnection con1 = new SqlConnection();
            //con1.ConnectionString = ConfigurationManager.ConnectionStrings["DBconnection"].ConnectionString;
            //con1.ConnectionString = "Data Source = 123.176.34.15;port=4043;Integrated Security=False; Initial Catalog = survey; User ID = TestLogin; Password = ASD123!@#;";
            con1.ConnectionString = _base.Decrypt(ConfigurationManager.ConnectionStrings["MysqlPath"].ConnectionString);
            //SqlDataAdapter da = new SqlDataAdapter("select * from question where submitted =1 AND MailStatus=0", con1);
            MySqlDataAdapter da = new MySqlDataAdapter("select * from question where submitted =1 AND MailStatus=0", con1);
            DataTable        dt = new DataTable();

            da.Fill(dt);
            Base @base = new Base();



            foreach (DataRow dr in dt.Rows)
            {
                ReportDocument ss = new ReportDocument();
                ConnectionInfo myConnectionInfo = new ConnectionInfo();
                myConnectionInfo.AllowCustomConnection = true;
                myConnectionInfo.ServerName            = _base.Decrypt(ConfigurationManager.AppSettings["SERVERNAME"].ToString());
                myConnectionInfo.DatabaseName          = _base.Decrypt(ConfigurationManager.AppSettings["DATABASE"].ToString());
                myConnectionInfo.IntegratedSecurity    = Convert.ToBoolean(ConfigurationManager.AppSettings["INTEGRATEDSECURITY"].ToString());
                myConnectionInfo.UserID   = _base.Decrypt(ConfigurationManager.AppSettings["USERID"].ToString());
                myConnectionInfo.Password = _base.Decrypt(ConfigurationManager.AppSettings["PASSWORD"].ToString());
                myConnectionInfo.Type     = ConnectionInfoType.SQL;

                string Rpt_Path   = System.Web.Hosting.HostingEnvironment.MapPath(ConfigurationManager.AppSettings["rptLocation"].ToString());
                string outputPath = System.Web.Hosting.HostingEnvironment.MapPath(ConfigurationManager.AppSettings["OutputPath_pdf"].ToString());

                try
                {
                    JavaScriptSerializer scr  = new JavaScriptSerializer();
                    Question2            Que2 = (Question2)scr.Deserialize(dr["la_q2"].ToString().Replace("\\", ""), typeof(Question2));
                    Question4            Que4 = (Question4)scr.Deserialize(dr["la_q4"].ToString().Replace("\\", ""), typeof(Question4));
                    Question7            Que7 = (Question7)scr.Deserialize(dr["la_q7"].ToString().Replace("\\", ""), typeof(Question7));
                    question8            Que8 = (question8)scr.Deserialize(dr["la_q8"].ToString().Replace("\\", ""), typeof(question8));
                    //List<string> Que9 = (List<string>)scr.Deserialize(dr["la_q9"].ToString().Replace("\\", ""), typeof(List<string>));
                    Question11 Que11 = (Question11)scr.Deserialize(dr["la_q11"].ToString().Replace("\\", ""), typeof(Question11));
                    //Question15 Que15 = (Question15)scr.Deserialize(dr["la_q15"].ToString().Replace("\\", ""), typeof(Question15));
                    FQ1 fq1 = (FQ1)scr.Deserialize(dr["fq1"].ToString().Replace("\\", ""), typeof(FQ1));
                    FQ2 fq2 = (FQ2)scr.Deserialize(dr["fq2"].ToString().Replace("\\", ""), typeof(FQ2));
                    FQ3 fq3 = (FQ3)scr.Deserialize(dr["fq3"].ToString().Replace("\\", ""), typeof(FQ3));


                    string que1  = dr["la_q1"].ToString();
                    string que3  = dr["la_q3"].ToString();
                    string que5  = dr["la_q5"].ToString();
                    string que6  = dr["la_q6"].ToString();
                    string que9  = dr["la_q9"].ToString();
                    string que10 = dr["la_q10"].ToString();
                    string que12 = dr["la_q12"].ToString();
                    string que13 = dr["la_q13"].ToString();
                    string que14 = dr["la_q14"].ToString();
                    string que15 = dr["la_q15"].ToString();

                    String User_ID = dr["User_ID"].ToString();

                    con1.Open();
                    string       q    = "Select * from  users  WHERE User_ID = " + User_ID + " ";
                    MySqlCommand cmd3 = new MySqlCommand(q, con1);
                    //var a = cmd3.ExecuteScalar();

                    MySqlDataReader reader = cmd3.ExecuteReader();
                    MySqlUser       u      = new MySqlUser();
                    while (reader.Read())
                    {
                        u.FirstName   = reader.GetString("First_Name");
                        u.SecoundName = reader.GetString("Second_Name");
                        u.Email       = reader.GetString("Email");
                        u.Compnay     = reader.GetString("Company_Name");
                        u.UserName    = reader.GetString("User_Name");
                    }

                    con1.Close();

                    CrystalReport crypt = new CrystalReport();


                    crypt.SetParameterValue("Company_Name", u.Compnay);
                    crypt.SetParameterValue("User", u.FirstName + " " + u.SecoundName);
                    crypt.SetParameterValue("Promantus_POC", "Promantus");



                    crypt.SetParameterValue("Q4.1", Que4.la_q4_1);
                    crypt.SetParameterValue("Q4.2", Que4.la_q4_2);
                    crypt.SetParameterValue("Q4.3", Que4.la_q4_3);
                    //crypt.SetParameterValue("Q4.5", Que4.la_q4_5.ToString());

                    crypt.SetParameterValue("Q6", que6);

                    crypt.SetParameterValue("Q11", Que11.la_q11_1.ToString() + " , " + Que11.la_q11_2.ToString());

                    crypt.SetParameterValue("Q12", que12);

                    crypt.SetParameterValue("Q13", que13);

                    crypt.SetParameterValue("Q14", que14);

                    //crypt.SetParameterValue("Q15", Que15.la_q15_1 + " , " + Que15.la_q15_2.ToString());
                    crypt.SetParameterValue("Q15", que15);

                    crypt.SetParameterValue("f1", fq1.f1);
                    crypt.SetParameterValue("f2", fq1.f2);
                    crypt.SetParameterValue("f3", fq1.f3);
                    crypt.SetParameterValue("f4", fq2.f4);
                    crypt.SetParameterValue("f5", fq2.f5);
                    crypt.SetParameterValue("f6", fq2.f6);
                    crypt.SetParameterValue("f7", fq3.f7);
                    crypt.SetParameterValue("f8", fq3.f8);
                    if (que3 == "no")
                    {
                        if (Que4.la_q4_1 != "SAP ECC6.0" && Que4.la_q4_1 != "EHP")
                        {
                            crypt.SetParameterValue("Img_Op1", true);
                            crypt.SetParameterValue("Img_Op2", false);
                        }
                        else
                        {
                            crypt.SetParameterValue("Img_Op2", true);
                            crypt.SetParameterValue("Img_Op1", false);
                        }
                    }

                    foreach (CrystalDecisions.CrystalReports.Engine.Table myTable in crypt.Database.Tables)
                    {
                        TableLogOnInfo myTableLogonInfo = myTable.LogOnInfo;
                        myTableLogonInfo.ConnectionInfo = myConnectionInfo;
                        myTable.ApplyLogOnInfo(myTableLogonInfo);
                        myTable.Location = myConnectionInfo.DatabaseName + ".dbo." + myTable.Location.Substring(myTable.Location.LastIndexOf(".") + 1);
                        myTable.LogOnInfo.ConnectionInfo.ServerName = myConnectionInfo.ServerName;
                    }

                    CrystalReportViewer crb = new CrystalReportViewer();
                    crb.ReportSource = crypt;


                    ss.Load(Rpt_Path);


                    #region Q2
                    String Q2 = "";
                    if (Que2 != null)
                    {
                        if (Que2.la_q2_1 != "" && Que2.la_q2_1 != "undefined")
                        {
                            Q2 = Que2.la_q2_1 + ",";
                        }
                        if (Que2.la_q2_2 == "yes")
                        {
                            Q2 = Q2 + " Development,";
                        }

                        if (Que2.la_q2_3 == "yes")
                        {
                            Q2 = Q2 + " Sandbox,";
                        }

                        if (Que2.la_q2_4 == "yes")
                        {
                            Q2 = Q2 + " Quality / Test,";
                        }

                        if (Que2.la_q2_5 == "yes")
                        {
                            Q2 = Q2 + " Production,";
                        }

                        if (Que2.la_q2_6 != "")
                        {
                            Q2 = Q2 + Que2.la_q2_6;// " Any other System / Client in the SAP Landscape";
                        }

                        #endregion Q2
                        ss.SetParameterValue("Q2", Q2);
                    }

                    ss.SetParameterValue("Q4.1", Que4.la_q4_1);
                    ss.SetParameterValue("Q4.2", Que4.la_q4_2);
                    ss.SetParameterValue("Q4.3", Que4.la_q4_3);
                    //ss.SetParameterValue("Q4.5", Que4.la_q4_5.ToString());

                    ss.SetParameterValue("Q6", que6);

                    if (que3 == "no")
                    {
                        if (Que4.la_q4_1 != "SAP ECC6.0" && Que4.la_q4_1 != "EHP")
                        {
                            ss.SetParameterValue("Img_Op1", true);
                            ss.SetParameterValue("Img_Op2", false);
                        }
                        else
                        {
                            ss.SetParameterValue("Img_Op2", true);
                            ss.SetParameterValue("Img_Op1", false);
                        }
                    }

                    #region Q7
                    String Q7 = "";
                    if (Que7 != null)
                    {
                        if (Que7.la_q7_FI == "yes")
                        {
                            Q7 = Q7 + "Financials,";
                        }
                        if (Que7.la_q7_CO == "yes")
                        {
                            Q7 = Q7 + " Controlling,";
                        }
                        if (Que7.la_q7_MM == "yes")
                        {
                            Q7 = Q7 + " Materials Management,";
                        }

                        if (Que7.la_q7_SD == "yes")
                        {
                            Q7 = Q7 + " Sales & Distribution,";
                        }

                        if (Que7.la_q7_PP == "yes")
                        {
                            Q7 = Q7 + " Production Planning,";
                        }

                        if (Que7.la_q7_QM == "yes")
                        {
                            Q7 = Q7 + " Quality Management,";
                        }
                        if (Que7.la_q7_PS == "yes")
                        {
                            Q7 = " Project Systems,";
                        }

                        if (Que7.la_q7_PM == "yes")
                        {
                            Q7 = Q7 + " Plant Maintenance,";
                        }

                        if (Que7.la_q7_CS == "yes")
                        {
                            Q7 = Q7 + " Customer Service,";
                        }

                        if (Que7.la_q7_HR == "yes")
                        {
                            Q7 = Q7 + " Human Resources,";
                        }

                        if (Que7.la_q7_WM == "yes")
                        {
                            Q7 = Q7 + " Warehouse Management,";
                        }

                        if (Que7.la_q7_LO_VC == "yes")
                        {
                            Q7 = Q7 + " Variant Configuration,";
                        }

                        if (Que7.la_q7_LO_WTY == "yes")
                        {
                            Q7 = Q7 + " Warranty Management,";
                        }

                        if (Que7.la_q7_LO_SPM == "yes")
                        {
                            Q7 = Q7 + " Spare Parts Management,";
                        }

                        if (Que7.la_q7_other != "")
                        {
                            Q7 = Q7 + Que7.la_q7_other;
                        }


                        ss.SetParameterValue("Q7", Q7);
                    }
                    #endregion Q7
                    ss.SetParameterValue("Q11", Que11.la_q11_1.ToString() + " , " + Que11.la_q11_2.ToString());

                    ss.SetParameterValue("Q12", que12);
                    ss.SetParameterValue("Q13", que13);

                    ss.SetParameterValue("Q14", que14);

                    ss.SetParameterValue("Q15", que15);

                    //ss.SetParameterValue("Q15", Que15.la_q15_1 + " , " + Que15.la_q15_2.ToString());

                    ss.SetParameterValue("f1", fq1.f1);
                    ss.SetParameterValue("f2", fq1.f2);
                    ss.SetParameterValue("f3", fq1.f3);
                    ss.SetParameterValue("f4", fq2.f4);
                    ss.SetParameterValue("f5", fq2.f5);
                    ss.SetParameterValue("f6", fq2.f6);
                    ss.SetParameterValue("f7", fq3.f7);
                    ss.SetParameterValue("f8", fq3.f8);

                    ss.SetParameterValue("Company_Name", u.Compnay);
                    ss.SetParameterValue("User", u.FirstName + " " + u.SecoundName);
                    ss.SetParameterValue("Promantus_POC", "Promantus");


                    ExportOptions CrExportOptions;
                    DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
                    PdfRtfWordFormatOptions    CrFormatTypeOptions          = new PdfRtfWordFormatOptions();
                    CrDiskFileDestinationOptions.DiskFileName = outputPath + User_ID + ".pdf";
                    CrExportOptions = ss.ExportOptions;
                    {
                        CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                        CrExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
                        CrExportOptions.DestinationOptions    = CrDiskFileDestinationOptions;
                        CrExportOptions.FormatOptions         = CrFormatTypeOptions;
                    }
                    ss.Export();
                    // con1.Open();
                    // string q = "Select Email from  users  WHERE User_ID = " + User_ID + " ";
                    // MySqlCommand cmd3 = new MySqlCommand(q, con1);
                    //var a= cmd3.ExecuteScalar();

                    Boolean S = @base.AddQuestionnaire_Mail(Convert.ToInt32(User_ID), u.Email);
                    con1.Open();
                    string       myQuery = "UPDATE question SET MailStatus = " + S + " WHERE User_ID = " + User_ID + " ";
                    MySqlCommand cmd2    = new MySqlCommand(myQuery, con1);
                    cmd2.ExecuteNonQuery();
                    con1.Close();
                }
                catch (Exception ex)
                {
                    _log.createLog(ex, "-->CrystalReportPDF-->Loop" + ex.Message.ToString());
                }
                finally
                {
                    if (ss != null)
                    {
                        ss.Close();
                        ss.Dispose();
                    }
                }
            }
        }
Example #29
0
        public void OneSideImmediatelyLoadTest()
        {
            Question2 question;
            Guid answerID;
            // 添加数据记录
            using (var repo = RepositoryContext.GetRepository())
            {
                question = new Question2() { Name = "question1123", CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now };

                var addAnswer1 = new Answer2()
                {
                    Name = "answer1",
                    CreatedOn = DateTime.Now,
                    UpdatedOn = DateTime.Now,
                    Question = question
                };
                var addAnswer2 = new Answer2()
                {
                    Name = "answer2",
                    CreatedOn = DateTime.Now,
                    UpdatedOn = DateTime.Now,
                    Question = question
                };
                answerID = addAnswer1.ID;

                question.Answers.Add(addAnswer1);
                question.Answers.Add(addAnswer2);

                repo.Add(question);

                repo.SaveChanges();
            }

            // 由Answer到Question
            using (var repo = RepositoryContext.GetRepository())
            {
                //SELECT * FROM [Answer] answer0_ WHERE answer0_.ID='029ECE8D-ACD5-461A-BE09-4099708494A7';
                //SELECT * FROM [Question] this_ WHERE this_.ID = '0F20A549-3E1E-499D-9ADF-06BBD472E0BE';
                var testAnswer = repo.GetByID<Answer2>(answerID);

                var tQuestion = testAnswer.Question;

                Assert.AreEqual(tQuestion.ID, question.ID);
                //SELECT * FROM [Question] this_ WHERE this_.ID = '0F20A549-3E1E-499D-9ADF-06BBD472E0BE';
                var testQuestion = repo.GetAll<Question2>(p => p.ID == testAnswer.Question.ID);

                Assert.AreEqual(testQuestion[0].ID, testAnswer.Question_ID);
            }
        }
Example #30
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Third Day");
            Console.WriteLine("");

            Console.WriteLine("Question 1 !!!");
            int[] testQ1arr1 = new int[] { 1, 2, 3, 4 };
            int   testQ1Len1 = 2;

            int[]           testQ1arr2 = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };
            int             testQ1Len2 = 3;
            Question1Proper question1  = new Question1Proper();

            int[][] q1ResultTest1 = question1.subArrs(testQ1arr1, testQ1Len1);
            for (int i = 0; i < q1ResultTest1.Length; i++)
            {
                for (int j = 0; j < q1ResultTest1[i].Length; j++)
                {
                    Console.Write(q1ResultTest1[i][j]);
                }
                Console.WriteLine();
            }
            int[][] q1ResultTest2 = question1.subArrs(testQ1arr2, testQ1Len2);
            for (int i = 0; i < q1ResultTest2.Length; i++)
            {
                for (int j = 0; j < q1ResultTest2[i].Length; j++)
                {
                    Console.Write(q1ResultTest2[i][j]);
                }
                Console.WriteLine();
            }

            Console.WriteLine("");

            Question2 question2 = new Question2();

            Console.WriteLine("Question 2 !!!!");
            string testQ2str1 = "?rail? !SafeTy!";
            string testQ2str2 = "fairy tales";
            string testQ2str3 = "rail safeee";

            Console.WriteLine($"Question 2:?rail? !SafeTy!: rail safety: {question2.AreStringsAnagrams(testQ2str1, testQ2str2)} ");
            Console.WriteLine($"Question 2:rail? SafeTy!: rail safeee: {question2.AreStringsAnagrams(testQ2str1, testQ2str3)} ");

            Console.WriteLine("");

            Question3 question3 = new Question3();

            Console.WriteLine("Question 3 !!!!");
            question3.BuildPyramid(-1);
            question3.BuildPyramid(1);
            question3.BuildPyramid(2);
            question3.BuildPyramid(3);
            question3.BuildPyramid(4);
            question3.BuildPyramid(7);

            Question5 question5 = new Question5();

            question5.PrintPascal(5);
            Console.WriteLine($"Print only the last line..example input 5:");
            question5.SinglePascal(5);

            Console.ReadLine();
        }
 public void AnswertheQuestions()
 {
     Question1.Click();
     Question2.Click();
     Question3.Click();
 }
Example #32
0
    static void Main2()
    {
        Question2 answer = new Question2();

        answer.Execute();
    }