Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                string       ipAddress      = "";
                const string ServerRegistry = "SOFTWARE\\Goji Solutions\\Harmoni";
                clsRegistry  reg            = new clsRegistry();
                ipAddress = reg.GetStringValue(Registry.LocalMachine, ServerRegistry, "LocalIpAddress");
                if (ipAddress == null)
                {
                    Console.WriteLine("Failed to get the resgitry key for local ip address");
                }
                else
                {
                    WCFConnect.OpenService(ipAddress, 8022);
                }
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
                Console.ReadKey();
                return;
            }

            Console.ReadLine();
            WCFConnect.Close();
        }
Ejemplo n.º 2
0
        private void OnCreated(object sender, FileSystemEventArgs e)
        {
            try
            {
                const string FMT  = "yyyy-MM-dd HH:mm:ss.fffffff";
                clsRegistry  reg  = new clsRegistry();
                string       time = reg.GetStringValue(
                    Registry.LocalMachine,
                    "SOFTWARE\\Goji solutions\\Field\\Watson\\",
                    "StartCapture");
                if (reg.strRegError != null)
                {
                    throw (new SystemException("Cannot get watson start time"));
                }
                m_startTime = DateTime.ParseExact(time, FMT, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);


                // first date time is the created time , second is the upload time
                ulong g360Index;
                //Console.WriteLine("e.FullPath:" + e.FullPath);
                //Console.WriteLine("m_startTime:" + m_startTime);
                //Console.WriteLine("m_FileOwnerUserName:"******"Add file Ok");
                pCallback(18, m_clientIpAddress, Path.GetFileName(e.FullPath), e.FullPath, "Watson file", 1, m_startTime, g360Index, m_FileOwnerUserName);
                //Console.WriteLine("Add file to queue: " + e.FullPath);
                m_event.Set();
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
            }
        }
Ejemplo n.º 3
0
        public Form1()
        {
            InitializeComponent();
            Control.CheckForIllegalCrossThreadCalls = false;

            NetCard.NetCard n         = new NetCard.NetCard();
            string          ipAddress = n.getComputerIP();
            clsRegistry     reg       = new clsRegistry();

            if (ipAddress == "0.0.0.0")
            {
                string bip = reg.GetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Field", "IpAddress");
                if (reg.strRegError == null)
                {
                }
                else
                {
                    GetManualIpAddress g = new GetManualIpAddress();
                    if (g.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        ipAddress = g.IpAddress;
                        reg.SetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Field", "IpAddress", ipAddress);
                    }
                }
            }
            label5.Visible = true;
            label5.Text    = ipAddress;
            label1.Text    = "Goji MPFM Watson WCF Field installation version " + Properties.Settings.Default.WatsonInstallerVersion;
            ThreadedExecuter <string> executer = new ThreadedExecuter <string>(ProcessThread_1, ThreadCompleted);

            executer.Start();
        }
Ejemplo n.º 4
0
        void OpenService()
        {
            try
            {
                string       ipAddress             = "10.0.0.17";
                const string MegaPopServerRegistry = "SOFTWARE\\Eli\\ChatServer";
                clsRegistry  reg = new clsRegistry();
                ipAddress = reg.GetStringValue(Registry.LocalMachine, MegaPopServerRegistry, "LocalIpAddress");



                // Create the url that is needed to specify
                // where the service should be started
                urlService = "net.tcp://" + ipAddress + ":8099/ChatService";

                // Instruct the ServiceHost that the type
                // that is used is a ServiceLibrary.service1
                host          = new ServiceHost(typeof(ChatService));
                host.Opening += new EventHandler(host_Opening);
                host.Opened  += new EventHandler(host_Opened);
                host.Closing += new EventHandler(host_Closing);
                host.Closed  += new EventHandler(host_Closed);

                // The binding is where we can choose what
                // transport layer we want to use. HTTP, TCP ect.
                NetTcpBinding tcpBinding = new NetTcpBinding();
                tcpBinding.TransactionFlow = false;
                tcpBinding.Security.Transport.ProtectionLevel      = System.Net.Security.ProtectionLevel.EncryptAndSign;
                tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
                tcpBinding.Security.Mode = SecurityMode.Transport;
                // <- Very crucial

                // Add a endpoint
                host.AddServiceEndpoint(typeof(ChatServiceLib.IChatService), tcpBinding, urlService);

                // A channel to describe the service.
                // Used with the proxy scvutil.exe tool
                ServiceMetadataBehavior metadataBehavior;
                metadataBehavior =
                    host.Description.Behaviors.Find <ServiceMetadataBehavior>();

                if (metadataBehavior == null)
                {
                    // This is how I create the proxy object
                    // that is generated via the svcutil.exe tool
                    metadataBehavior                = new ServiceMetadataBehavior();
                    metadataBehavior.HttpGetUrl     = new Uri("http://" + ipAddress + ":8002/ChatService");
                    metadataBehavior.HttpGetEnabled = true;
                    metadataBehavior.ToString();
                    host.Description.Behaviors.Add(metadataBehavior);
                    urlMeta = metadataBehavior.HttpGetUrl.ToString();
                }
                host.Open();
            }
            catch (Exception err)
            {
                File.AppendAllText("c:\\chatwcf.txt", err.Message + Environment.NewLine);
            }
        }
