Exemple #1
0
        static void Main(string[] args)
        {
            try
            {
                if (Setup(args))
                {
                    CFindServiceSCU mwl = new CFindServiceSCU(SOPClass.ModalityWorklistInformationModelFIND);
                    mwl.Syntaxes.Add(Syntax.ImplicitVrLittleEndian);
                    mwl.Syntaxes.Add(Syntax.ExplicitVrLittleEndian);
                    mwl.Syntaxes.Add(Syntax.ExplicitVrBigEndian);

                    Association association = new Association();
                    association.AddService(mwl);

                    if (association.Open(scu, scp, address, port))
                    {
                        DataSet query = GetQuery();

                        RecordCollection records = mwl.CFind(query);

                        DumpRecords(records);
                    }
                    else
                    {
                        throw new Exception(String.Format("Can't connect to {0}:{1}:{2}", scp, address, port));
                    }
                    association.Close();
                }
            }
            catch (Exception ex)
            {
                System.Console.Out.WriteLine(ex.Message);
            }
        }
Exemple #2
0
        static void echomwl(string title, IPAddress address, int port)
        {
            VerificationServiceSCU echo = new VerificationServiceSCU();

            echo.Syntaxes.Add(Syntax.ImplicitVrLittleEndian);

            QueryRetrieveServiceSCU mwl = new QueryRetrieveServiceSCU();

            mwl.Syntaxes.Add(Syntax.ImplicitVrLittleEndian);

            Association association = new Association();

            association.AddService(mwl);
            association.AddService(echo);

            if (association.Open(title, address, port))
            {
                bool result = echo.Echo();
                System.Console.WriteLine("\necho {0}.", (result) ? "succeded" : "failed");
                if (result)
                {
                    DataSet          query   = GetQuery(null);
                    RecordCollection records = mwl.CFind(query);
                    WriteRecords(records);
                }
            }
            else
            {
                System.Console.WriteLine("\ncan't Open.");
            }
            association.Close();
        }
 internal Database(string ConnectionString, string FingerTable, bool UseIdentityProcess = false, bool AutoLoadData = true, string LoadSQL = "")
 {
     try
     {
         _ConnectionString = ConnectionString;
         Connection        = new SqlConnection(ConnectionString);
         Connection.Open();
         m_records = new RecordCollection(this, FingerTable, UseIdentityProcess, AutoLoadData, LoadSQL);
     }
     catch (Exception ex)
     {
         try
         {
             logger.WriteLog(ex);
         }
         catch (Exception exx)
         {
         }
         throw new Exception("Error Reaching Database");
     }
     finally
     {
         if (Connection.State == ConnectionState.Open)
         {
             Connection.Close();
         }
     }
 }
Exemple #4
0
 /// <summary>
 /// Reads a CGT and creates all the objects needed to create
 /// a tokenizer and parser at a later time.
 /// </summary>
 /// <param name="stream">The CGT stream.</param>
 private void ReadFile(Stream stream)
 {
     try
     {
         Reset();
         this.stream = stream;
         CalithaBinReader reader = new CalithaBinReader(stream);
         string header = "";
         try
         {
             header = reader.ReadUnicodeString();
             if (! header.StartsWith("GOLD"))
                 throw new CGTStructureException("File header is invalid");
         }
         catch (EndOfStreamException e)
         {
             throw new CGTStructureException("File header is invalid",e);
         }
         RecordCollection records = new RecordCollection();
         while (!(stream.Position == stream.Length))
         {
             records.Add(ReadRecord(reader));
         }
         structure = new CGTStructure(header,records);
         content = new CGTContent(structure);
         dfaStates = CreateDFAStates(content);
         parserStates = CreateParserStates(content);
     }
     finally
     {
         stream.Close();
     }
 }
