/// <summary>
        ///<para>Uploads the specified file to the Proschlaf DataStore. There, the file is processed and relevant customer data is extracted and stored in a separate database.</para>
        ///<para>Note that this method returns after the file has been uploaded and thus no information about the database insert process (which starts after the file has been uploaded) is given. </para>
        ///<para>Also note that the dates stored in the uploaded file MUST be in German DateTime-format.</para>
        ///<para>The client as to ensure the data integrity of the uploaded data; meaning that no data record is uploaded multiple times to the DataStore.</para>
        /// Currently, the data structures of the following Proschlaf softwares are supported:
        ///     - Liegesimulator
        ///     - Ergonometer
        ///     - Orthonometer
        ///     - Ergonometer NL
        ///     - LS 2.0
        /// </summary>
        /// <param name="filePath">The path to the file to be uploaded.</param>
        /// <param name="branchOfficeName">The name of the vendor where the uploading software is located at.</param>
        /// <param name="branchOfficeCode">The code of the vendor where the uploading software is located at (usually an internal SAP code).</param>
        /// <param name="softwareName">The name of the uploading software (e.g. "Liegesimulator" or "Ergonometer".</param>
        /// <param name="softwareVersion">The assembly version of the uploading software.</param>
        /// <param name="simulatorDeviceSerialNumbers">A list of ids of the simulator devices connected to the uploading software.</param>
        /// <returns>Null if everything went fine or an exception.</returns>
        public Exception UploadCustomerData(string filePath, string branchOfficeName, string branchOfficeCode, string softwareName, string softwareVersion, List <string> simulatorDeviceSerialNumbers, bool isTestUpload)
        {
            try
            {
                ChannelFactory <IDataStoreServices> cf = GetChannelFactory();

                IDataStoreServices channel = cf.CreateChannel();

                using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    string fileName = Path.GetFileName(filePath);

                    RemoteFileInfo file = new RemoteFileInfo(branchOfficeCode, branchOfficeName, fileName, isTestUpload, fileStream.Length, simulatorDeviceSerialNumbers.ToArray(), softwareName, softwareVersion, fileStream);

                    ReturnValue returnVal = channel.UploadDatabaseFile(file);

                    return(returnVal.Exception);
                }
            }
            catch (CommunicationException cex)
            {
                return(cex);
            }
            catch (Exception ex)
            {
                return(ex);
            }
        }
        /// <summary>
        /// Checks if the Proschlaf DataStore service is available.
        /// </summary>
        /// <returns>True if available, false otherwise.</returns>
        public bool CheckServerAvailability(out string error)
        {
            string response = null;

            error = null;
            string errorMsg = null;

            Task t = Task.Factory.StartNew(() =>
            {
                try
                {
                    ChannelFactory <IDataStoreServices> cf = GetChannelFactory();

                    IDataStoreServices channel = cf.CreateChannel();
                    response = channel.TestConnection();
                }
                catch (Exception ex)
                {
                    errorMsg = ex.ToString();
                }
            });

            bool taskFinishedProperly = t.Wait(5000); //if the channel doesn't open within 5 seconds, the service is presumed not available

            error = errorMsg;
            return(taskFinishedProperly & response != null); //taskFinishedProperly must be true and response must not be null
        }
Beispiel #3
0
        private static IDataStoreSource CreateSource(string name, bool configured, bool available, IDataStoreServices services = null)
        {
            var sourceMock = new Mock <IDataStoreSource>();

            sourceMock.Setup(m => m.IsConfigured(It.IsAny <IEntityOptions>())).Returns(configured);
            sourceMock.Setup(m => m.GetStoreServices(It.IsAny <IServiceProvider>())).Returns(services);
            sourceMock.Setup(m => m.Name).Returns(name);

            return(sourceMock.Object);
        }
        private static IDataStoreSource CreateSource(string name, bool configured, bool available, IDataStoreServices services = null)
        {
            var sourceMock = new Mock<IDataStoreSource>();
            sourceMock.Setup(m => m.IsConfigured(It.IsAny<IEntityOptions>())).Returns(configured);
            sourceMock.Setup(m => m.GetStoreServices(It.IsAny<IServiceProvider>())).Returns(services);
            sourceMock.Setup(m => m.Name).Returns(name);

            return sourceMock.Object;
        }