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


C# FbCommand.GetGeneratorValue方法代码示例

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


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

示例1: AddDataRecords

        public void AddDataRecords(IEnumerable<DataRecord> data, out int newData, out int NewTags)
        {
            newData = 0;
            NewTags = 0;
            lock (_conw)
            {
                if (cts.IsCancellationRequested) return;
                StoppedEvent.Reset();
                if (_conw.State != System.Data.ConnectionState.Open)
                    _conw.Open();
                try
                {
                    var ttTc = Helpers.TickCount;
                    long diTc = 0, mTc = 0, tTc = 0, tiTc = 0, tc = 0;
                    bool failed = false;
                    using (var tr = _conw.BeginTransaction(_writeTransactionOptions))
                    {
                        //var removed = new List<long>();
                        try
                        {
                            var md5 = new Dictionary<int, long>();
                            using (FbCommand cmd = new FbCommand(string.Empty, _conw, tr)/*, cmd1_5 = new FbCommand(string.Empty, _con, tr)*/)
                            {
                                long mc = cmd.GetGeneratorValue("GEN_MD5_INDEX");
                                List<string> tgs = new List<string>();

                                var mlMD5 = cmd.CreateParameter();
                                var mlRating = cmd.CreateParameter();
                                var mlMD5Id = cmd.CreateParameter();
                                mlMD5Id.Direction = System.Data.ParameterDirection.Output;
                                cmd.Parameters.AddRange(new FbParameter[] { mlMD5, mlRating, mlMD5Id });

                                cmd.CommandText = "update or insert into MD5_LIST (MD5, RATING) values (?,?) MATCHING (MD5) returning MD5_ID";
                                using (
                                    FbCommand cmd2 = new FbCommand("update or insert into SERVERS_LIST (SERVER_NAME, SERVER_GROUP_ID) values (?,?) matching (SERVER_NAME) returning SERVER_ID", _conw, tr),
                                    cmd3 = new FbCommand("update or insert into DATA_INFO (DATA_MD5_ID, DATA_SERVER_ID, DATA_POST_NUMBER, DATA_EXT_ID, DATA_SIZE, AUTOR_ID, CHILD_POST, PARENT_POST) values (?,?,?,?,?,?,?,?) matching (DATA_MD5_ID, DATA_SERVER_ID)", _conw, tr),
                                    cmd4 = new FbCommand("update or insert into EXT_LIST (EXT) values (?) matching (EXT) returning EXT_ID", _conw, tr),
                                    cmd5 = new FbCommand("update or insert into AUTORS (AUTOR) values (?) matching (AUTOR) returning AUTOR_ID", _conw, tr)
                                )
                                {
                                    #region parameters

                                    #region SERVERS_LIST   
                                    var slServerName = cmd2.CreateParameter();
                                    var slServerGroup = cmd2.CreateParameter();
                                    var slServerId = cmd2.CreateParameter();
                                    slServerId.Direction = System.Data.ParameterDirection.Output;
                                    cmd2.Parameters.AddRange(new[] { slServerName, slServerGroup, slServerId });
                                    #endregion

                                    #region DATA_INFO
                                    var diMD5Id = cmd3.CreateParameter();
                                    var diServerId = cmd3.CreateParameter();
                                    var diPost = cmd3.CreateParameter();
                                    var diExtId = cmd3.CreateParameter();
                                    var diFileSize = cmd3.CreateParameter();
                                    var diAutorId = cmd3.CreateParameter();
                                    var diParentPost = cmd3.CreateParameter();
                                    var diChildPost = cmd3.CreateParameter();
                                    cmd3.Parameters.AddRange(new[] { diMD5Id, diServerId, diPost, diExtId, diFileSize, diAutorId, diChildPost, diParentPost });
                                    #endregion

                                    #region EXT_LIST
                                    var elExt = cmd4.CreateParameter();
                                    var elExtId = cmd4.CreateParameter();
                                    elExtId.Direction = System.Data.ParameterDirection.Output;
                                    cmd4.Parameters.AddRange(new[] { elExt, elExtId });
                                    #endregion

                                    #region AUTORS
                                    var aAutor = cmd5.CreateParameter();
                                    var aAutorId = cmd5.CreateParameter();
                                    aAutorId.Direction = System.Data.ParameterDirection.Output;
                                    cmd5.Parameters.AddRange(new[] { aAutor, aAutorId });
                                    #endregion

                                    #endregion

                                    var autors = new Dictionary<string, int>();
                                    var exts = new Dictionary<string, int>();
                                    var servers = new Dictionary<string, int>();
                                    int i = 0;
                                    foreach (var d in data)
                                        if (!string.IsNullOrWhiteSpace(d.MD5) && d.Servers != null)
                                        {
                                            i++;
                                            mlMD5.Value = d.MD5;
                                            mlRating.Value = (Char)d.Rating;
                                            tc = Helpers.TickCount;
                                            if (cmd.ExecuteNonQuery() > 0)
                                            {
                                                mTc += Helpers.TickCount - tc;
                                                long id = md5[i] = (long)mlMD5Id.Value;
                                                diMD5Id.Value = id;
                                                if (mc < id)
                                                    newData++;
                                                int indx = 0;

                                                #region preparing tags list
                                                if (d.Tags != null)
//.........这里部分代码省略.........
开发者ID:xCMNx,项目名称:BooruViewer.Net,代码行数:101,代码来源:FBDatabase.cs

示例2: AddTags

 public Dictionary<string, long> AddTags(FbTransaction tr, IEnumerable<string> tags, out int newTags)
 {
     newTags = 0;
     var r = new Dictionary<string, long>();
     using (FbCommand cmd = new FbCommand("update or insert into TAGS_LIST (TAG) values (?) MATCHING (TAG) returning TAG_ID", tr.Connection, tr))
     {
         long tc = cmd.GetGeneratorValue("GEN_TAG_INDEX");
         var p = new FbParameter();
         p.Direction = System.Data.ParameterDirection.Output;
         var p2 = new FbParameter();
         cmd.Parameters.Add(p2);
         cmd.Parameters.Add(p);
         long id;
         foreach (var t in tags)
             if (TagsCachedId.TryGetValue(t, out id))
                 r[t] = id;
             else
             {
                 p2.Value = t;
                 if (cmd.ExecuteNonQuery() > 0)
                     if (tc < (TagsCachedId[t] = r[t] = (long)p.Value))
                         newTags++;
             }
     }
     return r;
 }
开发者ID:xCMNx,项目名称:BooruViewer.Net,代码行数:26,代码来源:FBDatabase.cs


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