Ejemplo n.º 5
0
        public FileServerWinClient()
        {
            clsRegistry reg  = new clsRegistry();
            string      time = reg.GetStringValue(
                Registry.LocalMachine,
                "SOFTWARE\\Goji solutions\\Field\\Watson\\",
                "StartCapture");

            if (reg.strRegError == null)
            {
                m_startTime = DateTime.ParseExact(time, FMT, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
            }

            m_fieldGuid = reg.GetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Field", "Guid");
            if (reg.strRegError != null)
            {
                m_fieldGuid = "error no guid";
            }

            uint x;

            x = reg.GetDWORDValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Field\\Streaming", "fifo_threshold");
            if (reg.strRegError == null)
            {
                if (x > 2)
                {
                    m_fifoFileThreshold = (int)x;
                }
            }

            // Get string value
            string strValue = reg.GetStringValue(
                Registry.LocalMachine,
                "SOFTWARE\\Goji solutions\\Field\\Watson",
                "WatsonStatus");

            if (reg.strRegError == null && strValue == "running")
            {
                m_watsonRunning = true;
            }
            if (reg.strRegError == null && strValue == "stopped")
            {
                m_watsonRunning = false;
            }
        }
Ejemplo n.º 6
0
        public string GetClientGuid()
        {
            clsRegistry reg = new clsRegistry();

            m_fieldGuid = reg.GetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Field", "Guid");
            if (reg.strRegError != null)
            {
                m_fieldGuid = "error no guid";
            }
            return(m_fieldGuid);
        }
Ejemplo n.º 7
0
        void Initialize()
        {
            try
            {
                NetCard.NetCard n = new NetCard.NetCard();
                m_ipAddress = n.getComputerIP();
                while (m_ipAddress == "0.0.0.0")
                {
                    Thread.Sleep(10000);
                    m_ipAddress = n.getComputerIP();
                }
                File.WriteAllText("c:\\WCFStreamingClient.txt", "Initialized done: ip " + m_ipAddress);

                clsRegistry reg = new clsRegistry();
                m_fieldGuid = reg.GetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Field", "Guid");
                if (reg.strRegError != null)
                {
                    m_fieldGuid = "error no guid";
                }

                FileServerWinClient.CallbackMessage pCallback = new FileServerWinClient.CallbackMessage(CallbackMessage);
                m_fileServerClient.SetCallback(pCallback);


                string strValue = reg.GetStringValue(
                    Registry.LocalMachine,
                    "SOFTWARE\\Goji solutions\\Field\\Watson",
                    "FileOwnerUserName");

                if (reg.strRegError == null)
                {
                    m_FileOwnerUserName = strValue;
                }
                else
                {
                    m_FileOwnerUserName = "******";
                }


                strValue = reg.GetStringValue(
                    Registry.LocalMachine,
                    "SOFTWARE\\Goji solutions\\Field\\Watson",
                    "WatsonStatus");
                if (reg.strRegError == null && strValue == "running")
                {
                    string userName;
                    userName = reg.GetStringValue(Registry.LocalMachine,
                                                  "SOFTWARE\\Goji solutions\\Field\\Watson",
                                                  "OperateUserName");

                    if (reg.strRegError != null)
                    {
                        pCallback(600, m_ipAddress, string.Empty, string.Empty, "Operator Owner does not exists", 0, DateTime.Now, 0, string.Empty);
                        return;
                    }

                    strValue = reg.GetStringValue(
                        Registry.LocalMachine,
                        "SOFTWARE\\Goji solutions\\Field\\Watson",
                        "StartWatchMonitorDirectory");
                    if (reg.strRegError == null)
                    {
                        if (Directory.Exists(strValue) == true)
                        {
                            m_fileServerClient.StartWatch(strValue, "*.bin", true, userName);
                        }
                    }
                }
            }
            catch (Exception err)
            {
                File.AppendAllText("c:\\GojiWCFStreamingClient.txt", err.Message);
            }
        }
Ejemplo n.º 8
0
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == -1)
            {
                MessageBox.Show("please select upload type");
                return;
            }

            clsRegistry reg = new clsRegistry();

            m_baseGuid = reg.GetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Base", "Guid");
            if (reg.strRegError != null)
            {
                m_baseGuid = Guid.NewGuid().ToString();
                reg.SetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Base", "Guid", m_baseGuid);
            }
            string guid = m_client.GetClientGuid();

            NetCard.NetCard n      = new NetCard.NetCard();
            string          baseIp = n.getComputerIP();

            if (baseIp == "0.0.0.0")
            {
                string bip = reg.GetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Base", "IpAddress");
                if (reg.strRegError == null)
                {
                    baseIp = bip;
                }
                else
                {
                    MessageBox.Show("You need to specify the base ip address in the registry");
                    return;
                }
            }

            if (checkBox1.Checked == true)
            {
                if (comboBox1.SelectedIndex == 0)
                {
                    try
                    {
                        Dictionary <string, string> storageDirectoryDic = new Dictionary <string, string>();
                        storageDirectoryDic.Add(guid, textBox3.Text);
                        GojiWCFStreamingBase.StartStorageServer(storageDirectoryDic);


                        if (SetCopyTimerEvent() == false)
                        {
                            return;
                        }
                        m_client.AddDateToUploadTargetFolder(checkBox8.Checked);
                        m_client.ConnectToStreamingServer(baseIp, textBox4.Text, textBox5.Text);
                        button14.Enabled = true;
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show(err.Message);
                    }
                }
                else if (comboBox1.SelectedIndex == 1)
                {
                    try
                    {
                        string s = m_client.InitializeDropBox();
                        if (s != "ok")
                        {
                            MessageBox.Show(s);
                        }
                        else
                        {
                            m_client.StartDropBoxUploadMode(true);
                            button14.Enabled = true;
                        }
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show(err.Message);
                    }
                }
                else if (comboBox1.SelectedIndex == 2)
                {
                    m_client.StartTCPStreamingServer(1024 * 1024 * 30, 5005);
                    m_client.OpenTCPStreamingClient(baseIp, textBox4.Text, textBox5.Text);
                }
                checkBox1.ForeColor = System.Drawing.Color.Green;
            }
            else
            {
                if (comboBox1.SelectedIndex == 0)
                {
                    m_client.CloseCopyThread();
                    while (m_client.IsCopyThreadIsAlive() == true)
                    {
                        Application.DoEvents();
                        Thread.Sleep(1000);
                    }
                }
                else
                {
                    try
                    {
                        m_client.StartDropBoxUploadMode(false);
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show(err.Message);
                    }
                }
                checkBox1.ForeColor = System.Drawing.Color.Red;
            }
        }
