当前位置: 首页>>代码示例>>C#>>正文


C# Database.Connect方法代码示例

本文整理汇总了C#中Database.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# Database.Connect方法的具体用法?C# Database.Connect怎么用?C# Database.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Database的用法示例。


在下文中一共展示了Database.Connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateRMRecord

        private static void CreateRMRecord(FileInfo f)
        {

           // msg. //LoadMessage(@"C:\Docs\TestMail.eml");
            var strmessageId = findmessagid(f);
            //Console.WriteLine("message id: " + strmessageId);

            using (Database db = new Database())
            {
                db.Connect();
                TrimMainObjectSearch objs = new TrimMainObjectSearch(db, BaseObjectTypes.Record);
                //objs.SetSearchString("messageId = " + strmessageId);
                objs.SetSearchString("messageId= *[email protected]*");
                if(objs.FastCount>0)
                {
                    Console.WriteLine("Found a record with the same message ID");
                }
                else
                {
                    Console.WriteLine("Did not find a message id");
                }
                //RecordType rt = new RecordType(db,3);
                //Record r = new Record(rt);              
                //r.Container = new Record(db, 172693);
                //r.Title = f.Name;
                //r.Save();
                //Console.WriteLine("New RM email record: " + r.Number);
                //Record r = new Record(db, 172736);


            }
        }
开发者ID:WyldLynxGitHub,项目名称:SunshineCoastCouncil-master,代码行数:32,代码来源:Program.cs

示例2: Main

 static void Main(string[] args)
 {
     TrimApplication.Initialize();
     using(Database db = new Database())
     {
         //db.Id="45";
         db.Connect();
     bulkLoaderSample bls = new bulkLoaderSample();
     bls.run(db);
     }
 }
开发者ID:WyldLynxGitHub,项目名称:SunshineCoastCouncil-master,代码行数:11,代码来源:Program.cs

示例3: TrimAbstract

        public TrimAbstract(string trimServer, string trimDatasetId)
        {
            Db = new Database
                     {
                         WorkgroupServerName = trimServer
                     };

            if(!String.IsNullOrWhiteSpace(trimDatasetId))
            {
                Db.Id = trimDatasetId;
            }

            Db.Connect();
        }
开发者ID:johnsimons,项目名称:TrimWebService,代码行数:14,代码来源:TrimAbstract.cs

示例4: Migrate

        private static void Migrate()
        {
            string connectionString = "Data Source=yfdev.cloudapp.net;Initial Catalog=SCC_ECM;Persist Security Info=True;User ID=EPL;Password=Password1!";
            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();
                using (SqlCommand command = new SqlCommand("SELECT top 25 * FROM View_1", con))
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    using (Database db = new Database())
                    {
                        db.Id = "03";
                        db.Connect();
                        while (reader.Read())
                        {
                            RecordType rt = new RecordType(db, 16);
                            Record rCont = GetFolderUri(reader.GetString(6), reader.GetString(7), db);
                            if (rCont != null)
                            {

                                Record r = new Record(rt);
                                r.Container = rCont;
                                r.LongNumber = reader.GetInt32(0).ToString();
                                r.Title = reader.GetString(1);
                                r.DateCreated = (TrimDateTime)reader.GetDateTime(2);
                                string loc = "D:\\" + reader.GetString(3);
                                if (File.Exists(loc))
                                {
                                    InputDocument id = new InputDocument(loc);
                                    r.SetDocument(id, false, false, "Migrated from ECM t1");
                                }

                                r.Save();
                                Console.WriteLine("Record Created: " + r.Number);
                            }
                            else
                            {
                                Console.WriteLine("Could not find folder");
                            }
                        }
                    }
                }
            }
        }
开发者ID:WyldLynxGitHub,项目名称:SunshineCoastCouncil-master,代码行数:44,代码来源:Program.cs