Exemple #5
0
        public void Init()
        {
            this.listSwitch = ListSwitch.None;
            this.Heroes     = new RecordCollection();

            DHLOOKUP.RefreshTaverns();
        }
        /// <summary>
        /// 加载记录命令内容
        /// </summary>
        async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;
            try
            {
                RecordCollection.Clear();
                var records = await DataStore.GetItemsAsync(true);

                records = records.OrderByDescending(p => p.Year).ThenByDescending(p => p.Month)
                          .ThenByDescending(p => p.Day).ThenByDescending(p => p.Id);

                foreach (var record in records)
                {
                    RecordCollection.Add(record);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #7
0
        internal void InitList(RecordCollection heroes)
        {
            itemsLV.BeginUpdate();

            // init list

            itemsLV.Items.Clear();

            foreach (unit hero in heroes)
            {
                if (hero.iconImage.IsNull)
                {
                    continue;
                }

                ListViewItem lvi_Hero = new ListViewItem();

                lvi_Hero.ImageKey = hero.iconName;
                //lvi_Hero.Text = hero.ID;
                lvi_Hero.Tag = hero;
                foreach (unit tavern in DHLOOKUP.taverns)
                {
                    if (tavern.sellunits.Contains(hero.codeID))
                    {
                        lvi_Hero.Group = itemsLV.Groups[tavern.ID];
                    }
                }

                itemsLV.Items.Add(lvi_Hero);
            }

            itemsLV.EndUpdate();

            captionB.Text = "Heroes (" + itemsLV.Items.Count + ")";
        }
Exemple #8
0
        /// <summary>
        /// Checks, if the given domain redirects to mailinator
        /// </summary>
        /// <param name="Host">host name</param>
        /// <returns>true, if mailinator inbox</returns>
        public static bool IsMailinator(string Host)
        {
            List <uint>      Questionable_IPs = new List <uint>();
            RecordCollection RC = Dns.Lookup(Host, Dns.QueryTypes.DNS_TYPE_MX);

            if (RC == null)
            {
                return(false);
            }
            for (int i = 0; i < RC.RecordTypes.Length; i++)
            {
                if (RC.RecordTypes[i] == Dns.QueryTypes.DNS_TYPE_MX)
                {
                    Questionable_IPs.AddRange(GetRecords(RecordCollection.ToString(((Dns.DNS_MX_DATA)RC.FoundRecords[i]).pNameExchange)));
                }
            }

            foreach (uint Mailinator_IP in Mailinator_IPs)
            {
                if (Questionable_IPs.Contains(Mailinator_IP))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #9
0
 public PageInfo()
 {
     Page = 1;
     PageSize = 10;
     RecordCollection a = new RecordCollection();
     Record b = new Record();
 }
Exemple #10
0
        private async Task <MongoDbRecord> LockRecord(byte[] lockToken, Record r)
        {
            var key     = r.Key.ToByteArray();
            var version = r.Version.ToByteArray();

            if (version.Length != 0)
            {
                var res = await RecordCollection.FindOneAndUpdateAsync(
                    x => x.Key.Equals(key) && x.Version.Equals(version) && (x.TransactionLock == null || x.TransactionLock.Equals(lockToken)),
                    Builders <MongoDbRecord> .Update
                    .Set(x => x.TransactionLock, lockToken)
                    );

                if (res == null)
                {
                    var e = new ConcurrentMutationException(r);
                    e.Data["ExceptionType"] = "LockRecord";
                    throw e;
                }
#if DEBUG
                Logger.LogDebug($"Locked token {new ByteString(lockToken)} {r.Key.ToString()}");
#endif
                return(res);
            }
            return(null);
        }
Exemple #11
0
        void mwl(string title, IPAddress address, int port, Dictionary <string, string> filter)
        {
            CFindServiceSCU mwl = new CFindServiceSCU(SOPClass.ModalityWorklistInformationModelFIND);

            mwl.Syntaxes.Add(Syntax.ExplicitVrLittleEndian);
            mwl.Syntaxes.Add(Syntax.ExplicitVrBigEndian);
            mwl.Syntaxes.Add(Syntax.ImplicitVrLittleEndian);

            Association association = new Association();

            association.AddService(mwl);

            if (association.Open(title, address, port))
            {
                DataSet query = GetQuery(filter);

                RecordCollection records = mwl.CFind(query);
                RecordCollectionTest.WriteRecords(records);
            }
            else
            {
                System.Console.WriteLine("\ncan't Open.");
            }
            association.Close();
        }
Exemple #12
0
 private void LoadRecords()
 {
     using (StreamReader stream = new StreamReader(Application.dataPath + RecordPath))
     {
         string json = stream.ReadToEnd();
         records = JsonUtility.FromJson <RecordCollection>(json);
     }
 }
        public void LoadExistingFilesTest()
        {
            string           path    = Path.Combine(Tools.RootFolder, @"EK\Capture\Dicom\DicomToolKit\Test\Data");
            RecordCollection records = new RecordCollection(path, true);

            records.Load();
            WriteRecords(records);
        }
 public MediaSetViewModel(RecordCollection recordCollection, string mediaTypeName)
 {
     this.MediaTypeName = mediaTypeName;
     MediaViewModels=new List<MediaViewModel>();
     foreach (Record rec in recordCollection)
     {
         MediaViewModels.Add(new MediaViewModel(rec));
     }
 }
        public RecordCollectionTests()
        {
            SynchronizationContext.SetSynchronizationContext(new TestSynchronizationContext());

            this.testScheduler = new TestScheduler();
            this.logSource = new Mock<ILogSource>(MockBehavior.Strict);

            this.logSource.SetupGet(x => x.Status).Returns(this.status.ObserveOn(this.testScheduler));

            this.collection = new RecordCollection(this.logSource.Object) {Scheduler = this.testScheduler};
            this.collection.Initialize();
        }
Exemple #16
0
        public override void InsertRecords(string tableName, IEnumerable <Record> records)
        {
            var collection = new RecordCollection();

            collection.AddRange(records);

            using (var excel = ExcelOpenXmlDocument.Load(ConnectionDetails.Database))
            {
                var data = collection.ToDataTable();
                excel.Import(data, tableName, true, (uint)(excel.GetRowCount(tableName) + 1));
            }
        }
Exemple #17
0
    public static void Main(string[] args)
    {
        //creation of object:
        RecordCollection cd1 = new RecordCollection("Automatic for the People", "REM", "Alternative", "Cassette", 1992, 1);

        RecordCollection cd2 = new RecordCollection("Queen II", "Queen", "Rock", "Cassette", 1974, 1);

        //system order instructions
        enterUserName();
        cd1.addRecord(cd1);
        cd2.addRecord(cd2);
        Menu();
    }
Exemple #18
0
        void AppendMarcRecords(RecordCollection records,
                               Encoding encoding,
                               int start_index)
        {
            if (records == null)
            {
                return;
            }

            int i = start_index;

            foreach (Record record in records)
            {
                this.AppendHtml("<div class='debug green' >" + (i + 1) + ") ===</div>");

                if (string.IsNullOrEmpty(record.m_strDiagSetID) == false)
                {
                    // 这是诊断记录

                    this.AppendHtml("<div>" + HttpUtility.HtmlEncode(record.ToString()).Replace("\r\n", "<br/>") + "</div>");
                    i++;
                    continue;
                }

                // 把byte[]类型的MARC记录转换为机内格式
                // return:
                //		-2	MARC格式错
                //		-1	一般错误
                //		0	正常
                int nRet = MarcLoader.ConvertIso2709ToMarcString(record.m_baRecord,
                                                                 encoding == null ? Encoding.GetEncoding(936) : encoding,
                                                                 true,
                                                                 out string strMARC,
                                                                 out string strError);
                if (nRet == -1)
                {
                    this.AppendHtml("<div>" + strError + "</div>");
                    i++;
                    continue;
                }

                // 获得 MARC 记录的 HTML 格式字符串
                string strHtml = MarcUtil.GetHtmlOfMarc(strMARC,
                                                        null,
                                                        null,
                                                        false);

                this.AppendHtml(strHtml);
                i++;
            }
        }
Exemple #19
0
        private async Task RollbackTransaction(byte[] hash)
        {
            // Rollback is idempotent && reentrant : may be call twice even at the same time
            try
            {
#if DEBUG
                Logger.LogDebug($"Rollbacking transaction {new ByteString(hash)}");
#endif
                // get affected records
                var trn = await PendingTransactionCollection.Find(x => x.TransactionHash.Equals(hash)).SingleOrDefaultAsync();

                if (trn != null)
                {
                    // revert records values & version
                    foreach (var r in trn.InitialRecords)
                    {
                        await RecordCollection.FindOneAndUpdateAsync(
                            x => x.Key.Equals(r.Key) && x.TransactionLock.Equals(trn.LockToken),
                            Builders <MongoDbRecord> .Update.Set(x => x.Value, r.Value).Set(x => x.Version, r.Version).Unset(x => x.TransactionLock)
                            );
                    }

                    foreach (var r in trn.AddedRecords)
                    {
                        await RecordCollection.FindOneAndDeleteAsync(
                            x => x.Key.Equals(r) && x.TransactionLock.Equals(trn.LockToken)
                            );
                    }

                    // remove transaction
                    await TransactionCollection.DeleteOneAsync(x => x.TransactionHash.Equals(hash));

                    await RecordCollection.UpdateOneAsync(
                        x => x.TransactionLock == trn.LockToken,
                        Builders <MongoDbRecord> .Update
                        .Unset(x => x.TransactionLock)
                        );

                    // remove pending transaction
                    await PendingTransactionCollection.DeleteOneAsync(x => x.TransactionHash.Equals(hash));

                    Logger.LogInformation($"Transaction {new ByteString(hash)} rollbacked");
                }
            }
            catch (Exception ex)
            {
                var msg = "Error rollbacking transaction : " + new ByteString(hash).ToString();
                Logger.LogCritical(msg, ex);
                throw new Exception(msg, ex);
            }
        }
        private async Task UnlockRecord(byte[] lockToken, Record r)
        {
            var key = r.Key.ToByteArray();
            var res = await RecordCollection.UpdateOneAsync(
                x => x.Key.Equals(key) && x.TransactionLock == lockToken,
                Builders <MongoDbRecord> .Update
                .Unset(x => x.TransactionLock)
                );

            if (res.ModifiedCount != 1 || res.MatchedCount != 1)
            {
                throw new ConcurrentMutationException(r);
            }
        }
Exemple #21
0
        public void InternalQueryTest2()
        {
            DicomDir dir = new DicomDir(".");

            dir.Empty();

            ApplicationEntity storage = new ApplicationEntity("ImageServer", IPAddress.Parse("127.0.0.1"), 2000);

            StorageTest.Start(storage);

            StorageTest.store(@"EK\Capture\Dicom\DicomToolKit\Test\Data\DicomDir\Y2ASNFDS.dcm", storage, false);
            StorageTest.store(@"EK\Capture\Dicom\DicomToolKit\Test\Data\DicomDir\WNGVU1P1.dcm", storage, false);
            StorageTest.store(@"EK\Capture\Dicom\DicomToolKit\Test\Data\DicomDir\THGLUZ5J.dcm", storage, false);

            StorageTest.Stop();

            ApplicationEntity host = new ApplicationEntity("IMAGESERVER", 2190);

            CFindTest.Start(host);

            CFindServiceSCU find = new CFindServiceSCU(SOPClass.StudyRootQueryRetrieveInformationModelFIND);

            find.Syntaxes.Add(Syntax.ExplicitVrLittleEndian);

            Association association = new Association();

            association.AddService(find);

            if (association.Open(host.Title, host.Address, host.Port))
            {
                Series series = new Series();
                series[t.StudyInstanceUID].Value = "1.2.840.113564.109517115.2009111711190101521";

                DataSet filter = new DataSet();
                filter.Elements = series.Elements;

                filter.Set(t.QueryRetrieveLevel, "SERIES");

                RecordCollection records = find.CFind(filter);
                RecordCollectionTest.WriteRecords(records);
            }
            else
            {
                System.Console.WriteLine("\ncan't Open.");
            }
            association.Close();
            dir.Empty();

            CFindTest.Stop();
        }
        private void PreviosTrack()
        {
            if (SelectRecord != null)
            {
                int Current_index = RecordCollection.IndexOf(SelectRecord);
                if (Current_index < RecordCollection.Count || Current_index > 1)
                {
                    SelectRecord = RecordCollection.FindByIndex(--Current_index);
                    Dispose();

                    Play();
                }
            }
        }
        private void NextTrack()
        {
            if (SelectRecord != null)
            {
                int Current_index = RecordCollection.IndexOf(SelectRecord);
                if (Current_index < RecordCollection.Count - 1)
                {
                    SelectRecord = RecordCollection.Next(++Current_index);
                    Dispose();

                    Play();
                }
            }
        }
        public async Task <IReadOnlyList <Record> > GetAllRecords(RecordType type, string name)
        {
            var list = new List <Record>();
            var res  = await RecordCollection.FindAsync(x => x.Type == type && x.Name == name);

            await res.ForEachAsync(r =>
            {
                list.Add(new Record(new ByteString(r.Key), new ByteString(r.Value), new ByteString(r.Version)));
            }

                                   );

            return(list.AsReadOnly());
        }
Exemple #25
0
        /// <summary>
        /// Gets A records from DNS
        /// </summary>
        /// <param name="Hostname">hostname to get A records from</param>
        /// <returns>List of IP addresses (as 4 byte integers)</returns>
        static uint[] GetRecords(string Hostname)
        {
            List <uint>      L  = new List <uint>();
            RecordCollection RC = Dns.Lookup(Hostname, Dns.QueryTypes.DNS_TYPE_A);

            for (int i = 0; i < RC.RecordTypes.Length; i++)
            {
                if (RC.RecordTypes[i] == Dns.QueryTypes.DNS_TYPE_A)
                {
                    L.Add(((Dns.DNS_A_DATA)RC.FoundRecords[i]).IpAddress);
                }
            }
            return(L.ToArray());
        }
        public RecordCollectionTests()
        {
            SynchronizationContext.SetSynchronizationContext(new TestSynchronizationContext());

            this.testScheduler = new TestScheduler();
            this.logSource     = new Mock <ILogSource>(MockBehavior.Strict);

            this.logSource.SetupGet(x => x.Status).Returns(this.status.ObserveOn(this.testScheduler));

            this.collection = new RecordCollection(this.logSource.Object)
            {
                Scheduler = this.testScheduler
            };
            this.collection.Initialize();
        }
Exemple #27
0
        /// <summary>
        /// To prepare recordcollection object using entitycollection
        /// </summary>
        /// <param name="entityCollection"></param>
        /// <returns></returns>
        private RecordCollection GetRecordCollection(EntityCollection entityCollection)
        {
            if (entityCollection == null)
            {
                return(null);
            }
            trace.Trace("GetRecordCollection - Start");
            var recordCollection = new RecordCollection()
            {
                ActivityParty = GetEntityRecordCollection(entityCollection)
            };

            trace.Trace("GetRecordCollection - End");
            return(recordCollection);
        }
 public static void WriteRecords(RecordCollection records)
 {
     if (records != null)
     {
         foreach (Elements record in records)
         {
             foreach (Element element in record.InOrder)
             {
                 Debug.WriteLine(String.Format("{0}:{1}:{2}", element.Tag.ToString(), element.Description, element.Value));
             }
             Debug.WriteLine("");
         }
         Debug.WriteLine(String.Format("\n{0} records returned.", (records == null) ? 0 : records.Count));
     }
 }
Exemple #29
0
 private static void DumpRecords(RecordCollection records)
 {
     if (records != null)
     {
         foreach (Elements record in records)
         {
             foreach (Element element in record.InOrder)
             {
                 System.Console.Out.WriteLine(String.Format("{0}:{1}:{2}", element.Tag.ToString(), element.Description, element.Value));
             }
             System.Console.Out.WriteLine("");
         }
         System.Console.Out.WriteLine(String.Format("\n{0} records returned.", (records == null) ? 0 : records.Count));
     }
 }
        public async Task <IReadOnlyList <Record> > GetKeyStartingFrom(ByteString prefix)
        {
            var prefixS = Encoding.UTF8.GetString(prefix.ToByteArray());
            var list    = new List <Record>();
            var res     = await RecordCollection.FindAsync(x => x.KeyS.StartsWith(prefixS));

            await res.ForEachAsync(r =>
            {
                list.Add(new Record(new ByteString(r.Key), new ByteString(r.Value), new ByteString(r.Version)));
            }

                                   );

            return(list.AsReadOnly());
        }
Exemple #31
0
        public async Task <IReadOnlyList <Record> > GetRecords(IEnumerable <ByteString> keys)
        {
            var list = new List <Record>();

            foreach (var k in keys)
            {
                var replay     = false;
                var retryCount = Configuration.ReadRetryCount;
                var delay      = Configuration.ReadLoopDelay;
                do
                {
                    var cmpkey = k.ToByteArray();
                    var r      = await RecordCollection.Find(x => x.Key == cmpkey).FirstOrDefaultAsync();

                    if (r == null)
                    {
                        list.Add(new Record(k, ByteString.Empty, ByteString.Empty));
                        replay = false;
                    }
                    else
                    {
                        // retry
                        if (r.TransactionLock != null)
                        {
                            if (retryCount <= 0)
                            {
                                throw new Exception("Lock timeout reading record " + cmpkey.ToString());
                            }
#if DEBUG
                            Logger.LogDebug($"Waiting token {new ByteString(r.TransactionLock)} {k.ToString()} {retryCount}");
#endif
                            await Task.Delay(delay);

                            delay  = TimeSpan.FromMilliseconds(delay.TotalMilliseconds * 1.5);
                            replay = true;
                            retryCount--;
                        }
                        else
                        {
                            list.Add(new Record(k, new ByteString(r.Value), new ByteString(r.Version)));
                            replay = false;
                        }
                    }
                } while (replay);
            }

            return(list.AsReadOnly());
        }
Exemple #32
0
 public RecordCollection ExecuteRecord(string SQLText)
 {
     RecordCollection rcc = new RecordCollection();
     using (IDataReader rd = ExecuteReader(SQLText))
     {
         while (rd.Read())
         {
             Record rc = new Record();
             for (int i = 0; i < rd.FieldCount; i++)
             {
                 rc.Add(rd.GetName(i), rd.GetValue(i));
             }
             rcc.Add(rc);
         }
     }
     return rcc;
 }
        static void Main(string[] args)
        {
            Application app = new Application();

            LogOnStatus status = app.LogOn("LUXDAM", "Eduard_Pasmetukhau", "P2ssw0rd!");

            if (status == LogOnStatus.LoggedOn)
            {
                Console.WriteLine("Ok");
            }
            else Console.WriteLine(status);

            Classification c = new Classification(app);
            ClassificationHelper ch = new ClassificationHelper(app);
            Guid? rootGuid= ch.GetId(new SearchExpression("name = 'Luxottica Content*'"));
            
            Console.WriteLine("List of classification with parent Luxottica Content");
            //Console.ReadKey();


            if (rootGuid != null)
            {
                ClassificationCollection classCollections = new ClassificationCollection(app);
                classCollections.Load(new SearchExpression(String.Format("parent = '{0}'", rootGuid)));
                foreach (Classification classification in classCollections)
                {
                    Console.WriteLine(classification.Label + " Guid: "+classification.Id);
                }
            }
            Console.WriteLine();
            Console.ReadKey();
            Console.WriteLine("First 10 Guids of Records in classification Luxottica Content");

            RecordCollection rc = new RecordCollection(app);
            rc.Load(new SearchExpression(String.Format("classification = '{0}'", rootGuid)));
            

            foreach (Record r in rc.Take<Record>(10))
            {
                Console.WriteLine(r.Id);
            }

            Console.ReadKey();

            
        }
Exemple #34
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            RecordService recordService = new RecordService();

            records = new RecordCollection(recordService.GetAll());

            ProgramService programService = new ProgramService();

            programs = new ProgramCollection(programService.GetAll());

            dgridTvRecord.ItemsSource = records.collecion;
            dgridProgram.ItemsSource  = programs.collecion;

            ChannelService channelService = new ChannelService();

            channels = new ChannelCollection(channelService.GetAll());
        }
Exemple #35
0
 static void Main(string[] args)
 {
     try
     {
         _app = new Application();
         LogIn(_app);
         RecordCollection rc = new RecordCollection(_app);
         rc.Load(new SearchExpression("FieldName('UPC code') = *"));
         Dictionary <string, Guid> dictionaryForSearch = new Dictionary <string, Guid>();
         Dictionary <Guid, string> dictionaryForExcel  = new Dictionary <Guid, string>();
         string currentValue = null;
         foreach (Record r in rc)
         {
             currentValue = r.Fields.GetField <TextField>("UPC code").Value.TrimStart('0');
             if (!String.IsNullOrEmpty(currentValue))
             {
                 if (dictionaryForSearch.ContainsKey(currentValue))
                 {
                     dictionaryForExcel.Add(r.Id, currentValue);
                     Guid g = dictionaryForSearch[currentValue];
                     if (!dictionaryForExcel.ContainsKey(g))
                     {
                         dictionaryForExcel.Add(g, currentValue);
                     }
                 }
                 else
                 {
                     dictionaryForSearch.Add(currentValue, r.Id);
                 }
             }
         }
         Console.WriteLine("Count of duplicate assets: " + dictionaryForExcel.Count);
         ExcelWriter writer = new ExcelWriter(ConfigurationSettings.AppSettings["ExcelPath"]);
         writer.Write(dictionaryForExcel, _app);
         Console.WriteLine("Save complite");
         Console.ReadKey();
     }
     finally
     {
         if (_app.IsLoggedOn)
         {
             _app.LogOff();
         }
     }
 }
Exemple #36
0
        public List<string> FindRecordWithSpecialTypes(string[] types)
        {
            var result = new List<string>();
            var searchExpr = new SearchExpression("Extension = eps OR Extension = pdf");
            var recordCollection = new RecordCollection(application);
            recordCollection.Load(searchExpr);

            foreach (Record record in recordCollection)
            {
                result.Add(record.Id.ToString());
            }
            return result;
        }
Exemple #37
0
        // 获得记录
        // 确保一定可以获得nCount个
        int DoPresent(
            ZConnection connection,
            string strResultSetName,
            int nStart,
            int nCount,
            string strElementSetName,
            string strPreferredRecordSyntax,
            out RecordCollection records,
            out string strError)
        {
            records = new RecordCollection();
            if (nCount == 0)
            {
                strError = "nCount为0";
                return 0;
            }

            int nGeted = 0;
            for (; ; )
            {
                RecordCollection temprecords = null;
                int nRet = DoOncePresent(
                    connection,
                    strResultSetName,
                    nStart + nGeted,
                    nCount - nGeted,
                    strElementSetName,
                    strPreferredRecordSyntax,
                    out temprecords,
                    out strError);
                if (nRet == -1)
                    return -1;
                if (temprecords == null)
                    break;

                nGeted += temprecords.Count;
                if (temprecords.Count > 0)
                    records.AddRange(temprecords);

                if (nGeted >= nCount || temprecords.Count == 0)
                    break;
            }

            return 0;
        }
Exemple #38
0
        // 获得记录
        // 不确保一定可以获得nCount个
        // parameters:
        //		nStart	开始记录(从0计算)
        int DoOncePresent(
            ZConnection connection,
            string strResultSetName,
            int nStart,
            int nCount,
            string strElementSetName,
            string strPreferredRecordSyntax,
            out RecordCollection records,
            out string strError)
        {
            records = null;
            strError = "";

            if (nCount == 0)
            {
                strError = "nCount为0";
                return 0;
            }


            BerTree tree = new BerTree();
            PRESENT_REQUEST struPresent_request = new PRESENT_REQUEST();
            byte[] baPackage = null;
            int nRet;
            int nRecvLen;

            // -->
            BerTree tree1 = new BerTree();
            int nTotlen = 0;

            struPresent_request.m_strReferenceId = this.CurrentRefID;
            struPresent_request.m_strResultSetName = strResultSetName; // "default";
            struPresent_request.m_lResultSetStartPoint = nStart + 1;
            struPresent_request.m_lNumberOfRecordsRequested = nCount;
            struPresent_request.m_strElementSetNames = strElementSetName;
            struPresent_request.m_strPreferredRecordSyntax = strPreferredRecordSyntax;

            nRet = tree.PresentRequest(struPresent_request,
                                     out baPackage);
            if (nRet == -1)
            {
                strError = "CBERTree::PresentRequest() fail!";
                return -1;
            }


#if DUMPTOFILE
	DeleteFile("presentrequest.bin");
	DumpPackage("presentrequest.bin",
		(char *)baPackage.GetData(),
		baPackage.GetSize());
	DeleteFile ("presentrequest.txt");
	tree.m_RootNode.DumpToFile("presentrequest.txt");
#endif

            nRet = CheckConnect(
                connection,
                out strError);
            if (nRet == -1)
                return -1;

            /*
            nRet = this.ZChannel.SendTcpPackage(
                baPackage,
                baPackage.Length,
                out strError);
            if (nRet == -1 || nRet == 1)
            {
                // CloseZAssociation();
                return -1;
            }

            //////////////


            baPackage = null;
            nRet = this.ZChannel.RecvTcpPackage(
                        out baPackage,
                        out nRecvLen,
                        out strError);
            if (nRet == -1)
            {
                // CloseZAssociation();
                goto ERROR1;
            }
             * */

            byte [] baOutPackage = null;
            nRet = connection.ZChannel.SendAndRecv(
                baPackage,
                out baOutPackage,
                out nRecvLen,
                out strError);
            if (nRet == -1)
                return -1;

#if DUMPTOFILE	
	DeleteFile("presendresponse.bin");
	DumpPackage("presentresponse.bin",
				(char *)baPackage.GetData(),
				baPackage.GetSize());
#endif


            tree1.m_RootNode.BuildPartTree(baOutPackage,
                0,
                baOutPackage.Length,
                out nTotlen);

#if DUMPTOFILE
	DeleteFile("PresentResponse.txt"); 
	tree1.m_RootNode.DumpDebugInfoToFile("PresentResponse.txt");
#endif

            SEARCH_RESPONSE search_response = new SEARCH_RESPONSE();
            nRet = BerTree.GetInfo_PresentResponse(tree1.GetAPDuRoot(),
                                   ref search_response,
                                   out records,
                                   true,
                                   out strError);
            if (nRet == -1)
                goto ERROR1;

            /*
            nRet = FitDebugInfo_PresentResponse(&tree1,
                                      strError);
            if (nRet == -1) {
                goto ERROR1;
            }

            DeleteFile("PresentResponse.txt"); 
            tree1.m_RootNode.DumpDebugInfoToFile("PresentResponse.txt");
            */


            if (search_response.m_diagRecords.Count != 0)
            {
                /*
                string strDiagText;
                string strAddInfo;

                nRet = GetDiagTextByNumber("bib1diag.txt",
                                m_search_response.m_nDiagCondition,
                                strDiagText,
                                strAddInfo,
                                strError);
                if (nRet == -1) {
                    if (this->m_bAllowMessageBox)
                        AfxMessageBox(strError);
                    return -1;
                }
                if (strDiagText.GetLength())
                    strError = strDiagText;
                else
                    strError.Format("diag condition[%d] diag set id[%s]",
                    m_search_response.m_nDiagCondition,
                    m_search_response.m_strDiagSetID);
                 * */
                strError = "error diagRecords:\r\n\r\n---\r\n" + search_response.m_diagRecords.GetMessage();
                return -1;
            }

            return 0;
        ERROR1:
            return -1;
        }
Exemple #39
0
        // 结果集追加到listview中
        // parameters:
        //      records 当前新获得一批记录。需要追加到connection的Records中
        int FillRecordsToBrowseView(
            Stop stop,
            ZConnection connection,
            RecordCollection records,
            out string strError)
        {

            Debug.Assert(connection == this.GetCurrentZConnection(), "不是当前connection,装入listview会破坏界面");

            strError = "";
            if (connection.Records == null)
                connection.Records = new RecordCollection();

            int nExistCount = connection.Records.Count;
            Debug.Assert(this.listView_browse.Items.Count == nExistCount, "");

            // 加入新的一批
            connection.Records.AddRange(records);

            int nRet = FillRecordsToBrowseView(
                stop,
                connection,
                connection.Records,
                nExistCount,
                records.Count,
                out strError);
            if (nRet == -1)
                return -1;

            return 0;
        }
Exemple #40
0
        /*
        void LinkRecordsToListView(RecordCollection records)
        {
            this.CurrentRecords = records;

            if (this.CurrentRecords != null)
                this.listView_browse.VirtualListSize = this.CurrentRecords.Count;
            else
                this.listView_browse.VirtualListSize = 0;

            // 迫使刷新
            this.listView_browse.Invalidate();
        }*/

#if NOOOOOOOOOOOOOOOOOOOOO
        // 把存储在records结构中的信息填入listview
        // parameters:
        int FillRecordsToBrowseView(
            Stop stop,
            ZConnection connection,
            RecordCollection records,
            int nStart,
            int nCount,
            out string strError)
        {
            strError = "";

            if (records == null)
                return 0;

            if (nStart + nCount > records.Count)
            {
                strError = "nStart["+nStart.ToString()+"]和nCount["+nCount.ToString()+"]参数之和超出records集合的尺寸["+records.Count.ToString()+"]";
                return -1;
            }

            for (int i = nStart; i < nStart + nCount; i++)
            {
                Application.DoEvents();	// 出让界面控制权

                if (stop != null)
                {
                    if (stop.State != 0)
                    {
                        strError = "用户中断";
                        return -1;
                        // TODO: 中断后怎么办?似最后一条记录不代表Records中的最后了
                    }
                }

                DigitalPlatform.Z3950.Record record = records[i];

                ListViewItem item = new ListViewItem(
                    (nStart + i + 1).ToString(),
                    record.m_nDiagCondition == 0 ? BROWSE_TYPE_NORMAL : BROWSE_TYPE_DIAG);

                string strBrowseText = "";

                int nRet = 0;
                string[] cols = null;

                if (record.m_nDiagCondition != 0)
                {
                    strBrowseText = "诊断记录 condition=" + record.m_nDiagCondition.ToString() + "; addinfo=\"" + record.m_strAddInfo + "\"; diagSetOID=" + record.m_strDiagSetID;
                    goto DOADD;
                }
                else
                {
                    byte[] baRecord = record.m_baRecord;    //Encoding.ASCII.GetBytes(record.m_strRecord);

                    string strMARC = "";
                    string strMarcSyntaxOID = "";

                    // 可能为XML格式
                    if (record.m_strMarcSyntaxOID == "1.2.840.10003.5.109.10")
                    {
                        // 看根节点的名字空间,如果符合MARCXML, 就先转换为USMARC,否则,就直接根据名字空间找样式表加以转换
                        string strContent = Encoding.UTF8.GetString(baRecord);

                        string strNameSpaceUri = "";
                        nRet = GetRootNamespace(strContent,
                            out strNameSpaceUri,
                            out strError);
                        if (nRet == -1)
                        {
                            strBrowseText = strError;
                            goto DOADD;
                        }

                        if (strNameSpaceUri == Ns.usmarcxml)
                        {
                            string strOutMarcSyntax = "";
                            // 将MARCXML格式的xml记录转换为marc机内格式字符串
                            // parameters:
                            //		bWarning	==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换
                            //		strMarcSyntax	指示marc语法,如果=="",则自动识别
                            //		strOutMarcSyntax	out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值
                            nRet = MarcUtil.Xml2Marc(strContent,
                                true,
                                "usmarc",
                                out strOutMarcSyntax,
                                out strMARC,
                                out strError);
                            if (nRet == -1)
                            {
                                strBrowseText = strError;
                                goto DOADD;
                            }

                            strMarcSyntaxOID = "1.2.840.10003.5.10";

                            nRet = GetBrowseText(
                                strMarcSyntaxOID,
                                strMARC,
                                out strBrowseText,
                                out strError);
                            if (nRet == -1)
                                strBrowseText = strError;

                            goto DOADD;

                        }

                        cols = new string[1];
                        cols[0] = strContent;
                        goto DOADDCOLS;
                    }

                    strMarcSyntaxOID = record.m_strMarcSyntaxOID;

                    // ISO2709转换为机内格式
                    nRet = Marc8Encoding.ConvertByteArrayToMarcRecord(
                        baRecord,
                        connection.GetRecordsEncoding(this.MainForm, strMarcSyntaxOID),  // Encoding.GetEncoding(936),
                        true,
                        out strMARC,
                        out strError);
                    if (nRet < 0)
                    {
                        strBrowseText = strError;
                        goto DOADD;
                    }


                    if (connection.TargetInfo.DetectMarcSyntax == true)
                    {
                        // 探测MARC记录从属的格式:
                        // return:
                        //		-1	无法探测
                        //		1	UNIMARC	规则:包含200字段
                        //		10	USMARC	规则:包含008字段(innopac的UNIMARC格式也有一个奇怪的008)
                        nRet = DetectMARCSyntax(strMARC);
                        if (nRet == 1)
                            strMarcSyntaxOID = "1.2.840.10003.5.1";
                        else if (nRet == 10)
                            strMarcSyntaxOID = "1.2.840.10003.5.10";

                        // 把自动识别的结果保存下来
                        record.AutoDetectedMarcSyntaxOID = strMarcSyntaxOID;
                    }


                    nRet = GetBrowseText(
                        strMarcSyntaxOID,
                        strMARC,
                        out strBrowseText,
                        out strError);
                    if (nRet == -1)
                        strBrowseText = strError;


                }

            DOADD:
                cols = strBrowseText.Split(new char[] { '\t' });
            DOADDCOLS:
                for (int j = 0; j < cols.Length; j++)
                {
                    item.SubItems.Add(cols[j]);
                }

                item.Tag = record;
                this.listView_browse.Items.Add(item);
            }
            return 0;
        }
Exemple #41
0
        public List<string> FindRecordWithFieldCreator()
        {
            var result = new List<string>();
            var searchExpression = new SearchExpression("FieldName(\"Creator\") <> \"\"");
            var recordCollection = new RecordCollection(application);
            recordCollection.Load(searchExpression);

            foreach (Record record in recordCollection)
            {
                result.Add(record.Id.ToString());
            }
            return result;
        }
Exemple #42
0
        public List<string> FindRecordWithFileSize(string size)
        {
            var result = new List<string>();
            var searchExpression = new SearchExpression("File.Version.Filesize > " + size);
            var recordCollection = new RecordCollection(application);
            recordCollection.Load(searchExpression);

            foreach (Record record in recordCollection)
            {
                result.Add(record.Id.ToString());
            }
            return result;
        }
Exemple #43
0
 public CGTStructure(string header, RecordCollection records)
 {
     this.header = header;
     this.records = records;
 }
Exemple #44
0
        public List<string> FindRecordFromClassifications(string classification)
        {
            var result = new List<string>();
            var searchExpression = new SearchExpression("Classification.NamePath ="+classification);
            var recordCollection = new RecordCollection(application);
            recordCollection.Load(searchExpression);

            foreach (Record record in recordCollection)
            {
                result.Add(record.Id.ToString());
            }
            return result;
        }
        private List<string> GetByte64Previews()
        {
            RecordCollection recordCollection = new RecordCollection((Application)Session["AdamApp"]);
            Adam.Core.Search.SearchExpression se = new Adam.Core.Search.SearchExpression("File.Version.Extension = jpg");

            recordCollection.Load(se);
            List<string> base64Previews = new List<string>();
            byte[] tempBytes;
            foreach (Record rec in recordCollection)
            {
                tempBytes = rec.Files.Master.GetPreview().GetBytes();
                base64Previews.Add(Convert.ToBase64String(tempBytes));
            }

            return base64Previews;
        }