Exemple #1
0
        public void send_to_builder()
        {
            string[] arr = new string[100];
            arr = rd1.Split('-');

            var date = DateTime.Now;
            table = tableClient.GetTableReference("builder");
            try
            {
                 if (table.CreateIfNotExists())
                 {
                        Console.Write("builder" + " Table ");
                        Console.WriteLine("Created ");
                 }
                 else
                 {
                        Console.WriteLine("builder" + " Table not created");
                 }
            }
            catch (StorageException s)
            {
                  Console.WriteLine("Refresh and retry " + s.ToString());
                  return;
            }

            BuilderEntity bd = new BuilderEntity(arr[2],arr[6]);
            bd.buildername = arr[1];
            bd.contactnumber = arr[5];
            bd.customername = arr[3];
            bd.location = arr[4];
            TableOperation insertOperation = TableOperation.Insert(bd);
            // Execute the insert operation.
            try
            {

                  table.Execute(insertOperation);

                  Console.WriteLine(arr[2]+" "+ arr[6] + "     Record Inserted");

            }
            catch (Exception e)
            {
                  Console.WriteLine(e.ToString());

            }
        }
Exemple #2
0
        public void retrive_from_builder_customer()
        {
            string[] arr = new string[100];
            arr = rd1.Split('-');

            string tableName = "builder";
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
            ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
            CloudTableClient tableClient1 = storageAccount.CreateCloudTableClient();
            CloudTable table1 = null;
            try
            {
                table1 = tableClient1.GetTableReference(tableName);
                TableQuery<BuilderEntity> Query = new TableQuery<BuilderEntity>().Where(
                TableQuery.CombineFilters(TableQuery.CombineFilters(
                TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, arr[3]),
                TableOperators.And,
                TableQuery.GenerateFilterCondition("buildername", QueryComparisons.Equal, arr[2])), TableOperators.And, TableQuery.GenerateFilterCondition("location", QueryComparisons.Equal, arr[4])));
                List<BuilderEntity> AddressList = new List<BuilderEntity>();
                BuilderEntity bd = new BuilderEntity();
                File.Delete("D:\\retrive.txt");
                using (StreamWriter writer =
                new StreamWriter("D:\\retrive.txt",true))
                {
                    foreach (BuilderEntity entity in table1.ExecuteQuery(Query))
                    {
                        bd.customername = entity.customername;
                        writer.Write(bd.customername);
                        writer.Write("-");
                    }
                    writer.Close();
                }

            }
               catch (Exception e)
            {
                Console.WriteLine("TABLE NAME= " + tableName + "  doesnot exist ");
                Console.WriteLine("Send again.............");
                processfun();

            }
            string data;
            System.IO.StreamReader file1 = new System.IO.StreamReader("D:\\retrive.txt");
            data = file1.ReadToEnd();
            Console.WriteLine(data);
            file1.Close();
            TcpClient newclient = new TcpClient();
            Console.WriteLine("Trying to connect........!");
            try
            {
                newclient.Connect(arr[1], 8902);

                Console.WriteLine("Connected to " + arr[1]);
                StreamWriter sw = new StreamWriter(newclient.GetStream());
                sw.WriteLine(data.ToString());
                sw.Flush();
                newclient.Close();
                Console.WriteLine("Successfully transfered.....!");
            }
            catch(Exception e)
            {
                Console.WriteLine(e);
                processfun();
            }
        }