Exemple #1
0
        void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            bool dataFlag = false;
            bool fileFlag = false;

            if (ConfigManager.SaveWcfConfig(ConfigConst.WcfData,
                                            this.tbServerIp.Caption.Trim() + ":" + this.tbServerPort.Caption.Trim()))
            {
                ConfigurationManager.RefreshSection("system.serviceModel/behaviors");
                ConfigurationManager.RefreshSection("system.serviceModel/bindings");
                ConfigurationManager.RefreshSection("system.serviceModel/client");
                ConfigurationManager.RefreshSection("system.serviceModel/services");

                GlobalStaticObj.channelFactory = null;

                if (WCFClientProxy.TestDataProxy())
                {
                    dataFlag = true;
                    GlobalStaticObj.DataServerIp = this.tbServerIp.Caption.Trim();
                    GlobalStaticObj.DataPort     = int.Parse(this.tbServerPort.Caption.Trim());
                }
                else
                {
                    this.tbServerIp.Caption   = GlobalStaticObj.DataServerIp;
                    this.tbServerPort.Caption = GlobalStaticObj.DataPort.ToString();
                    ConfigManager.SaveWcfConfig(ConfigConst.WcfData,
                                                this.tbServerIp.Caption.Trim() + ":" + this.tbServerPort.Caption.Trim());
                }
            }

            if (ConfigManager.SaveWcfConfig(ConfigConst.WcfFile,
                                            this.tbFileServerIp.Caption.Trim() + ":" + this.tbFilePort.Caption.Trim()))
            {
                ConfigurationManager.RefreshSection("system.serviceModel/behaviors");
                ConfigurationManager.RefreshSection("system.serviceModel/bindings");
                ConfigurationManager.RefreshSection("system.serviceModel/client");
                ConfigurationManager.RefreshSection("system.serviceModel/services");

                GlobalStaticObj.channelFactoryFile = null;

                if (WCFClientProxy.TestFileProxy())
                {
                    fileFlag = true;
                    GlobalStaticObj.FileServerIp = this.tbFileServerIp.Caption.Trim();
                    GlobalStaticObj.FilePort     = int.Parse(this.tbFilePort.Caption.Trim());
                }
                else
                {
                    this.tbFileServerIp.Caption = GlobalStaticObj.FileServerIp;
                    this.tbFilePort.Caption     = GlobalStaticObj.FilePort.ToString();
                    //恢复原来的连接
                    ConfigManager.SaveWcfConfig(ConfigConst.WcfFile,
                                                this.tbFileServerIp.Caption.Trim() + ":" + this.tbFilePort.Caption.Trim());
                }
            }

            Tuple <bool, bool> E = new Tuple <bool, bool>(dataFlag, fileFlag);

            e.Result = E;
        }
        /// <summary>
        /// Inits the façade with declarative data taken from the application configuration
        /// file (app.config).
        /// </summary>
        /// <param name="operationServiceEndpointName">Name of the configuration of the
        /// file system operation service to be used.</param>
        /// <param name="readerServiceEndpointName">Name of the configuration of the
        /// data reader service to be used.</param>
        /// <param name="writerServiceEndpointName">Name of the configuration of the
        /// data writer service to be used.</param>
        public FileSystemFacade(string operationServiceEndpointName, string readerServiceEndpointName,
                                string writerServiceEndpointName)
        {
            OperationService = WCFClientProxy <IFSOperationService> .GetReusableInstance(operationServiceEndpointName);

            ReaderService = WCFClientProxy <IFSReaderService> .GetReusableInstance(readerServiceEndpointName);

            WriterService = WCFClientProxy <IFSWriterService> .GetReusableInstance(writerServiceEndpointName);
        }
Exemple #3
0
        public void Updater(string DurationCode)
        {
            Tazeyab.Common.IBaseServer baseservice = WCFClientProxy <Tazeyab.Common.IBaseServer> .GetReusableInstance("WSHttpBinding_IBaseServer");

            ClientUpdater updater           = new ClientUpdater(baseservice, null);
            var           updaterbyduration = new Task(() => { updater.UpdateFromServerByTimer(string.IsNullOrEmpty(DurationCode) ? Config.getConfig <string>("DefaultDurationCode") : DurationCode); });

            updaterbyduration.Start();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            var proxy = WCFClientProxy <IFSOperationService> .GetReusableInstance("operationService");

            bool available = proxy.IsFileAvailable("/root/hello.txt");

            ReaderClient client = new ReaderClient();

            client.WriteRootFolders();

            Console.ReadLine();
        }
