private void sendOrCancelBtn_Click(object sender, RoutedEventArgs e)
 {
     if (_isImageUpload)
     {
         if (_isSendButton)
         {
             _isSendButton           = false;
             sendOrCancelBtn.Content = "Cancel";
             byte[] message;
             _client = new ServerServiceClient(new System.ServiceModel.InstanceContext(this));
             using (MemoryStream stream = new MemoryStream())
             {
                 _image.Save(stream, ImageFormat.Bmp);
                 message = stream.GetBuffer();
             }
             _client.StartFilter(message, filterComboBox.SelectedItem.ToString());
         }
         else
         {
             _client.StopFilter();
         }
     }
     else
     {
         MessageBox.Show("Select image please");
     }
 }
Esempio n. 2
0
        private void Login_Click(object sender, EventArgs e)
        {
            var serverClient = new ServerServiceClient();

            String user = userTextBox.Text;
            String pass = passTextBox.Text;

            serverClient.ClientCredentials.UserName.UserName = user;
            serverClient.ClientCredentials.UserName.Password = pass;

            loginButton.Enabled = false;
            passTextBox.Text = "";

            serverClient.Open();
            launchMainForm(serverClient);
            try
            {

            }
            catch ( Exception exception )
            {
                serverClient.Abort();
                var info = new InfoForm();
                info.Add(exception.Message);
                info.ShowDialog(this);

            }
        }
Esempio n. 3
0
        private void launchMainForm(ServerServiceClient serverClient)
        {
            if (serverClient.State == CommunicationState.Opened)
            {
                // Handling user interfaces
                RegistView mf = new RegistView(serverClient);
                this.Visible = false;

                // Running Main form
                mf.ShowDialog(this);

                // Restoring Login interface
                this.Visible = true;
                loginButton.Enabled = true;

                // Close connection
                serverClient.Close();
                return;
            }
            serverClient.Abort();
            var info = new InfoForm();
            info.Add("Erro a conectar ao servidor");
            info.ShowDialog(this);
            loginButton.Enabled = true;
        }
Esempio n. 4
0
        private void Login_Click(object sender, EventArgs e)
        {
            var serverClient = new ServerServiceClient();

            String user = userTextBox.Text;
            String pass = passTextBox.Text;

            serverClient.ClientCredentials.UserName.UserName = user;
            serverClient.ClientCredentials.UserName.Password = pass;

            loginButton.Enabled = false;
            passTextBox.Text    = "";


            serverClient.Open();
            launchMainForm(serverClient);
            try
            {
            }
            catch (Exception exception)
            {
                serverClient.Abort();
                var info = new InfoForm();
                info.Add(exception.Message);
                info.ShowDialog(this);
            }
        }
Esempio n. 5
0
        public PersonView(ServerServiceClient serverClient,Person p)
        {
            InitializeComponent();

            person = p;
            nameBoxText.Text = p.Name;
            birthBoxText.Text = p.Birthday.ToShortDateString();
            moradaBoxText.Text = p.Address;
            textBox3.Text = p.Nif.ToString();
            TimeSpan x = DateTime.Now - p.Birthday;
            idadeBoxText.Text = (x.Days/365).ToString();

            nacioBoxText.Text = p.Birthplace;
            this.serverClient = serverClient;

            try
            {
                SampleGenericDelegate<int, Regist[]> del = new SampleGenericDelegate<int, Regist[]>(serverClient.GetRegists);

                IAsyncResult result = del.BeginInvoke(person.Nif, null, null);

                registos = del.EndInvoke(result);

                if (registos != null)
                    SetRegists();

            }
            catch (Exception e)
            {
                var info = new InfoForm();
                info.Add(e.Message);
                info.ShowDialog(this);
                info.Dispose();
            }
        }
