Exemplo n.º 1
0
        static void sUpdate_tParam(string vPath_XLSX, string vSheet_Name, string vParam_Name)
        {
            string vError = "";

            Hashtable[] arrHash = stExcel.sExcel_Read_2_Hashtable_Until_Empty(vPath_XLSX, vSheet_Name, "A2", "", "Name", out vError);


            string vResult = "";

            foreach (var hashMenu in arrHash)
            {
                string vValue = hashMenu["Name"].ToString();
                vResult = q.sVBCLRF_Max_Line(vResult, vValue, ",");
            }
            DataModel.tPARAM oParam = new DataModel.tPARAM();
            oParam.VPARAMNAME = vParam_Name;
            oParam.VPARAMVAL  = vResult;
            oParam.oBasic_Operation.Upsert();
        }
Exemplo n.º 2
0
        static void sUpdate_tParam2(string vPath_XLSX, string vSheet_Name, string vList_Column, string vCheckColEmpty, string vAccess_Col, string vExtension_Name)
        {
            string vError = "";

            Hashtable[] arrHash = stExcel.sExcel_Read_2_Hashtable_Until_Empty(vPath_XLSX, vSheet_Name, "A2", vCheckColEmpty, vList_Column, out vError);

            foreach (var hashMenu in arrHash)
            {
                string vCol_Name  = q.sSplit(vAccess_Col, ",")[0];
                string vCol_Value = q.sSplit(vAccess_Col, ",")[1];

                string vName        = vExtension_Name + hashMenu[vCol_Name].ToString();
                string vValue       = hashMenu[vCol_Value].ToString();
                string vDescription = hashMenu["Rule"].ToString() + " = " + hashMenu["Sample"].ToString();

                DataModel.tPARAM oParam = new DataModel.tPARAM();
                oParam.VPARAMNAME = vName;
                oParam.VPARAMVAL  = vValue;
                oParam.VPARAMDESC = vDescription;
                oParam.oBasic_Operation.Upsert();
            }
        }
Exemplo n.º 3
0
        private void BtnReset_Click(object sender, EventArgs e)
        {
            sTimer1_Pending(false);

            cWinForm_Tools.sCursor_Change();
            #region change status
            var oParam1 = new DataModel.tPARAM();
            oParam1.VPARAMNAME = "EXECUTE_UIPATH";
            oParam1.VPARAMVAL  = "0";
            oParam1.oBasic_Operation.Update();
            sStatus_UIPath_Update("");

            #endregion

            string vPeriod = txtPeriod.Text;
            int    i       = 1;
            foreach (TreeNode oNode in treeView1.Nodes)
            {
                foreach (TreeNode oPlants in oNode.Nodes)
                {
                    if (oPlants.Checked)
                    {
                        var oJobHistory = new DataModel.tJOB_HISTORY();
                        oJobHistory.IPERIOD     = q.sInt_Try_Parse(vPeriod);
                        oJobHistory.ISTEPID     = q.sInt_Try_Parse(oNode.Tag);
                        oJobHistory.VPLANTID    = oPlants.Tag.ToString();
                        oJobHistory.VSTATUSID   = "";
                        oJobHistory.VSTATUSDESC = "";
                        oJobHistory.IUSERFLAG   = 0;
                        oJobHistory.DLASTUPD    = q.sDateTime_Now();
                        oJobHistory.oBasic_Operation.Upsert();
                    }
                }

                i++;
            }



            int PeriodIsNumber   = 1;
            int CountPeriod      = 0;
            int Last2DigitPeriod = 0;
            CountPeriod      = vPeriod.Length;
            Last2DigitPeriod = q.sString_2_Integer((vPeriod.Substring(CountPeriod - 2)));
            //row below is trying to parse the vPeriod into the number. If the parsing is failed, then the PeriodISnumber will become 0, otherwise the PeriodIsNumber=vPeriod
            int.TryParse(vPeriod, out PeriodIsNumber);


            if (PeriodIsNumber == 0 || CountPeriod != 6 || Last2DigitPeriod > 12) //If Period Number is 0, it means that vPeriod is not Integer
            {
                MessageBox.Show("Nilai Text Box di Period Harus Angka dengan Format YYYYMM dan Panjang 6 Digit dengan Nila MM tidak boleh lebih besar dari 12 ");
            }
            else
            {
                var oParam = new DataModel.tPARAM();
                oParam.VPARAMNAME = "PERIOD";
                oParam.VPARAMVAL  = vPeriod;
                oParam.oBasic_Operation.Upsert();


                cWinForm_Tools.sCursor_Change(true);
                sTimer_Set(true);
                chkTimer.Checked = false;



                //Do Refresh Screen after reset db job
                //Logic explanation, if  EXECUTE_UIPATH = 1, then get search period value from database
                //else get the period value from textbox (because when the job is running, it is not possible to get other period
                string vFlag = sdConnection.sRead_2_Text("SELECT VPARAMVAL FROM AHMFARPA_MSTPARAMS WHERE VPARAMNAME='EXECUTE_UIPATH'");
                if (vFlag == "1")
                {
                    txtPeriod.Text = vPeriod;
                }
                sSearch(false);
            }
        }
Exemplo n.º 4
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            //Check whether the period is number or not
            string vPeriod = txtPeriod.Text;



            int PeriodIsNumber   = 1;
            int CountPeriod      = 0;
            int Last2DigitPeriod = 0;

            //row below is trying to parse the vPeriod into the number. If the parsing is failed, then the PeriodISnumber will become 0, otherwise the PeriodIsNumber=vPeriod
            int.TryParse(vPeriod, out PeriodIsNumber);
            CountPeriod = vPeriod.Length;


            Last2DigitPeriod = q.sString_2_Integer((vPeriod.Substring(CountPeriod - 2)));
            String CountFlag1Job = sdConnection.sRead_2_Text("select count(1) from [AHMFARPA_HISJOBS] where IUSERFLAG=1 and IPERIOD=" + vPeriod);

            if (PeriodIsNumber == 0 || CountPeriod != 6) //If Period Number is 0, it means that vPeriod is not Integer
            {
                MessageBox.Show("Nilai Text Box di Period Harus Angka dengan Format YYYYMM dan Panjang 6 Digit");
            }



            else if (Last2DigitPeriod > 12 || Last2DigitPeriod < 1)
            {
                MessageBox.Show("Nilai Text Box di Period Harus Angka dengan Format YYYYMM dan Panjang 6 Digit. Nilai MM tidak boleh lebih besar dari 12");
            }

            else
            {
                //in Beginning, set all UserFlag to 0
                sdConnection.sSave("update AHMFARPA_HISJOBS set IUSERFLAG=0");

                //====================================================================================================
                //step below will set the execute_uipath parameter in database to 1

                sTimer1_Pending(false);

                cWinForm_Tools.sCursor_Change();
                #region change status
                var oParam1 = new DataModel.tPARAM();
                oParam1.VPARAMNAME = "EXECUTE_UIPATH";
                oParam1.VPARAMVAL  = "1";
                oParam1.oBasic_Operation.Update();
                sStatus_UIPath_Update("");

                #endregion



                int i = 1;

                foreach (TreeNode oNode in treeView1.Nodes)
                {
                    foreach (TreeNode oPlants in oNode.Nodes)
                    {
                        if (oPlants.Checked)
                        {
                            string vStatus = sdConnection.sRead_2_Text("SELECT TOP 1 VSTATUSID FROM AHMFARPA_HISJOBS WHERE IPERIOD=" + vPeriod + " and ISTEPID=" + oNode.Tag + " and VPLANTID='" + oPlants.Tag.ToString() + "'");


                            if (vStatus == "S")
                            {
                                MessageBox.Show("Step " + oNode.Tag + " Pada Plant: " + oPlants.Tag.ToString() + " tidak boleh diexecute karena Status=S. Mohon update status terlebih dahulu");


                                oParam1.VPARAMVAL = "0";
                                oParam1.oBasic_Operation.Update();
                                sStatus_UIPath_Update("");

                                goto End;
                            }
                        }



                        if (oPlants.Checked)
                        {
                            var oJobHistory = new DataModel.tJOB_HISTORY();
                            oJobHistory.IPERIOD   = q.sInt_Try_Parse(vPeriod);
                            oJobHistory.ISTEPID   = q.sInt_Try_Parse(oNode.Tag);
                            oJobHistory.VPLANTID  = oPlants.Tag.ToString();
                            oJobHistory.IUSERFLAG = 1;
                            oJobHistory.DLASTUPD  = q.sDateTime_Now();
                            oJobHistory.oBasic_Operation.Upsert();
                        }
                    } // end of inner foreach (plant)

                    i++;
                } //end of outer foreach (step)

                var oParam = new DataModel.tPARAM();
                oParam.VPARAMNAME = "PERIOD";
                oParam.VPARAMVAL  = vPeriod;
                oParam.oBasic_Operation.Upsert();


                cWinForm_Tools.sCursor_Change(true);
                sTimer_Set(true);

                //this part is disabled to make sure that the job in orchestrator is not run automatically.
                //=================================================================================================================================
                // the step below will get token and szend request to orchestrator to start the job

                try
                {
                    string vUsername = sdConnection.sRead_2_Text("SELECT VPARAMVAL FROM AHMFARPA_MSTPARAMS WHERE VPARAMNAME='WinForm_Username'");

                    string vPassword = sdConnection.sRead_2_Text("SELECT VPARAMVAL FROM AHMFARPA_MSTPARAMS WHERE VPARAMNAME='WinForm_Password'");

                    string vTenant = sdConnection.sRead_2_Text("SELECT VPARAMVAL FROM AHMFARPA_MSTPARAMS WHERE VPARAMNAME='WinForm_Tenant'");


                    string token = Logic.cBackend.GetToken(vUsername, vPassword, vTenant);

                    Console.WriteLine("TOKEN=" + token);

                    Logic.cBackend.SendRequest(token);
                }

                catch (Exception we)
                {
                    if (we.Message.Contains("400"))
                    {
                        MessageBox.Show("Error code 400. Detail Error: " + we.Message);
                    }

                    else
                    {
                        MessageBox.Show(we.Message + ". Please check the following items to troubleshoot:" + Environment.NewLine + "1. Connection to Orchestrator" + Environment.NewLine + "2. Username, Password, and Tenant Name that is stored in Database for login to Orchestrator");
                    }
                }//end of try catch



                chkTimer.Checked = false;

                End :;
                sSearch(false);
            } //end of else
        }     //end of function button Ok (Execute) Click