예제 #1
0
 static void Main(string[] args)
 {
       Console.Write("\n This is MetadataHandler!! ");
       MetadataHandler obj=new MetadataHandler();
       List<string[]> list=new List<string[]>();
       string[] dummy1={"k1",k2"};
        string[] dummy2={"sjnsjndfjv"};
       string[] dummy3={"diary.txt"};
       list.Add(dummy1);
       list.Add(dummy2);
       list.Add(dummy3);                            
       obj.createMetadata(list)
       
 }
예제 #2
0
            //initiates the FileHandler o create a new for the uploaded file and create corresponding metadata file
            protected override void ProcessMessages()
            {
                while (true)
                {
                    ServiceMessage msg       = bq.deQ();
                    var            appDomain = AppDomain.CurrentDomain;
                    string         temp1     = appDomain.BaseDirectory;
                    Directory.SetCurrentDirectory(temp1);
                    Directory.SetCurrentDirectory(@"..\\Testfiles\\textfiles");
                    if (msg.ResourceName != "metadata")
                    {
                        string     fileName = msg.ResourceName.Remove(msg.ResourceName.IndexOf(","));
                        FileStream fs       = null;

                        if (File.Exists(fileName))
                        {
                            byte[] block_data = Encoding.UTF8.GetBytes(msg.Contents);
                            fs = File.Open(fileName, FileMode.Append, FileAccess.Write);
                            fs.Write(block_data, 0, block_data.Length);
                        }
                        else
                        {
                            byte[] block_data = Encoding.UTF8.GetBytes(msg.Contents);
                            fs = File.Open(fileName, FileMode.Create, FileAccess.Write);
                            fs.Write(block_data, 0, block_data.Length);
                        }

                        fs.Close();
                    }

                    else
                    {
                        MetadataHandler mdhandler = new MetadataHandler();
                        mdhandler.createMetadata(msg.list);
                    }
                }
            }