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


C# Transaction.CallReader方法代码示例

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


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

示例1: CheckAlbumInformations

        public static Int64 CheckAlbumInformations(MediaFile file, Int64 artistId, Transaction tran)
        {
            const String select =
                        "select a.LIBRARY_ID,a.PARENT_ID, b.PROPERTY_VALUE from MEDIA_LIBRARY a " +
                        "inner join MEDIA_LIBRARY_PROPERTY b on a.LIBRARY_ID = b.LIBRARY_ID " +
                        "where a.TYPE_ID = @ML_TYPE_ID and b.TYPE_ID = @TYPE_ID and b.PROPERTY_VALUE = @NAME";

            Int64 returnId;
            if (String.IsNullOrEmpty(file.AlbumName))
            {
                return getUnknownAlbum(tran);
            }
            else
            {
                using (DataReader reader = tran.CallReader(select,
                    Static.Db.NewParameter("@ML_TYPE_ID", MediaLibraryType.Album),
                    Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.Name),
                    Static.Db.NewParameter("@NAME", file.AlbumName)))
                {

                    if (reader.Read())
                    {
                        if (artistId != reader["PARENT_ID"])
                            tran.CallNonQuery(MediaLibrary.UpdateMediaLibrarySql,
                               Static.Db.NewParameter("@LIBRARY_ID", reader["LIBRARY_ID"]),
                               Static.Db.NewParameter("@PARENT_ID", artistId),
                               Static.Db.NewParameter("@MOD_DATE", DateTime.Now));

                        if (!file.AlbumName.Equals((String)reader["PROPERTY_VALUE"], StringComparison.InvariantCultureIgnoreCase))
                            tran.CallNonQuery(MediaLibrary.UpdateMediaLibraryPropertySql,
                                Static.Db.NewParameter("@LIBRARY_ID", reader["LIBRARY_ID"]),
                                Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.Name),
                                Static.Db.NewParameter("@PROPERTY_VALUE", file.AlbumName),
                                Static.Db.NewParameter("@MOD_DATE", DateTime.Now));

                        returnId = reader["LIBRARY_ID"];
                    }
                    else
                    {
                        tran.CallNonQuery(MediaLibrary.InsertMediaLibrarySql,
                            Static.Db.NewParameter("@TYPE_ID", MediaLibraryType.Album),
                            Static.Db.NewParameter("@MOD_DATE", DateTime.Now),
                            Static.Db.NewParameter("@PARENT_ID", artistId));

                        returnId = tran.CallValue(Static.GetIdentityStatement);

                        tran.CallNonQuery(MediaLibrary.InsertMediaLibraryPropertySql,
                            Static.Db.NewParameter("@LIBRARY_ID", returnId),
                            Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.Name),
                            Static.Db.NewParameter("@PROPERTY_VALUE", file.AlbumName),
                            Static.Db.NewParameter("@MOD_DATE", DateTime.Now));
                    }
                }
            }
            return returnId;
        }
开发者ID:nexus49,项目名称:grado,代码行数:56,代码来源:Album.cs

示例2: getUnknownArtist

        private static long getUnknownArtist(Transaction tran)
        {
            const String select =
                "select a.LIBRARY_ID from MEDIA_LIBRARY a " +
                "inner join MEDIA_LIBRARY_PROPERTY b on a.LIBRARY_ID = b.LIBRARY_ID " +
                "where b.TYPE_ID = @TYPE_ID and b.PROPERTY_VALUE = @NAME";

            Int64 returnId;

            using (DataReader reader = tran.CallReader(select,
                Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.Name),
                Static.Db.NewParameter("@NAME", UnknownArtistName)))
            {

                if (reader.Read())
                {
                    returnId = reader["LIBRARY_ID"];
                }
                else
                {
                    tran.CallNonQuery(MediaLibrary.InsertMediaLibrarySql,
                    Static.Db.NewParameter("@TYPE_ID", MediaLibraryType.Artist),
                    Static.Db.NewParameter("@MOD_DATE", DateTime.Now),
                    Static.Db.NewParameter("@PARENT_ID", DBNull.Value));

                    returnId = tran.CallValue(Static.GetIdentityStatement);

                    tran.CallNonQuery(MediaLibrary.InsertMediaLibraryPropertySql,
                    Static.Db.NewParameter("@LIBRARY_ID", returnId),
                    Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.Name),
                    Static.Db.NewParameter("@PROPERTY_VALUE", UnknownArtistName),
                    Static.Db.NewParameter("@MOD_DATE", DateTime.Now));
                }
            }

            return returnId;
        }
开发者ID:nexus49,项目名称:grado,代码行数:37,代码来源:Artist.cs

