private void pictureBox1_Click(object sender, EventArgs e)
        {
            TreeNode tn = treeView1.SelectedNode;

            if (tn != null)
            {
                string enviornment = string.Empty;
                using (ResXResourceSet resxSet = new ResXResourceSet(@"Release\Credential.resx"))
                {
                    enviornment = resxSet.GetString("ENV");
                }
                if (enviornment != "" && enviornment != "DVT")
                {
                    HealthCheck.ExecuteCS.Utility.VpnCreate();
                    ArrayList al = new ArrayList();
                    al = new Helper_Automation().GetXMLsource(Release.DefaultConfig.PathListXmlFileName, "DirectoryPath");
                    string sourepath           = Convert.ToString(al[0]);
                    string DestinationLocation = "\\\\" + treeView1.SelectedNode.Text + "\\" + sourepath.Replace(Release.DefaultConfig.HomePath, "");
                    Task   t = IOoperation.MoveLocation(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\" + "vpnConnect" + ".bat", DestinationLocation + "\\" + "vpnConnect" + ".bat");

                    using (ResXResourceSet resxSet = new ResXResourceSet(@"Release\Credential.resx"))
                    {
                        enviornment = resxSet.GetString("ENV");
                        if (enviornment == "DVT")
                        {
                            // SchedulerOperation.CreateTaskRunOnce("execution.bat", sourepath, chk_Machine.SelectedItem.ToString());
                            SchedulerOperation.CreateTaskRunOnce("vpnConnect.bat", Convert.ToString(al[0]), treeView1.SelectedNode.Text);
                        }
                        else
                        {
                            SchedulerOperation.CreateTaskRunOnceWithDifferentaccount("vpnConnect.bat", Convert.ToString(al[0]), treeView1.SelectedNode.Text);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Enviornment should be staging or production..");
                }
            }
            else
            {
                MessageBox.Show("Select IP");
            }
        }
예제 #2
0
        private void Execute(string IP)
        {
            try
            {
                DataSet ds = new DataSet();
                if (File.Exists(HealthCheckResource.MasterFilepath))
                {
                    ds.ReadXml(HealthCheckResource.MasterFilepath);
                    if (ds != null && ds.Tables.Count > 0)
                    {
                    }
                }
                foreach (var a in listBox1.SelectedItems)
                {
                    lst.Add(Convert.ToString(a));
                }


                List <string> pathlst       = new List <string>();
                List <string> batchfilelist = new List <string>();

                DataRow[]     drr           = ds.Tables[0].Select("IP='" + IP + "'");
                string[]      arr           = null;
                StringBuilder sb            = new StringBuilder();
                string        SchedulerName = string.Empty;
                string        rbtntext      = string.Empty;
                if (lbl_enviornment.Text == "DVT")
                {
                    rbtntext = "devtest";
                }
                else if (lbl_enviornment.Text == "STG")
                {
                    rbtntext = "staging";
                }
                if (lbl_enviornment.Text == "PRD")
                {
                    rbtntext = "Production";
                }
                else if (lbl_enviornment.Text == "QAC")
                {
                    rbtntext = "qac";
                }
                if (drr != null && drr.Count <DataRow>() > 0)
                {
                    foreach (DataRow dr in drr)
                    {
                        SchedulerName = Convert.ToString(dr["SchdulerName"]);
                        batchfilelist.Add(SchedulerName + ".bat");
                        pathlst.Add(Convert.ToString(dr["FolderPath"]));
                        #region edit
                        arr = Convert.ToString(dr["ConfigFile"]).Split(';');
                        int i = 1;
                        foreach (string rec in arr)
                        {
                            if (rec.Replace("\r\n", string.Empty).Length > 3 || Path.GetFileNameWithoutExtension(rec.Replace("\r\n", string.Empty)).ToLower() == "*.xml")
                            {
                                sb.Append("(" + i + ")" + "  " + rec.Replace("\r\n", string.Empty));
                                sb.Append(Environment.NewLine);
                                i++;
                            }
                        }
                        #endregion
                        try
                        {
                            Utility.ReportFolderCreate(" \\\\" + IP + "\\" + Convert.ToString("c:\\Report".Replace(Release.DefaultConfig.HomePath, ""))); //check
                        }
                        catch (Exception ex) { }

                        HealthCheck.ExecuteCS.Utility.ConfigFileCreate(Convert.ToString(dr["FolderPath"]), rbtntext, lst.ToArray(), SchedulerName);
                        string DestinationLocation = "\\\\" + IP + "\\" + Convert.ToString(dr["FolderPath"]).Replace(Release.DefaultConfig.HomePath, "") + "" + "\\" + SchedulerName + ".bat";
                        Task   t = IOoperation.MoveLocation(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\" + SchedulerName + ".bat", DestinationLocation);
                    }
                    HealthCheck.ExecuteCS.Utility.ConfigFileCreate(pathlst.ToArray(), batchfilelist.ToArray());
                    ArrayList al = new ArrayList();
                    al = new Helper_Automation().GetXMLsource(Release.DefaultConfig.PathListXmlFileName, "DirectoryPath");
                    string remotelocation = " \\\\" + IP + "\\" + Convert.ToString(al[0]).Replace(Release.DefaultConfig.HomePath, "");
                    if (File.Exists(remotelocation + "\\" + "callAllHelathCheck.bat"))
                    {
                        File.Delete(remotelocation + "\\" + "callAllHelathCheck.bat");
                    }
                    File.Move("callAllHelathCheck.bat", remotelocation + "\\" + "callAllHelathCheck.bat");
                    using (ResXResourceSet resxSet = new ResXResourceSet(@"Release\Credential.resx"))
                    {
                        enviornment = resxSet.GetString("ENV");
                        if (enviornment == "DVT")
                        {
                            // SchedulerOperation.CreateTaskRunOnce("execution.bat", sourepath, chk_Machine.SelectedItem.ToString());
                            SchedulerOperation.CreateTaskRunOnce("callAllHelathCheck.bat", Convert.ToString(al[0]), IP);
                        }
                        else
                        {
                            SchedulerOperation.CreateTaskRunOnceWithDifferentaccount("callAllHelathCheck.bat", Convert.ToString(al[0]), IP);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }