Exemple #1
0
 /// <summary>
 /// 设置任务中的各种值,如员工名称、院系名称等
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 private Song.Entities.Task setEmployeeValue(Task entity)
 {
     //设置承接任务的员工名称
     Song.Entities.EmpAccount ea = Gateway.Default.From<EmpAccount>().Where(EmpAccount._.Acc_Id == entity.Task_WorkerId).ToFirst<EmpAccount>();
     if (ea != null) entity.Task_WorkerName = ea.Acc_Name;
     return entity;
 }
Exemple #2
0
        /// <summary>
        /// 将已经登录入的用户,写入seesion或cookies
        /// </summary>
        /// <param name="acc"></param>
        /// <param name="twoDomain">机构的二级域名,如果没有,则用机构id</param>
        public void Write(Song.Entities.EmpAccount acc, string twoDomain)
        {
            System.Web.HttpContext _context = System.Web.HttpContext.Current;
            //登录标识名
            string key = WeiSha.Common.Login.Get["Admin"].KeyName.String;

            key = twoDomain + "_" + key;
            if (Admin.LoginPattern == LoginPatternEnum.Cookies)
            {
                System.Web.HttpCookie cookie = new System.Web.HttpCookie(key);
                cookie.Value = acc.Acc_Id.ToString();
                string exp = WeiSha.Common.Login.Get["Admin"].Expires.String;
                //如果登录有效时间设置为auto,则默认为10分钟
                if (exp.Equals("auto", StringComparison.CurrentCultureIgnoreCase))
                {
                    cookie.Expires = DateTime.Now.AddDays(10);
                }
                else
                {
                    cookie.Expires = DateTime.Now.AddMinutes(WeiSha.Common.Login.Get["Admin"].Expires.Int32 ?? 10);
                }
                _context.Response.Cookies.Add(cookie);
            }
            if (Admin.LoginPattern == LoginPatternEnum.Session)
            {
                _context.Session[key] = acc.Acc_Id;
            }
            this._register(acc);
        }
Exemple #3
0
 /// <summary>
 /// 设置初始界面
 /// </summary>
 private void fill()
 {
     if (addrid > -1)
     {
         Song.Entities.AddressList addr = Business.Do <IAddressList>().AddressSingle(addrid);
         if (addr != null)
         {
             lbName.Text    = addr.Adl_Name;
             lbMobile.Text  = addr.Adl_MobileTel;
             lbCompany.Text = addr.Adl_Company;
         }
     }
     if (empid > -1)
     {
         Song.Entities.EmpAccount ea = Business.Do <IEmployee>().GetSingle(empid);
         lbName.Text    = ea.Acc_Name;
         lbMobile.Text  = ea.Acc_MobileTel;
         lbCompany.Text = ea.Dep_CnName;
     }
     if (smsid > -1)
     {
         Song.Entities.SmsMessage tm = Business.Do <ISMS>().GetSingle(smsid);
         tbContext.Text = tm.Sms_Context;
     }
 }
Exemple #4
0
 /// <summary>
 /// 添加在线人数
 /// </summary>
 /// <param name="acc"></param>
 public void OnlineUserAdd(Song.Entities.EmpAccount acc)
 {
     lock (_lock)
     {
         this._onlineUser.Add(acc);
     }
 }
Exemple #5
0
        /// <summary>
        /// 确定按钮的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnEnter_Click(object sender, EventArgs e)
        {
            //验证码错误
            if (!CustomValidator1.IsValid)
            {
                return;
            }
            //验证密码
            //if (!CustomValidator2.IsValid)
            //    return;
            if (!this.CustomValidator2_ServerValidate(null, null))
            {
                return;
            }
            //验证,作为超管登录,必须是根机构员工
            Song.Entities.EmpAccount emp = Business.Do <IEmployee>().GetSingle(org.Org_ID, tbAccName.Text.Trim(), this.tbPw1.Text.Trim());
            //写入Session
            LoginState.Admin.Write(emp);
            //记录 登录日志
            bool isLogin = Business.Do <ISystemPara>()["SysIsLoginLogs"].Boolean ?? true;

            if (isLogin)
            {
                Business.Do <ILogs>().AddLoginLogs();
            }
            Response.Redirect("console.aspx");
        }
