public void SaveTo(XmlTextWriter xw)
        {
            xw.WriteAttributeString("type", MappedType.ToString());
            xw.WriteAttributeString("source", Source.ToString());
            xw.WriteAttributeString("uuid", UUID.ToString());

            if (Source == SourceType.RawInput)
            {
                xw.WriteAttributeString("vid", VendorID.ToString("X"));
                xw.WriteAttributeString("pid", ProductID.ToString("X"));
                xw.WriteAttributeString("rpt_hash", ReportHash.ToString());
                xw.WriteAttributeString("idx", DeviceIndex.ToString());
            }
            else if (Source == SourceType.XInput)
            {
                xw.WriteAttributeString("idx", DeviceIndex.ToString());
            }
            else if (Source == SourceType.MUNIA)
            {
                xw.WriteAttributeString("devicepath", DevicePath);
            }
            else if (Source == SourceType.Arduino)
            {
                xw.WriteAttributeString("arduino_port", ArduinoPort.Name);
                xw.WriteAttributeString("arduino_type", ArduinoSource.ToString());
            }

            xw.WriteStartElement("buttons");
            foreach (var btn in ButtonMaps)
            {
                btn.SaveTo(xw);
            }
            xw.WriteEndElement();

            xw.WriteStartElement("axes");
            foreach (var axis in AxisMaps)
            {
                axis.SaveTo(xw);
            }
            xw.WriteEndElement();

            xw.WriteStartElement("buttons_to_axis");
            foreach (var btn in ButtonToAxisMaps)
            {
                btn.SaveTo(xw);
            }
            xw.WriteEndElement();

            xw.WriteStartElement("axis_to_buttons");
            foreach (var axis in AxisToButtonMaps)
            {
                axis.SaveTo(xw);
            }
            xw.WriteEndElement();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            /*Sleep for 1.5 minute*/

            //Thread.Sleep(90000);
            DataTable     Pdt      = new DataTable();
            DataTable     RawFile  = new DataTable();
            string        ProcName = "procExportDocumentLineDetail";
            StringBuilder SqlQuery = new StringBuilder("Select ");
            string        ReportHash;

            string SqlConn = ConfigurationManager.ConnectionStrings["SqlProdConn"].ConnectionString;
            string Connect = ConfigurationManager.ConnectionStrings["ProdConnection"].ConnectionString;
            string Target  = ConfigurationManager.ConnectionStrings["ProdConnectionTarget"].ConnectionString;

            using (SqlConnection Conn = new SqlConnection(SqlConn))
            {
                Conn.Open();

                using (OdbcConnection SnowConnection = new OdbcConnection(Connect))
                {
                    SnowConnection.Open();

                    using (OdbcConnection TConnection = new OdbcConnection(Target))
                    {
                        TConnection.Open();

                        try

                        {
                            string command = "Select Parameters from nUnitTesting where ProcName = '" + ProcName + "'";

                            Console.WriteLine(command);

                            OdbcCommand GetValuesNames = new OdbcCommand(command, SnowConnection);

                            string Para = (string)GetValuesNames.ExecuteScalar();

                            string[] Parameters = Para.Split(',');

                            for (int NumParams = 1; NumParams < Parameters.Length; NumParams++)
                            {
                                SqlQuery.Append("Para" + NumParams + ", ");
                            }


                            /*With Parameters.Length, we can get the actual values for each of the parameters from the control table*/

                            SqlQuery.Append("Para" + Parameters.Length + " ,TableId,StageName" + " from nUnitTesting where ProcName = '" + ProcName + "'");

                            Console.WriteLine(SqlQuery.ToString());

                            /* for (int NumParams = 1; NumParams < Parameters.Length; NumParams++)
                             * {
                             *
                             *
                             *   SqlQuery.Append("Para" + NumParams + ", ");
                             *
                             * }
                             *
                             * /*Get the number of parameters for that procName
                             *
                             * SqlQuery.Append("Para" + Parameters.Length + " from dbo.nUnitTesting where ProcName = '" + ProcName + "'");
                             *
                             * Console.WriteLine(SqlQuery.ToString()); */



                            /*Select the parameter permutations and store them in Parameters data table*/

                            OdbcCommand GetParameterValues = new OdbcCommand(SqlQuery.ToString(), SnowConnection);

                            using (var Y = new OdbcDataAdapter(GetParameterValues))
                            {
                                Y.Fill(Pdt);
                            }

                            foreach (DataRow dr in Pdt.Rows)
                            {
                                DataTable Tab   = new DataTable();
                                DataTable S3Tab = new DataTable();

                                string StartDate = dr["Para3"].ToString();
                                string EndDate   = dr["Para4"].ToString();
                                string Company   = dr["Para2"].ToString();
                                var    TableId   = Convert.ToInt32(dr["TableId"].ToString());
                                var    StageName = dr["StageName"].ToString();

                                try
                                {
                                    string dir = @"C:\Users\franco.mang\Desktop\s3\";

                                    var sharedFile = new SharedCredentialsFile();

                                    sharedFile.TryGetProfile("default", out var profile);


                                    AWSCredentialsFactory.TryGetAWSCredentials(profile, sharedFile, out var credentials);



                                    AmazonS3Client s3Client = new AmazonS3Client(credentials);

                                    ReportHash = GetHash(SnowConnection, dr, ProcName, Parameters, StageName);

                                    string Hash = ReportHash.Split('-')[0];

                                    string path = dir + Hash + ".csv";

                                    var sfexec = Convert.ToDouble(ReportHash.Split('-')[1]);

                                    DownLoadFile(path, s3Client, Hash);

                                    Tab = QueryOps(Conn, dr, ProcName, Parameters);

                                    S3Tab = ExtractFile(path);

                                    Console.WriteLine("SqlCount" + " " + Tab.Rows.Count);
                                    Console.WriteLine("S3Count" + " " + S3Tab.Rows.Count);
                                    Console.ReadLine();


                                    //MatchOnly(Tab, S3Tab, Company, StartDate, EndDate, ProcName, TConnection, TableId, sfexec);
                                }
                                catch (Exception Ex)
                                {
                                    Console.WriteLine("AWS Error - {0}", Ex.Message.ToString());
                                    Console.WriteLine(Ex.ToString());
                                    Console.ReadLine();
                                }
                            }
                        }

                        catch (SqlException Ex)
                        {
                            Console.WriteLine(Ex.Message.ToString());
                            Console.ReadLine();
                        }
                    }
                }
            }
        }