Example #1
0
        static void ExecuteSoap()
        {
            var client = new SoapServiceClient("NeliburSoapService");

            var createRequest = new CreateClientRequest
            {
                Email = "*****@*****.**"
            };
            ClientResponse response = client.Post <ClientResponse>(createRequest);

            var updateRequest = new UpdateClientRequest
            {
                Email = "*****@*****.**",
                Id    = response.Id
            };

            response = client.Put <ClientResponse>(updateRequest);

            var getClientRequest = new GetClientRequest
            {
                Id = response.Id
            };

            response = client.Get <ClientResponse>(getClientRequest);

            var deleteRequest = new DeleteClientRequest
            {
                Id = response.Id
            };

            client.Delete(deleteRequest);
        }
Example #2
0
        public void WhenISendDataThruPostAction(Table table)
        {
            Order             order  = table.CreateSet <Order>().Single();
            SoapServiceClient client = GetClient();

            client.Post(order);
        }
Example #3
0
        public void WhenIUpdateDataThruPutAsyncAction(Table table)
        {
            UpdateOrder       request = table.CreateSet <UpdateOrder>().Single();
            SoapServiceClient client  = GetClient();

            client.PutAsync(request).Wait();
        }
        public void GetImagePropertyThumbnail()
        {
            SoapServiceClient service           = new SoapServiceClient();
            String            imagePropertyGuid = GetNextImagePropertyGuid();

            service.GetImagePropertyThumbnailSoap(imagePropertyGuid, "true");
        }
        public void GetResizedImageTest()
        {
            SoapServiceClient service = new SoapServiceClient();

            System.IO.Stream stream = service.GetResizedImageSoap("640", "480", GetNextImageGuid());
            stream.Close();
        }
Example #6
0
 public ContactsVM()
 {
     _DB = new ContactsContext();
     soapClient = new SoapService.SoapServiceClient();
     Contacts = new ObservableCollection<Contact>();
     Addresses = new ObservableCollection<Address>();
     Companies = new ObservableCollection<Company>();
     AddressIDs = new ObservableCollection<int>();
     /* Old save command
     SaveCommand = new DelegateCommand(() => {
         _DB.SaveChanges();
     });
      */
     SaveCommand = new DelegateCommand(() => {
         foreach (var x in Contacts) {
             soapClient.AddContact(x);
         }
         soapClient.Save();
     });
     /*old Add Contact
     AddContactCommand = new DelegateCommand(() => {
         ViewingContact = new Contact();
         Contacts.Add(ViewingContact);
         _DB.Contacts.Add(VewingContact);
     });
      */
     AddContactCommand = new DelegateCommand(() => {
         ViewingContact = new Contact();
         Contacts.Add(ViewingContact);
         //soapClient.AddContactAsync(ViewingContact);
     });
     AddCompanyCommand = new DelegateCommand(() => {
         ViewingCompany = new Company();
         Companies.Add(ViewingCompany);
         _DB.Companies.Add(ViewingCompany);
     });
     AddAddressCommand = new DelegateCommand(() => {
         ViewingAddress = new Address();
         Addresses.Add(ViewingAddress);
         _DB.Addresses.Add(ViewingAddress);
     });
     DeleteContactCommand = new DelegateCommand(() => {
         _DB.Contacts.Remove(ViewingContact);
         Contacts.Remove(ViewingContact);
     });
     DeleteCompanyCommand = new DelegateCommand(() => {
         _DB.Contacts.Remove(ViewingContact);
         Contacts.Remove(ViewingContact);
     });
     DeleteAddressCommand = new DelegateCommand(() => {
         _DB.Contacts.Remove(ViewingContact);
         Contacts.Remove(ViewingContact);
     });
     AddContactMethodCommand = new DelegateCommand(() => {
         var cm = new ContactMethod();
         ViewingContact.ContactMethods.Add(cm);
     });
     init();
 }
Example #7
0
        public void WhenIUpdateDataThruPutAsyncActionWithResponse(Table table)
        {
            UpdateOrder       request = table.CreateSet <UpdateOrder>().Single();
            SoapServiceClient client  = GetClient();
            bool response             = client.PutAsync <bool>(request).Result;

            ScenarioContext.Current[ResopnseKey] = response;
        }