Exemple #6
0
        //递交员工与角色的关联
        public void UpdateEmp4Posi(string xml)
        {
            if (xml == "" || xml == null)
            {
                return;
            }
            XmlDocument resXml = new XmlDocument();

            xml = Server.UrlDecode(xml);
            try
            {
                resXml.LoadXml(xml, false);
                XmlNodeList nodeList = resXml.SelectSingleNode("nodes").ChildNodes;
                //取rootid
                XmlNode    nodes   = resXml.SelectSingleNode("nodes");
                XmlElement xenodes = (XmlElement)nodes;
                int        posi    = Convert.ToInt32(xenodes.Attributes["posi"].Value);
                Business.Do <IPosition>().DeleteRelation4Emp(posi);
                //遍历所有子节点
                foreach (XmlNode xn in nodeList)
                {
                    XmlElement xe               = (XmlElement)xn;
                    int        empid            = Convert.ToInt32(xe.Attributes["empid"].Value);
                    Song.Entities.EmpAccount mm = Business.Do <IEmployee>().GetSingle(empid);
                    if (mm != null && mm.Acc_AccName.ToLower() != "admin")
                    {
                        mm.Posi_Id = posi;
                        Business.Do <IEmployee>().Save(mm);
                    }
                }
            }
            catch
            {
            }
        }