Esempio n. 6
0
        private void launchMainForm(ServerServiceClient serverClient)
        {
            if (serverClient.State == CommunicationState.Opened)
            {
                // Handling user interfaces
                RegistView mf = new RegistView(serverClient);
                this.Visible = false;

                // Running Main form
                mf.ShowDialog(this);

                // Restoring Login interface
                this.Visible        = true;
                loginButton.Enabled = true;

                // Close connection
                serverClient.Close();
                return;
            }
            serverClient.Abort();
            var info = new InfoForm();

            info.Add("Erro a conectar ao servidor");
            info.ShowDialog(this);
            loginButton.Enabled = true;
        }
Esempio n. 7
0
        //  private Person person;
        // private Person[] persons;

        public OcorrView(ServerServiceClient serverClient)
        {
            InitializeComponent();
            this.serverClient = serverClient;
            SampleGenericDelegate2 <CrimeType[]> del = new SampleGenericDelegate2 <CrimeType[]>(serverClient.GetAllCrimeType);

            IAsyncResult result = del.BeginInvoke(null, null);

            crimes = del.EndInvoke(result);
            foreach (CrimeType c in crimes)
            {
                comboBox1.Items.Add(c.Name);
            }

            /*
             * comboBox1.SelectedIndex = 0;
             *
             * if (regist == null)
             * {
             * // this.regist = new Regist();
             *  this.person = person;
             *  Editable();
             * }
             * else
             * {
             *  NonEditable();
             * // this.person = person;
             *  this.regist = regist;
             *  date_time_text.Text = regist.Date.ToShortDateString();
             *  id_text.Text = regist.Id.ToString();
             *  Description.Text = regist.Description;
             * }
             */
        }
Esempio n. 8
0
 public DocumentView(ServerServiceClient serverClient, Person person)
 {
     InitializeComponent();
     this.serverClient = serverClient;
     this.person       = person;
     View();
 }
Esempio n. 9
0
        //  private Person person;
        // private Person[] persons;
        public OcorrView(ServerServiceClient serverClient)
        {
            InitializeComponent();
            this.serverClient = serverClient;
            SampleGenericDelegate2<CrimeType[]> del = new SampleGenericDelegate2<CrimeType[]>(serverClient.GetAllCrimeType);

            IAsyncResult result = del.BeginInvoke(null, null);

            crimes = del.EndInvoke(result);
            foreach (CrimeType c in crimes)
            {
                comboBox1.Items.Add(c.Name);
            }

            /*
              comboBox1.SelectedIndex = 0;

            if (regist == null)
            {
               // this.regist = new Regist();
                this.person = person;
                Editable();
            }
            else
            {
                NonEditable();
               // this.person = person;
                this.regist = regist;
                date_time_text.Text = regist.Date.ToShortDateString();
                id_text.Text = regist.Id.ToString();
                Description.Text = regist.Description;
            }
            */
        }
 public void StopWorking()
 {
     _client                 = null;
     _isSendButton           = true;
     sendOrCancelBtn.Content = "Send";
     progressBar.Value       = 0;
 }
Esempio n. 11
0
 public DocumentView(ServerServiceClient serverClient, Person person)
 {
     InitializeComponent();
     this.serverClient = serverClient;
     this.person = person;
     View();
 }
Esempio n. 12
0
        public MainWindow()
        {
            Registration.LogIn login = new Registration.LogIn();
            login.ShowDialog();
            User user = login.user;

            MessageBox.Show(user.Login + " = " + user.Password);
            InitializeComponent();
            site  = new InstanceContext(this);
            proxy = new ServerServiceClient(site);
            proxy.Auth(user.Login, user.Password);
        }
Esempio n. 13
0
        /// <summary>
        /// Gets the file names.
        /// </summary>
        public async Task <IEnumerable <string> > GetFileNames()
        {
            string[] fileNames;
            using (ServerServiceClient serverServiceClient = new ServerServiceClient())
            {
                fileNames = await serverServiceClient.GetFileNamesAsync();
            }

            UpdateFilesOnUi(fileNames);

            return(fileNames);
        }