Example #8
0
        public void WhenISendDataThruPostWithResponseAction(Table table)
        {
            Order             order  = table.CreateSet <Order>().Single();
            SoapServiceClient client = GetClient();
            bool response            = client.Post <bool>(order);

            ScenarioContext.Current[ResopnseKey] = response;
        }
        public void GetImageThumbnailTest()
        {
            SoapServiceClient service = new SoapServiceClient();

            System.IO.Stream stream = service.GetImageThumbnailSoap("T", GetNextImageGuid());
            stream.Close();
            stream = service.GetImageThumbnailSoap("M", GetNextImageGuid());
            stream.Close();
        }
        public async Task RestTest()
        {
            SoapServiceClient service = new SoapServiceClient();
            Uri           uri         = new Uri(service.Endpoint.Address.Uri, "GetImageProperties");
            Task <string> test        = GetAsync(uri.ToString());
            string        result      = await test;

            Microsoft.VisualStudio.TestTools.UnitTesting.StringAssert.Contains(result, "<ArrayOfImageProperty");
        }
        /// <summary>Hit when the user user clicks the Connect button.</summary>
        /// <param name="sender">btnConnect</param>
        /// <param name="e">RoutedEventArgs</param>
        private void btnConnect_Click(object sender, RoutedEventArgs e)
        {
            if (e != null)
            {
                e.Handled = true;
            }

            try
            {
                bool tag = (bool)this.btnConnect.Tag;
                if (tag)
                {
                    this._client = null;

                    //Set form.
                    this.grdEntry.IsEnabled      = true;
                    this.barProg.IsIndeterminate = false;
                    this.barProg.Value           = 0;
                    this.btnConnect.Content      = "_Get Projects";
                    this.btnConnect.Tag          = false;
                    this.txtStatus.Text          = "";
                    this.txtStatus.ToolTip       = null;
                }
                else
                {
                    if (this.txbServer.Text.ToLowerInvariant().EndsWith(".asmx") || this.txbServer.Text.ToLowerInvariant().EndsWith(".aspx") || this.txbServer.Text.ToLowerInvariant().EndsWith(".svc"))
                    {
                        MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_NewProject_URLErrorMessage"), StaticFuncs.getCultureResource.GetString("app_NewProject_URLError"), MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    }
                    else
                    {
                        //Start the connections.
                        this.barProg.IsIndeterminate = true;
                        this.barProg.Foreground      = (Brush) new System.Windows.Media.BrushConverter().ConvertFrom(StaticFuncs.getCultureResource.GetString("app_Colors_StyledBarColor"));
                        this.grdEntry.IsEnabled      = false;
                        this.btnConnect.Content      = "_Cancel";
                        this.btnConnect.Tag          = true;
                        this.txtStatus.Text          = "Connecting to server...";
                        this.cmbProjectList.Items.Clear();
                        this.grdAvailProjs.IsEnabled = false;

                        //Create new client.
                        this._client = StaticFuncs.CreateClient(this.txbServer.Text.Trim());
                        this._client.Connection_Authenticate2Completed += new EventHandler <Connection_Authenticate2CompletedEventArgs>(_client_CommunicationFinished);
                        this._client.User_RetrieveByUserNameCompleted  += new EventHandler <User_RetrieveByUserNameCompletedEventArgs>(_client_CommunicationFinished);
                        this._client.Project_RetrieveCompleted         += new EventHandler <Project_RetrieveCompletedEventArgs>(_client_CommunicationFinished);

                        this._client.Connection_Authenticate2Async(this.txbUserID.Text, this.txbUserPass.Password, StaticFuncs.getCultureResource.GetString("app_ReportName"));
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, "btnConnect_Click()");
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public async Task SearchImagePropertiesTest()
        {
            SoapServiceClient service = new SoapServiceClient();
            List <IDBrowserServiceCode.ImagePropertyRecursive> result = service.SearchImagePropertiesSoap("David Masshardt");

            if (result.Count == 0)
            {
                throw new Exception("No items found with SearchImagePropertiesSoap");
            }
        }
        public async Task GetFilePathsTest()
        {
            SoapServiceClient service = new SoapServiceClient();
            List <IDBrowserServiceCode.FilePath> result = service.GetFilePathsSoap();

            if (result.Count == 0)
            {
                throw new Exception("No file paths found with GetFilePathsSoap");
            }
        }
Example #14
0
        public void WhenISendDeleteRequestByIdThruDeleteAsyncAction(int id)
        {
            var request = new DeleteOrderById
            {
                Id = id
            };
            SoapServiceClient client = GetClient();

            client.DeleteAsync(request).Wait();
        }
        public async Task GetCatalogItemImagePropertiesTest()
        {
            SoapServiceClient service = new SoapServiceClient();
            List <IDBrowserServiceCode.ImagePropertyRecursive> result = service.GetCatalogItemImagePropertiesSoap(GetNextImageGuid());

            if (result.Count == 0)
            {
                throw new Exception("No image properties found with GetCatalogItemImagePropertiesSoap");
            }
        }
Example #16
0
        private async Task <string> AppelerServiceSOAPCSharp(string nom)
        {
            string            message = "";
            SoapServiceClient client  = new SoapServiceClient();

            message = await client.HelloWorldAsync(nom);

            await client.CloseAsync();

            return(message);
        }
Example #17
0
        public void WhenIRequestDataByThruIdGetAction(int id)
        {
            var request = new GetOrderById
            {
                Id = id
            };
            SoapServiceClient client   = GetClient();
            List <Order>      response = client.Get <List <Order> >(request);

            ScenarioContext.Current[ResopnseKey] = response;
        }
Example #18
0
        public void WhenISendDeleteRequestByIdThruDeleteWithResponseAction(int id)
        {
            var request = new DeleteOrderById
            {
                Id = id
            };
            SoapServiceClient client = GetClient();
            bool response            = client.Delete <bool>(request);

            ScenarioContext.Current[ResopnseKey] = response;
        }
Example #19
0
        public void WhenISendDeleteRequestByIdThruDeleteAction(int id)
        {
            var request = new DeleteOrderById
            {
                Id = id
            };

            using (SoapServiceClient client = GetClient())
            {
                client.Delete(request);
            }
        }
        /// <summary>Creates a web client for use.</summary>
        /// <param name="serverAddress">The base address of the server.</param>
        /// <returns>ImportExportClient</returns>
        public static SoapServiceClient CreateClient(string serverAddress)
        {
            SoapServiceClient retClient = null;

            try
            {
                //The endpoint address.
                EndpointAddress EndPtAddr = new EndpointAddress(new Uri(serverAddress + Settings.Default.app_ServiceURI));
                //Create the soap client.
                BasicHttpBinding wsDualHttp = new BasicHttpBinding();
                wsDualHttp.CloseTimeout           = TimeSpan.FromMinutes(1);
                wsDualHttp.OpenTimeout            = TimeSpan.FromMinutes(1);
                wsDualHttp.ReceiveTimeout         = TimeSpan.FromMinutes(1);
                wsDualHttp.SendTimeout            = TimeSpan.FromMinutes(1);
                wsDualHttp.BypassProxyOnLocal     = false;
                wsDualHttp.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
                wsDualHttp.MaxBufferPoolSize      = Int32.MaxValue;
                wsDualHttp.MaxReceivedMessageSize = Int32.MaxValue;
                wsDualHttp.MessageEncoding        = WSMessageEncoding.Text;
                wsDualHttp.TextEncoding           = Encoding.UTF8;
                wsDualHttp.UseDefaultWebProxy     = true;
                wsDualHttp.ReaderQuotas.MaxDepth  = Int32.MaxValue;
                wsDualHttp.ReaderQuotas.MaxStringContentLength   = Int32.MaxValue;
                wsDualHttp.ReaderQuotas.MaxArrayLength           = Int32.MaxValue;
                wsDualHttp.ReaderQuotas.MaxBytesPerRead          = Int32.MaxValue;
                wsDualHttp.ReaderQuotas.MaxNameTableCharCount    = Int32.MaxValue;
                wsDualHttp.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.Certificate;
                wsDualHttp.Security.Message.AlgorithmSuite       = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
                wsDualHttp.Security.Mode = BasicHttpSecurityMode.None;
                wsDualHttp.AllowCookies  = true;
                wsDualHttp.TransferMode  = TransferMode.Streamed;
                //Configure for alternative connection types.
                if (EndPtAddr.Uri.Scheme == "https")
                {
                    wsDualHttp.Security.Mode = BasicHttpSecurityMode.Transport;
                    wsDualHttp.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;

                    //Allow self-signed certificates
                    Inflectra.SpiraTest.IDEIntegration.VisualStudio2012.Business.Spira_ImportExport.PermissiveCertificatePolicy.Enact("");
                }

                retClient = new SpiraTeam_Client.SoapServiceClient(wsDualHttp, EndPtAddr);
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex);
                retClient = null;
            }

            return(retClient);
        }
        private void InitNullEvents()
        {
            OnAfterOpenSolution += () => {
                address  = SpiraContext.BaseUri.ToString();
                id       = SpiraContext.Login;
                password = SpiraContext.Password;

                //Create new client.
                this._client = StaticFuncs.CreateClient(address.Trim());
                this._client.Connection_Authenticate2Completed += new EventHandler <Connection_Authenticate2CompletedEventArgs>(_client_CommunicationFinished);
                this._client.User_RetrieveByUserNameCompleted  += new EventHandler <User_RetrieveByUserNameCompletedEventArgs>(_client_CommunicationFinished);
                this._client.Project_RetrieveCompleted         += new EventHandler <Project_RetrieveCompletedEventArgs>(_client_CommunicationFinished);

                this._client.Connection_Authenticate2Async(id, password, StaticFuncs.getCultureResource.GetString("app_ReportName"));
            };
        }
        public static void Initilization(TestContext context)
        {
            ImagePropertyGuids = new List <String>();

            System.Net.ServicePointManager.ServerCertificateValidationCallback =
                ((sender, certificate, chain, sslPolicyErrors) => true);

            SoapServiceClient service = new SoapServiceClient();

            ImageGuids = service.GetRandomImageGuidsSoap();

            List <IDBrowserServiceCode.ImageProperty> ImageProperties = service.GetImagePropertiesSoap(null);

            foreach (IDBrowserServiceCode.ImageProperty imageProperty in ImageProperties)
            {
                ImagePropertyGuids.Add(imageProperty.GUID);
            }
        }
Example #23
0
        private static void Main()
        {
            var client = new SoapServiceClient("NeliburSoapService");

            var createRequest = new CreateClientRequest
            {
                Email = "*****@*****.**"
            };

            Console.WriteLine("POST Request: {0}", createRequest);
            var response = client.Post <ClientResponse>(createRequest);

            Console.WriteLine("POST Response: {0}\n", response);

            var updateRequest = new UpdateClientRequest
            {
                Email = "*****@*****.**",
                Id    = response.Id
            };

            Console.WriteLine("PUT Request: {0}", updateRequest);
            response = client.Put <ClientResponse>(updateRequest);
            Console.WriteLine("PUT Response: {0}\n", response);

            var getClientRequest = new GetClientRequest
            {
                Id = response.Id
            };

            Console.WriteLine("GET Request: {0}", getClientRequest);
            response = client.Get <ClientResponse>(getClientRequest);
            Console.WriteLine("GET Response: {0}\n", response);

            var deleteRequest = new DeleteClientRequest
            {
                Id = response.Id
            };

            Console.WriteLine("DELETE Request: {0}", deleteRequest);
            client.Delete(deleteRequest);

            Console.ReadKey();
        }
        /// <summary>Refreshes project name if necessary.</summary>
        private void refreshProject()
        {
            //Only run if it's not set.
            if ((this.ProjectName == "Project" || string.IsNullOrEmpty(this.ProjectName)) || this.UserID == -1)
            {
                try
                {
                    SoapServiceClient client = StaticFuncs.CreateClient(this.ServerURL.ToString());

                    //Connect and get the project information.
                    if (client.Connection_Authenticate2(this.UserName, this.UserPass, StaticFuncs.getCultureResource.GetString("app_ReportName")))
                    {
                        //Connected, get project and user information.
                        this.ProjectName = client.Project_RetrieveById(this.ProjectId).Name;
                        this.UserID      = client.User_RetrieveByUserName(this.UserName, false).UserId.Value;
                    }
                }
                catch
                { }
            }
        }
Example #25
0
        private static void Main()
        {
            var client = new SoapServiceClient("NeliburSoapService");

            var createRequest = new CreateClientRequest
            {
                Email = "*****@*****.**"
            };
            Console.WriteLine("POST Request: {0}", createRequest);
            var response = client.Post<ClientResponse>(createRequest);
            Console.WriteLine("POST Response: {0}\n", response);

            var updateRequest = new UpdateClientRequest
            {
                Email = "*****@*****.**",
                Id = response.Id
            };

            Console.WriteLine("PUT Request: {0}", updateRequest);
            response = client.Put<ClientResponse>(updateRequest);
            Console.WriteLine("PUT Response: {0}\n", response);

            var getClientRequest = new GetClientRequest
            {
                Id = response.Id
            };
            Console.WriteLine("GET Request: {0}", getClientRequest);
            response = client.Get<ClientResponse>(getClientRequest);
            Console.WriteLine("GET Response: {0}\n", response);

            var deleteRequest = new DeleteClientRequest
            {
                Id = response.Id
            };
            Console.WriteLine("DELETE Request: {0}", deleteRequest);
            client.Delete(deleteRequest);

            Console.ReadKey();
        }
        /// <summary>Tests the importer's password.</summary>
        /// <param name="sender">Button</param>
        /// <param name="e">RoutedEventArgs</param>
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            //Hide the controls..
            this.divTesting.Cursor     = Cursors.Wait;
            this.divTesting.Visibility = System.Windows.Visibility.Visible;
            this.txtTesting.Text       = "Testing.";
            this.txtTesting.Foreground = Brushes.Black;
            this.spnSpinner.Visibility = System.Windows.Visibility.Visible;
            this.divTesting.MouseDown -= divTesting_MouseDown;



            SoapServiceClient client = SpiraClientFactory.CreateClient_Spira5(this.serverUrl);

            client.Connection_Authenticate2Completed    += client_Connection_Authenticate2Completed;
            client.Project_RetrieveCompleted            += client_Project_RetrieveCompleted;
            client.Connection_ConnectToProjectCompleted += client_Connection_ConnectToProjectCompleted;
            client.User_CreateCompleted += client_User_CreateCompleted;
            client.User_DeleteCompleted += client_User_DeleteCompleted;

            //Now connect..
            client.Connection_Authenticate2Async(this.serverUser, this.serverPass, Common.APP_NAME, client);
        }
Example #27
0
        protected SoapServiceClient GetClient()
        {
            var client = new SoapServiceClient(EndpointConfigurationName);

            return(client);
        }
        static void Main(string[] args)
        {
            #region //SENDING SMS VIA REST HTTP GET
            var requestUri = string.Format(
                "https://www.etracker.cc/bulksms/send?user={0}&pass={1}&type={2}&to={3}&from={4}&text={5}&servid={6}",
                "username",
                "password",
                "0",
                "60123456789",
                "from",
                "test",
                "serviceid");

            using (var httpClient = new HttpClient())
            {
                using (var response = httpClient.GetAsync(requestUri).Result)
                {
                    // by calling .Content a synchronous call will be performed
                    using (var responseContent = response.Content)
                    {
                        // by calling .Result the result will be read synchronously
                        var GEThttpContent = responseContent.ReadAsStringAsync().Result;
                    }

                    var GEThttpStatusCode        = response.StatusCode;
                    var GEThttpStatusDescription = response.ReasonPhrase;
                }
            }
            #endregion

            #region//SENDING SMS VIA REST HTTP POST
            //Serialize the object into JSON string
            string parameter = JsonConvert.SerializeObject(new
            {
                user   = "******",
                pass   = "******",
                type   = "0",
                to     = "60123456789",
                from   = "from",
                text   = "test",
                servid = "serviceid"
            });

            using (var httpClient = new HttpClient())
            {
                //Store the JSON string as the content to be sent to the web API.
                //Specify the HTTP Content-Type header as application/json
                //Specify application/xml if the content is in XML format
                var content = new StringContent(parameter);
                content.Headers.ContentType.MediaType = "application/json";

                //Assign the value of the Accept ("application/xml" or "application/json header
                //for an HTTP request in order to get the response in the desired format.
                httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue
                                                                ("application/json"));

                using (var response = httpClient.PostAsync("https://www.etracker.cc/bulksms/send", content).Result)
                {
                    // by calling .Content a synchronous call will be performed
                    using (var responseContent = response.Content)
                    {
                        // by calling .Result the result will be read synchronously
                        var POSThttpContent = responseContent.ReadAsStringAsync().Result;
                    }

                    var POSThttpStatusCode        = response.StatusCode;
                    var POSThttpStatusDescription = response.ReasonPhrase;
                }
            }
            #endregion

            #region//SENDING SMS VIA SOAP WEB SERVICE
            using (var proxy = new SoapServiceClient())
            {
                var soapParam = new SoapParam
                {
                    Username    = "******",
                    Password    = "******",
                    MessageType = "0",
                    Msisdn      = "60123456789",
                    From        = "from",
                    Text        = "test",
                    ServiceID   = "serviceid"
                };
                proxy.Send(soapParam);
            }
            #endregion

            #region//SENDING EMAIL VIA HTTP POST
            List <Recipient> sendList = new List <Recipient>();
            sendList.Add(new Recipient {
                Name = "Recipient", Email = "*****@*****.**"
            });

            string emailParameter = JsonConvert.SerializeObject(new
            {
                to     = sendList,
                sender = new Sender {
                    Name = "Sender", Email = "*****@*****.**"
                },
                htmlContent = "Email Test Content",
                subject     = "Email Test Subject",
                replyTo     = new Sender {
                    Name = "ReplyTo", Email = "*****@*****.**"
                },
                username  = "******",
                password  = "******",
                serviceId = "serviceID",
                IsHashed  = false
            });

            using (var httpClient = new HttpClient())
            {
                //Store the JSON string as the content to be sent to the web API.
                //Specify the HTTP Content-Type header as application/json
                //Specify application/xml if the content is in XML format
                var emailContent = new StringContent(emailParameter);
                emailContent.Headers.ContentType.MediaType = "application/json";

                //Assign the value of the Accept ("application/xml" or "application/json header
                //for an HTTP request in order to get the response in the desired format.
                httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue
                                                                ("application/json"));

                using (var response = httpClient.PostAsync("https://www.etracker.cc/BulkEmail/Send", emailContent).Result)
                {
                    // by calling .Content a synchronous call will be performed
                    using (var responseContent = response.Content)
                    {
                        // by calling .Result the result will be read synchronously
                        var POSThttpContent = responseContent.ReadAsStringAsync().Result;
                    }

                    var POSThttpStatusCode        = response.StatusCode;
                    var POSThttpStatusDescription = response.ReasonPhrase;
                }
            }
            #endregion

            #region//SENDING MMS VIA HTTP POST
            //Assign values to variables
            string user         = "******";
            string password     = "******";
            string serviceid    = "serviceid";
            string subject      = "MMS Title";
            string text         = "MMS Text Message";
            string recipients   = JsonConvert.SerializeObject(new string[] { "60103456789", "60123456789" });
            string iscontenturi = "1";
            string MMSContent   = null;

            if (iscontenturi == "0")
            {
                //The below bytes value is only an example. Replace it if your content is in bytes.
                MMSContent = JsonConvert.SerializeObject(new byte[] { 0x01, 0x9A, 0x3D, 0x23, 0xAB, 0x5A });
            }
            else if (iscontenturi == "1")
            {
                MMSContent = JsonConvert.SerializeObject(@"http://res.cloudinary.com/demo/image/upload/v1525209117/folder1/folder2/sample.jpg");
            }

            //"0" represents file type jpg. [0 = jpg], [1 = jpeg], [2 = png], [3 = bmp], [4 = gif], [11 = mp3], [12 = mid], [13 = midi], [14 = wav], [15 = amr], [21 = mp4], [22 = 3gp]
            string multimediafiletype = "0";

            //Multipart Form Data. Each MultipartFormDataContentshould have the string name as specified.
            MultipartFormDataContent mContent = new MultipartFormDataContent();
            mContent.Add(new StringContent(user), "user");
            mContent.Add(new StringContent(password), "password");
            mContent.Add(new StringContent(serviceid), "serviceid");
            mContent.Add(new StringContent(subject), "subject");
            mContent.Add(new StringContent(text), "text");
            mContent.Add(new StringContent(recipients), "recipients");
            mContent.Add(new StringContent(iscontenturi), "iscontenturi");
            mContent.Add(new StringContent(MMSContent), "content");
            mContent.Add(new StringContent(multimediafiletype), "multimediafiletype");

            string             url       = "http://mms.etracker.cc/MMSWebAPI/api/BulkMMS/";
            string             requestID = DateTime.Now.ToString("yyyyMMddhhmmssfff");
            HttpRequestMessage req       = new HttpRequestMessage(HttpMethod.Post, $"{url}{requestID}");
            req.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("multipart/form-data"));
            req.Content = mContent;

            HttpClient httpClientMMS = new HttpClient();

            using (var response = httpClientMMS.SendAsync(req).Result)
            {
                var statusCode = response.StatusCode;
                var message    = response.ReasonPhrase;
            }
            #endregion
        }
        public void GetCatalogItemsTest()
        {
            SoapServiceClient service = new SoapServiceClient();

            service.GetCatalogItemsSoap("true", GetNextImagePropertyGuid());
        }
        public void GetImagePropertiesTest()
        {
            SoapServiceClient service = new SoapServiceClient();

            service.GetImagePropertiesSoap(null);
        }
