예제 #1
0
 public override string ToString()
 {
     return("Event Id: " + Event_Id + " Employee Id: " +
            Employee_Id.GetValueOrDefault() + " Start Time: " + Start_Time.GetValueOrDefault().ToShortDateString() +
            " Duration in days: " + Duration_In_Days.GetValueOrDefault() + " Describe: " + Describe +
            " Account group: " + Account_Group);
 }
예제 #2
0
 public bool Equals(Material_Apply other)
 {
     return(string.Equals(Teacher_Id, other.Teacher_Id) &&
            Apply_Time.Equals(other.Apply_Time) &&
            Start_Time.Equals(other.Start_Time) &&
            End_Time.Equals(other.End_Time) &&
            string.Equals(Teach_Depart, other.Teach_Depart) &&
            string.Equals(Teach_Field, other.Teach_Field) &&
            string.Equals(Material_Id, other.Material_Id));
 }
예제 #3
0
        internal void Addingdate()
        {
            Actions actions = new Actions(Global.GlobalDefinitions.driver);



            //Populate the Excel sheet
            Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "Share_Skill");

            //click on share skill
            SSbutton.Click();
            Thread.Sleep(2000);

            //Click on title
            Title.Click();
            Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title"));

            //clic on description
            Description.Click();
            Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description"));

            //Click on Category
            actions.MoveToElement(Category).Build().Perform();
            Thread.Sleep(1000);
            IList <IWebElement> Select_Cat = Category.FindElements(By.TagName("option"));

            Console.WriteLine("List of category" + Select_Cat);
            int categorycount = Select_Cat.Count;

            for (int i = 0; i < categorycount; i++)
            {
                if (Select_Cat[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Category"))
                {
                    Select_Cat[i].Click();
                    Console.WriteLine("Category is" + Select_Cat[i].Text);
                    Base.test.Log(LogStatus.Info, "Selected Category");
                }
            }

            //Click on Sub Category
            actions.MoveToElement(SubCategory).Build().Perform();
            Thread.Sleep(1000);
            IList <IWebElement> Select_SubCat = SubCategory.FindElements(By.TagName("option"));

            Console.WriteLine("List of category" + Select_SubCat);
            int Scategorycount = Select_SubCat.Count;

            for (int i = 0; i < Scategorycount; i++)
            {
                if (Select_SubCat[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Sub-Category"))
                {
                    Select_SubCat[i].Click();
                    Console.WriteLine("Category is" + Select_SubCat[i].Text);
                    Base.test.Log(LogStatus.Info, "Selected Category");
                }
            }

            //Add tags
            actions.MoveToElement(Tags).Build().Perform();
            string tag1 = GlobalDefinitions.ExcelLib.ReadData(2, "Tags");
            string tag2 = GlobalDefinitions.ExcelLib.ReadData(3, "Tags");
            string tag3 = GlobalDefinitions.ExcelLib.ReadData(4, "Tags");

            Tags.SendKeys(tag1);
            Tags.SendKeys(Keys.Enter);

            Thread.Sleep(2000);
            Tags2.Click();
            // actions.MoveToElement(Tags2).Build().Perform();
            Tags2.SendKeys(tag2);

            Thread.Sleep(1000);
            //actions.MoveToElement(Tags).Build().Perform();
            //Tags.SendKeys(tag3);



            //Select service type
            actions.MoveToElement(ServiceType).Build().Perform();
            IList <IWebElement> ST = ServiceType.FindElements(By.XPath("//div/input[@name='serviceType']/following-sibling :: label"));

            for (int i = 0; i < ST.Count; i++)
            {
                Console.WriteLine("service from web" + ST[i].Text);
                if (ST[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType"))
                {
                    HourlyService.Click();
                }
                else
                {
                    One_off_service.Click();
                }
                break;
            }

            //Select Location type
            actions.MoveToElement(LocationType).Build().Perform();
            IList <IWebElement> LT = ServiceType.FindElements(By.XPath("//div/input[@name='locationType']/following-sibling :: label"));

            for (int i = 0; i < LT.Count; i++)
            {
                Console.WriteLine("service from web" + LT[i].Text);
                if (LT[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "LocationType"))
                {
                    Onsite.Click();
                }
                else
                {
                    Online.Click();
                }
                break;
            }


            //Click on start date
            Startdate.Click();

            Thread.Sleep(1000);
            //Enter start date
            string s1 = Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartDate");

            string[] s = s1.Split(' ');
            Console.WriteLine("1st part of string:" + s[0]);
            Console.WriteLine("2nd part of string:" + s[1]);
            string SD = s[0];

            Startdate.SendKeys(SD);

            //click on enddate
            Enddate.Click();
            //Enter End date
            string E1 = Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndDate");

            string[] E = E1.Split(' ');
            Console.WriteLine("Enddate 1st part is:" + E[0]);
            Console.WriteLine("End date second part is:" + E[1]);
            string ED = E[0];

            Enddate.SendKeys(ED);

            Thread.Sleep(1000);
            //Enter day
            actions.MoveToElement(Days).Build().Perform();
            IList <IWebElement> Day_Name = Days.FindElements(By.XPath("//div[@class='ui checkbox']/input/following-sibling :: label"));

            Console.WriteLine("Days are" + Day_Name);
            IList <IWebElement> Day_check = Days.FindElements(By.XPath("//input[@tabindex='0' and @type='checkbox']"));

            Console.WriteLine("Day checkbox" + Day_check);
            Thread.Sleep(1000);
            int Day_Count      = Day_Name.Count;
            int DayCheck_Count = Day_check.Count;

            for (int i = 0; i < Day_Count; i++)
            {
                if (Day_Name[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Day"))
                {
                    int j = i;
                    Day_check[j].Click();
                    Console.WriteLine("selected day is" + Day_Name[i]);
                }
            }

            //Enter starttime
            Start_Time.Click();
            string t1 = Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartTime");

            Console.WriteLine("Starttime is:" + t1);
            Start_Time.SendKeys(t1);

            //Enter Endtime
            End_Time.Click();
            string ET = Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndTime");

            Console.WriteLine("Endtime is:" + ET);
            End_Time.SendKeys(ET);

            //Select SkillExchange
            actions.MoveToElement(Skill_trade).Build().Perform();
            IList <IWebElement> Skill_E = Skill_trade.FindElements(By.XPath("//div/input[@name='skillTrades']/following-sibling :: label"));
            int SkillCount = Skill_E.Count;

            Console.WriteLine("count of radio buttons:" + SkillCount);
            for (int i = 0; i < SkillCount; i++)
            {
                if (Skill_E[i].Text == GlobalDefinitions.ExcelLib.ReadData(3, "SkillTrade"))
                {
                    Console.WriteLine("Skil is" + Skill_E[i].Text);
                    Skill_Exchange.Click();
                    actions.MoveToElement(Add_tags).Build().Perform();
                    string Tag = GlobalDefinitions.ExcelLib.ReadData(2, "SkillExchange");
                    Add_tags.SendKeys(Tag);
                    Base.test.Log(LogStatus.Info, "Selected skill");
                }

                else
                {
                    Credit.Click();
                    actions.MoveToElement(Add_credit).Build().Perform();
                    string Cr = GlobalDefinitions.ExcelLib.ReadData(2, "Credit");
                    Add_credit.SendKeys(Cr);
                }
                break;
            }


            //Click on Worksample
            PlusIcon.Click();

            //Performing the upload file operation using AutoIT

            AutoItX3 autoIT = new AutoItX3();

            autoIT.WinActivate("Open");
            Thread.Sleep(3000);
            string sample1 = GlobalDefinitions.ExcelLib.ReadData(2, "WorkSample");

            Console.WriteLine("file path is" + sample1);
            Thread.Sleep(2000);
            autoIT.Send(@sample1);
            Thread.Sleep(3000);
            autoIT.Send("{Enter}");
            Thread.Sleep(2000);

            //Downloading the file
            Download.Click();

            //Deleting a file
            Delete.Click();
            Thread.Sleep(500);

            actions.MoveToElement(Active).Build().Perform();
            IList <IWebElement> Active_Name = Active.FindElements(By.XPath("//div[@class='ui radio checkbox']/input[@name='isActive']/following-sibling :: label"));

            Console.WriteLine("Days are" + Active_Name);
            IList <IWebElement> Active_radio = Active.FindElements(By.XPath("//input[@name='isActive' and @type='radio']"));

            Console.WriteLine("Day checkbox" + Active_radio);
            Thread.Sleep(1000);
            int Active_Count = Active_Name.Count;

            for (int i = 0; i < Active_Count; i++)
            {
                if (Active_Name[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Active"))
                {
                    int j = i;
                    Active_radio[j].Click();
                }
            }

            //click on save
            actions.MoveToElement(Buttons).Build().Perform();
            IList <IWebElement> BT = ServiceType.FindElements(By.XPath("//input[@type='button']"));

            for (int i = 0; i < BT.Count; i++)
            {
                Console.WriteLine("Button from web" + BT.Count);
                if (GlobalDefinitions.ExcelLib.ReadData(2, "Buttons") == "Save")
                {
                    Save.Click();
                }
                else
                {
                    Cancel.Click();
                }
                break;
            }


            string text = Global.GlobalDefinitions.driver.Title;

            if (text == "ServiceListing")
            {
                Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Share skill page");
            }
            else
            {
                Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Not valid page");
            }
        }
예제 #4
0
        private void Lecture_CheckedChanged(object sender, EventArgs e)
        {
            //the function checks if the checkbox that was checked is lecture
            //if it does, the function will load the lectures info into the listboxes accordingly
            int Count = 0, val = 0;

            if (Lecture.Checked && Practice.Checked)
            {
                Practice.Checked = false;
            }
            if (!Lecture.Checked)
            {
                Lecture_Select.Enabled = false;
                Lecture_Select.Enabled = false;
                ID.ResetText();
                ID.Items.Clear();
                Start_Time.ResetText();
                Start_Time.Items.Clear();
                End_Time.ResetText();
                End_Time.Items.Clear();
                Courses.ResetText();
                Courses.Items.Clear();
                Days.ResetText();
                Days.Items.Clear();
                Day.Text = "";
                Teacher_ID.ResetText();
                Teacher_ID.Items.Clear();
                Lecture_Select.Enabled = true;
                Lecture_Select.Items.Clear();
                Lecture_Select.ResetText();
                Search.Enabled = false;
                StartTime.ResetText();
                StartTime.Items.Clear();
                EndTime.ResetText();
                EndTime.Items.Clear();
                Teacher.ResetText();
                Teacher.Items.Clear();
                ClassCombobox.ResetText();
                ClassCombobox.Items.Clear();
                ClassCombobox.Enabled = false;
                Teacher.Enabled       = false;
                StartTime.Enabled     = false;
                EndTime.Enabled       = false;
                Day.Enabled           = false;
            }
            else
            {
                ID.ResetText();
                ID.Items.Clear();
                Start_Time.ResetText();
                Start_Time.Items.Clear();
                End_Time.ResetText();
                End_Time.Items.Clear();
                Courses.ResetText();
                Courses.Items.Clear();
                Days.ResetText();
                Days.Items.Clear();
                Day.Text = "";
                Teacher_ID.ResetText();
                Teacher_ID.Items.Clear();
                Lecture_Select.Enabled = true;
                Lecture_Select.Items.Clear();
                Lecture_Select.ResetText();
                Search.Enabled = false;
                StartTime.ResetText();
                StartTime.Items.Clear();
                EndTime.ResetText();
                EndTime.Items.Clear();
                Teacher.ResetText();
                Teacher.Items.Clear();
                ClassCombobox.ResetText();
                ClassCombobox.Items.Clear();
                ClassCombobox.Enabled = false;
                Teacher.Enabled       = false;
                StartTime.Enabled     = false;
                EndTime.Enabled       = false;
                Day.Enabled           = false;
                if (StartTime.Items.Count == 0)
                {
                    for (int i = 8; i < 21; i++)
                    {
                        StartTime.Items.Add(i + ":00");
                    }
                }
                Lesson = "Lecture";

                if (!SqlWorker.CheckForInternetConnection())
                {
                    MessageBox.Show("There is no internet connection.\nPlease try again later.", "Error"
                                    , MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                DataSet TableShow = SqlWorker.GetDataSet("SELECT CourseName , StartTime , Day ,EndTime , Lecturer, ID From Lecture");
                val = TableShow.Tables[0].Rows.Count;
                while (val > Count)
                {
                    Lecture_Select.Items.Add(TableShow.Tables[0].Rows[Count]["ID"].ToString());
                    ID.Items.Add(TableShow.Tables[0].Rows[Count]["ID"].ToString());
                    Courses.Items.Add(TableShow.Tables[0].Rows[Count]["CourseName"].ToString());
                    Start_Time.Items.Add(TableShow.Tables[0].Rows[Count]["StartTime"].ToString());
                    End_Time.Items.Add(TableShow.Tables[0].Rows[Count]["EndTime"].ToString());
                    Days.Items.Add(TableShow.Tables[0].Rows[Count]["Day"].ToString());
                    Teacher_ID.Items.Add(TableShow.Tables[0].Rows[Count]["Lecturer"].ToString());
                    Count++;
                }
            }
        }
예제 #5
0
        public static void Main(String[] args)
        {
            bool Test_UMR  = false;
            bool Read_Only = false;

            foreach (string arg in args)
            {
                if (arg.Equals(@"/u"))
                {
                    Test_UMR = true;
                }
                if (arg.Equals(@"/r"))
                {
                    Read_Only = true;
                }
            }

            if (Test_UMR)
            {
                Test_Space.Testing.Main_Test();
                return;
            }

            System.IO.StreamWriter Log_File;
#if DEBUG
            Log_File = System.IO.File.AppendText(@"PhaseOpt_Kar_Main_Test.log");
#else
            Log_File = System.IO.File.AppendText(@"PhaseOpt_Kar_Main.log");
#endif

            Log_File.WriteLine("{0}: PhaseOpt startup", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();

#if DEBUG
            PhaseOpt_KAR PO_A = new PhaseOpt_KAR(@"PhaseOpt_Kar_A_Test.log");
            PhaseOpt_KAR PO_B = new PhaseOpt_KAR(@"PhaseOpt_Kar_B_Test.log");

            PO_A.Read_Config("PhaseOpt_A_Test.xml");
            PO_B.Read_Config("PhaseOpt_B_Test.xml");
#else
            PhaseOpt_KAR PO_A = new PhaseOpt_KAR(@"PhaseOpt_Kar_A.log");
            PhaseOpt_KAR PO_B = new PhaseOpt_KAR(@"PhaseOpt_Kar_B.log");

            PO_A.Read_Config("PhaseOpt_A.xml");
            PO_B.Read_Config("PhaseOpt_B.xml");
#endif
            PO_A.Name = "GC A";
            PO_B.Name = "GC B";
            PO_A.Connect_DB();
            PO_B.Connect_DB();

            if (Read_Only)
            {
                PO_A.DB_Connection.IP21_Read_Only = true;
                PO_B.DB_Connection.IP21_Read_Only = true;
            }

            DateTime Start_Time;
            double   Sleep_Time       = 0.0;
            int      errors_A         = 0;
            int      errors_B         = 0;
            int      errors_current_A = 0;
            int      errors_current_B = 0;

            while (true)
            {
                Start_Time = DateTime.Now;

                Log_File.WriteLine("{0}: Read composition A", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                Log_File.WriteLine("{0}: Read composition B", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();

                Log_File.WriteLine("{0}: Read from IP21 A", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                Log_File.WriteLine("{0}: Read from IP21 B", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();

                Parallel.Invoke(
                    () =>
                {
                    PO_A.Read_Composition();
                    PO_A.Read_Current_Kalsto_Composition();
                    errors_A         = PO_A.Validate();
                    errors_current_A = PO_A.Validate_Current();
                },

                    () =>
                {
                    PO_B.Read_Composition();
                    PO_B.Read_Current_Kalsto_Composition();
                    errors_B         = PO_B.Validate();
                    errors_current_B = PO_B.Validate_Current();
                }
                    );

                // Calculate composition mixes, cricondenbar and set status flag
                Parallel.Invoke(
                    () =>
                {
                    if (errors_A < 1)
                    {
                        PO_A.Calculate_Karsto();
                        Log_File.WriteLine("{0}: Calculate CCB at Kårstø A", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                    }
                    else
                    {
                        Log_File.WriteLine("{0}: Errors in A.", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                    }
                },

                    () =>
                {
                    if (errors_B < 1)
                    {
                        PO_B.Calculate_Karsto();
                        Log_File.WriteLine("{0}: Calculate CCB at Kårstø B", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                    }
                    else
                    {
                        Log_File.WriteLine("{0}: Errors in B.", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                    }
                },
                    // Read and calculate cricondenbar for current
                    // compositions at Kalstø
                    () =>
                {
                    if (errors_A < 1)
                    {
                        PO_A.Calculate_Kalsto_Statpipe();
                        Log_File.WriteLine("{0}: Calculate Statpipe stream at Kalstø A", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                    }
                    else
                    {
                        Log_File.WriteLine("{0}: Errors in Statpipe current composition A", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                    }
                },

                    () =>
                {
                    if (errors_A < 1)
                    {
                        PO_A.Calculate_Kalsto_Asgard();
                        Log_File.WriteLine("{0}: Calculate Åsgard stream at Kalstø A", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                    }
                    else
                    {
                        Log_File.WriteLine("{0}: Errors in Asgard current composition A", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                    }
                },

                    () =>
                {
                    if (errors_B < 1)
                    {
                        PO_B.Calculate_Kalsto_Statpipe();
                        Log_File.WriteLine("{0}: Calculate Statpipe stream at Kalstø B", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                    }
                    else
                    {
                        Log_File.WriteLine("{0}: Errors in Statpipe current composition B", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                    }
                },

                    () =>
                {
                    if (errors_B < 1)
                    {
                        PO_B.Calculate_Kalsto_Asgard();
                        Log_File.WriteLine("{0}: Calculate Åsgard stream at Kalstø B", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                    }
                    else
                    {
                        Log_File.WriteLine("{0}: Errors in Asgard current composition B", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                    }
                }
                    );

                Log_File.WriteLine("{0}: Read current composition from IP21 A", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();
                Log_File.WriteLine("{0}: Read current composition from IP21 B", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log_File.Flush();

                PO_A.Trigger_Watchdog();

                if (errors_A < 1)
                {
                    PO_A.Calculate_Dropout_Curves(PO_A.Mix_To_T410, PO_A.T400);
                    PO_A.Calculate_Dropout_Curves(PO_A.Mix_To_T100, PO_A.T100);
                }

                Sleep_Time = (Start_Time.AddSeconds(150.0) - DateTime.Now).TotalMilliseconds;
                if (Sleep_Time > 1.0)
                {
                    Console.WriteLine("Waiting {0} seconds", Sleep_Time / 1000.0);
                    System.Threading.Thread.Sleep((int)Sleep_Time);
                }
            }
        }
        // If: Starttime is valid format, endtime is valid format and there is a day selected
        //starttime is before endtime
        //
        private void Save_ShiftTemplate(object sender, RoutedEventArgs e)
        {
            // If the bool isValidated at one of the checks is marked as false the ShiftTemplate will not be created.
            // Instead a message explaning the error will be written
            bool isValidated;

            if (!CheckIfValidTime(Start_Time.Text))
            {
                isValidated           = false;
                Error_message.Content = "Start time is not a valid hour format";
            }

            else if (!CheckIfValidTime(End_Time.Text))
            {
                isValidated           = false;
                Error_message.Content = "End time is not a valid minute format";
            }

            else if (Day_List.SelectedItem == null)
            {
                isValidated           = false;
                Error_message.Content = "A day haven't been selected";
            }
            else if (CompareTime(Start_Time.Text, End_Time.Text))
            {
                isValidated           = false;
                Error_message.Content = "Start time must be before end time";
            }
            else
            {
                isValidated = true;
            }

            // If all validation checkout then the ShiftTemplate infomration is exstracted and saved to the database
            if (isValidated == true)
            {
                ListBoxItem SelectedDay = Day_List.SelectedItem as ListBoxItem;

                int DayInWeek = 0;
                switch (SelectedDay.Content.ToString())
                {
                case "Monday":
                    DayInWeek = 1;
                    break;

                case "Tuesday":
                    DayInWeek = 2;
                    break;

                case "Wednesday":
                    DayInWeek = 3;
                    break;

                case "Thursday":
                    DayInWeek = 4;
                    break;

                case "Friday":
                    DayInWeek = 5;
                    break;

                case "Saturday":
                    DayInWeek = 6;
                    break;

                case "Sunday":
                    DayInWeek = 7;
                    break;

                default:
                    DayInWeek = 0;
                    break;
                }

                // Creates a datetime with the given times.
                DateTime Start;
                DateTime End;
                string   s = DayInWeek + "/01/2007 ";
                string   t = s;
                s += Start_Time.Text;
                t += End_Time.Text;
                s += ":00";
                t += ":00";

                // If the datatime is not able to be parsed to a DataTime object, the ShiftTemplate is not made
                // As of the validation this should not be able to happen
                if (!(DateTime.TryParse(s, out Start) && DateTime.TryParse(t, out End)))
                {
                    throw new ArgumentException("Start or End is not a valid datetime");
                }

                // Gets the selected tags and adds them to a list of strings
                List <string> TemplateTags = new List <string>();
                foreach (ListBoxItem item in Tag_List.SelectedItems)
                {
                    string tag = item.Content.ToString();
                    TemplateTags.Add(tag);
                }

                // The ShiftTemplate object is made with the gathered information
                ShiftTemplate shiftTemplate = new ShiftTemplate(Start, End, Database.Instance.ListToString(TemplateTags));
                shiftTemplate.SaveInfoShiftTemplate();

                // After the object is saved it is saved to the database and the inputboxes are cleared
                Core.Instance.AddTemplateToList(shiftTemplate);
                Start_Time.Clear();
                End_Time.Clear();
                Error_message.Content = "";
                Tag_List.UnselectAll();
                LoadShift();
            }
        }
        private void Lecture_CheckedChanged(object sender, EventArgs e)
        {
            //the function checks if the checkbox that was checked is lecture
            //if it does, the function will load the lectures info into the listboxes accordingly
            int Count = 0, val = 0;

            if (Lecture.Checked && Practice.Checked)
            {
                Practice.Checked = false;
            }
            if (!Lecture.Checked)
            {
                Lecture_Select.Enabled = false;
                Class_Search.Enabled   = false;
                UpdateDB.Visible       = false;
                Current_Class.Visible  = false;
                Classes.Visible        = false;
                Classes.ResetText();
                Classes.Items.Clear();
            }
            else
            {
                ID.ResetText();
                ID.Items.Clear();
                Start_Time.ResetText();
                Start_Time.Items.Clear();
                End_Time.ResetText();
                End_Time.Items.Clear();
                Courses.ResetText();
                Courses.Items.Clear();
                Days.ResetText();
                Days.Items.Clear();
                Lecture_Select.Enabled = true;
                Lecture_Select.Items.Clear();
                Lecture_Select.ResetText();
                Lesson = "Lecture";

                if (!SqlWorker.CheckForInternetConnection())
                {
                    MessageBox.Show("There is no internet connection.\nPlease try again later.", "Error"
                                    , MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                DataSet TableShow = SqlWorker.GetDataSet("SELECT CourseName , StartTime , Day ,EndTime , ID From Lecture");
                val = TableShow.Tables[0].Rows.Count;
                while (val > Count)
                {
                    Lecture_Select.Items.Add(TableShow.Tables[0].Rows[Count]["ID"].ToString());
                    ID.Items.Add(TableShow.Tables[0].Rows[Count]["ID"].ToString());
                    Courses.Items.Add(TableShow.Tables[0].Rows[Count]["CourseName"].ToString());
                    Start_Time.Items.Add(TableShow.Tables[0].Rows[Count]["StartTime"].ToString());
                    End_Time.Items.Add(TableShow.Tables[0].Rows[Count]["EndTime"].ToString());
                    Days.Items.Add(TableShow.Tables[0].Rows[Count]["Day"].ToString());
                    Count++;
                    progressBar1.Value += 100 / val;
                }
                progressBar1.Value = 100;
                MessageBox.Show("Loading completed.", "Load", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                progressBar1.Value = 0;
            }
        }
예제 #8
0
        //为RealTimeList赋值
        private void DoWork()
        {
            DBCatcher.Conditions  = string.Format("where lot_type='Production' and  Claim_time >='{0}' and Claim_Time < '{1}'", Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), End_Time.ToString("yyyy-MM-dd HH:mm:ss"));
            DBCatcher2.Conditions = string.Format("where lot_type='Production' and  Scrap_time >='{0}' and Scrap_Time < '{1}'", Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), End_Time.ToString("yyyy-MM-dd HH:mm:ss"));
            var list  = DBCatcher.GetEntities().EntityList;
            var list2 = DBCatcher2.GetEntities().EntityList;

            if (list.Count() <= 0)
            {
                throw new Exception("ReqRpt025Translator.GetBaseList()没有获取符合条件的数据");
            }
            LotCatcher.Conditions = string.Format("where lot_type='Production' and Created_Time <='{0}' and (Completion_Time >='{1}' or Completion_Time='1901-01-01 00:00:00' )", End_Time.ToString("yyyy-MM-dd HH:mm:ss"), Start_Time.ToString("yyyy-MM-dd HH:mm:ss"));
            var lotList = LotCatcher.GetEntities().EntityList;

            OpehsCatcher.Conditions = string.Format("where lot_type='Production' and Ope_Category='OperationComplete' and PD_Type not in ('Dummy','Measurement') and Claim_Time between '{0}' and '{1}'", Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), End_Time.ToString("yyyy-MM-dd HH:mm:ss"));
            var      OphesList = OpehsCatcher.GetEntities().EntityList;
            DateTime firstTime = Start_Time;

            while (firstTime < End_Time)
            {
                var rawList    = list.Where(w => w.Claim_Time >= firstTime && w.Claim_Time < firstTime.AddHours(12));
                var rawList2   = list2.Where(w => w.Scrap_Time >= firstTime && w.Scrap_Time < firstTime.AddHours(12));
                var rawLotList = lotList.Where(w => w.Created_Time <= firstTime && (w.Completion_Time >= firstTime || w.Completion_Time == DateTime.Parse("1901-01-01 00:00:00")));

                var rawOpehsList = OphesList.Where(w => w.Claim_Time >= firstTime && w.Claim_Time < firstTime.AddHours(12));

                if (rawList.Count() > 0)
                {
                    rawList.GroupBy(g => new { g.ProdSpec_ID, g.PartName }).Select(s => new { Product = s.Key, Qty = s.Sum(i => i.Cur_Wafer_Qty) }).ToList().ForEach(f => RealTimeList.Add(new RPT_RealTime_Lin()
                    {
                        Product_ID = f.Product.ProdSpec_ID, MoveQty = f.Qty, PartName = f.Product.PartName, Start_Time = firstTime, ScrappedQty = 0
                    }));
                    rawList.Select(s => new { s.Claim_Time, s.Cur_Wafer_Qty, EqpType = s.Eqp_ID.Substring(0, 6), s.ProdSpec_ID }).GroupBy(g => new { g.ProdSpec_ID, g.EqpType }).Select(s => new { Product = s.Key, Qty = s.Sum(i => i.Cur_Wafer_Qty) }).ToList().ForEach(f => MoveList.Add(new RPT_Move_By_EqpType()
                    {
                        Product_ID = f.Product.ProdSpec_ID, EqpType = f.Product.EqpType, Start_Time = firstTime, MoveQty = f.Qty
                    }));
                }
                if (rawList2.Count() > 0)
                {
                    rawList2.GroupBy(g => new { g.ProdSpec_ID, g.PartName }).Select(s => new { Product = s.Key, Qty = s.Sum(i => i.Qty) }).ToList().ForEach(f => RealTimeList.Where(w => w.Product_ID == f.Product.ProdSpec_ID && w.PartName == f.Product.PartName && w.Start_Time == firstTime).FirstOrDefault().ScrappedQty = f.Qty);
                }
                if (rawLotList.Count() > 0)
                {
                    var group = rawLotList.GroupBy(g => g.ProdSpec_ID);
                    foreach (var gp in group)
                    {
                        var entity = new RPT_Turn_Daily()
                        {
                            Product_ID     = gp.Key,
                            Start_Time     = firstTime,
                            WIP            = gp.Count(),
                            MoveQty        = RealTimeList.Where(w => w.Product_ID == gp.Key).Sum(s => s.MoveQty),
                            EffectiveSteps = rawOpehsList.Where(w => w.ProdSpec_ID == gp.Key).Count()
                        };
                        TurnDailyList.Add(entity);
                    }
                }
                firstTime = firstTime.AddHours(12);
            }

            //input or update
            var RealTimeCurrent = new DB2DataCatcher <RPT_RealTime_Lin>("ISTRPT.RPT_RealTime_Lin")
            {
                Conditions = string.Format("where Start_Time >='{0}' and Start_Time<='{1}'", Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), End_Time.ToString("yyyy-MM-dd HH:mm:ss"))
            }.GetEntities().EntityList;
            var TurnDailyCurrent = new DB2DataCatcher <RPT_Turn_Daily>("ISTRPT.RPT_Turn_Daily")
            {
                Conditions = string.Format("where Start_Time >='{0}' and Start_Time<='{1}'", Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), End_Time.ToString("yyyy-MM-dd HH:mm:ss"))
            }.GetEntities().EntityList;
            var MoveCurrent = new DB2DataCatcher <RPT_Move_By_EqpType>("ISTRPT.RPT_Move_By_EqpType")
            {
                Conditions = string.Format("where Start_Time >='{0}' and Start_Time<='{1}'", Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), End_Time.ToString("yyyy-MM-dd HH:mm:ss"))
            }.GetEntities().EntityList;

            foreach (var item in RealTimeList)
            {
                if (RealTimeCurrent.Where(w => w.Start_Time == item.Start_Time && w.Product_ID == item.Product_ID && w.PartName == item.PartName).Count() == 0)
                {
                    DBPusher.entities.EntityList.Add(item);
                }
                else
                {
                    UpdateSqlList.Add(string.Format("update ISTRPT.RPT_RealTime_Lin set MOVEQTY={0}, ScrappedQTY={4} where Start_Time='{1}' and Product_ID='{2}' and PartName='{3}'", item.MoveQty, item.Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), item.Product_ID, item.PartName, item.ScrappedQty));
                }
            }

            foreach (var item in TurnDailyList)
            {
                if (TurnDailyCurrent.Where(w => w.Start_Time == item.Start_Time && w.Product_ID == item.Product_ID).Count() == 0)
                {
                    TurnPusher.entities.EntityList.Add(item);
                }
                else
                {
                    UpdateSqlList.Add(string.Format("update ISTRPT.RPT_Turn_Daily set MoveQty={0},EffectiveSteps={1},WIP={2} where Start_Time='{3}' and Product_ID='{4}'", item.MoveQty.ToString(), item.EffectiveSteps.ToString(), item.WIP.ToString(), item.Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), item.Product_ID));
                }
            }

            foreach (var item in MoveList)
            {
                if (MoveCurrent.Where(w => w.Start_Time == item.Start_Time && w.Product_ID == item.Product_ID && w.EqpType == item.EqpType).Count() == 0)
                {
                    MovePusher.entities.EntityList.Add(item);
                }
                else
                {
                    UpdateSqlList.Add(string.Format("update ISTRPT.RPT_Move_By_EqpType set MOVEQTY={0} where Start_Time='{1}' and Product_ID='{2}' and EqpType='{3}' ", item.MoveQty, item.Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), item.Product_ID, item.EqpType));
                }
            }
            if (DBPusher.entities.EntityList.Count() > 0)
            {
                DBPusher.PushEntities();
            }
            if (TurnPusher.entities.EntityList.Count() > 0)
            {
                TurnPusher.PushEntities();
            }
            if (MovePusher.entities.EntityList.Count() > 0)
            {
                MovePusher.PushEntities();
            }
            if (UpdateSqlList.Count > 0)
            {
                DB2Helper db2 = new DB2Helper();
                db2.UpdateBatchCommand(UpdateSqlList);
            }
        }