示例3: CheckTrackInformations

        public static Int64 CheckTrackInformations(MediaFile file, Int64 albumId, Transaction tran)
        {
            const String select =
                        "select a.LIBRARY_ID,a.PARENT_ID, b.PROPERTY_VALUE as NAME, c.PROPERTY_VALUE as URL, c.PROPERTY_VALUE as MD5 from MEDIA_LIBRARY a " +
                        "left outer join MEDIA_LIBRARY_PROPERTY b on a.LIBRARY_ID = b.LIBRARY_ID and b.TYPE_ID = 1 " +
                        "left outer join MEDIA_LIBRARY_PROPERTY c on a.LIBRARY_ID = c.LIBRARY_ID and c.TYPE_ID = 2 " +
                        "left outer join MEDIA_LIBRARY_PROPERTY e on a.LIBRARY_ID = e.LIBRARY_ID and e.TYPE_ID = 3 " +
                        "where a.TYPE_ID = @ML_TYPE_ID " +
                        "and b.TYPE_ID = @TYPE_ID and b.PROPERTY_VALUE = @NAME " +
                        "and c.TYPE_ID = @URL_TYPE ";

            Int64 returnId;
            using (DataReader reader = tran.CallReader(select,
                Static.Db.NewParameter("@ML_TYPE_ID", MediaLibraryType.Track),
                Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.Name),
                Static.Db.NewParameter("@URL_TYPE", MediaLibraryPropertyType.FileUrl),
                Static.Db.NewParameter("@NAME", file.TitleName)))
            {

                if (reader.Read())
                {
                    if (albumId != reader["PARENT_ID"])
                        tran.CallNonQuery(MediaLibrary.UpdateMediaLibrarySql,
                           Static.Db.NewParameter("@LIBRARY_ID", reader["LIBRARY_ID"]),
                           Static.Db.NewParameter("@PARENT_ID", albumId),
                           Static.Db.NewParameter("@MOD_DATE", DateTime.Now));

                    if (!file.TitleName.Equals((String)reader["NAME"], StringComparison.InvariantCultureIgnoreCase))
                        tran.CallNonQuery(MediaLibrary.UpdateMediaLibraryPropertySql,
                            Static.Db.NewParameter("@LIBRARY_ID", reader["LIBRARY_ID"]),
                            Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.Name),
                            Static.Db.NewParameter("@PROPERTY_VALUE", file.TitleName),
                            Static.Db.NewParameter("@MOD_DATE", DateTime.Now));

                    if (!file.md5HashString.Equals((String)reader["MD5"], StringComparison.InvariantCultureIgnoreCase))
                        tran.CallNonQuery(MediaLibrary.UpdateMediaLibraryPropertySql,
                            Static.Db.NewParameter("@LIBRARY_ID", reader["LIBRARY_ID"]),
                            Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.Md5Hash),
                            Static.Db.NewParameter("@PROPERTY_VALUE", file.md5HashString),
                            Static.Db.NewParameter("@MOD_DATE", DateTime.Now));

                    if (!file.PathToFile.Equals((String)reader["URL"], StringComparison.InvariantCultureIgnoreCase))
                        tran.CallNonQuery(MediaLibrary.UpdateMediaLibraryPropertySql,
                            Static.Db.NewParameter("@LIBRARY_ID", reader["LIBRARY_ID"]),
                            Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.FileUrl),
                            Static.Db.NewParameter("@PROPERTY_VALUE", file.PathToFile),
                            Static.Db.NewParameter("@MOD_DATE", DateTime.Now));

                    returnId = reader["LIBRARY_ID"];

                }
                else
                {
                    tran.CallNonQuery(MediaLibrary.InsertMediaLibrarySql,
                        Static.Db.NewParameter("@TYPE_ID", MediaLibraryType.Track),
                        Static.Db.NewParameter("@MOD_DATE", DateTime.Now),
                        Static.Db.NewParameter("@PARENT_ID", albumId));

                    returnId = tran.CallValue(Static.GetIdentityStatement);

                    tran.CallNonQuery(MediaLibrary.InsertMediaLibraryPropertySql,
                        Static.Db.NewParameter("@LIBRARY_ID", returnId),
                        Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.Name),
                        Static.Db.NewParameter("@PROPERTY_VALUE", String.IsNullOrEmpty(file.TitleName)? UnknownTrackName: file.TitleName),
                        Static.Db.NewParameter("@MOD_DATE", DateTime.Now));

                    tran.CallNonQuery(MediaLibrary.InsertMediaLibraryPropertySql,
                       Static.Db.NewParameter("@LIBRARY_ID", returnId),
                       Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.FileUrl),
                       Static.Db.NewParameter("@PROPERTY_VALUE", file.PathToFile),
                       Static.Db.NewParameter("@MOD_DATE", DateTime.Now));
                }
            }

            checkImageInformations(file, returnId, tran);

            return returnId;
        }
开发者ID:nexus49,项目名称:grado,代码行数:78,代码来源:Track.cs


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