Exemple #7
0
        /// <summary>
        /// 初始化上下文数据
        /// </summary>
        /// <param name="context"></param>
        private void InitContext(HttpContext context)
        {
            //初始化参数
            this.Context     = context;
            this.Application = context.Application;
            this.Request     = context.Request;
            this.Response    = context.Response;
            this.Server      = context.Server;
            this.Session     = context.Session;

            //机构信息
            try
            {
                this.Organ = Business.Do <IOrganization>().OrganCurrent();
                if (this.Organ == null)
                {
                    throw new Exception("机构不存在!");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            //登录的信息
            if (Extend.LoginState.Accounts.IsLogin)
            {
                this.Account = Song.Extend.LoginState.Accounts.CurrentUser;
                this.Teacher = Song.Extend.LoginState.Accounts.Teacher;
            }
            if (Extend.LoginState.Admin.IsLogin)
            {
                this.Admin = Song.Extend.LoginState.Admin.CurrentUser;
            }
        }
Exemple #8
0
        /// <summary>
        /// 注册某个用户到在线列表中
        /// </summary>
        /// <param name="acc"></param>
        private void _register(Song.Entities.EmpAccount acc)
        {
            if (acc == null)
            {
                return;
            }
            //登录时间,该时间不入数据库,仅为临时使用
            acc.Acc_LastTime = DateTime.Now;
            //登录用户是否已经存在;
            bool isHav = false;

            for (int i = 0; i < this._onlineUser.Count; i++)
            {
                EmpAccount e = this._onlineUser[i];
                if (e == null)
                {
                    continue;
                }
                if (e.Acc_Id == acc.Acc_Id)
                {
                    this._onlineUser[i] = acc;
                    isHav = true;
                    break;
                }
            }
            //如果未登录,则注册进去
            if (!isHav)
            {
                this.OnlineUserAdd(acc);
            }
        }
Exemple #9
0
        /// <summary>
        /// 充值或扣费
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddMoney_Click(object sender, EventArgs e)
        {
            if (!Extend.LoginState.Admin.IsSuperAdmin)
            {
                throw new Exception("非系统管理员(即超管)无权此操作权限!");
            }
            Song.Entities.Accounts st = Business.Do <IAccounts>().AccountsSingle(id);
            if (st == null)
            {
                throw new Exception("当前信息不存在!");
            }
            //操作类型
            int type = 2;

            int.TryParse(rblOpera.SelectedItem.Value, out type);
            //操作金额
            int money = 0;

            int.TryParse(tbMoney.Text, out money);
            //操作对象
            Song.Entities.MoneyAccount ma = new MoneyAccount();
            ma.Ma_Money  = money;
            ma.Ma_Total  = st.Ac_Money; //当前资金总数
            ma.Ma_Remark = tbRemark.Text.Trim();
            ma.Ac_ID     = st.Ac_ID;
            ma.Ma_Source = "系统管理员操作";
            //充值方式,管理员充值
            ma.Ma_From      = 1;
            ma.Ma_IsSuccess = true;     //充值结果为“成功”
            //操作者
            Song.Entities.EmpAccount emp = Extend.LoginState.Admin.CurrentUser;
            try
            {
                string mobi = !string.IsNullOrWhiteSpace(emp.Acc_MobileTel) && emp.Acc_AccName != emp.Acc_MobileTel ? emp.Acc_MobileTel : "";
                //如果是充值
                if (type == 2)
                {
                    ma.Ma_Info = string.Format("系统管理员{0}({1}{2})向您充值{3}元", emp.Acc_Name, emp.Acc_AccName, mobi, money);
                    Business.Do <IAccounts>().MoneyIncome(ma);
                }
                //如果是转出
                if (type == 1)
                {
                    ma.Ma_Info = string.Format("系统管理员{0}({1}{2})扣除您{3}元", emp.Acc_Name, emp.Acc_AccName, mobi, money);
                    Business.Do <IAccounts>().MoneyPay(ma);
                }
                Extend.LoginState.Accounts.Refresh(st.Ac_ID);
                Master.AlertCloseAndRefresh("操作成功!");
            }
            catch (Exception ex)
            {
                this.Alert(ex.Message);
            }
        }
Exemple #10
0
        /// <summary>
        /// 充值或扣费
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddMoney_Click(object sender, EventArgs e)
        {
            if (!Extend.LoginState.Admin.IsAdmin)
            {
                throw new Exception("非管理员无权此操作权限!");
            }
            Song.Entities.Accounts st = Business.Do <IAccounts>().AccountsSingle(id);
            if (st == null)
            {
                throw new Exception("当前信息不存在!");
            }
            //操作类型
            int type = 2;

            int.TryParse(rblOpera.SelectedItem.Value, out type);
            //操作金额
            int coupon = 0;

            int.TryParse(tbCoupon.Text, out coupon);
            //操作对象
            Song.Entities.CouponAccount ca = new CouponAccount();
            ca.Ca_Value  = coupon;
            ca.Ca_Total  = st.Ac_Coupon; //当前卡券总数
            ca.Ca_Remark = tbRemark.Text.Trim();
            ca.Ac_ID     = st.Ac_ID;
            ca.Ca_Source = "管理员操作";
            //充值方式,管理员充值
            ca.Ca_From = 1;
            //操作者
            Song.Entities.EmpAccount emp = Extend.LoginState.Admin.CurrentUser;
            try
            {
                string mobi = !string.IsNullOrWhiteSpace(emp.Acc_MobileTel) && emp.Acc_AccName != emp.Acc_MobileTel ? emp.Acc_MobileTel : "";
                //如果是充值
                if (type == 2)
                {
                    ca.Ca_Info = string.Format("管理员{0}({1},{2})向您充值{3}个卡券", emp.Acc_Name, emp.Acc_AccName, mobi, coupon);
                    Business.Do <IAccounts>().CouponAdd(ca);
                }
                //如果是转出
                if (type == 1)
                {
                    ca.Ca_Info = string.Format("管理员{0}({1},{2})扣除您{3}个卡券", emp.Acc_Name, emp.Acc_AccName, mobi, coupon);
                    Business.Do <IAccounts>().CouponPay(ca);
                }
                Extend.LoginState.Accounts.Refresh(st.Ac_ID);
                Master.AlertCloseAndRefresh("操作成功!");
            }
            catch (Exception ex)
            {
                this.Alert(ex.Message);
            }
        }
Exemple #11
0
        /// <summary>
        /// 修改是否显示的状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void sbOpenMobile_Click(object sender, EventArgs e)
        {
            StateButton ub    = (StateButton)sender;
            int         index = ((GridViewRow)(ub.Parent.Parent)).RowIndex;
            int         id    = int.Parse(this.GridView1.DataKeys[index].Value.ToString());

            //
            Song.Entities.EmpAccount entity = Business.Do <IEmployee>().GetSingle(id);
            entity.Acc_IsOpenMobile = !entity.Acc_IsOpenMobile;
            Business.Do <IEmployee>().Save(entity);
            BindData(null, null);
        }
Exemple #12
0
        /// <summary>
        /// 获取当前登录用户的对象
        /// </summary>
        /// <returns></returns>
        public Song.Entities.EmpAccount Read()
        {
            int accid = this.CurrentUserId;

            if (accid < 1)
            {
                return(null);
            }

            Song.Entities.EmpAccount acc = this.CurrentUser;
            if (acc == null)
            {
                acc = Business.Do <IEmployee>().GetSingle(accid);
            }
            return(acc);
        }
        /// <summary>
        /// 获取管理员的状态
        /// </summary>
        /// <param name="orgid"></param>
        /// <returns></returns>
        public string GetAdminState(object orgid)
        {
            //根据公司id获取管理员。
            Song.Entities.EmpAccount admin = Business.Do <IEmployee>().GetAdminByOrgId(Convert.ToInt32(orgid));
            //获取当前分厂的员工
            Song.Entities.EmpAccount[] emps = Business.Do <IEmployee>().GetAll4Org(Convert.ToInt32(orgid), true, "");
            //如果有管理员
            if (admin != null)
            {
                return(admin.Acc_Name);
            }
            //如果没有管理员,但有其它员工
            if (emps.Length > 0)
            {
                return("【设置管理员】");
            }

            return("【添加】");
        }
Exemple #14
0
 /// <summary>
 /// 确定按钮的事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnEnter_Click(object sender, EventArgs e)
 {
     //验证码错误
     if (!CustomValidator1.IsValid)
     {
         return;
     }
     //验证密码
     //if (!CustomValidator2.IsValid)
     //    return;
     if (!this.CustomValidator2_ServerValidate(null, null))
     {
         return;
     }
     //通过验证,进入登录状态
     Song.Entities.EmpAccount emp = Business.Do <IEmployee>().GetSingle(org.Org_ID, tbAccName.Text.Trim(), this.tbPw1.Text.Trim());
     //写入Session
     LoginState.Admin.Write(emp);
     Master.Close();
 }
Exemple #15
0
        /// <summary>
        /// 将已经登录入的用户,写入seesion或cookies
        /// </summary>
        /// <param name="acc"></param>
        /// <param name="twoDomain">机构的二级域名,如果没有,则用机构id</param>
        public void Write(Song.Entities.EmpAccount acc, string twoDomain)
        {
            System.Web.HttpContext _context = System.Web.HttpContext.Current;
            //登录标识名
            string key = this.Key;

            if (Admin.LoginPattern == LoginPatternEnum.Cookies)
            {
                System.Web.HttpCookie cookie = new System.Web.HttpCookie(key);
                //cookie的值
                cookie.Value   = this.EncryptForDES(acc.Acc_Id);
                cookie.Expires = DateTime.Now.AddMinutes(this.Expires);
                _context.Response.Cookies.Add(cookie);
            }
            if (Admin.LoginPattern == LoginPatternEnum.Session)
            {
                _context.Session[key] = this.EncryptForDES(acc.Acc_Id);
            }
            this.Register(acc);
        }
Exemple #16
0
        private void fill()
        {
            acc = Extend.LoginState.Admin.CurrentUser;
            if (acc != null)
            {
                id          = acc.Acc_Id;
                name        = acc.Acc_Name;
                isAdmin     = Extend.LoginState.Admin.IsAdmin ? 0 : 1;
                lbName.Text = acc.Acc_Name;
            }
            //系统名称,即管理平台上方的名称
            string sysName = Business.Do <ISystemPara>()["SystemName"].String;

            if (sysName != null)
            {
                //consName.InnerText = sysName;
                this.Title += sysName;
            }
            appState = App.Get["appState"].String;
        }
Exemple #17
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="acc">账号,或身份证,或手机</param>
        /// <param name="pw">密码</param>
        /// <param name="orgid"></param>
        /// <returns></returns>
        public EmpAccount EmpLogin(string acc, string pw, int orgid)
        {
            WhereClip wc    = EmpAccount._.Org_ID == orgid;
            string    pwMd5 = new WeiSha.Common.Param.Method.ConvertToAnyValue(pw).MD5;

            wc.And(EmpAccount._.Acc_Pw == pwMd5);
            Song.Entities.EmpAccount entity = null;
            if (entity == null)
            {
                entity = Gateway.Default.From <EmpAccount>().Where(wc && EmpAccount._.Acc_AccName == acc).ToFirst <EmpAccount>();
            }
            if (entity == null)
            {
                entity = Gateway.Default.From <EmpAccount>().Where(wc && EmpAccount._.Acc_MobileTel == acc).ToFirst <EmpAccount>();
            }
            if (entity == null)
            {
                entity = Gateway.Default.From <EmpAccount>().Where(wc && EmpAccount._.Acc_IDCardNumber == acc).ToFirst <EmpAccount>();
            }
            return(entity);
        }
Exemple #18
0
        /// <summary>
        /// 修改是否显示的状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void sbAdmin_Click(object sender, EventArgs e)
        {
            try
            {
                StateButton ub    = (StateButton)sender;
                int         index = ((GridViewRow)(ub.Parent.Parent)).RowIndex;
                //获取员工id
                int accid = int.Parse(this.GridView1.DataKeys[index].Value.ToString());
                Song.Entities.EmpAccount entity = Business.Do <IEmployee>().GetSingle(accid);
                //分厂的管理岗位
                Song.Entities.Position posi = Business.Do <IPosition>().GetAdmin(id);

                entity.Posi_Id   = posi.Posi_Id;
                entity.Posi_Name = posi.Posi_Name;
                Business.Do <IEmployee>().Save(entity);
                BindData(null, null);
            }
            catch (Exception ex)
            {
                Message.ExceptionShow(ex);
            }
        }
Exemple #19
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnEnter_Click(object sender, EventArgs e)
 {
     try
     {
         Song.Entities.EmpGroup mm;
         if (id != 0)
         {
             mm = Business.Do <IEmpGroup>().GetSingle(id);
         }
         else
         {
             //如果是新增
             mm            = new Song.Entities.EmpGroup();
             mm.EGrp_IsUse = true;
         }
         //属性
         mm.EGrp_Name  = tbName.Text;
         mm.EGrp_IsUse = cbIsUse.Checked;
         //说明
         mm.EGrp_Intro = tbIntro.Text;
         //确定操作
         if (id == 0)
         {
             Song.Entities.EmpAccount acc = Extend.LoginState.Admin.CurrentUser;
             mm.Org_ID   = acc.Org_ID;
             mm.Org_Name = acc.Org_Name;
             Business.Do <IEmpGroup>().Add(mm);
         }
         else
         {
             Business.Do <IEmpGroup>().Save(mm);
         }
         Master.AlertCloseAndRefresh("操作成功!");
     }
     catch (Exception ex)
     {
         Message.ExceptionShow(ex);
     }
 }
Exemple #20
0
        /// <summary>
        /// 清理超时用户
        /// </summary>
        public void CleanOut()
        {
            //设置超时时间,单位分钟
            int    outTimeNumer = 3;
            string exp          = WeiSha.Common.Login.Get["Admin"].Expires.String;

            if (!exp.Equals("auto", StringComparison.CurrentCultureIgnoreCase))
            {
                outTimeNumer = WeiSha.Common.Login.Get["Admin"].Expires.Int32 ?? 10;
            }
            lock (_lock)
            {
                for (int i = this._onlineUser.Count - 1; i >= 0; i--)
                {
                    Song.Entities.EmpAccount em = this._onlineUser[i];
                    if (DateTime.Now < em.Acc_LastTime.AddMinutes(outTimeNumer))
                    {
                        this._onlineUser.RemoveAt(i);
                    }
                }
            }
        }
Exemple #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Song.Entities.EmpAccount emp = null;
            if (id < 1)
            {
                emp = Extend.LoginState.Admin.CurrentUser;
            }
            else
            {
                emp = Business.Do <IEmployee>().GetSingle(id);
            }
            string str = "";

            if (emp != null)
            {
                //资源的路径
                string resPath = Upload.Get["Employee"].Virtual;
                emp.Acc_Photo = resPath + emp.Acc_Photo;
                str           = emp.ToJson();
            }
            Response.Write(str);
            Response.End();
        }
Exemple #22
0
 public void CleanOut(Song.Entities.EmpAccount acc)
 {
     this.CleanOut(acc.Acc_Id);
 }
Exemple #23
0
        /// <summary>
        /// 将已经登录入的用户,写入seesion或cookies
        /// </summary>
        /// <param name="acc"></param>
        public void Write(Song.Entities.EmpAccount acc)
        {
            string domain = WeiSha.Common.Request.Domain.TwoDomain;

            Write(acc, domain);
        }