Exemple #1
0
 private OrdersCollections GetOrders()
 {
     using (var stream = File.OpenRead(Constants.OderXmlSourcePath))
     {
         return(XmlStreamSerializer.Deserialize <OrdersCollections>(stream));
     }
 }
Exemple #2
0
        public async Task ImportFromXml(Stream stream)
        {
            var deserializeData = XmlStreamSerializer.Deserialize <OrdersCollections>(stream);
            var dalOrders       = _mapper.Map <Orders[]>(deserializeData.Items);
            await _dbContext.Orders.AddRangeAsync(dalOrders);

            await _dbContext.SaveChangesAsync();
        }
        public static TXmlType RunGetXmlType <TXmlType>(FilePath svnExecutableFilePath, IArgumentsBuilder argumentsBuilder, bool throwIfAnyError = true)
        {
            var xmlText = SvnCommandServicesProvider.RunGetXmlText(svnExecutableFilePath, argumentsBuilder, throwIfAnyError);

            using (var stream = StreamHelper.FromString(xmlText))
            {
                var xmlType = XmlStreamSerializer.Deserialize <TXmlType>(stream, SvnXml.DefaultNamespace);
                return(xmlType);
            }
        }
        public static StatusType GetStatusXmlType(FilePath svnExecutableFilePath, AbsolutePath path, ILogger logger)
        {
            //var statusXmlText = SvnCommandServicesProvider.GetStatusXmlText(svnExecutableFilePath, path, logger);
            var statusXmlText = SvnCommandServicesProvider.GetStatusXmlText2(svnExecutableFilePath, path, logger);

            using (var stream = StreamHelper.FromString(statusXmlText))
            {
                var statusXmlType = XmlStreamSerializer.Deserialize <StatusType>(stream, SvnXml.DefaultNamespace);
                return(statusXmlType);
            }
        }
Exemple #5
0
        public void DeserializationTest()
        {
            OrdersCollections orders;

            using (var stream = File.OpenRead(Constants.OderXmlSourcePath))
            {
                orders = XmlStreamSerializer.Deserialize <OrdersCollections>(stream);
            }
            Assert.NotEmpty(orders.Items);
            Assert.NotEmpty(orders.Items.First().Articles);
            Assert.NotEmpty(orders.Items.First().Payments);
        }
        private static SvnStringPathStatus StatusRobust_Internal(this SvnCommand svnCommand, AbsolutePath absolutePath)
        {
            var arguments = SvnCommandServicesProvider.GetStatusVerboseForInstanceOnly(absolutePath)
                            .AddXml(); // Get XML.

            var outputCollector = SvnCommandServicesProvider.Run(svnCommand.SvnExecutableFilePath, arguments, false);

            if (outputCollector.AnyError)
            {
                var errorText = outputCollector.GetErrorText().Trim();

                var notWorkingCopyText = $"svn: warning: W155007: '{absolutePath}' is not a working copy";
                if (errorText == notWorkingCopyText)
                {
                    var output = new SvnStringPathStatus {
                        Path = absolutePath.Value, ItemStatus = ItemStatus.NotWorkingCopy
                    };
                    return(output);
                }

                var notFoundText = $"svn: warning: W155010: The node '{absolutePath}' was not found.";
                if (errorText == notFoundText)
                {
                    var output = new SvnStringPathStatus {
                        Path = absolutePath.Value, ItemStatus = ItemStatus.NotFound
                    };
                    return(output);
                }

                throw new Exception($"Unknown SVN error:\n{errorText}");
            }

            var xmlText = outputCollector.GetOutputText();

            using (var stream = StreamHelper.FromString(xmlText))
            {
                var xmlStatusType = XmlStreamSerializer.Deserialize <StatusType>(stream, SvnXml.DefaultNamespace);

                var statuses = SvnCommandServicesProvider.GetStatuses(xmlStatusType);

                var status = statuses.Count() < 1
                    ? new SvnStringPathStatus {
                    Path = absolutePath.Value, ItemStatus = ItemStatus.None
                }
                    : statuses.Single() // Should be only 1.
                ;

                return(status);
            }
        }
Exemple #7
0
        public async Task<CompleteMultipartUploadResult> CompleteMultipartUpload(CompleteMultipartUploadModel completeMultipartUploadModel)
        {
            CompleteMultipartUploadResult result = null;
            OssHttpRequestMessage httpRequestMessage = null;
            HttpResponseMessage response = null;
            try
            {

               
                Dictionary<string, string> parameters = new Dictionary<string, string>();
                parameters.Add("uploadId", completeMultipartUploadModel.UploadId);


                httpRequestMessage = new OssHttpRequestMessage(completeMultipartUploadModel.Bucket, completeMultipartUploadModel.Key, parameters);

                httpRequestMessage.Method = HttpMethod.Post;
                httpRequestMessage.Headers.Date = DateTime.UtcNow;

                XmlStreamSerializer<CompleteMultipartUploadModel> serializer = new XmlStreamSerializer<CompleteMultipartUploadModel>();
              //  FileStream fileStream = new FileStream("1.xml", FileMode.Open);

                //httpRequestMessage.Content = new StreamContent(fileStream);
                httpRequestMessage.Content = new StreamContent(serializer.Serialize(completeMultipartUploadModel));

                OssRequestSigner.Sign(httpRequestMessage, networkCredential);
                response = await httpClient.SendAsync(httpRequestMessage);

                if (response.IsSuccessStatusCode == false)
                {
                    await ErrorResponseHandler.Handle(response);
                }
                var temp = DeserializerFactory.GetFactory().CreateCompMultiUploadDeserializer();
                result = await temp.Deserialize(response);

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (httpRequestMessage != null)
                    httpRequestMessage.Dispose();

                if (response != null)
                    response.Dispose();
            }
            return result;

        }