Esempio n. 1
0
 /// <summary>
 /// 远程升级时,数据库操作
 /// </summary>
 private void RemotUpdate()
 {
     if (WriteData == null)
     {
         return;
     }
     using (DataTable dt = WriteData.Read("select top 1 * from AllTestStationTime"))
     {
         if (dt == null || dt.Columns.Count <= 0)
         {
             WriteData.Write("CREATE TABLE [dbo].[AllTestStationTime](" +
                             "[ID] [bigint] IDENTITY(1,1) NOT NULL," +
                             "	[TestTime] [datetime] NOT NULL,"+
                             "	[TestYear] [int] NULL,"+
                             "	[TestMonth] [int] NULL,"+
                             "	[TestDay] [int] NULL,"+
                             "	[WorkStation] [int] NOT NULL,"+
                             "	[StationName] [nvarchar](100) NULL,"+
                             "	[TimeCount] [int] NULL,"+
                             "	[OperaCount] [int] NULL,"+
                             "CONSTRAINT [PK_AllTestStationTime] PRIMARY KEY CLUSTERED " +
                             "(" +
                             "	[ID] ASC,"+
                             "	[TestTime] ASC,"+
                             "	[WorkStation] ASC"+
                             ")WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]" +
                             ") ON [PRIMARY]");
         }
     }
     using (DataTable dt = WriteData.Read("select top 1 * from AllTestStationTimeEveryHour"))
     {
         if (dt == null || dt.Columns.Count <= 0)
         {
             WriteData.Write("CREATE TABLE [dbo].[AllTestStationTimeEveryHour](" +
                             "	[ID] [bigint] IDENTITY(1,1) NOT NULL,"+
                             "	[TestTime] [datetime] NOT NULL,"+
                             "	[UseTime] [int] NULL,"+
                             "	[WorkStation] [int] NULL,"+
                             "	[StationName] [nvarchar](100) NOT NULL,"+
                             " CONSTRAINT [PK_AllTestStationTimeEveryHour] PRIMARY KEY CLUSTERED" +
                             "(" +
                             "	[ID] ASC,"+
                             "	[TestTime] ASC,"+
                             "	[StationName] ASC"+
                             ")WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]" +
                             ") ON [PRIMARY]");
         }
     }
 }
Esempio n. 2
0
    static void Main(string[] args)
    {
        // Phase 1
        // Wir legen zwei Objekte an, die Daten unerschiedlichen
        // Formats in Dateien schreiben

        XmlFileWriter myXmlFileWriter = new XmlFileWriter();

        myXmlFileWriter.SetName("DataFile.xml");
        myXmlFileWriter.WriteToFile("MessdatenMessdaten");

        //IWriter Writer1 = new JsonFileWriter();
        //Writer1.SetName("DataFile1");  // keine Element des Interfaces!
        //Writer1.WriteToFile("MessdatenMessdaten");

        // Phase 2 ("Closely coupled classes")
        // Wir wollen die Methoden abermals erweitern
        // und die Daten vor dem Schreiben filtern
        // Dazu implementieren wir eine neue Klasse
        //WriteDataToXml xmlWriter = new WriteDataToXml(myXmlFileWriter);
        //xmlWriter.Write("DatenDatenDaten");
        // Was stört?
        // 1. Sobald wir "XmlFileWriter" anpassen, muss auch
        //    FilteredDataToXML korrigiert werden
        // 2. Wir schreiben eine Klasse für xml, eine für json usw. :-(

        // Phase 2 ("Losely coupled classes")
        // Wir ersetzen die "feste Integration" durch ein
        // Interface. Jede Klasse die dieses Interface bedient, kann dann
        // eingebundne werden.
        WriteData xmlOutput = new WriteData(myXmlFileWriter);

        xmlOutput.Write("DiesUndJenes");

        JsonFileWriter myJsonFileWriter = new JsonFileWriter();

        myJsonFileWriter.SetName("Data.json");
        WriteData jsonOutput = new WriteData(myJsonFileWriter);

        jsonOutput.Write("UndNochWasAnderes");

        // Ziel erreicht :-)
    }
Esempio n. 3
0
 //Customers
 public void ToWrite()
 {
     WriteData.Write(selectedBooks);
 }