Example #31
0
        static void Main(string[] args)
        {
            _options = new Settings();
            if (Parser.Default.ParseArguments(args, _options))
            {
                //Make sure that the Spira string is a URL.
                Uri    serverUrl   = null;
                string servicePath = _options.SpiraServer +
                                     ((_options.SpiraServer.EndsWith("/") ? "" : "/")) +
                                     "Services/v5_0/SoapService.svc";
                if (!Uri.TryCreate(servicePath, UriKind.Absolute, out serverUrl))
                {
                    //Throw error: URL given not a URL.
                    return;
                }

                //See if we have a mappings file specified, if so, make sure it exists
                List <ArtifactMapping> artifactMappings = null;
                string customPropertyField = null;
                if (!String.IsNullOrWhiteSpace(_options.SpiraMappingsFile))
                {
                    if (!File.Exists(_options.SpiraMappingsFile))
                    {
                        //Throw error: Bad path.
                        ConsoleLog(LogLevelEnum.Normal, "Cannot access the mapping file, please check the location and try again!");
                        Environment.Exit(-1);
                    }
                    artifactMappings = new List <ArtifactMapping>();

                    //Read in the lines, the first column should contain:
                    //Filename,ArtifactTypeId,Custom_03
                    //where the number in the third column is the name of the custom property that the IDs will be using
                    using (StreamReader streamReader = File.OpenText(_options.SpiraMappingsFile))
                    {
                        string   firstLine = streamReader.ReadLine();
                        string[] headings  = firstLine.Split(',');

                        //See if we have a match on the custom property number
                        if (headings.Length > 2 && !String.IsNullOrWhiteSpace(headings[2]))
                        {
                            customPropertyField = headings[2].Trim();

                            //Now read in the rows of mappings
                            while (!streamReader.EndOfStream)
                            {
                                string          mappingLine     = streamReader.ReadLine();
                                ArtifactMapping artifactMapping = new ArtifactMapping();
                                string[]        components      = mappingLine.Split(',');
                                artifactMapping.Filename       = components[0];
                                artifactMapping.ArtifactTypeId = Int32.Parse(components[1]);
                                artifactMapping.ExternalKey    = components[2];
                                artifactMappings.Add(artifactMapping);
                            }
                            streamReader.Close();
                        }
                    }
                }

                //Make sure the path given is a real path..
                try
                {
                    Directory.GetCreationTime(_options.ImportPath);
                }
                catch
                {
                    //Throw error: Bad path.
                    ConsoleLog(LogLevelEnum.Normal, "Cannot access the import path, please check the location and try again!");
                    Environment.Exit(-1);
                }

                //Tell user we're operating.
                ConsoleLog(LogLevelEnum.Normal, "Importing files in " + _options.ImportPath);

                //Now run through connecting procedures.
                ConsoleLog(LogLevelEnum.Verbose, "Connecting to Spira server...");
                SoapServiceClient client = CreateClient_Spira5(serverUrl);
                client.Open();

                if (client.Connection_Authenticate2(_options.SpiraLogin, _options.SpiraPass, "DocumentImporter"))
                {
                    ConsoleLog(LogLevelEnum.Verbose, "Selecting Spira project...");
                    var           Projects = client.Project_Retrieve();
                    RemoteProject proj     = Projects.FirstOrDefault(p => p.ProjectId == _options.SpiraProject);

                    if (proj != null)
                    {
                        //Connect to the project.
                        if (client.Connection_ConnectToProject((int)_options.SpiraProject))
                        {
                            ConsoleLog(LogLevelEnum.Normal, "Uploading files...");

                            //Now let's get a list of all the files..
                            SearchOption  opt   = ((_options.PathRecursive) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
                            List <string> files = Directory.EnumerateFiles(_options.ImportPath, _options.ImportFilter, opt).ToList();

                            //Loop through each file and upload it.
                            ConsoleLog(LogLevelEnum.Verbose, "Files:");
                            foreach (string file in files)
                            {
                                string conLog = Path.GetFileName(file);
                                try
                                {
                                    //Get the file details..
                                    FileInfo fileInf = new FileInfo(file);
                                    string   size    = "";
                                    if (fileInf.Length >= 1000000000)
                                    {
                                        size = (fileInf.Length / 1000000000).ToString() + "Gb";
                                    }
                                    else if (fileInf.Length >= 1000000)
                                    {
                                        size = (fileInf.Length / 1000000).ToString() + "Mb";
                                    }
                                    else if (fileInf.Length >= 1000)
                                    {
                                        size = (fileInf.Length / 1000).ToString() + "Kb";
                                    }
                                    else
                                    {
                                        size = fileInf.Length.ToString() + "b";
                                    }
                                    conLog += " (" + size + ")";

                                    //Generate the RemoteDocument object.
                                    RemoteDocument newFile = new RemoteDocument();
                                    newFile.AttachmentTypeId = 1;
                                    newFile.FilenameOrUrl    = Path.GetFileName(file);
                                    newFile.Size             = (int)fileInf.Length;
                                    newFile.UploadDate       = DateTime.UtcNow;

                                    //Now we see if have mapped artifact
                                    ArtifactMapping mappedArtifact = artifactMappings.FirstOrDefault(m => m.Filename.ToLowerInvariant() == newFile.FilenameOrUrl.ToLowerInvariant());
                                    if (mappedArtifact != null && !String.IsNullOrEmpty(customPropertyField))
                                    {
                                        //We have to lookup the artifact, currently only incidents are supported
                                        if (mappedArtifact.ArtifactTypeId == 3)
                                        {
                                            //Retrieve the incident
                                            RemoteSort sort = new RemoteSort();
                                            sort.PropertyName  = "IncidentId";
                                            sort.SortAscending = true;
                                            List <RemoteFilter> filters = new List <RemoteFilter>();
                                            RemoteFilter        filter  = new RemoteFilter();
                                            filter.PropertyName = customPropertyField;
                                            filter.StringValue  = mappedArtifact.ExternalKey;
                                            filters.Add(filter);
                                            RemoteIncident remoteIncident = client.Incident_Retrieve(filters, sort, 1, 1).FirstOrDefault();

                                            if (remoteIncident != null)
                                            {
                                                RemoteLinkedArtifact remoteLinkedArtifact = new SpiraService.RemoteLinkedArtifact();
                                                remoteLinkedArtifact.ArtifactTypeId = mappedArtifact.ArtifactTypeId;
                                                remoteLinkedArtifact.ArtifactId     = remoteIncident.IncidentId.Value;
                                                newFile.AttachedArtifacts           = new List <RemoteLinkedArtifact>();
                                                newFile.AttachedArtifacts.Add(remoteLinkedArtifact);
                                            }
                                        }
                                        else
                                        {
                                            ConsoleLog(LogLevelEnum.Normal, "Warning: Only incident mapped artifacts currently supported, so ignoring the mapped artifacts of type: " + mappedArtifact.ArtifactTypeId);
                                        }
                                    }

                                    //Read the file contents. (Into memory! Beware, large files!)
                                    byte[] fileContents = null;
                                    fileContents = File.ReadAllBytes(file);

                                    ConsoleLog(LogLevelEnum.Verbose, conLog);
                                    if (fileContents != null && fileContents.Length > 1)
                                    {
                                        newFile.AttachmentId = client.Document_AddFile(newFile, fileContents).AttachmentId.Value;
                                    }
                                    else
                                    {
                                        throw new FileEmptyException();
                                    }
                                }
                                catch (Exception ex)
                                {
                                    conLog += " - Error. (" + ex.GetType().ToString() + ")";
                                    ConsoleLog(LogLevelEnum.Normal, conLog);
                                }
                            }
                        }
                        else
                        {
                            ConsoleLog(LogLevelEnum.Normal, "Cannot connect to project. Verify your Project Role.");
                            Environment.Exit(-1);
                        }
                    }
                    else
                    {
                        ConsoleLog(LogLevelEnum.Normal, "Cannot connect to project. Project #" + _options.SpiraProject.ToString() + " does not exist.");
                        Environment.Exit(-1);
                    }
                }
                else
                {
                    ConsoleLog(LogLevelEnum.Normal, "Cannot log in. Check username and password.");
                    Environment.Exit(-1);
                }
            }
            else
            {
                Environment.Exit(-1);
            }
        }
 protected SoapServiceClient GetClient()
 {
     var client = new SoapServiceClient(EndpointConfigurationName);
     return client;
 }
        public void GetImageInfoTest()
        {
            SoapServiceClient service = new SoapServiceClient();

            service.GetImageInfoSoap(GetNextImageGuid());
        }