Ejemplo n.º 1
0
 public bool CanEdit(QcUser user)
 {
     if (user.Name == this["任务负责人"] || user.UserID == this["任务负责人"])
     {
         return(true);
     }
     if (user.Name == this["创建人"] || user.UserID == this["创建人"])
     {
         return(true);
     }
     if (user.HasPermission("项目管理"))
     {
         return(true);
     }
     if (user.HasPermission("内置系统管理"))
     {
         return(true);
     }
     if (Parent != null)
     {
         if (Parent.CanEdit(user))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            var name = QcUser.GetName(value.ToString());

            return(name);
            //return base.ConvertTo(context, culture, value, destinationType);
        }
Ejemplo n.º 3
0
 public QcUserDescriptor(QcUser DynamicObject)
     : base(DynamicObject as DynamicDataRowObject
            , DynamicObject.IsNew() ? readonlyfieldsnew : readonlyfields
            , catetory
            , converter
            )
 {
 }
Ejemplo n.º 4
0
 public bool CanCreat(QcUser user)
 {
     if (user.HasPermission("产品级别管理"))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
 public bool CanCreatTask(QcUser user)
 {
     if (user.HasPermission("创建项目"))
     {
         return(true);
     }
     if (user.Name == this["项目负责人"] || user.UserID == this["项目负责人"])
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 6
0
        public static bool Regsister(string username, string password, string name, string sex, DateTime birthday, string tel, string part, DateTime worktime, string address, string content, string status = "注册")
        {
            if (QcUser.Users.Any(t => t.UserName == username || t.姓名 == name))
            {
                return(false);
            }
            QcUser user = new QcUser();

            user.UserName  = username;
            user.部门        = part;
            user.姓名        = name;
            user["用户密码"]   = password;
            user["性别"]     = sex;
            user["出生日期"]   = birthday.ToQcDateString();
            user["参加工作时间"] = worktime.ToQcDateString();
            user["联系电话"]   = tel;
            user["通讯地址"]   = address;
            user["备注"]     = content;
            user.UserID    = QcUser.GetNextCode();
            user["状态"]     = status;
            //user["状态"] = "启用";
            bool ret = user.Update();

            if (ret)
            {
                user.AddRole("项目负责人");
                user.AddRole("任务负责人");
                user.AddRole("作业员");
            }
            //if (QcProject.GetProjects("").Any(t => t.Name == "快速项目") == false)
            //{
            //    QcProject prj = new QcProject();
            //    prj["项目名称"] = "快速项目";
            //    prj["项目负责人"] = "sys";
            //    prj["承担部门"] = "临时";
            //    prj["项目来源"] = "其它";
            //    prj["项目类型"] = "其它";
            //    prj["创建人"] = "sys";
            //    if (prj.Update())
            //    {
            //        QcTask task = new QcTask(prj);
            //        task.Name = "快速任务";
            //        task["任务负责人"] = "sys";
            //        task["创建人"] = "sys";
            //        task["任务优先级"] = "1";
            //        task["任务状态"] = "未启动";
            //        task.Update();
            //    }
            //}
            QcTask.Get_CreatQuickTask();
            QcMsgPoster.PostMeassage(user.Code, user.tablename, user.CodeField, NodeChangeType.Create);
            return(ret);
        }
Ejemplo n.º 7
0
 public bool CanEdit(QcUser user)
 {
     if (user.Name == this["创建人"] || user.UserID == this["创建人"])
     {
         return(true);
     }
     if (user.HasPermission("内置系统管理"))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 8
0
        public static IEnumerable <QcJob> GetJob(QcUser user)
        {
            string name = user.UserID;
            string sql  = "select distinct j.* from " + QcProject.TableName + " p,"
                          + QcTask.TableName + " t," + QcJob.TableName + " j where (p.项目编号=t.项目编号 and"
                          + " t.任务编号=j.任务编号) and (t.任务负责人=' " + name + "' or t.创建人='" + name +
                          "' or p.项目负责人='" + name + "' or p.创建人='" + name + "' or j.创建人='" + name +
                          "' or j.作业员='" + name + "') order by j.修改日期 desc";
            var rows = DbHelper.Query(sql);

            return(rows.Select(t => new QcJob(t)));
        }
Ejemplo n.º 9
0
 public bool CanPrjEdit(QcUser user)
 {
     if (user.HasPermission("方案管理"))
     {
         return(true);
     }
     if (user.HasPermission("内置系统管理"))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 10
0
        public override QcCheckResult Check(string field = null)
        {
            QcCheckResult result   = new QcCheckResult(this);
            bool          checkall = (field == null);

            result.AddCheckNull(field, new[] { "任务名称", "任务负责人", "任务状态", "任务优先级" });
            result.AddCheckUsed(field, Parent.Nodes, new[] { "任务名称" }, (IsNew() ? 0 : 1));
            result.AddCheckEnum(field, "任务负责人", QcUser.GetUserIDsFromNames(任务负责人Converter.任务负责人));
            result.AddCheckEnum(field, "任务状态", 任务状态Converter.任务状态);
            result.AddCheckEnum(field, "任务优先级", 任务优先级Converter.任务优先级);
            if (result.Count > 0)
            {
                return(result);
            }
            return(null);
        }
Ejemplo n.º 11
0
 public bool CanEditRule(QcUser user)
 {
     if (user.Name == this["创建人"] || user.UserID == this["创建人"])
     {
         return(true);
     }
     if (this["修改权限"] == "完全公开" || this["修改权限"] == "规则公开")
     {
         return(true);
     }
     if (user.HasPermission("内置系统管理"))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 12
0
        public bool ChangePassword(string newpassword, string oldpassword)
        {
            string sql = "select * from QC_USE_USERINFO where 用户名='" + this.UserName + "' and 用户密码='" + QcEncrypt.Md5Hash(this.UserName + QcEncrypt.Md5Hash(oldpassword)) + "'";
            var    v   = DbHelper.Query(sql);

            if (v != null)
            {
                if (v.Count() > 0)
                {
                    QcUser u = new QcUser(v.First());
                    u["用户密码"] = QcEncrypt.Md5Hash(this.UserName + QcEncrypt.Md5Hash(newpassword));
                    return(u.Update());
                }
            }
            return(false);
        }
Ejemplo n.º 13
0
        public override QcCheckResult Check(string field = null)
        {
            QcCheckResult result   = new QcCheckResult(this);
            bool          checkall = (field == null);

            result.AddCheckNull(field, new[] { "项目类型", "项目来源", "承担部门", "项目负责人", "项目名称" });
            result.AddCheckUsed(field, QcProject.GetProjects(""), new[] { "项目名称" }, (IsNew() ? 0 : 1));
            result.AddCheckEnum(field, "项目类型", 项目类型Converter.项目类型);
            result.AddCheckEnum(field, "项目来源", 项目来源Converter.项目来源);
            result.AddCheckEnum(field, "承担部门", 承担部门Converter.承担部门);
            result.AddCheckEnum(field, "项目负责人", QcUser.GetUserIDsFromNames(项目负责人Converter.项目负责人));
            if (result.Count > 0)
            {
                return(result);
            }
            return(null);
        }
Ejemplo n.º 14
0
        public override QcCheckResult Check(string field = null)
        {
            QcCheckResult result   = new QcCheckResult(this);
            bool          checkall = (field == null);

            result.AddCheckNull(field, new[] { "作业名称", "作业员", "作业状态", "作业优先级" });
            result.AddCheckUsed(field, this.GetParent().Nodes, new[] { "作业名称" }, (IsNew() ? 0 : 1));
            result.AddCheckEnum(field, "作业员", QcUser.GetUserIDsFromNames(作业员Converter.作业员));
            result.AddCheckEnum(field, "作业状态", 作业状态Converter.作业状态);
            result.AddCheckEnum(field, "作业优先级", 作业优先级Converter.作业优先级);
            result.AddCheckEnum(field, "启动类型", 启动类型Converter.启动类型);
            result.AddCheckEnum(field, "产品级别编码", 产品级别编码Converter.级别s.Select(t => t.Code).ToArray());
            result.AddCheckEnum(field, "产品类别编码", 产品类别编码Converter.类别s.Select(t => t.Code).ToArray());
            result.AddCheckEnum(field, "方案ID", Get方案IDS());
            if (result.Count > 0)
            {
                return(result);
            }
            return(null);
        }
Ejemplo n.º 15
0
        public override bool Update(QcDbTransaction trans = null)
        {
            if (IsNew())
            {
                this.Code    = QcUser.GetNextCode();
                this["用户密码"] = QcEncrypt.Md5Hash(this.UserName + QcEncrypt.Md5Hash(this["用户密码"]));
            }
            bool ret = base.Update(trans);

            //子节点调用AddRole 和RemoveRole进行同步,此处不管
            if (ret == false && IsNew())
            {
                this.Code = "";
            }
            if (ret && !Users.Contains(this))
            {
                Users.Add(this);
            }
            //if (ret && !Users.Any(t=>t.UserName==this.UserName)) Users.Add(this);
            return(ret);
        }
Ejemplo n.º 16
0
        static public QcUser  RefreshUser(string strname)
        {
            var tu = lstUsers.FirstOrDefault(t => t.Name == strname);

            if (tu != null)
            {
                tu.Refresh();
                return(tu);
            }
            string sql   = "select * from " + TableName + " where 姓名='" + strname + "'";
            var    users = DbHelper.Query(sql);

            if (users != null)
            {
                var u = users.FirstOrDefault();
                if (u != null)
                {
                    var user = new QcUser(u);
                    lstUsers.Add(user);
                    return(user);
                }
            }
            return(null);;
        }
Ejemplo n.º 17
0
 public QcMsgClient(IEnumerable <INetUser> users, QcUser user)
     : base()
 {
     Users = users;
     User  = user;
 }
Ejemplo n.º 18
0
 public static List <QcJob> GetMyJob(QcUser user)
 {
     return(GetJob(string.Format("作业员='{0}'", user.UserID)));
 }
Ejemplo n.º 19
0
 public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
 {
     //return base.ConvertFrom(context, culture, value);
     return(QcUser.GetUserID(value.ToString()));
 }
Ejemplo n.º 20
0
 public static List <QcJob> GetMyJob(QcUser user, string state)
 {
     return(GetJob(string.Format("作业员='{0}' and 作业状态='{1}'", user.UserID, state)));
 }
Ejemplo n.º 21
0
 public 权限用户Converter(string Permission) : base(QcUser.GetUserByPermission(Permission))
 {
 }
Ejemplo n.º 22
0
 static public IEnumerable <QcProject> GetProjects(QcUser user)
 {
     return(GetProjects(""));
 }
Ejemplo n.º 23
0
        void server_ReceiveCmd(object sender, QcCmdEventArgs e)
        {
            lock (obj)
            {
                QcCmd  cmd  = e.Cmd;
                string from = e.Cmd.tokens(1);
                string to   = e.Cmd.tokens(2);
                if (lstUser.ContainsKey(from))
                {
                    lstUser[from].LastOnline = DateTime.Now;
                }
                switch (cmd.CmdType)
                {
                case QcProtocol.QcCommand.QcCheckLicense:
                    try
                    {
                        LicenseRetCode ret = LicenseRetCode.未授权;
                        //CONTINUE:
                        //    if (cmd == null) goto CONTINUE;
                        string type = cmd.tokens(1);
                        string arg  = cmd.tokens(2);
                        switch (type)
                        {
                        case "Feature":
                            int id = 0;
                            int.TryParse(arg, out id);
                            ret = License.CheckFeature(id);
                            break;

                        case "Module":
                            ret = License.CheckModule(arg);
                            break;

                        case "Product":
                            ret = License.CheckProduct(arg);
                            break;

                        case "Regsiter":
                            ret = License.RegsisterUser(arg);
                            break;

                        case "Release":
                            License.ReleaseUser(arg);
                            break;
                        }
                        e.Chanel.Send(QcCmd.MakeCmd(QcProtocol.QcCommand.QcCheckLicense, ret.ToString()));
                        e.Chanel.CloseLink();
                    }
                    catch (Exception ex)
                    {
                        QcLog.LogString("QcCheckLicense   " + cmd.ToString() + ":" + ex.Message);
                    }

                    break;

                case QcProtocol.QcCommand.QcUserLogin:
                    bool blLogined = false;
                    blLogined = true;
                    if (lstUser.ContainsKey(from) == false)
                    {
                        var user = QcUser.RefreshUser(from);
                        if (user != null)
                        {
                            var qmu = new QcMsgUser(user);
                            lstUser.TryAdd(qmu.Name, qmu);
                        }
                    }

                    if (lstUser.ContainsKey(from))
                    {
                        //这里判断一下是否可以登录
                        var msguser = lstUser[from];
                        var user    = msguser.User as QcUser;

                        string sql = "select * from " + QcUser.TableName + " where " + user.CodeField + "='" + user.Code + "' and 状态='启用'";
                        if (DbHelper.Exists(sql))
                        {
                            QcChanel chanel = new QcChanel();
                            chanel.SetChanel(e.Chanel, this);
                            lstUser[from].Chanel = chanel;
                            if (this.Logined != null)
                            {
                                var userfrom = lstUser[from];
                                var evtarg   = new QcMessagerLoginEventArg(userfrom);
                                this.Logined(this, evtarg);
                            }
                            //this.BroadcastMsg(e.Cmd.ToString());
                            this.BroadcastMsg(QcCmd.MakeCmd(QcProtocol.QcCommand.QcUserLogin, from, "*"));
                            blLogined = true;
                        }
                        else
                        {
                            blLogined = false;
                        }
                        QcClientService qcs = e.Chanel as QcClientService;
                        e.Chanel.Send(QcCmd.MakeCmd(QcProtocol.QcCommand.QcLoginReplay, blLogined));
                    }
                    break;

                case QcProtocol.QcCommand.QcListUser:
                    var strusers = "";
                    foreach (var u in OnlineUsers)
                    {
                        strusers += u.Name + ",";
                    }
                    e.Chanel.Send(QcCmd.MakeCmd(QcProtocol.QcCommand.QcListUser, strusers));
                    break;

                case QcProtocol.QcCommand.QcLoginOut:
                    if (lstUser.ContainsKey(from))
                    {
                        var userfrom = lstUser[from];
                        if (this.Loginout != null)
                        {
                            var evt = new QcMessagerLoginEventArg(userfrom);
                            this.Loginout(this, evt);
                        }
                        this.BroadcastMsg(QcCmd.MakeCmd(QcProtocol.QcCommand.QcLoginOut, from, "*"));
                        userfrom.Close();
                    }
                    break;

                case QcProtocol.QcCommand.QcDataUpdate:
                    this.BroadcastMsg(e.Cmd.ToString());
                    break;

                default:
                    if (to == "*")
                    {
                        this.BroadcastMsg(e.Cmd.ToString());
                        return;
                    }
                    else
                    {
                        if (lstUser.ContainsKey(to))
                        {
                            var user = lstUser[to];
                            user.Send(e.Cmd.ToString());
                        }
                    }
                    break;
                }
            }
        }