示例5: LoadComponents

        private void LoadComponents()
        {
            ContentPlaceHolder mpContentPlaceHolder;
            mpContentPlaceHolder =
              (ContentPlaceHolder)Master.FindControl("MainContent");

            Database obj = new Database();
            try
            {
                obj.Connect();
                obj.Query("SELECT * FROM ComponentTypes");

                if (obj.rdr.HasRows == true)
                {
                    while (obj.rdr.Read())
                    {
                        HtmlGenericControl li = new HtmlGenericControl("li");
                        if (mpContentPlaceHolder != null)
                        {
                            mpContentPlaceHolder.FindControl("tiles").Controls.Add(li);
                        }
                        HtmlGenericControl anchor = new HtmlGenericControl("a");
                        anchor.Attributes.Add("href", "ComponentList.aspx/?Type=" + Convert.ToString(obj.rdr["CompTypeID"].ToString()));
                        anchor.InnerHtml = "<div class=\"nailthumb-container\"><img src=\"../assets/img/CompTypeThumbs/" + Convert.ToString(obj.rdr["CompTypeThumbImage"].ToString()) + "\"></div>";
                        li.Controls.Add(anchor);
                        // li.InnerHtml = "<img src=\"../assets/img/Furniture/" + Convert.ToString(obj.rdr["CompTypeThumbImage"].ToString()) + "\">";
                        li.Attributes.Add("onclick", "");
                    }
                }
            }

            catch (Exception ex)
            {
                // MessageBox.Show(ex.Message.ToString() + " : " + ex.StackTrace.ToString(), "Load Error");
            }
            finally
            {
                obj.Close();
            }
        }
开发者ID:wiechars,项目名称:EF,代码行数:40,代码来源:ComponentTypes.aspx.cs

示例6: NotifikaceMapper

 public NotifikaceMapper()
 {
     db = new Database();
     db.Connect();
 }
开发者ID:IniTW8X,项目名称:VIS_Tiket_IS,代码行数:5,代码来源:NotifikaceMapper.cs