Exemple #5
0
        public string Execution(CommandList command)
        {
            if (command == CommandList.StartUpdater)
            {
                if (!(Tazeyab.Common.Updater.BaseUpdater.UpdatersIsRun() == Tazeyab.Common.Models.Enums.UpdaterList.UpdaterClient))
                {
                    Tazeyab.Common.IBaseServer baseservice = WCFClientProxy <Tazeyab.Common.IBaseServer> .GetReusableInstance("WSHttpBinding_IBaseServer");

                    ClientUpdater updater = new ClientUpdater(baseservice, null);
                    new Task(() => { updater.AutoUpdateFromServer(); }).Start();
                    Tazeyab.Common.EventsLog.GeneralLogs.WriteLog("Run  updater.AutoUpdateAsService", TypeOfLog.Start);
                    return("Start AutoUpdater");
                }
                else
                {
                    Tazeyab.Common.EventsLog.GeneralLogs.WriteLog("StopUpdating==false(Updater is running...)", TypeOfLog.Info);
                }

                return("Updater is running");
            }
            else if (command == CommandList.NoneStopUpdater)
            {
                Tazeyab.Common.IBaseServer baseservice = WCFClientProxy <Tazeyab.Common.IBaseServer> .GetReusableInstance("WSHttpBinding_IBaseServer");

                ClientUpdater updater = new ClientUpdater(baseservice, null);
                updater.NoneStopUpdateFromServer(Config.getConfig("DefaultDurationCode"));
            }
            else if (command == CommandList.UpdaterByTimer)
            {
                Tazeyab.Common.IBaseServer baseservice = WCFClientProxy <Tazeyab.Common.IBaseServer> .GetReusableInstance("WSHttpBinding_IBaseServer");

                ClientUpdater updater = new ClientUpdater(baseservice, null);
                updater.UpdateFromServerByTimer(Config.getConfig <string>("DefaultDurationCode"));
            }
            else if (command == CommandList.SetIcon)
            {
                Tazeyab.CrawlerEngine.SiteImprovement.SiteIcon.StartSetSiteIcons(0);
            }
            else if (command == CommandList.UpdateNewsPaper)
            {
                Tazeyab.CrawlerEngine.Updater.NewsPaperUpdater updater = new NewsPaperUpdater();
                updater.Start(new Tazeyab.Common.Models.StartUp()
                {
                    StartUpConfig = "NewsPaper"
                });
                updater.UploadNewsPaperImgToFtp();
            }
            return(string.Empty);
        }
 /// <summary>
 /// 下载文件
 /// </summary>
 /// <param name="fileName">文件名称</param>
 /// <returns>文件流</returns>
 public static Stream DownLoadFileByStream(string fileName, string path)
 {
     if (fileName.Length == 0)
     {
         return(null);
     }
     if (!WCFClientProxy.TestPCClientProxy())
     {
         return(null);
     }
     try
     {
         Stream stream = GlobalStaticObj.proxyFile.DownLoadFile(fileName, path, GlobalStaticObj.UserID, GlobalStaticObj.CookieStr);
         return(stream);
     }
     catch (Exception te)
     {
         return(null);
     }
 }
Exemple #7
0
        private void FormLogin_Load(object sender, EventArgs e)
        {
            this.dtDb = new DataTable();
            this.dtDb.Columns.Add("DisplayName");
            this.dtDb.Columns.Add("Name");
            this.dtDb.Columns.Add("Value");
            this.dtDb.Columns.Add("Code");
            this.dtDb.Columns.Add("Status");
            this.uiHandler -= new UiHandler(this.ShowAccData);
            this.uiHandler += new UiHandler(this.ShowAccData);

            //初始化Wcf
            WCFClientProxy.CreatePCClientProxy();

            //加载帐套信息
            ThreadPool.QueueUserWorkItem(new WaitCallback(this._LoadAccData));

            //初始化配置
            LocalVariable.Init();

            //加载登录记忆
            this.LoadMemery();
        }
