Example #1
0
        /// <summary>
        /// 检查组是否合法
        /// </summary>
        /// <param name="smmuser">组</param>
        /// <param name="strErr">错误信息</param>
        /// <param name="isnew">是否新记录</param>
        /// <returns>True合法</returns>
        public static bool Check(Smmgroup data, ref string strErr, bool isnew)
        {
            if (string.IsNullOrEmpty(data.Groupno))
            {
                strErr = "组号不能为空!";
                return(false);
            }
            if (string.IsNullOrEmpty(data.Groupname))
            {
                strErr = "组名不能为空!";
                return(false);
            }
            //如是新增组,检查组号是否存在
            if (isnew)
            {
                IBaseService service = RemotingHelper.GetRemotingService <IBaseService>();
                Smmgroup     group1  = service.GetOneByKey <Smmgroup>(data.Groupno);
                if (group1 != null)
                {
                    strErr = "已经存在组号为[" + data.Groupno + "]的组.";
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
        private void gridControl_Load(object sender, EventArgs e)
        {
            //RefreshData();

            if (!visu)
            {
                colCreater.Visible = false;
                colRemark.Visible  = false;
            }


            try
            {
                //string fileName = Application.StartupPath + @"\Itop.exe.config";
                //if (!System.IO.File.Exists(fileName)) return;



                //Configuration config = null;
                //config = ConfigurationManager.OpenExeConfiguration(fileName);

                //string serverAddress = config.AppSettings.Settings["serverAddress"].Value;
                //string serverPort = config.AppSettings.Settings["serverPort"].Value;
                //string serverProtocol = config.AppSettings.Settings["serverProtocol"].Value;

                Itop.Server.Interface.IConfigService ic = RemotingHelper.GetRemotingService <Itop.Server.Interface.IConfigService>();
                Itop.Domain.DataConfig dc = ic.GetDataConfig();

                IniWriteValue("数据库", "连接", "Provider=SQLOLEDB.1;Password="******";Persist Security Info=True;User ID=" + dc.Userid + ";Initial Catalog=" + dc.Database + ";Data Source=" + dc.Datasource + ";");
                ;
            }
            catch { }
        }
Example #3
0
        /// <summary>
        /// 检查用户是否合法
        /// </summary>
        /// <param name="smmuser">用户</param>
        /// <param name="strErr">错误信息</param>
        /// <param name="isnew">是否新记录</param>
        /// <returns>True合法</returns>
        public static bool Check(Smmuser smmuser, ref string strErr, bool isnew)
        {
            if (string.IsNullOrEmpty(smmuser.Userid))
            {
                strErr = "用户号不能为空!";
                return(false);
            }
            if (string.IsNullOrEmpty(smmuser.UserName))
            {
                strErr = "用户名不能为空!";
                return(false);
            }
            //如是新增记录,检查用户号是否存在
            if (isnew)
            {
                IBaseService service = RemotingHelper.GetRemotingService <IBaseService>();
                Smmuser      user1   = service.GetOneByKey <Smmuser>(smmuser.Userid);
                if (user1 != null)
                {
                    strErr = "已经存在用户号为[" + smmuser.Userid + "]的用户.";
                    return(false);
                }
            }

            return(true);
        }
Example #4
0
        static public bool Exec(bool closeMainForm)
        {
            if (closeMainForm)
            {
                MIS.MainForm.Close();
            }
            else
            {
                ILoginAction loginAction = RemotingHelper.GetRemotingService <ILoginAction>();
                if (loginAction == null)
                {
                    return(false);
                }

                try {
                    //MIS.WriteApplicationLog("系统", "退出系统");
                    //IMainMenuAction m = RemotingHelper.GetRemotingService<IMainMenuAction>();
                    //m.AddMenuClick(MIS.UserInfo, "Itop.Client.dll", "Itop.Client.Login.UserLogoutCommand", "Execute", -1);
                    loginAction.Out(MIS.Token, MIS.UserNumber);
                    MIS.Token = string.Empty;
                } catch (System.Net.Sockets.SocketException ex) {
                    MIS.WriteExceptionLog(ex.Message);
                    return(false);
                }
            }

            return(true);
        }
Example #5
0
        public DataSet GetData()
        {
            IMainMenuAction mainMenuAction = RemotingHelper.GetRemotingService <IMainMenuAction>();

            if (mainMenuAction == null)
            {
                return(null);
            }

            return(mainMenuAction.GetMainMenuDataSet(MIS.UserInfo));
        }
Example #6
0
        internal static void Create(ToolStripItemCollection items)
        {
            IBaseService service = RemotingHelper.GetRemotingService <IBaseService>();

            IList list = service.GetList <Smmprog>();

            DataTable table = DataConverter.ToDataTable(list, typeof(Smmprog));

            ClearMenu(items);
            CreateSubmenu(items, table, string.Empty);
        }
Example #7
0
 /// <summary>
 /// 获得系统参数
 /// </summary>
 /// <param name="propName">参数名称</param>
 /// <returns>参数值</returns>
 static public string Property(string propName)
 {
     if (m_props.ContainsKey(propName))
     {
         return(m_props[propName]);
     }
     else
     {
         IAppPropAction appPropAction = RemotingHelper.GetRemotingService <IAppPropAction>();
         string         result        = appPropAction.GetAppProperty(propName);
         m_props.Add(propName, result);
         return(result);
     }
 }
Example #8
0
        /// <summary>
        /// 建创修改ODBC
        /// </summary>

        public static void CreateODBC()
        {
            Itop.Server.Interface.IConfigService service = RemotingHelper.GetRemotingService <Itop.Server.Interface.IConfigService>();
            DataConfig  data = service.GetDataConfig();
            RegistryKey key  = Registry.CurrentUser.CreateSubKey(@"Software\ODBC\ODBC.INI\ODBC Data Sources");

            key.SetValue("BZHZY", "SQL Server");
            key.Close();
            key = Registry.CurrentUser.CreateSubKey(@"Software\ODBC\ODBC.INI\BZHZY");
            key.SetValue("Driver", Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\SQLSRV32.dll");
            key.SetValue("Server", data.Datasource);
            key.SetValue("Database", data.Database);
            key.SetValue("LastUser", data.Userid);
            key.Close();
            SetSystemIni(data);
        }
Example #9
0
        static private string GetUserName()
        {
            if (UserNumber == string.Empty)
            {
                return(string.Empty);
            }

            string       result      = string.Empty;
            ILoginAction loginAction = RemotingHelper.GetRemotingService <ILoginAction>();

            if (loginAction != null)
            {
                result = loginAction.GetUserName(UserInfo, UserNumber);
            }

            return(result);
        }
Example #10
0
        /// <summary>
        /// 菜单调用
        /// </summary>
        static public void Click(string assemblyName, string className, string methodName, int objId)
        {
            if (string.IsNullOrEmpty(assemblyName) || string.IsNullOrEmpty(className) ||
                string.IsNullOrEmpty(methodName))
            {
                return;
            }

            // 调用方法
            string[] paramValue = (objId == -1) ? new string[0] : new string[] { objId.ToString() };
            bool     result     = (bool)MethodInvoker.Execute(assemblyName, className, methodName, paramValue);

            if (result && MIS.Token != string.Empty)
            {
                //记录菜单点击次数
                IMainMenuAction m = RemotingHelper.GetRemotingService <IMainMenuAction>();
                m.AddMenuClick(MIS.UserInfo, assemblyName, className, methodName, objId);
                MIS.MainFormInterface.RefreshRecentMenu();
            }
        }
Example #11
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);
            }
        }
Example #12
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;
            }
        }
Example #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));
        }
Example #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);
        }