Esempio n. 14
0
        public DocumentEditor(ServerServiceClient serverClient, Person person)
        {
            InitializeComponent();
            this.person = person;
            this.serverClient = serverClient;
            if (documents == null)
            {
                SampleGenericDelegate2<DocumentType[]> del = new SampleGenericDelegate2<DocumentType[]>(serverClient.GetAllDocumentType);

                IAsyncResult result = del.BeginInvoke( null, null);

                documents = del.EndInvoke(result);
            }
            Editable();
        }
Esempio n. 15
0
        public DocumentEditor(ServerServiceClient serverClient, Person person)
        {
            InitializeComponent();
            this.person       = person;
            this.serverClient = serverClient;
            if (documents == null)
            {
                SampleGenericDelegate2 <DocumentType[]> del = new SampleGenericDelegate2 <DocumentType[]>(serverClient.GetAllDocumentType);

                IAsyncResult result = del.BeginInvoke(null, null);

                documents = del.EndInvoke(result);
            }
            Editable();
        }
Esempio n. 16
0
 static void Main(string[] args)
 {
     try
     {
         ServerServiceClient client = new ServerServiceClient();
         var result = client.getHighscoresForLevel("test1");
         Console.WriteLine(result.scores.Count());
         client.Close();
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception thrown: " + e.ToString());
     }
     Console.WriteLine("Press Enter key to exit");
     Console.ReadLine();
 }
