Пример #1
0
        protected void btnNext_Click(object sender, EventArgs e)
        {
            try
            {
                bool validate = false;

                foreach (GridViewRow gr in grdTestCases.Rows)
                {
                    RadioButton rboSelect = (RadioButton)gr.FindControl("RboGrid");

                    if (rboSelect.Checked)
                    {
                        validate = true;

                        hfwprefix.Value     = grdTestCases.Rows[gr.RowIndex].Cells[2].Text;
                        hfp_styr_lpnr.Value = grdTestCases.Rows[gr.RowIndex].Cells[1].Text;
                        hfp_db2_lpnr.Value  = grdTestCases.Rows[gr.RowIndex].Cells[6].Text;
                        hfp_up_lpnr.Value   = grdTestCases.Rows[gr.RowIndex].Cells[7].Text;

                        //'Check if the current machine is closed

                        DataTable dtMachineStatus = UtilityClass.CheckMachineStatus(Convert.ToInt32(hfp_up_lpnr.Value));

                        if (dtMachineStatus.Rows.Count > 0)
                        {
                            if (dtMachineStatus.Rows[0]["Status"].ToString().Trim() == "9")
                            {
                                throw new Exception("The current machine is closed until further notice.Contact Telia ProSoft");
                            }
                            else
                            {
                                hfwip.Value = dtMachineStatus.Rows[0]["IP-adress2"].ToString().Trim();
                            }
                        }

                        // Check if it is running in the current DB2 environment or if the DB2 environment is closed
                        // If all, ok, save DB2 environment into variables

                        DataTable dtdb2Env = UtilityClass.CheckDB2EnviornmenrVariables(Convert.ToInt32(hfp_db2_lpnr.Value));

                        if (dtdb2Env.Rows.Count > 0)
                        {
                            if (dtMachineStatus.Rows[0]["Status"].ToString().Trim() == "1")
                            {
                                throw new Exception("Driving is in progress in the current environment");
                            }
                            else if (dtMachineStatus.Rows[0]["Status"].ToString().Trim() == "9")
                            {
                                throw new Exception("The environment is closed until further notice.Contact Telia ProSoft");
                            }
                            else
                            {
                                DB2EnviornmentVariable db2 = new DB2EnviornmentVariable();

                                db2.wmaskin  = dtdb2Env.Rows[0]["Maskin"].ToString();
                                db2.wIMS     = dtdb2Env.Rows[0]["IMS-system"].ToString();
                                db2.wDSN     = dtdb2Env.Rows[0]["DSN-system"].ToString();
                                db2.wPSB     = dtdb2Env.Rows[0]["PSB"].ToString();
                                db2.walias   = dtdb2Env.Rows[0]["Alias"].ToString();
                                db2.wcreator = dtdb2Env.Rows[0]["Creator"].ToString();
                                db2.wvol     = dtdb2Env.Rows[0]["Volcreator"].ToString();

                                Session.Add("DB2EnviornmentVariable", db2);
                            }
                        }

                        // Check for BIC data is associated with this test

                        DataTable dtbicdata = UtilityClass.CheckBICData(Convert.ToInt32(hfp_styr_lpnr.Value));

                        BICData bicData;

                        if (dtbicdata.Rows.Count > 0)
                        {
                            bicData = new BICData();

                            bicData.p_BICnr        = dtbicdata.Rows[0]["BICnr"].ToString();
                            bicData.p_BIC_lager_nr = dtbicdata.Rows[0]["BIC-lager-nr"].ToString();
                            bicData.wtyp           = dtbicdata.Rows[0]["Typ"].ToString();

                            Session.Add("bicData", bicData);
                        }
                        else
                        {
                            throw new Exception("You have not created BIC data for this test");
                        }

                        //Check for CDR data is associated with this test

                        int p_CDRnr = UtilityClass.GetCDRNo(Convert.ToInt32(hfp_styr_lpnr.Value));

                        if (p_CDRnr == 0)
                        {
                            throw new Exception("You have not created CDR data for this test.");
                        }

                        //Control of LOC data is associated with this test

                        int p_LOKnr = UtilityClass.GetLOCNo(Convert.ToInt32(hfp_styr_lpnr.Value));

                        if (p_LOKnr == 0)
                        {
                            p_LOKnr = 0;
                        }

                        // Download Country Type
                        int wagr = UtilityClass.GetCountryType(Convert.ToInt32(bicData.p_BIC_lager_nr));

                        if (wagr == 0)
                        {
                            throw new Exception("The customer is missing in the BIC layer.");
                        }

                        //Get email address and MVS user
                        DataTable dtusd = UtilityClass.GetEmailandUser(Convert.ToString(Session["CurrentUser"]));

                        UserDetails usd;

                        if (dtusd.Rows.Count > 0)
                        {
                            usd = new UserDetails();

                            usd.wemail     = dtusd.Rows[0]["Email"].ToString();
                            usd.p_mvs_user = dtusd.Rows[0]["IBM-userid"].ToString();
                        }
                        else
                        {
                            throw new Exception("There is no information about your LAN user");
                        }

                        //Download drive type
                        string winit = UtilityClass.GetDriveType(Convert.ToInt32(hfp_styr_lpnr.Value));
                        if (winit == "")
                        {
                            throw new Exception("There is no information about the test.");
                        }



                        string path    = "~/DownloadFiles/PPVData.txt";
                        string jclPath = "~/DownloadFiles/JCL.txt";
                        string p_ppvdb = UtilityClass.GetDatabaseVersion();

                        StringBuilder fileData = new StringBuilder();
                        string        wtxt     = string.Empty;
                        wtxt = "\"00 STRT " + DateTime.Now.Date.ToString("yyyy-MM-dd") + " " + DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Second.ToString().PadLeft(2, '0') + " Email=" + usd.wemail + CreateWhiteSpace(80, usd.wemail.Length) + "\"";
                        //fileData.Append(wtxt + Environment.NewLine);
                        AppentDataToFile(wtxt, ref fileData);

                        //Write INFO mail
                        string wtst = hfp_styr_lpnr.Value.PadLeft(5, '0');
                        string wdb2 = hfp_db2_lpnr.Value.PadLeft(5, '0');
                        wtxt = "\"01 INFO TESTNR=" + wtst + " DB2NR=" + wdb2 + " LAN-USER="******"CurrentUser"]) + "\"";
                        //fileData.Append(wtxt + Environment.NewLine);
                        AppentDataToFile(wtxt, ref fileData);

                        //Type ENVIRONMENTAL POST
                        DB2EnviornmentVariable dbEnviornment = (DB2EnviornmentVariable)Session["DB2EnviornmentVariable"];
                        //var wvol = dbEnviornment.wvol.PadRight(8 - dbEnviornment.wvol.Length, ' ').Replace(" ", " ");
                        var wvol = dbEnviornment.wvol + CreateWhiteSpace(8, dbEnviornment.wvol.Length);

                        //var wDNS = dbEnviornment.wDSN.PadRight(4 - dbEnviornment.wDSN.Length, ' ').Replace(" ", " ");
                        var wDNS = dbEnviornment.wDSN + CreateWhiteSpace(4, dbEnviornment.wDSN.Length);

                        wtxt = "\"02 MILJ IMS=" + dbEnviornment.wIMS + " PSB=" + dbEnviornment.wPSB + " ALIAS=" + dbEnviornment.walias;
                        wtxt = wtxt + " CREATOR=" + dbEnviornment.wcreator + " DSN=" + wDNS + " VOL=" + wvol;
                        wtxt = wtxt + " INIT=" + winit + " PCDB=" + p_ppvdb + "\"";

                        //fileData.Append(wtxt + Environment.NewLine);
                        AppentDataToFile(wtxt, ref fileData);

                        Write_BIC(bicData.wtyp, wagr, winit, ref fileData, bicData);

                        Write_CDR(p_CDRnr, ref fileData);

                        if (p_LOKnr > 0)
                        {
                            Write_LOKNO(p_LOKnr, ref fileData);
                        }

                        string want = p_ant_ut.ToString();
                        if (want.Length < 5)
                        {
                            want = want.PadLeft(5, '0');
                        }

                        wtxt = "\"99 S**T Antal poster: " + want + "\"";

                        AppentDataToFile(wtxt, ref fileData);

                        DatabaseConnection dc = new DatabaseConnection();

                        if (dc.UpdateTables(Convert.ToInt32(hfp_db2_lpnr.Value), Convert.ToInt32(hfp_styr_lpnr.Value)))
                        {
                            string path1 = Server.MapPath(path);
                            File.WriteAllText(Server.MapPath(path), fileData.ToString());
                            File.WriteAllText(Server.MapPath(jclPath), CreateJCLFile(hfwprefix.Value, dbEnviornment.wDSN).ToString());

                            hlJCL.Visible = true;
                            hlPPV.Visible = true;

                            Show("OK files created!Please run the manual routine to Mainframe!", this);
                            ShowMessage("OK files created!Please run the manual routine to Mainframe!");
                        }
                    }
                }

                if (!validate)
                {
                    throw new Exception("Please select a test !!!");
                }
            }
            catch (Exception ex)
            {
                hlJCL.Visible = false;
                hlPPV.Visible = false;

                Show(ex.Message, this);
                ShowMessage(ex.Message);
            }
        }