Ejemplo n.º 9
0
        public Form1()
        {
            m_running = true;
            InitializeComponent();
            label18.Text = m_totalFieldFiles.ToString();
            Control.CheckForIllegalCrossThreadCalls = false;

            groupBox3.Enabled = false;
            p  = new GojiWCFStreamingBase.ClientCallbackMessage(ClientCallbackMsg);
            p1 = new GojiWCFStreamingBase.ServerCallbackMessage(ServerCallbackMsg);
            GojiWCFStreamingBase.SetServerCallback = p1;
            m_client = new GojiWCFStreamingBase(p);

            textBox1.Text = Properties.Settings.Default.FieldIpAddress;
            textBox7.Text = Properties.Settings.Default.FieldComputerUserName;
            textBox6.Text = Properties.Settings.Default.FieldComputerPassword;

            textBox4.Text           = Properties.Settings.Default.StorageServerUserName;
            textBox5.Text           = Properties.Settings.Default.StorageServerPassword;
            textBox2.Text           = Properties.Settings.Default.FieldDirectoryToMinotor;
            textBox3.Text           = Properties.Settings.Default.StorageDirectoryToUpload;
            comboBox1.SelectedIndex = Properties.Settings.Default.UploadMode;
            textBox10.Text          = Properties.Settings.Default.DeleteAllUploadedFilesTimer;
            textBox12.Text          = Properties.Settings.Default.uploadWrongFilesDirectory;
            textBox13.Text          = Properties.Settings.Default.SyncDirectory;
            checkBox4.Checked       = Properties.Settings.Default.RecoursiveSync;
            textBox14.Text          = Properties.Settings.Default.OperatorUserName;
            checkBox6.Checked       = Properties.Settings.Default.OperationsByUser;
            button14.Enabled        = false;

            try
            {
                MapNetworkDrives();
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }


            NetCard.NetCard n      = new NetCard.NetCard();
            string          baseIp = n.getComputerIP();

            if (baseIp == "0.0.0.0")
            {
                clsRegistry reg = new clsRegistry();
                string      bip = reg.GetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Base", "IpAddress");
                if (reg.strRegError == null)
                {
                    baseIp    = bip;
                    this.Text = "Goji Field uploaded managment " + baseIp;
                }
                else
                {
                    MessageBox.Show("You need to specify the base ip address in the registry");
                    GetManualIpAddress g = new GetManualIpAddress();
                    g.ShowDialog();
                    if (g.DialogResult == System.Windows.Forms.DialogResult.OK)
                    {
                        baseIp    = g.IpAddress;
                        this.Text = "Goji Field uploaded managment " + baseIp;
                        reg.SetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Base", "IpAddress", baseIp);
                    }
                    return;
                }
            }
            else
            {
                this.Text = "Goji Field uploaded managment " + baseIp;
            }
        }