Exemple #8
0
        private void panelYes_Click(object sender, EventArgs e)
        {
            this.errorProvider.Clear();

            if (string.IsNullOrEmpty(this.tbServerIp.Caption.Trim()))
            {
                Utility.Common.Validator.SetError(this.errorProvider, this.tbServerIp, "数据服务器Ip不能为空!");
                return;
            }
            if (!InetetTest(this.tbServerIp.Caption.Trim(), 100))
            {
                FormMessgeBox.ShowMsg(this, "数据服务器地址无法连接!", this.panelTop.BackColor);
                return;
            }
            if (string.IsNullOrEmpty(this.tbServerPort.Caption.Trim()))
            {
                Utility.Common.Validator.SetError(this.errorProvider, this.tbServerPort, "数据服务端口不能为空!");
                return;
            }

            if (string.IsNullOrEmpty(this.tbFileServerIp.Caption.Trim()))
            {
                Utility.Common.Validator.SetError(this.errorProvider, this.tbFileServerIp, "文件服务器Ip不能为空!");
                return;
            }
            if (!InetetTest(this.tbFileServerIp.Caption.Trim(), 100))
            {
                FormMessgeBox.ShowMsg(this, "文件服务器地址无法连接!", this.panelTop.BackColor);
                return;
            }
            if (string.IsNullOrEmpty(this.tbFilePort.Caption.Trim()))
            {
                Utility.Common.Validator.SetError(this.errorProvider, this.tbFilePort, "文件服务端口不能为空!");
                return;
            }

            bool dataFlag = false;
            bool fileFlag = false;

            if (ConfigManager.SaveWcfConfig(ConfigConst.WcfData,
                                            this.tbServerIp.Caption.Trim() + ":" + this.tbServerPort.Caption.Trim()))
            {
                ConfigurationManager.RefreshSection("system.serviceModel/behaviors");
                ConfigurationManager.RefreshSection("system.serviceModel/bindings");
                ConfigurationManager.RefreshSection("system.serviceModel/client");
                ConfigurationManager.RefreshSection("system.serviceModel/services");

                GlobalStaticObj.channelFactory = null;

                if (WCFClientProxy.TestDataProxy())
                {
                    dataFlag = true;
                    GlobalStaticObj.DataServerIp = this.tbServerIp.Caption.Trim();
                    GlobalStaticObj.DataPort     = int.Parse(this.tbServerPort.Caption.Trim());
                }
                else
                {
                    this.tbServerIp.Caption   = GlobalStaticObj.DataServerIp;
                    this.tbServerPort.Caption = GlobalStaticObj.DataPort.ToString();
                    ConfigManager.SaveWcfConfig(ConfigConst.WcfData,
                                                this.tbServerIp.Caption.Trim() + ":" + this.tbServerPort.Caption.Trim());
                }
            }

            if (ConfigManager.SaveWcfConfig(ConfigConst.WcfFile,
                                            this.tbFileServerIp.Caption.Trim() + ":" + this.tbFilePort.Caption.Trim()))
            {
                ConfigurationManager.RefreshSection("system.serviceModel/behaviors");
                ConfigurationManager.RefreshSection("system.serviceModel/bindings");
                ConfigurationManager.RefreshSection("system.serviceModel/client");
                ConfigurationManager.RefreshSection("system.serviceModel/services");

                GlobalStaticObj.channelFactoryFile = null;

                if (WCFClientProxy.TestFileProxy())
                {
                    fileFlag = true;
                    GlobalStaticObj.FileServerIp = this.tbFileServerIp.Caption.Trim();
                    GlobalStaticObj.FilePort     = int.Parse(this.tbFilePort.Caption.Trim());
                }
                else
                {
                    this.tbFileServerIp.Caption = GlobalStaticObj.FileServerIp;
                    this.tbFilePort.Caption     = GlobalStaticObj.FilePort.ToString();
                    //恢复原来的连接
                    ConfigManager.SaveWcfConfig(ConfigConst.WcfFile,
                                                this.tbFileServerIp.Caption.Trim() + ":" + this.tbFilePort.Caption.Trim());
                }
            }

            if (dataFlag && fileFlag)
            {
                FormMessgeBox.ShowMsg(this, "数据、文件通讯服务连接测试成功!", this.panelTop.BackColor);
                this.Close();
            }
            else
            {
                if (dataFlag)
                {
                    FormMessgeBox.ShowMsg(this, "数据通讯服务连接测试成功,\r\n文件通讯服务连接测试失败!", this.panelTop.BackColor);
                    //if (this.RefreshDataStart != null)
                    //{
                    //    this.RefreshDataStart();
                    //}
                }
                else if (fileFlag)
                {
                    FormMessgeBox.ShowMsg(this, "数据通讯服务连接测试失败,\r\n文件通讯服务连接测试成功!", this.panelTop.BackColor);
                }
                else
                {
                    FormMessgeBox.ShowMsg(this, "数据、文件通讯服务连接测试失败!", this.panelTop.BackColor);
                }
            }
        }