Esempio n. 17
0
 public void Join(ClientData client)
 {
     if (null == client || mServerClient != null)
     {
         return;
     }
     mServerClient = new ServerServiceClient(new InstanceContext(new ServerCallback()), "defalultOperationClient");
     client.Port   = mServerClient.Endpoint.Address.Uri.Port.ToString();
     try
     {
         mServerClient.Join(client);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Esempio n. 18
0
        /// <summary>
        /// Downloads the file.
        /// </summary>
        public async Task <Stream> DownloadFile(string fileName)
        {
            Log($"{fileName} is requested by the client.");
            string cachedFileLocation = Path.Combine(CommonConstants.CacheFilesLocation, $"{fileName}");
            bool   fileWasCached      = CommonFunctionality.DoesFileExist(cachedFileLocation);

            if (fileWasCached)
            {
                Log($"{fileName} was previously cached.");
                byte[] allCachedBytes = System.IO.File.ReadAllBytes(cachedFileLocation);
                FileCurrentVersionStatus fileCurrentVersionStatus;
                using (ServerServiceClient serverServiceClient = new ServerServiceClient())
                {
                    fileCurrentVersionStatus = await serverServiceClient.IsCurrentVersionOfFileAsync(fileName, allCachedBytes.CalculateSha256Hash());

                    if (fileCurrentVersionStatus == FileCurrentVersionStatus.Modified)
                    {
                        Log($"{fileName} has been modified on the main server.");
                        Stream downloadFile = await UpdateCachedFile(fileName, allCachedBytes, serverServiceClient, cachedFileLocation);

                        MarkFileAsCached(fileName);
                        return(downloadFile);
                    }
                }

                if (fileCurrentVersionStatus == FileCurrentVersionStatus.UpToDate)
                {
                    MarkFileAsCached(fileName);
                    return(new MemoryStream(allCachedBytes));
                }

                throw new FileNotFoundException();
            }

            // File hasn't been cached before.
            using (ServerServiceClient serverServiceClient = new ServerServiceClient())
            {
                Log($"{fileName} hasn't been cached before. Downloading it from the main server for the first time.");
                Stream downloadedFile = await serverServiceClient.DownloadFileAsync(fileName);

                byte[] fileContent = CommonFunctionality.ReadFully(downloadedFile);
                SaveToNewFile(fileContent, cachedFileLocation);
                MarkFileAsCached(fileName);
                return(new MemoryStream(fileContent));
            }
        }
Esempio n. 19
0
        static void Main(string[] args)
        {
            var client = new ServerServiceClient("BasicHttpBinding_IServerService", "http://localhost:8000/ServerService");

            client.Test("test text");
            var sessionName = GetSessionName();

            client.StoreSession(sessionName);
            Console.WriteLine(client.GetSessionName());

            client.SendByteData(new byte[100000]);
            client.SendString(sessionName);

            Console.WriteLine("Uploaded");

            Console.ReadLine();
            client.Close();
        }
Esempio n. 20
0
        public Participants(ServerServiceClient serverClient,Regist regist)
        {
            InitializeComponent();
            this.serverClient = serverClient;

            SampleGenericDelegate<int, Person[]> del = new SampleGenericDelegate<int, Person[]>(serverClient.GetAllPersonByIdRegist);

               IAsyncResult result= del.BeginInvoke(regist.Id, null, null);

               this.persons=del.EndInvoke(result);

            this.regist = regist;

            foreach (Person p in persons)
                dataGridView1.Rows.Add(new object[]
                {
                    p.Nif, p.Name, p.Address, p.Birthday.ToShortDateString(), p.Birthplace,
                });
        }
Esempio n. 21
0
 public TestClass(string pathToImage)
 {
     client = new ServerServiceClient(new System.ServiceModel.InstanceContext(this));
     try
     {
         filters = client.GetFilters();
     }
     catch (Exception)
     {
         throw new Exception("Server is not avaliable");
     }
     try
     {
         testImage = new Bitmap(pathToImage);
     }
     catch (FileNotFoundException e)
     {
         throw e;
     }
 }
Esempio n. 22
0
 public TimeSpan Work()
 {
     try
     {
         DateTime startFilterTime = DateTime.Now;
         byte[]   message;
         client = new ServerServiceClient(new System.ServiceModel.InstanceContext(this));
         using (MemoryStream stream = new MemoryStream())
         {
             testImage.Save(stream, ImageFormat.Bmp);
             message = stream.GetBuffer();
         }
         client.StartFilter(message, filters.First());
         return(DateTime.Now - startFilterTime);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public MainWindow()
 {
     InitializeComponent();
     _isImageUpload = false;
     _isSendButton  = true;
     _client        = new ServerServiceClient(new System.ServiceModel.InstanceContext(this));
     try
     {
         var filters = _client.GetFilters();
         foreach (var f in filters)
         {
             filterComboBox.Items.Add(f);
         }
         filterComboBox.SelectedItem = filters.First();
     }
     catch
     {
         MessageBox.Show("Server is not avaliable");
         Close();
     }
 }
Esempio n. 24
0
        public Participants(ServerServiceClient serverClient, Regist regist)
        {
            InitializeComponent();
            this.serverClient = serverClient;

            SampleGenericDelegate <int, Person[]> del = new SampleGenericDelegate <int, Person[]>(serverClient.GetAllPersonByIdRegist);

            IAsyncResult result = del.BeginInvoke(regist.Id, null, null);

            this.persons = del.EndInvoke(result);

            this.regist = regist;

            foreach (Person p in persons)
            {
                dataGridView1.Rows.Add(new object[]
                {
                    p.Nif, p.Name, p.Address, p.Birthday.ToShortDateString(), p.Birthplace,
                });
            }
        }
        public void GetImage(byte[] image)
        {
            progressBar.Value = 100;
            Bitmap bmp;

            using (MemoryStream stream = new MemoryStream(image))
            {
                bmp = (Bitmap)Image.FromStream(stream);
            }
            var imgSource = Imaging.CreateBitmapSourceFromHBitmap(bmp.GetHbitmap(), IntPtr.Zero,
                                                                  Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(_image.Width, _image.Height));

            img.Source        = imgSource;
            progressBar.Value = 0;
            if (!_isSendButton)
            {
                _isSendButton           = true;
                sendOrCancelBtn.Content = "Send";
            }
            _client = null;
        }
Esempio n. 26
0
        public PersonEditor(ServerServiceClient serverClient, Regist regist)
        {
            InitializeComponent();
            this.serverClient = serverClient;
            photoDialog       = new OpenFileDialog();
            _regist           = regist;
            p = new Person();
            photoDialog.Filter =
                "Image files (*.jpg, *.jpeg, *.jpe, *.jfif) | *.jpg; *.jpeg; *.jpe; *.jfif;";
            //photoDialog.InitialDirectory = @"C:\";
            photoDialog.Title = "Seleccione uma foto correspondente ";

            Closed += (sender, args) =>
            {
                photoDialog.Dispose();
                if (fileStream != null)
                {
                    fileStream.Dispose();
                }
                Dispose(true);
            };
        }
Esempio n. 27
0
        public PersonEditor(ServerServiceClient serverClient,Regist regist)
        {
            InitializeComponent();
            this.serverClient = serverClient;
            photoDialog = new OpenFileDialog();
            _regist = regist;
            p = new Person();
            photoDialog.Filter =
                "Image files (*.jpg, *.jpeg, *.jpe, *.jfif) | *.jpg; *.jpeg; *.jpe; *.jfif;";
            //photoDialog.InitialDirectory = @"C:\";
            photoDialog.Title = "Seleccione uma foto correspondente ";

            Closed += (sender, args) =>
            {
                photoDialog.Dispose();
                if (fileStream != null)
                {
                    fileStream.Dispose();
                }
                Dispose(true);
            };
        }
Esempio n. 28
0
        static void Main(string[] args)
        {
            //To add ServerServiceClient use
            //svcutil.exe http://localhost:8000/ServerService?wsdl
            //OR easier way
            //To add new right click on project "Add Service Reference"
            //Update right click on "Service References->ServiceReference1" then "Update Service Reference"
            ServerServiceClient client = new ServerServiceClient("BasicHttpBinding_IServerService", "http://localhost:8000/ServerService");
            var result = client.Test("test text");

            Console.WriteLine("Session Name:");
            var sessionName = Console.ReadLine();

            client.StoreSession(sessionName);
            Console.WriteLine(client.GetSessionName());
            Console.ReadLine();

            client.SendByteData(new byte[100000]);
            Console.WriteLine("Uploaded");

            Console.ReadLine();
            client.Close();
        }
Esempio n. 29
0
        public RegistoCriminal(ServerServiceClient serverClient)
        {
            InitializeComponent();
            this.serverClient = serverClient;
             try
            {
                SampleGenericDelegate2<Regist[]> del = new SampleGenericDelegate2<Regist[]>(serverClient.GetAllRegists);

                IAsyncResult result = del.BeginInvoke(null, null);

                registos = del.EndInvoke(result);
                 if(registos!=null)
                     SetRegists();

            }
            catch (Exception e)
            {
                var info = new InfoForm();
                info.Add(e.Message);
                info.ShowDialog(this);
                info.Dispose();
            }
        }
Esempio n. 30
0
        public PersonView(ServerServiceClient serverClient, Person p)
        {
            InitializeComponent();

            person             = p;
            nameBoxText.Text   = p.Name;
            birthBoxText.Text  = p.Birthday.ToShortDateString();
            moradaBoxText.Text = p.Address;
            textBox3.Text      = p.Nif.ToString();
            TimeSpan x = DateTime.Now - p.Birthday;

            idadeBoxText.Text = (x.Days / 365).ToString();

            nacioBoxText.Text = p.Birthplace;
            this.serverClient = serverClient;

            try
            {
                SampleGenericDelegate <int, Regist[]> del = new SampleGenericDelegate <int, Regist[]>(serverClient.GetRegists);

                IAsyncResult result = del.BeginInvoke(person.Nif, null, null);

                registos = del.EndInvoke(result);

                if (registos != null)
                {
                    SetRegists();
                }
            }
            catch (Exception e)
            {
                var info = new InfoForm();
                info.Add(e.Message);
                info.ShowDialog(this);
                info.Dispose();
            }
        }
Esempio n. 31
0
        public RegistoCriminal(ServerServiceClient serverClient)
        {
            InitializeComponent();
            this.serverClient = serverClient;
            try
            {
                SampleGenericDelegate2 <Regist[]> del = new SampleGenericDelegate2 <Regist[]>(serverClient.GetAllRegists);

                IAsyncResult result = del.BeginInvoke(null, null);

                registos = del.EndInvoke(result);
                if (registos != null)
                {
                    SetRegists();
                }
            }
            catch (Exception e)
            {
                var info = new InfoForm();
                info.Add(e.Message);
                info.ShowDialog(this);
                info.Dispose();
            }
        }
 private BusinessStructure()
 {
     BDService = new ServerServiceClient();
     SetSounds();
 }
Esempio n. 33
0
 /// <summary>
 /// Request the end of the thread method.
 /// </summary>
 public void Stop()
 {
     lock (this)
     {
         m_running = false;
         serverService = null;
         ClientUtility.Log(logger, " Close service.");
     }
 }
        void deptStockOutView_DispatchDepartmentStockOut(object sender, DepartmentStockOutEventArgs e)
        {
            Department destDept = DepartmentLogic.FindById(e.DepartmentStockOut.OtherDepartmentId);
            if (destDept != null)
            {
                foreach (DepartmentStockOutDetail detail in e.DepartmentStockOut.DepartmentStockOutDetails)
                {
                    string prdMasterId = detail.Product.ProductMaster.ProductMasterId;
                    DepartmentPricePK pricePk = new DepartmentPricePK
                                                    {
                                                        DepartmentId = 0,
                                                        ProductMasterId = prdMasterId
                                                    };
                    detail.DepartmentPrice = DepartmentPriceLogic.FindById(pricePk);
                }

                SyncFromDeptToDept fromDeptToDept = new SyncFromDeptToDept
                                                        {
                                                            DestinationDept = destDept
                                                        };
                fromDeptToDept.DepartmentStockOutList = new ArrayList();
                fromDeptToDept.DepartmentStockOutList.Add(e.DepartmentStockOut);

                CopyToSyncFolder(fromDeptToDept);

                ServerServiceClient serverService = new ServerServiceClient(new InstanceContext(this), ClientSetting.ServiceBinding);
                serverService.MakeRawDepartmentStockOut(destDept,e.DepartmentStockOut,new DepartmentPrice());

            }
        }
Esempio n. 35
0
 public RegistView(ServerServiceClient serverClient)
 {
     InitializeComponent();
     this.serverClient = serverClient;
 }
Esempio n. 36
0
 public RegistView(ServerServiceClient serverClient)
 {
     InitializeComponent();
      this.serverClient = serverClient;
 }
 public static void CloseAfariaServiceServer(ServerServiceClient svcServer)
 {
     try
     {
         if (svcServer != null)
         {
             // Get the state of the service
             System.ServiceModel.CommunicationState commState = svcServer.State;
             // If the service is faulted, we still need to abort
             if (commState == System.ServiceModel.CommunicationState.Faulted)
             {
                 svcServer.Abort();
             }
             // If the state is not already closed or in the process of closing, we should close the context
             else if (commState != System.ServiceModel.CommunicationState.Closing ||
                 commState != System.ServiceModel.CommunicationState.Closed)
             {
                 // Get the context info to get the context ID, although we saved this in the context string variable
                 Server.ContextInfo contextInfo = svcServer.GetContextInfo();
                 // Assure that there is a valid context ID
                 if (!string.IsNullOrWhiteSpace(contextInfo.ContextId))
                 {
                     // Close the context
                     svcServer.CloseContext();
                 }
                 // Now close the service
                 svcServer.Close();
             }
             // If the channel is closing/closed, attempt to close out the context, but don't need to close state
             else
             {
                 // We will likely throw an exception here.
                 svcServer.CloseContext();
             }
             svcServer = null;
         }
     }
     catch (Exception ex)
     {
         // Just ouput the exception, proper handling should initiate a new service, initiate the context to the previous,
         // and then close out the context and service
         Console.WriteLine(ex.Message.ToString());
         logger.Error("Error while closing Server service", ex);
     }
 }
        public static ServerServiceClient GetAfariaServiceServer(Dictionary<string, string> server, Dictionary<string, string> credentials)
        {
            string serverApiAddr = String.Format("net.tcp://{0}:{1}/AfariaService/{2}", server["IPAddr"], server["Port"], "Server");
            ServerServiceClient svcServer = new ServerServiceClient("NetTcpBinding_IServerService", serverApiAddr);
            svcServer.ClientCredentials.Windows.ClientCredential.Domain = credentials["Domain"];
            svcServer.ClientCredentials.Windows.ClientCredential.UserName = credentials["UserName"];
            svcServer.ClientCredentials.Windows.ClientCredential.Password = credentials["Password"];
            logger.Info("Creating Server service: {0}", serverApiAddr);

            return svcServer;
        }
Esempio n. 39
0
        private async Task <Stream> UpdateCachedFile(string fileName, byte[] cachedFileContent, ServerServiceClient serverServiceClient, string cachedFileLocation)
        {
            List <Chunk> cachedChunks = RabinKarpAlgorithm.Slice(cachedFileContent);

            DifferenceChunkDto[] differenceChunkDtos = await serverServiceClient.GetUpdatedChunksAsync(fileName, cachedChunks.Select(CachedChunkDtoMapper.Map).ToArray());

            byte[] newFileContent = ConstructContentOfTheUpdateFile(differenceChunkDtos, cachedChunks, fileName);
            System.IO.File.WriteAllBytes(cachedFileLocation, newFileContent);
            return(new MemoryStream(newFileContent));
        }
Esempio n. 40
0
 public LogIn()
 {
     InitializeComponent();
     site  = new InstanceContext(this);
     proxy = new ServerServiceClient(site);
 }
Esempio n. 41
0
            public WcfTestClient(IStatistics statistics, TestClientSettings settings)
                : base(statistics, settings)
            {
                _stopwatch.Start();

                _service = new ServerServiceClient(
                    new NetTcpBinding
                    {
                        Security = new NetTcpSecurity
                        {
                            Mode = SecurityMode.None,
                            Transport = new TcpTransportSecurity
                            {
                                ProtectionLevel = ProtectionLevel.None
                            },
                            Message = new MessageSecurityOverTcp
                            {
                                ClientCredentialType = MessageCredentialType.None
                            }
                        }
                        // , TransferMode = TransferMode.Streamed
                    },
                    new EndpointAddress("net.tcp://" + Settings.Host + ":" + Constants.WcfPort + "/ServerService/")
                );

                _service.Open();
            }
        void mainStockInView_DispatchDepartmentStockOut(object sender, DepartmentStockOutEventArgs e)
        {
            Department destDept = DepartmentLogic.FindById(e.DepartmentStockOut.OtherDepartmentId);
            if (destDept != null)
            {
                foreach (DepartmentStockOutDetail detail in e.DepartmentStockOut.DepartmentStockOutDetails)
                {
                    string prdMasterId = detail.Product.ProductMaster.ProductMasterId;
                    DepartmentPricePK pricePk = new DepartmentPricePK
                                                    {
                                                        DepartmentId = 0,
                                                        ProductMasterId = prdMasterId
                                                    };
                    detail.DepartmentPrice = DepartmentPriceLogic.FindById(pricePk);
                }

                ServerServiceClient serverService = new ServerServiceClient(new InstanceContext(this), ClientSetting.ServiceBinding);
                serverService.MakeRawDepartmentStockOut(destDept,e.DepartmentStockOut,new DepartmentPrice());
            }
        }
 private BusinessStructure()
 {
     BDService = new ServerServiceClient();
     SetSounds();
 }
Esempio n. 44
0
        private void ThreadMethod()
        {
            m_running = true;
                while (m_running)
                {
                    if(!connected)
                    {
                        try
                        {
                            ((MainForm) GlobalCache.Instance().MainForm).ServiceStatus.Text = " Đang kết nối ...";
                            //ClientUtility.Log(logger, ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text);
                            serverService = new ServerServiceClient(new InstanceContext(this), ClientSetting.ServiceBinding);
                            serverService.JoinDistributingGroup(CurrentDepartment.Get());
                            ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text = "Kết nối với dịch vụ.";
                            //ClientUtility.Log(logger, ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text);
                        }
                        catch (Exception)
                        {

                        }
                        Thread.Sleep(100);
                    }
                    else
                    {
                        Thread.Sleep(100);
                    }
                }
        }
Esempio n. 45
0
        private void ThreadMethod()
        {
            m_running = true;
                while (m_running)
                {
                    if(!connected)
                    {
                        try
                        {

                            ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text = " Đang kết nối ...";
                            serverService = new ServerServiceClient(new InstanceContext(this), ClientSetting.ServiceBinding);
                            serverService.JoinDistributingGroup(CurrentDepartment.Get());
                            ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text = " Kết nối với dịch vụ.";
                            Thread.Sleep(100);

                        }
                        catch (Exception ex)
                        {
                            //ClientUtility.Log(logger,ex.Message);
                        }

                    }
                    else
                    {
                        try
                        {
                            // Wait until thread is stopped
                            if (!IsDoingStockOut)
                            {
                                ((MainForm) GlobalCache.Instance().MainForm).ServiceStatus.Text =
                                    " Yêu cầu thông tin ... ";
                                //serverService.RequestDepartmentStockOut(CurrentDepartment.Get().DepartmentId);
                                ((MainForm) GlobalCache.Instance().MainForm).ServiceStatus.Text = " Chờ lệnh ... ";
                            }
                            Thread.Sleep(SleepTime);
                        }
                        catch (Exception)
                        {
                            if(serverService.State == CommunicationState.Faulted
                               || serverService.State == CommunicationState.Closed)
                            {
                                connected = false;
                                serverService = null;
                            }
                            ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text = " Thất bại ... ";
                            //ClientUtility.Log(logger, ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text);
                            Thread.Sleep(1000 * 3);
                            ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text = " Xử lý lại ... ";
                        }

                    }
                }
        }
Esempio n. 46
0
 public MainForm(ServerServiceClient serverClient)
 {
     InitializeComponent();
     this.serverClient = serverClient;
 }
Esempio n. 47
0
 public MainForm(ServerServiceClient serverClient)
 {
     InitializeComponent();
     this.serverClient = serverClient;
 }
Esempio n. 48
0
 void Start()
 {
     client = new ServerServiceClient(new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress("http://localhost:8000/Snak/ServerService"));
 }
Esempio n. 49
0
	void Start () {
        client = new ServerServiceClient(new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress("http://localhost:8000/Snak/ServerService"));
    }
        void _departmentStockInView_DispatchDepartmentStockIn(object sender, DepartmentStockInEventArgs e)
        {
            Department destDept = DepartmentLogic.FindById(e.Department.DepartmentId);
            if (destDept != null)
            {
                GlobalMessage message = (GlobalMessage)GlobalUtility.GetObject("GlobalMessage");
                message.PublishMessage(ChannelConstants.DEPT2MAIN_SYNC, "Đang gửi thông tin xuống cửa hàng ...");
                ServerServiceClient serverService = new ServerServiceClient(new InstanceContext(this), ClientSetting.ServiceBinding);
                serverService.MakeRawDepartmentStockIn(destDept, e.DepartmentStockIn);
            }

            e.EventResult = "Made Stock-in back";
        }