Ejemplo n.º 10
0
        private void checkBox9_CheckedChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == -1)
            {
                MessageBox.Show("please select upload type");
                return;
            }
            if (checkBox1.Checked == true)
            {
                if (comboBox1.SelectedIndex == 0)
                {
                    try
                    {
                        clsRegistry reg = new clsRegistry();
                        m_baseGuid = reg.GetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Base", "Guid");
                        if (reg.strRegError != null)
                        {
                            m_baseGuid = Guid.NewGuid().ToString();
                            reg.SetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Base", "Guid", m_baseGuid);
                        }

                        string guid = m_client.GetClientGuid();
                        m_client.StartTCPStreamingServer(1024 * 1024 * 10, 5005);

                        NetCard.NetCard n      = new NetCard.NetCard();
                        string          baseIp = n.getComputerIP();
                        if (baseIp == "0.0.0.0")
                        {
                            string bip = reg.GetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Base", "IpAddress");
                            if (reg.strRegError == null)
                            {
                                baseIp = bip;
                            }
                            else
                            {
                                MessageBox.Show("You need to specify the base ip address in the registry");
                                return;
                            }
                        }
                        if (SetCopyTimerEvent() == false)
                        {
                            return;
                        }
                        m_client.OpenTCPStreamingClient(baseIp, textBox4.Text, textBox5.Text);
                        button14.Enabled = true;
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show(err.Message);
                    }
                }
                else
                {
                }
                checkBox1.ForeColor = System.Drawing.Color.Green;
            }
            else
            {
                checkBox1.ForeColor = System.Drawing.Color.Red;
            }
        }