Exemple #9
0
        private void panelYes_Click(object sender, EventArgs e)
        {
            this.errorProvider.Clear();

            if (string.IsNullOrEmpty(this.tbServerIp.Caption.Trim()))
            {
                Utility.Common.Validator.SetError(this.errorProvider, this.tbServerIp, "数据服务器Ip不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(this.tbServerPort.Caption.Trim()))
            {
                Utility.Common.Validator.SetError(this.errorProvider, this.tbServerPort, "数据服务端口不能为空!");
                return;
            }

            if (string.IsNullOrEmpty(this.tbFileServerIp.Caption.Trim()))
            {
                Utility.Common.Validator.SetError(this.errorProvider, this.tbFileServerIp, "文件服务器Ip不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(this.tbFilePort.Caption.Trim()))
            {
                Utility.Common.Validator.SetError(this.errorProvider, this.tbFilePort, "文件服务端口不能为空!");
                return;
            }

            bool dataFlag = false;
            bool fileFlag = false;

            if (ConfigManager.SaveWcfConfig(ConfigConst.WcfData,
                                            this.tbServerIp.Caption.Trim() + ":" + this.tbServerPort.Caption.Trim()))
            {
                if (WCFClientProxy.TestDataProxy())
                {
                    dataFlag = true;
                    GlobalStaticObj.DataServerIp = this.tbServerIp.Caption.Trim();
                    GlobalStaticObj.DataPort     = int.Parse(this.tbServerPort.Caption.Trim());
                }
                else
                {
                    this.tbServerIp.Caption   = GlobalStaticObj.DataServerIp;
                    this.tbServerPort.Caption = GlobalStaticObj.DataPort.ToString();
                    ConfigManager.SaveWcfConfig(ConfigConst.WcfData,
                                                this.tbServerIp.Caption.Trim() + ":" + this.tbServerPort.Caption.Trim());
                }
            }


            if (ConfigManager.SaveWcfConfig(ConfigConst.WcfFile,
                                            this.tbFileServerIp.Caption.Trim() + ":" + this.tbFilePort.Caption.Trim()))
            {
                if (WCFClientProxy.TestFileProxy())
                {
                    fileFlag = true;
                    GlobalStaticObj.FileServerIp = this.tbFileServerIp.Caption.Trim();
                    GlobalStaticObj.FilePort     = int.Parse(this.tbFilePort.Caption.Trim());
                }
                else
                {
                    this.tbFileServerIp.Caption = GlobalStaticObj.FileServerIp;
                    this.tbFilePort.Caption     = GlobalStaticObj.FilePort.ToString();
                    //恢复原来的连接
                    ConfigManager.SaveWcfConfig(ConfigConst.WcfFile,
                                                this.tbFileServerIp.Caption.Trim() + ":" + this.tbFilePort.Caption.Trim());
                }
            }

            if (dataFlag && fileFlag)
            {
                if (this.RefreshDataStart != null)
                {
                    this.RefreshDataStart();
                }
                FormMessgeBox.ShowMsg(this, "数据、文件通讯服务连接测试成功!", this.panelTop.BackColor);
                this.Close();
            }
            else
            {
                if (dataFlag)
                {
                    FormMessgeBox.ShowMsg(this, "数据通讯服务连接测试成功,文件通讯服务连接测试失败!", this.panelTop.BackColor);
                    if (this.RefreshDataStart != null)
                    {
                        this.RefreshDataStart();
                    }
                }
                else if (fileFlag)
                {
                    FormMessgeBox.ShowMsg(this, "数据通讯服务连接测试失败,文件通讯服务连接测试成功!", this.panelTop.BackColor);
                }
                else
                {
                    FormMessgeBox.ShowMsg(this, "数据、文件通讯服务连接测试失败!", this.panelTop.BackColor);
                }
            }
        }