示例7: processtoRM

        private static void processtoRM()
        {
            long recuri = 0;
            long folderUri = 0;
            long classUri = 0;
            
            if (!TrimApplication.HasBeenInitialized)
            {
                TrimApplication.Initialize();
            }
            TrimApplication.HasUserInterface = true;

            using (Database db = new Database())
            {
                try
                {
                    db.Connect();
                    Console.WriteLine("Connected to RM successfully as : " + db.CurrentUser.Name + " on " + db.Id + "/" + db.WorkgroupServerName);
                    Console.WriteLine("Hit q to quit or any other key to continue");
                    if (Console.ReadLine() == "q")
                    {
                        Environment.Exit(0);
                    }

                }
                catch (Exception exp)
                {
                    Console.WriteLine("Error: " + exp);
                    return;
                }
                Console.WriteLine("Enter location of Json file");
                FileLocation = Console.ReadLine();
                List<Sheets> myMessage = JsonConvert.DeserializeObject<List<Sheets>>(File.ReadAllText(@FileLocation));
                Console.WriteLine("Enter the Classification Uri for this process:");
                foreach (var file in myMessage)
                {

                    toplevelUri = Convert.ToInt64(Console.ReadLine());
                    if (getToplevel(toplevelUri, db) != null)
                    {
                        toplevel = getToplevel(toplevelUri, db).Title;
                        Console.WriteLine("Confirm that this is the folder stating point for this process: " + toplevel + " Hit q to quit or any other key to continue.");
                        if (Console.ReadLine() == "q")
                        {
                            Environment.Exit(0);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Please check the high level classification Uri and try again:");
                        Console.ReadLine();
                        Environment.Exit(0);
                    }

                    Console.WriteLine("Enter the SS line number to process from, minimum should be 2.");
                    long linenumber = Convert.ToInt64(Console.ReadLine());
                    long tl = toplevelUri;
                    foreach (Rows r in file.Rows.Where(x => x.SheetLine >= linenumber))
                    {

                        try
                        {
                            Classification cl1 = (Classification)db.FindTrimObjectByName(BaseObjectTypes.Classification, toplevel + " - " + CleanupFolderName(r.level1));
                            if (cl1 == null)
                            {
                                cl1 = CreateFolderStructure(r.level1, toplevel, "c", db, FindStartingNumber(tl, db));
                                classUri = cl1.Uri;
                            }

                            Classification cl2 = (Classification)db.FindTrimObjectByName(BaseObjectTypes.Classification, cl1.Title + " - " + CleanupFolderName(r.level2));
                            if (cl2 == null)
                            {
                                cl2 = CreateFolderStructure(r.level2, cl1.Title, "c", db, FindStartingNumber(cl1.Uri, db));
                                classUri = cl2.Uri;
                            }

                            Classification cl3 = (Classification)db.FindTrimObjectByName(BaseObjectTypes.Classification, cl2.Title + " - " + CleanupFolderName(r.level3));
                            if (cl3 == null)
                            {
                                cl3 = CreateFolderStructure(r.level3, cl2.Title, "r", db, FindStartingNumber(cl2.Uri, db));
                                classUri = cl3.Uri;
                            }

                            if (r.Folders != null)
                            {
                                if (r.Folders.Count() > 0)
                                {
                                    foreach (var f in r.Folders)
                                    {
                                        Record chkRec = CheckifFolderAlreadyExists(cl3, f.folder, db);
                                        //
                                        if (chkRec == null)
                                        {
                                            //Console.WriteLine("Did not find existing folder: " + cl3.Title + " " + f.folder);
                                            try
                                            {
                                                recuri = CreateNewRMfolder(f.folder, cl3.Uri, db);
                                                f.RMuri = recuri.ToString();
                                                Console.WriteLine("Created new folder: Uri " + recuri.ToString());
                                            }
//.........这里部分代码省略.........
开发者ID:WyldLynxGitHub,项目名称:SunshineCoastCouncil-master,代码行数:101,代码来源:Program.cs

示例8: OpenDatabase

        protected bool OpenDatabase()
        {
            try
             {
            database = new Database();
            string connection_str = data.ConnectionString;

            Mohid.Core.Result r = database.Connect(connection_str);
            if (r != Mohid.Core.Result.TRUE)
            {
               if (r == Mohid.Core.Result.EXCEPTION)
                  throw database.RaisedException;

               return false;
            }

            return true;
             }
             catch (Exception ex)
             {
            if (Debug)
               Console.WriteLine("Engine.OpenDatabase Exception: {0}", ex.Message);

            return false;
             }
        }
开发者ID:JauchOnGitHub,项目名称:csharptoolbox,代码行数:26,代码来源:Engine.cs

示例9: BuildRMLocations

        static void BuildRMLocations(List<Position> full)
        {
            TrimApplication.Initialize();

            try
            {
                using (Database db = new Database())
                {
                    //5503
                    Location locUseProfileof = new Location(db, 19509);
                    Location LocHighLevel = new Location(db, 5503);
                    db.Id = "03";
                    db.Connect();
                    FieldDefinition fd = new FieldDefinition(db, 501);
                    //
                    //Classification cla = new Classification(db);
                    
                    foreach (Position p in full)
                    {
                        //if (p.RMUri == 0)
                        //{
                            Location posloc = new Location(db, LocationType.Position);
                            //{
                            posloc.Surname = p.Title + " - " + p.Position_Number.ToString();
                            posloc.SetNotes("Entered by auto process: Source ID: " + p.Position_Number.ToString(), NotesUpdateType.AppendWithNewLine);
                            posloc.AddRelationship(LocHighLevel, LocRelationshipType.MemberOf, false);
                            //bu3loc.SetFieldValue(fd, new UserFieldValue("Business Unit 3"));
                            posloc.IsWithin = true;
                            //posloc.UseProfileOf = locUseProfileof;
                            posloc.Save();
                            p.RMUri = posloc.Uri;
                            Console.WriteLine("Created " + p.Title + " - " + p.Position_Number.ToString());
                            //
                            foreach (User u in p.user.Where(x => x.RMUri == 0))
                            {
                                //if (u.RMUri == 0)
                                //{
                                    try
                                    {
                                        Location userloc = new Location(db, LocationType.Person);
                                        //{
                                        userloc.Surname = u.Surname;
                                        userloc.GivenNames = u.FirstName;
                                        userloc.EmailAddress = u.Email;
                                        userloc.CanLogin = true;
                                        userloc.LogsInAs = u.FirstName[0].ToString() + u.Surname[0].ToString() + u.Employee_Number.ToString();
                                        userloc.AdditionalLogin = u.Email;
                                        string dlogon = lstDomain.Where(x=>x.email==u.Email).First().DomainLogon;
                                        if(dlogon.Length>1)
                                        {
                                        userloc.LogsInAs = "MSC\\"+dlogon;
                                        }
                                        else
                                        {
                                            userloc.LogsInAs = "MSC\\";
                                        }
                                        //userloc.UserType = UserTypes.Contributor;

                                        userloc.SetNotes("Entered by auto process: Source ID: " + u.Employee_Number, NotesUpdateType.AppendWithNewLine);
                                        userloc.AddRelationship(posloc, LocRelationshipType.MemberOf, false);
                                        //bu3loc.SetFieldValue(fd, new UserFieldValue("Business Unit 3"));
                                        userloc.IsWithin = true;
                                        userloc.UseProfileOf = locUseProfileof;
                                        userloc.Save();
                                        u.RMUri = userloc.Uri;
                                        BuildRMpersonalFolders(userloc);
                                        Console.WriteLine("Created " + u.Surname);
                                        //}
                                    }
                                    catch (Exception exp)
                                    {
                                        Console.WriteLine("Error creating person location: " + exp.Message.ToString());
                                    }
                                //}
                                //else
                                //{
                                //    Location userloc = new Location(db, u.RMUri);
                                //    userloc.AddRelationship(posloc, LocRelationshipType.MemberOf, false);
                                //    userloc.Save();
                                //}
                            }
                        //}
                        //else
                        //{
                        //    Location posloc = new Location(db, p.RMUri);
                        //    //posloc.AddRelationship(bu2loc, LocRelationshipType.MemberOf, false);
                        //    posloc.Save();
                        //}
                    }




                    //
                    //Build SCC org
                    //Location lOrg = new Location(db, LocationType.Organization);
                    //lOrg.Surname = "Sunshine Coast Council";
                    //lOrg.IsWithin = true;
                    //lOrg.SetFieldValue(fd, new UserFieldValue("Organisation"));
                    //lOrg.UseProfileOf = locUseProfileof;
//.........这里部分代码省略.........
开发者ID:WyldLynxGitHub,项目名称:SunshineCoastCouncil-master,代码行数:101,代码来源:Program.cs

示例10: processfiles

        private static void processfiles()
        {
            if (!TrimApplication.HasBeenInitialized)
            {
                TrimApplication.Initialize();
            }
            TrimApplication.HasUserInterface = true;
            using (Database db = new Database())
            {
                try
                {
                    db.Connect();
                    //db.PreventDuplicatedDocuments = true;
                    Console.WriteLine("Connected to RM successfully as : " + db.CurrentUser.Name + " on " + db.Id + "/" + db.WorkgroupServerName);
                    Console.WriteLine("Hit q to quit or any other key to continue");
                    if (Console.ReadLine() == "q")
                    {
                        Environment.Exit(0);
                    }

                }
                catch (Exception exp)
                {
                    Console.WriteLine("Error: " + exp);
                    return;
                }

                Console.WriteLine("Enter location of Json file");
                FileLocation = Console.ReadLine();

                int intMigratedfiles = 0;
                bool bDelete = false;
                Console.WriteLine("Confirm Y to delete source or N to leave.");
                switch (Console.ReadLine())
                {
                    case "Y":
                    case "y":
                        bDelete = true;
                        break;
                    case "N":
                    case "n":
                        bDelete = false;
                        break;
                    default:
                        bDelete = false;
                        break;

                }
                List<Sheets> myMessage = JsonConvert.DeserializeObject<List<Sheets>>(File.ReadAllText(@FileLocation));
                try
                {
                    foreach (var file in myMessage)
                    {
                        foreach (Rows r in file.Rows)
                        {
                            if (r.Folders != null)
                            {
                                foreach (Folder f in r.Folders)
                                {
                                    if (f.MigrateLoc != null)
                                    {
                                        if (Directory.Exists(f.MigrateLoc))
                                        {
                                            intMigratedfiles = 0;
                                            var txtFiles = Directory.EnumerateFiles(f.MigrateLoc, "*.*", SearchOption.TopDirectoryOnly);
                                            r.OriginalFileCount = txtFiles.Count();
                                            foreach (var ff in txtFiles)
                                            {
                                                if (CreateNewRMRecord(ff, Convert.ToInt64(f.RMuri), db) > 0)
                                                {
                                                    Console.WriteLine("File created in RM: " + ff);
                                                    intMigratedfiles++;

                                                    if (bDelete)
                                                    {
                                                        try
                                                        {
                                                            File.Delete(ff);
                                                            Console.WriteLine("File deleted: " + ff);
                                                        }
                                                        catch (Exception exp)
                                                        {
                                                            Console.WriteLine("Error deleting File: " + exp.Message.ToString());
                                                        }
                                                    }
                                                }
                                            }
                                            db.LogExternalEvent("There were "+txtFiles.Count().ToString()+" files in " + f.MigrateLoc + " and "+intMigratedfiles.ToString()+" successfully migrated. Failed file migrations are listed individually.", BaseObjectTypes.Record, Convert.ToInt64(f.RMuri), true);
                                        }
                                        else
                                        {
                                            db.LogExternalEvent("File location passed for migrating incorrect: " + f.MigrateLoc, BaseObjectTypes.Record, Convert.ToInt64(f.RMuri), true);
                                        }
                                    }
                                    if (f.SubFolders != null)
                                    {
                                        foreach (Subfolder sf in f.SubFolders)
                                        {
                                            if (sf.MigrateLoc != null)
                                            {
//.........这里部分代码省略.........
开发者ID:WyldLynxGitHub,项目名称:SunshineCoastCouncil-master,代码行数:101,代码来源:Program.cs

示例11: ProcessProperty

        static void ProcessProperty(string Name)
        {
            TrimApplication.Initialize();
            using (Database db = new Database())
            {
                db.Id = "10";
                //db.WorkgroupServerName = "https://SCDB98:9443";
                db.Connect();
                //Console.WriteLine("DB test: " + db.CurrentUser.Name);
                //
                JsonSerializer s = new JsonSerializer();
                try
                {
                    T1Property t1 = null;
                    using (StreamReader sr = new StreamReader(Name))
                    {
                        using (JsonTextReader reader = new JsonTextReader(sr))
                        {
                            //T1Integration t1 = new T1Integration();
                            t1 = (T1Property)s.Deserialize(reader, typeof(T1Property));
                        }
                    }
                    if (t1 != null)
                    {
                        FieldDefinition fdPropertyAddress = new FieldDefinition(db, 502);
                        if (t1.EddieUri == 0)
                        {
                            RecordType rt = new RecordType(db, 1);
                            Record rec = new Record(rt);
                            FieldDefinition fdPropertyNo = new FieldDefinition(db, 504);                           
                            rec.Title = "Property folder - " + t1.PropertyNumber.ToString();
                            rec.SetFieldValue(fdPropertyNo, new UserFieldValue(t1.PropertyNumber));
                            rec.SetFieldValue(fdPropertyAddress, new UserFieldValue(t1.PropertyAddress));
                            Classification c = new Classification(db, 2616);
                            rec.Classification = c;
                            Location loc = new Location(db, 43);
                            rec.SetAssignee(loc);
                            //rec.assig




                            rec.Save();
                            t1.EddieUri = rec.Uri;
                            t1.EddieRecordUrl = rec.WebURL;
                            Console.WriteLine("New property record created ok - number: " + rec.Number);
                        }
                        else
                        {
                            //RecordType rt = new RecordType(db, 2);
                            Record rec = new Record(db, t1.EddieUri);
                            //Record cont = new Record(db, t1.lEddieUri);
                            //rec.Container = cont;
                            //rec.Title = "Application - " + t1.ApplicationNo;
                            //if (t1.propertyLoc != null)
                            //{
                            //    rec.SetDocument(t1.propertyLoc);
                            //}
                            rec.SetFieldValue(fdPropertyAddress, new UserFieldValue(t1.PropertyAddress));
                            rec.Save();
                            //t1.EddieUri = rec.Uri;
                            t1.EddieRecordUrl = rec.WebURL;
                            Console.WriteLine("Property record upgrades - number: " + rec.Number);
                        }
                        using (StreamWriter sw = new StreamWriter(pathout + "T1 property - "+t1.PropertyNumber.ToString()+".txt"))
                        {
                            using (JsonWriter writer = new JsonTextWriter(sw))
                            {
                                s.Serialize(writer, t1);
                                Console.WriteLine("Property file returned");
                            }
                        };
                        FileInfo f = new FileInfo(Name);
                        if (f.Exists)
                            f.Delete();
                    }
                }
                catch (Exception exp)
                {
                    Console.WriteLine("Error: " + exp.Message.ToString());
                    throw;
                }

            }

        }
开发者ID:WyldLynxGitHub,项目名称:SunshineCoastCouncil-master,代码行数:86,代码来源:Program.cs

示例12: OddeleniMapper

 public OddeleniMapper()
 {
     db = new Database();
     db.Connect();
 }
开发者ID:IniTW8X,项目名称:VIS_Tiket_IS,代码行数:5,代码来源:OddeleniMapper.cs

示例13: Form1

 public Form1()
 {
     InitializeComponent();
     //
     if (!TrimApplication.HasBeenInitialized)
     {
         TrimApplication.Initialize();
     }
     TrimApplication.HasUserInterface = true;
     Stopwatch watch = new Stopwatch();
     
     using (Database db = new Database())
     {
         try
         {
             watch.Start();
            
             //
             db.Connect();
             //
              watch.Stop();
             var clock = watch.Elapsed.Seconds.ToString();
             //MessageBox.Show(string.Format("Finished in {0} seconds", clock));
             //
             label1.Text = "Connected to RM successfully as : " + db.CurrentUser.Name + " on " + db.Id + "/" + db.WorkgroupServerName + " - RM Workgroup connection time: " + clock + " seconds";
             label1.Visible = true;
         }
         catch (Exception exp)
         {
             label1.Text = "Error: " + exp;
             return;
         }
     }
 }
开发者ID:WyldLynxGitHub,项目名称:SunshineCoastCouncil-master,代码行数:34,代码来源:Form1.cs

示例14: KategorieMapper

 public KategorieMapper()
 {
     db = new Database();
     db.Connect();
 }
开发者ID:IniTW8X,项目名称:VIS_Tiket_IS,代码行数:5,代码来源:KategorieMapper.cs

示例15: Main

        static void Main(string[] args)
        {
            Database db = null;
             string query;
             OdbcDataReader dbReader;
             int interval_seconds_guess;
             string dateFormat;
             string server = "http://www.meteoagri.com/";

             Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

             try
             {
            db = new Database();
            CmdArgs cmdArgs = new CmdArgs(args);
            List<DataToRead> list = new List<DataToRead>();
            int defaultDaysToDownload;

            string user, pass;

            bool save_ts = cmdArgs.HasOption("save_ts");
            bool save_db = cmdArgs.HasOption("save_db");

            if (!cmdArgs.HasParameter("user"))
               throw new Exception("Must provide the user. Uses '--user user_name'.");

            if (!cmdArgs.HasParameter("pass"))
               throw new Exception("Must provide the pass. Uses '--pass password'.");

            user = cmdArgs.Parameters["user"];
            pass = cmdArgs.Parameters["pass"];

            if (cmdArgs.HasParameter("cfg"))
            {
               Config conf = new Config(cmdArgs.Parameters["cfg"]);
               conf.Load();

               if (save_db)
               {
                  ConfigNode dbConf = conf.Root.ChildNodes.Find(delegate(ConfigNode node) { return node.Name == "database.config"; });
                  if (dbConf == null)
                     throw new Exception("No 'database.config' block was found.");

                  if (db.Connect(dbConf["db.conn.string"].AsString()) != Result.TRUE)
                     throw new Exception("Connection to database was not possible. The message returned was: " + db.RaisedException.Message);
               }

               server = conf.Root["server", "http://www.meteoagri.com/"].AsString();
               defaultDaysToDownload = conf.Root["days.to.download", 14].AsInt();
               dateFormat = conf.Root["date.format", "#yyyy-MM-dd HH:mm:ss#"].AsString();
               interval_seconds_guess = conf.Root["interval.guess", 900].AsInt();

               List<ConfigNode> nodeList = conf.Root.ChildNodes.FindAll(delegate(ConfigNode node) { return node.Name == "data.to.read"; });
               if (nodeList == null)
                  throw new Exception("No blocks 'nodes.to.read' were found.");

               DataToRead item;
               NodeData nd;
               int blockNumber = 1;
               foreach (ConfigNode node in nodeList)
               {
                  item = new DataToRead();
                  list.Add(item);

                  item.TimeSeriesFileName = node["time.series.file.name", ""].AsString();
                  item.TableName    = node["table.name"].AsString();
                  item.DBDateColumn = node["db.date.column"].AsString();

                  List<ConfigNode> cfList = node.ChildNodes.FindAll(delegate(ConfigNode n) { return n.Name == "node"; });
                  if (cfList == null)
                     throw new Exception("No blocks 'node' were found on block number " + blockNumber.ToString());

                  foreach (ConfigNode cn in cfList)
                  {
                     nd = new NodeData();
                     nd.DefaultValue = cn["default.value", ""].AsString();
                     nd.DBColumn = cn["column"].AsString();
                     nd.TSHeader = cn["ts.header", nd.DBColumn].AsString();
                     nd.NodeID   = cn["node.id"].AsString();
                     item.NodesList.Add(nd);
                  }

                  if (save_db)
                  {
                     query = string.Format("SELECT {0} FROM {1} ORDER BY {0} DESC",
                                           item.DBDateColumn, item.TableName);

                     dbReader = db.ExecuteQuerySingleRow(query);

                     item.Start = DateTime.Now.AddDays(-defaultDaysToDownload);

                     if (dbReader.HasRows)
                     {
                        while (dbReader.Read())
                           item.Start = dbReader.GetDateTime(dbReader.GetOrdinal(item.DBDateColumn)).AddDays(1);

                        if (!dbReader.IsClosed)
                           dbReader.Close();
                     }
                  }
//.........这里部分代码省略.........
开发者ID:JauchOnGitHub,项目名称:csharptoolbox,代码行数:101,代码来源:Program.cs


注:本文中的Database.Connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。