Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Configuring client...");
            RemotingConfiguration.Configure("ClientConsole2.exe.config");

            Console.WriteLine("Creating proxy...");
            IRemoteFactory2 factory = (IRemoteFactory2)RemotingHelper.CreateProxy(typeof(IRemoteFactory2));

            Console.WriteLine("Calling GetAge()...");
            int age = factory.GetAge();

            Console.WriteLine(">> Call successful: " + age.ToString());

            Console.WriteLine("Calling SetAge()...");
            factory.SetAge(age * 2);
            Console.WriteLine(">> Call successful!");

            Console.WriteLine("Calling GetPerson()...");
            Person p = factory.GetPerson();

            Console.WriteLine(">> Person retrieved: {0} {1}, {2}", p.Firstname, p.Lastname, p.Age.ToString());

            Console.ReadLine();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates and configures a Remoting channel.
        /// </summary>
        /// <returns>Remoting channel</returns>
        public override IChannel CreateChannel()
        {
            var channel = ChannelServices.GetChannel(_channelName);

            if (channel == null)
            {
                _channelSettings["name"]     = _channelName;
                _channelSettings["portName"] = "zyan_" + Guid.NewGuid().ToString();
                if (!_channelSettings.ContainsKey("authorizedGroup"))
                {
                    _channelSettings["authorizedGroup"] = AuthorizedGroup;
                }

                if (!_channelSettings.ContainsKey("exclusiveAddressUse"))
                {
                    _channelSettings["exclusiveAddressUse"] = ExclusiveAddressUse;
                }

                _channelSettings["secure"] = _useWindowsSecurity;
                if (_useWindowsSecurity)
                {
                    _channelSettings["tokenImpersonationLevel"] = _impersonationLevel;
                    _channelSettings["protectionLevel"]         = _protectionLevel;
                }

                if (_channelFactory == null)
                {
                    throw new ApplicationException(LanguageResource.ApplicationException_NoChannelFactorySpecified);
                }

                channel = _channelFactory(_channelSettings, BuildClientSinkChain(), BuildServerSinkChain());
                RemotingHelper.ResetCustomErrorsMode();
            }

            return(channel);
        }
        /// <summary>
        /// Creates and configures a Remoting channel.
        /// </summary>
        /// <returns>Remoting channel</returns>
        public override IChannel CreateChannel()
        {
            IChannel channel = ChannelServices.GetChannel(_channelName);

            if (channel == null)
            {
                _channelSettings["name"]   = _channelName;
                _channelSettings["port"]   = _httpPort;
                _channelSettings["secure"] = false;

                ConfigureEncryption();
                ConfigureCompression();

                if (_channelFactory == null)
                {
                    throw new ApplicationException(LanguageResource.ApplicationException_NoChannelFactorySpecified);
                }

                channel = _channelFactory(_channelSettings, BuildClientSinkChain(), BuildServerSinkChain());
                RemotingHelper.ResetCustomErrorsMode();
            }

            return(channel);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 设置远程服务器站点的IP地址。
 /// </summary>
 /// <param name="name">服务器站点IP地址。</param>
 public static void SelectServerIP(string IP)
 {
     RemotingHelper.SelectServerIP(IP);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 根据服务器名称选择远程服务器站点的IP地址。
 /// </summary>
 /// <param name="name">服务器名称。</param>
 public static void SelectServerSite(string name)
 {
     RemotingHelper.SelectServerSite(name);
 }
Exemplo n.º 6
0
        protected void _sendPing_Command(object sender, CommandEventArgs e)
        {
            IPingService service = (IPingService)RemotingHelper.GetObject(typeof(IPingService));

            _pingReturn.Text = service.Ping();
        }
Exemplo n.º 7
0
        public async Task <ActionResult <List <string> > > GetAll(string appName, string serviceName, string partitionKey)
        {
            var service = RemotingHelper.GetStatefulServiceHandler(appName, serviceName, partitionKey);

            return(await service.QueryState(null));
        }
Exemplo n.º 8
0
 public override void ConnectApplications()
 {
     RemotingHelper.ConnectDecelerationHardwareControl();
 }
Exemplo n.º 9
0
 public IntermedImpl()
 {
     _server = (IRemoteFactory)RemotingHelper.CreateProxy(typeof(IRemoteFactory));
 }
Exemplo n.º 10
0
 static void Main(string[] args)
 {
     RemotingHelper.RemotingServiceInitialize();
     Console.WriteLine("Ready....");
     Console.ReadLine();
 }
Exemplo n.º 11
0
        /// <summary>
        /// 执行登录
        /// </summary>
        private void DoLogin()
        {
            if (utxtuser.tbox.Text == string.Empty)
            {
                MsgBox.Show("工号没有输入");
                utxtuser.Focus();
                return;
            }

            ILoginAction loginAction = RemotingHelper.GetRemotingService <ILoginAction>();

            if (loginAction == null)
            {
                MsgBox.Show("ILoginAction没有被正确注册");
                return;
            }

            string      token;
            string      userNumber = utxtuser.tbox.Text.Trim();
            string      password   = utxtpwd.tbox.Text;
            LoginData   data       = new LoginData(userNumber, password);
            LoginStatus status;

            try {
                loginAction.Login(data, out token, out status);
            } catch (System.Net.Sockets.SocketException) {
                MsgBox.Show("无法连接服务器,请稍候重试");
                utxtpwd.tbox.Focus();
                return;
            }
            switch (status)
            {
            case LoginStatus.OK:
                if (m_reLogin)
                {
                    // 原来的用户退出
                    if (!UserLogoutCommand.Exec(false))
                    {
                        MsgBox.Show("无法连接服务器,请稍候重试");
                        utxtpwd.tbox.Focus();
                        return;
                    }

                    //MIS.WriteApplicationLog("系统", "退出系统");
                }
                DialogResult   = DialogResult.OK;
                MIS.Token      = token;
                MIS.UserNumber = data.UserNumber;
                //MIS.WriteApplicationLog("系统", "登录系统");

                // 记录最近一次登录的用户的工号
                Itop.Client.Option.Settings.SetLastLoginUserNumber(userNumber);

                break;

            case LoginStatus.InvalidUser:
                MsgBox.Show("工号输入错误");
                utxtuser.tbox.Focus();
                break;

            case LoginStatus.InvalidPassword:
                if (m_error.ContainsKey(userNumber))
                {
                    // 错误加一
                    m_error[userNumber]++;
                }
                else
                {
                    // 第一次错误
                    m_error.Add(userNumber, 1);
                }

                if (m_error[userNumber] >= 3)
                {
                    if (!m_reLogin)
                    {
                        MsgBox.Show("密码输入错误次数超过三次,无法登录系统");
                        CloseServer();
                        Application.Exit();
                    }
                    else
                    {
                        MsgBox.Show("密码输入错误次数超过三次,请稍候重试");
                        DialogResult = DialogResult.Cancel;
                    }
                }
                else
                {
                    MsgBox.Show("密码输入错误,请重新输入密码");
                }
                utxtpwd.tbox.Text = "";
                utxtpwd.tbox.Focus();
                break;

            default:
                break;
            }
        }
Exemplo n.º 12
0
 public void Init(HttpApplication context)
 {
     RemotingHelper.RemotingServiceInitialize();
 }
Exemplo n.º 13
0
        /// <summary>
        /// 判断是否具有某个权限
        /// </summary>
        /// <param name="actionId">Action Id</param>
        /// <returns></returns>
        public static bool HasRight(string actionId)
        {
            IRightsAction ra = RemotingHelper.GetRemotingService <IRightsAction>();

            return(ra.HasRight(UserInfo, actionId));
        }
Exemplo n.º 14
0
        /// <summary>
        /// 记录日志
        /// </summary>
        /// <param name="moduleName">模块名称</param>
        /// <param name="info">日志内容</param>
        public static void WriteApplicationLog(string moduleName, string info)
        {
            ISysLogAction sl = RemotingHelper.GetRemotingService <ISysLogAction>();

            sl.WriteLog(UserInfo, moduleName, info);
        }
Exemplo n.º 15
0
 protected virtual void RegisterRemotingObject(string configFile)
 {
     RemotingHelper.RegisterRemotingObject(configFile);
 }
Exemplo n.º 16
0
        /// <summary>
        /// 根据服务器名称获取远程服务器站点的IP地址。
        /// </summary>
        /// <param name="name">服务器名称。</param>
        /// <returns>服务器站点的IP地址。</returns>
        public static string GetServerIP(string name)
        {
            string serverIP = RemotingHelper.GetServerIP(name);

            return(serverIP);
        }
Exemplo n.º 17
0
        /// <summary>
        /// 获取正在使用的服务器站点的IP地址。
        /// </summary>
        /// <returns>服务器站点的IP地址。</returns>
        public static string GetUsingServerIP()
        {
            string usingServerIP = RemotingHelper.GetUsingServerIP();

            return(usingServerIP);
        }
Exemplo n.º 18
0
        //private static IOraService oraService;

        //public static IOraService OraService
        //{
        //    get
        //    {
        //        if (oraService == null)
        //        {
        //            oraService = RemotingHelper.GetRemotingService<IOraService>();
        //        }
        //        if (oraService == null) MsgBox.Show("服务没有注册");
        //        return OraService;
        //    }
        //}

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            IOraService OraService = RemotingHelper.GetRemotingService <IOraService>();

            try
            {
                FlashWindow frmLoad = new FlashWindow();
                //f.SetText("计算中请等待。");
                frmLoad.Show();
                frmLoad.RefleshStatus("计算中请等待...");
                //Application.DoEvents();
                frmLoad.SplashData();
                string str_sql  = "";
                string selYear  = year.Text;
                string selMonth = month.Text;

                string StartDate = "";
                string EndDate   = "";
                IList  list2     = new List <PSP_interface>();
                if (selMonth != "全部")
                {
                    StartDate = selYear + "-" + selMonth + "-01 00:00:00";
                    EndDate   = selYear + "-" + selMonth + "-31 23:59:59";
                    str_sql   = "select c.name,b.code,b.name,sum(case a.power_Type when 10 then a.total_value else 0 end),sum(case a.power_Type when 11 then a.total_value else 0 end) from mp_day_e" + selYear + " a,switch b,substation c " +
                                "where b.substation_id=c.id and b.id=a.mp_id and (a.power_Type='10' or a.power_Type='11') and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate +
                                "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name";


                    //con = GetConn();
                    DataSet d = OraService.GetDataSet(str_sql, connstr); // GetDataSet(str_sql);

                    for (int i = 0; i < d.Tables[0].Rows.Count; i++)
                    {
                        PSP_interface p = new PSP_interface();
                        p.UMonth = month.Text;
                        p.UYear  = Convert.ToInt32(year.Text);
                        if (Convert.IsDBNull(d.Tables[0].Rows[i][3]))
                        {
                            p.Number = 0;
                        }
                        else
                        {
                            p.Number = Convert.ToDouble(Math.Round(Convert.ToDouble(d.Tables[0].Rows[i][3]) / 10000, 2));
                        }
                        if (Convert.IsDBNull(d.Tables[0].Rows[i][4]))
                        {
                            p.col1 = "0";
                        }
                        else
                        {
                            p.col1 = Convert.ToString(Math.Round(Convert.ToDouble(d.Tables[0].Rows[i][4]) / 10000, 2));
                        }
                        p.Substation_Name = d.Tables[0].Rows[i][0].ToString();
                        p.Switch_Id       = d.Tables[0].Rows[i][1].ToString();
                        p.Switch_Name     = d.Tables[0].Rows[i][2].ToString();
                        p.UID             = Guid.NewGuid().ToString();
                        list2.Add(p);
                    }
                    str_sql = "select c.name,b.code,b.name,sum(a.value) from mp_measure" + selYear + selMonth + " a,switch b,substation c " +
                              "where b.substation_id=c.id and b.id=a.mp_id and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate +
                              "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name";
                    DataSet d2 = OraService.GetDataSet(str_sql, connstr);
                    for (int i = 0; i < d2.Tables[0].Rows.Count; i++)
                    {
                        PSP_interface p = new PSP_interface();
                        //p.UMonth = month.Text;
                        //p.UYear = Convert.ToInt32(year.Text);
                        //if (Convert.IsDBNull(d.Tables[0].Rows[i][3]))
                        //{
                        //    p.Number = 0;
                        //}
                        //else
                        //{
                        //    p.Number = Convert.ToDouble(d.Tables[0].Rows[i][3]);
                        //}
                        if (Convert.IsDBNull(d2.Tables[0].Rows[i][3]))
                        {
                            p.LoadValue = 0;
                        }
                        else
                        {
                            p.LoadValue = Convert.ToDouble(Math.Round(Convert.ToDouble(d2.Tables[0].Rows[i][3]), 2));
                        }
                        //p.Substation_Name = d.Tables[0].Rows[i][0].ToString();
                        //p.Switch_Id = d.Tables[0].Rows[i][1].ToString();
                        //p.Switch_Name = d.Tables[0].Rows[i][2].ToString();
                        //p.UID = Guid.NewGuid().ToString();
                        ((PSP_interface)list2[i]).LoadValue = p.LoadValue;;
                    }

                    ctrlglebeType1.GridControl.DataSource = list2;
                }
                else
                {
                    try
                    {
                        for (int n = 1; n < 13; n++)
                        {
                            string mm = n.ToString();
                            if (mm.Length < 2)
                            {
                                mm = "0" + mm;
                            }
                            StartDate = selYear + "-" + mm + "-01 00:00:00";
                            EndDate   = selYear + "-" + mm + "-31 23:59:59";
                            str_sql   = "select c.name,b.code,b.name,sum(case a.power_Type when 10 then a.total_value else 0 end),sum(case a.power_Type when 11 then a.total_value else 0 end) from mp_day_e" + selYear + " a,switch b,substation c " +
                                        "where b.substation_id=c.id and b.id=a.mp_id and (a.power_Type='10' or a.power_Type='11') and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate +
                                        "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name";
                            //con = GetConn();
                            DataSet d = OraService.GetDataSet(str_sql, connstr);
                            for (int i = 0; i < d.Tables[0].Rows.Count; i++)
                            {
                                PSP_interface p = new PSP_interface();
                                p.UMonth = mm;
                                p.UYear  = Convert.ToInt32(year.Text);
                                if (Convert.IsDBNull(d.Tables[0].Rows[i][3]))
                                {
                                    p.Number = 0;
                                }
                                else
                                {
                                    p.Number = Convert.ToDouble(Math.Round(Convert.ToDouble(d.Tables[0].Rows[i][3]) / 10000, 2));
                                }

                                if (Convert.IsDBNull(d.Tables[0].Rows[i][4]))
                                {
                                    p.col1 = "0";
                                }
                                else
                                {
                                    p.col1 = Convert.ToString(Math.Round(Convert.ToDouble(d.Tables[0].Rows[i][4]) / 10000, 2));
                                }
                                p.Substation_Name = d.Tables[0].Rows[i][0].ToString();
                                p.Switch_Id       = d.Tables[0].Rows[i][1].ToString();
                                p.Switch_Name     = d.Tables[0].Rows[i][2].ToString();
                                p.UID             = Guid.NewGuid().ToString();
                                list2.Add(p);
                            }
                            str_sql = "select c.name,b.code,b.name,sum(a.value) from mp_measure" + selYear + mm + " a,switch b,substation c " +
                                      "where b.substation_id=c.id and b.id=a.mp_id  and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate +
                                      "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name";
                            //con = GetConn();
                            DataSet d2 = OraService.GetDataSet(str_sql, connstr);
                            for (int i = 0; i < d2.Tables[0].Rows.Count; i++)
                            {
                                PSP_interface p = new PSP_interface();
                                //p.UMonth = mm;
                                //p.UYear = Convert.ToInt32(year.Text);
                                //if (Convert.IsDBNull(d.Tables[0].Rows[i][3]))
                                //{
                                //    p.Number = 0;
                                //}
                                //else
                                //{
                                //    p.Number = Convert.ToDouble(d.Tables[0].Rows[i][3]);
                                //}
                                if (Convert.IsDBNull(d2.Tables[0].Rows[i][3]))
                                {
                                    p.LoadValue = 0;
                                }
                                else
                                {
                                    p.LoadValue = Convert.ToDouble(Math.Round(Convert.ToDouble(d2.Tables[0].Rows[i][3]), 2));
                                }
                                //p.Substation_Name = d.Tables[0].Rows[i][0].ToString();
                                //p.Switch_Id = d.Tables[0].Rows[i][1].ToString();
                                //p.Switch_Name = d.Tables[0].Rows[i][2].ToString();
                                //p.UID = Guid.NewGuid().ToString();
                                ((PSP_interface)list2[i]).LoadValue = p.LoadValue;
                            }
                        }
                    }
                    catch (Exception ex) {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        ctrlglebeType1.GridControl.DataSource = list2;
                    }
                }
                if (list2.Count > 0)
                {
                }
                else
                {
                }
                frmLoad.Close();
            }
            catch (Exception e1) {
                MessageBox.Show("没有找到相关信息,请重新选择时间。" + e1.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 19
0
 public HttpRemotingHandlerFactory()
 {
     RemotingHelper.RemotingServiceInitialize();
 }
Exemplo n.º 20
0
 private IRemoteMonitorServer RemoteServer()
 {
     return((IRemoteMonitorServer)RemotingHelper.GetRemoteObject(typeof(IRemoteMonitorServer), "IRemoteTelephoneServer", ServerName()));
 }