Beispiel #1
0
        /// <summary>
        ///  根据ID更新信息
        /// </summary>
        /// Author  : Napoleon
        /// Created : 2015-01-26 16:21:38
        public ActionResult UpdateMenu(string id, string projectName, string parentId, string htmlId, string url, string icon, string sort, string remark)
        {
            SystemMenu menu = new SystemMenu();

            menu.Id       = id;
            menu.Name     = projectName;
            menu.ParentId = parentId;
            menu.HtmlId   = htmlId;
            menu.Url      = url;
            menu.Icon     = icon;
            menu.Sort     = Convert.ToDecimal(sort);
            menu.Remark   = remark;
            menu.Operator = PublicFields.UserCookie.ReadCookie <SystemUser>().UserName;
            int    count = _menuService.UpdateMenu(menu);
            string status = "failue", msg, json;

            switch (count)
            {
            case -1:
                msg = "该菜单已经存在,请不要使用重复的菜单名!";
                break;

            case 1:
                status = "success";
                msg    = "更新成功!";
                break;

            default:
                msg = "更新失败!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
        /// <summary>
        ///  新增系统
        /// </summary>
        /// Author  : Napoleon
        /// Created : 2015-01-24 09:29:42
        public ActionResult SaveAdd(string projectId, string projectName, string remark)
        {
            SystemProject project = new SystemProject();

            project.ProjectId   = projectId;
            project.ProjectName = projectName;
            project.Remark      = remark;
            project.Operator    = PublicFields.UserCookie.ReadCookie <SystemUser>().UserName;
            int    count = _projectService.InsertProject(project);
            string status = "failue", msg, json;

            if (count > 0)
            {
                status = "success";
                msg    = "添加成功!";
            }
            else if (count == 0)
            {
                msg = "添加失败!";
            }
            else
            {
                msg = "添加失败,该系统代码已经存在,请不要重复添加!";
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #3
0
        /// <summary>
        ///  用户校验
        /// </summary>
        /// <param name="userName">用户账号</param>
        /// <param name="passWord">用户密码</param>
        /// Author  : Napoleon
        /// Created : 2015-01-07 10:04:36
        public ActionResult CheckUser(string userName, string passWord)
        {
            SystemUser user = _userService.CheckUser(userName, passWord, PublicFields.ProjectId);
            string     status = "failue", msg = "登录失败!", json;

            if (user != null)
            {
                if (user.IsUse.Equals(PublicFields.IsDefaultUse))
                {
                    //用户信息
                    user.WriteCookie(PublicFields.UserCookie);
                    //用户权限
                    SystemUserAndRule rule = _userAndRuleService.GetRule(user.Id, PublicFields.ProjectId);
                    if (rule == null)
                    {
                        msg = "登录失败,该账号不能登录本系统!";
                    }
                    else
                    {
                        rule.RuleId.WriteCookie(PublicFields.RuleIdCookies);
                        status = "success";
                        msg    = "登录成功!";
                    }
                }
                else
                {
                    msg = "登录失败,该账号已禁用,请联系管理员!";
                }
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #4
0
        public CLogin ForceOut(string userName, string userpass)
        {
            PublicFunc.DeleteUserResLock(GetUpdateVal());
            SqlCommand cmd = PmConnections.CtrlCmd();

            cmd.CommandText = "SELECT online FROM wapUserstate WHERE empid = '" + GetUpdateVal() + "'";
            SqlDataReader rd = cmd.ExecuteReader();

            if (rd.Read())
            {
                if (Convert.ToBoolean(rd[0]))
                {
                    rd.Close();
                    cmd.CommandText = "DELETE FROM wapUserstate WHERE empid = '" + GetUpdateVal() + "'";
                    cmd.ExecuteNonQuery();
                }
                rd.Close();
                cmd.Connection.Close();
                return(Login(userName, userpass));
            }
            else
            {
                return(Login(userName, userpass));
            }
        }
Beispiel #5
0
        /// <summary>
        ///  保存新增
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="parentId">The parent identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="sort">The sort.</param>
        /// <param name="remark">The remark.</param>
        /// Author  : Napoleon
        /// Created : 2015-01-27 16:03:55
        public ActionResult SaveRule(string projectId, string parentId, string name, decimal sort, string remark)
        {
            SystemRule rule = new SystemRule();

            rule.ProjectId = projectId;
            rule.Id        = CustomId.GetCustomId();
            rule.ParentId  = string.IsNullOrWhiteSpace(parentId) ? "0" : parentId;
            rule.Name      = name;
            rule.Sort      = sort;
            rule.Remark    = remark;
            rule.Operator  = PublicFields.UserCookie.ReadCookie <SystemUser>().UserName;
            int    count = _ruleService.InsertRule(rule);
            string status = "failue", msg, json;

            switch (count)
            {
            case -1:
                msg = "添加失败,该角色名称已经存在,请不要重复添加!";
                break;

            case 1:
                status = "success";
                msg    = "添加成功!";
                break;

            default:
                msg = "添加失败!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #6
0
        public List <CFinishHistory> GetOpFinishHistory(string orderuid)
        {
            SqlCommand cmd = PmConnections.SchCmd();

            cmd.CommandText = "SELECT eventMessage,eventTime,finishedQty,failedQty,planQty,jobQty,mesOperator FROM wapMesEventRec WHERE OrderUID = '" + orderuid + "' ORDER BY EventTime";
            SqlDataAdapter da        = new SqlDataAdapter(cmd);
            DataTable      dthistory = new DataTable();

            da.Fill(dthistory);
            da.Dispose();
            cmd.Connection.Close();
            List <CFinishHistory> cFinishHistories = new List <CFinishHistory>();

            foreach (DataRow item in dthistory.Rows)
            {
                CFinishHistory cFinish = new CFinishHistory
                {
                    EventMessage = item["eventMessage"].ToString(),
                    EventTime    = PublicFunc.ForMatDateTimeStr(Convert.ToDateTime(item["eventTime"]), 1),
                    FinishedQty  = Convert.ToDouble(item["finishedQty"]),
                    FailedQty    = Convert.ToDouble(item["failedQty"]),
                    PlannedQty   = Convert.ToDouble(item["planQty"]),
                    JobQty       = Convert.ToDouble(item["jobQty"]),
                    MesOperator  = item["mesOperator"].ToString()
                };
                cFinishHistories.Add(cFinish);
            }
            return(cFinishHistories);
        }
Beispiel #7
0
 private void BBI_Reg_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (BET_ToolCode.EditValue.ToString().Trim() == string.Empty)
     {
         MessageBox.Show("注册码格式不正确!");
         return;
     }
     if (!PublicFunc.CompareCode(BET_ToolCode.EditValue.ToString().Trim()))
     {
         MessageBox.Show("注册码不正确!");
         return;
     }
     // db.SetRange();
     //  MessageBox.Show(BET_ToolCode.EditValue.ToString().Length.ToString());
     if (!db.EditRegCode(BET_ToolCode.EditValue.ToString().Trim()) || !PublicFunc.CompareCode(db.GetRegCode()))
     {
         MessageBox.Show("保存数据不正确!");
         return;
     }
     else
     {
         MessageBox.Show("感谢您的注册!");
         TxtData.XMLConfigure.Reged = true;
         BBI_Reg.Enabled            = BET_ToolCode.Enabled = !TxtData.XMLConfigure.Reged;
         BSI_RegStatus.Caption      = TxtData.XMLConfigure.Reged ? "已注册" : "未注册";
     }
     //  Frm_Main_Load(this, null);
 }
Beispiel #8
0
        /// <summary>
        ///  保存新增的导航菜单
        /// </summary>
        /// <param name="menuName">导航菜单名称</param>
        /// <param name="menuType">菜单类型</param>
        /// <param name="menuId">新闻菜单</param>
        /// <param name="menuUrl">链接地址</param>
        /// <param name="isUse">是否可用</param>
        /// <param name="orderBy">排序</param>
        /// Author  : Napoleon
        /// Created : 2015-06-09 15:37:10
        public ActionResult SaveAdd(string menuName, string menuType, string menuId, string menuUrl, string isUse, decimal orderBy)
        {
            string        status = "failue", msg = "新增失败!", json;
            SystemNavMenu nav = new SystemNavMenu();

            nav.Id            = CustomId.GetCustomId();
            nav.MenuName      = menuName;
            nav.MenuType      = int.Parse(menuType);
            nav.MenuId        = menuId;
            nav.MenuUrl       = menuUrl;
            nav.IsUse         = int.Parse(isUse);
            nav.OrderBy       = orderBy;
            nav.OperationTime = DateTime.Now;
            int i = _navMenuService.InsertSystemNavMenu(nav);

            switch (i)
            {
            case 1:
                status = "success";
                msg    = "新增成功!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #9
0
 public dynamic LoadForm(string formName)
 {
     formName = PublicFunc.GetConfigByKey_AppSettings("TemplatePrefix") + formName;
     return
         (stAnswerRepo.Entities.Select(n => new { n.TemplateName, n.TemplateData, n.TemplateDesc })
          .FirstOrDefault(m => m.TemplateName == formName));
 }
Beispiel #10
0
        /// <summary>
        ///  更新新闻菜单
        /// </summary>
        /// <param name="hiddenId">ID</param>
        /// <param name="menuName">导航菜单名称</param>
        /// <param name="menuType">菜单类型</param>
        /// <param name="menuId">新闻菜单</param>
        /// <param name="menuUrl">链接地址</param>
        /// <param name="isUse">是否可用</param>
        /// <param name="orderBy">排序</param>
        /// Author  : Napoleon
        /// Created : 2015-06-09 15:37:10
        public ActionResult UpdateEdit(string hiddenId, string menuName, string menuType, string menuId, string menuUrl, string isUse, decimal orderBy)
        {
            string        status = "failue", msg = "更新失败!", json;
            SystemNavMenu nav = new SystemNavMenu();

            nav.Id            = hiddenId;
            nav.MenuName      = menuName;
            nav.MenuType      = string.IsNullOrWhiteSpace(menuType) ? 0 : int.Parse(menuType);
            nav.MenuId        = menuId;
            nav.MenuUrl       = menuUrl;
            nav.IsUse         = int.Parse(isUse);
            nav.OrderBy       = orderBy;
            nav.OperationTime = DateTime.Now;
            int i = _navMenuService.UpdateSystemNavMenu(nav);

            switch (i)
            {
            case 1:
                status = "success";
                msg    = "更新成功!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #11
0
        /// <summary>
        ///  新增菜单
        /// </summary>
        /// Author  : Napoleon
        /// Created : 2015-01-24 16:19:31
        public ActionResult SaveMenu(string projectName, string projectId, string parentId, string htmlId, string url, string icon, string sort, string remark)
        {
            SystemMenu menu = new SystemMenu();

            menu.ProjectId = projectId;
            menu.Id        = CustomId.GetCustomId();
            menu.ParentId  = string.IsNullOrWhiteSpace(parentId) ? "0" : parentId;
            menu.Name      = projectName;
            menu.HtmlId    = htmlId;
            menu.Url       = url;
            menu.Icon      = icon;
            menu.Sort      = Convert.ToDecimal(sort);
            menu.Remark    = remark;
            menu.Operator  = PublicFields.UserCookie.ReadCookie <SystemUser>().UserName;
            int    count = _menuService.InsertMenu(menu);
            string status = "failue", msg, json;

            switch (count)
            {
            case -1:
                msg = "添加失败,该菜单名称已经存在,请不要重复添加!";
                break;

            case 1:
                status = "success";
                msg    = "添加成功!";
                break;

            default:
                msg = "添加失败!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #12
0
        /// <summary>
        ///  新增用户权限
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="company">The company.</param>
        /// <param name="rule">The rule.</param>
        /// Author  : Napoleon
        /// Created : 2015-01-23 09:48:45
        public ActionResult SavePermitAdd(string projectId, string userId, string company, string rule)
        {
            SystemUserAndRule rules = new SystemUserAndRule();

            rules.ProjectId    = projectId;
            rules.Id           = CustomId.GetCustomId();
            rules.UserId       = userId;
            rules.RuleParentId = company;
            rules.RuleId       = rule;
            int    count = _userAndRuleService.InsertUserRule(rules);
            string status = "failue", msg, json;

            switch (count)
            {
            case -1:
                msg = "添加失败,该用户已经拥有类似权限,不能重复添加!";
                break;

            case 1:
                status = "success";
                msg    = "添加成功!";
                break;

            default:
                msg = "添加失败!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #13
0
        /// <summary>
        ///  更新用户信息
        /// </summary>
        /// Author  : Napoleon
        /// Created : 2015-01-19 15:53:14
        public ActionResult UpdateUser(string id, string projectId, string userName, string realName, string mobilePhone, string isUse, string userAddress, decimal sort, string remark)
        {
            SystemUser user = new SystemUser();

            user.Id          = id;
            user.UserName    = userName;
            user.RealName    = realName;
            user.MobilePhone = mobilePhone;
            user.IsUse       = isUse;
            user.UserAddress = userAddress;
            user.Sort        = sort;
            user.Remark      = remark;
            user.Operator    = PublicFields.UserCookie.ReadCookie <SystemUser>().UserName;
            user.ProjectId   = projectId;
            int    count = _userService.UpdateUser(user);
            string status = "failue", msg, json;

            switch (count)
            {
            case -1:
                msg = "更新失败,该账号已存在!";
                break;

            case 1:
                status = "success";
                msg    = "更新成功!";
                break;

            default:
                msg = "更新失败!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #14
0
        public Frm_Main()
        {
            //卸载与安装
            if (!File.Exists(Application.StartupPath + "\\Packaging.mdb") && File.Exists(Application.StartupPath + "\\Backup\\Packaging.mdb"))
            {
                File.Copy(Application.StartupPath + "\\Backup\\Packaging.mdb", Application.StartupPath + "\\Packaging.mdb", true);
            }

            //2013.11.20
            //检查数据库是否存在

            if (!File.Exists(Application.StartupPath + "\\Packaging.mdb"))
            {
                MessageBox.Show("程序根目录中数据库文件Packaging.MDB不存在");
                System.Environment.Exit(System.Environment.ExitCode);
                this.Dispose();
                this.Close();
                return;
            }

            PublicFunc.Init();
            DevExpress.Data.CurrencyDataController.DisableThreadingProblemsDetection = true;
            // PublicFunc.ReadXMLConfigure();

            InitializeComponent();
            BI_ListClose_ItemClick(this, null);
            TE_Title.Text = "Packaging";
            RC_Main.DefaultPageCategory.Expanded = true;
            RC_Main.Minimized = true;
            InitSkinGallery();



            db = new DataBaseManage();

            TxtData.XMLConfigure.RegCode = db.GetRegCode();
            TxtData.XMLConfigure.Reged   = PublicFunc.CompareCode(TxtData.XMLConfigure.RegCode);
            db.SaveCs8cConfigure();
            PublicFunc.ReadCs8CConfigure();

            db.GetIp(ref TxtData.XMLConfigure.IpAddress, ref TxtData.XMLConfigure.RestrictCode);
            db.GetPopedom(ref TxtData.PublicData.ScreenEnable);

            TxtData.XMLConfigure.User = db.GetAutoLogin();


            if (TxtData.XMLConfigure.User != null)
            {
                TxtData.XMLConfigure.Login   = true;
                TxtData.XMLConfigure.PopeDom = db.GetUserPopm(TxtData.XMLConfigure.User);
                db.AddLog(TxtData.XMLConfigure.User + "登录");
            }
            PublicFunc.ReadXMLConfigure();


            poll = new Thread(new ThreadStart(PublicFunc.Poll));
            poll.Start();
        }
Beispiel #15
0
        private void BT_ok_Click(object sender, EventArgs e)
        {
            if (TB_Code.Text.Trim() == "")
            {
                MessageBox.Show("输入不能为空!");
                return;
            }
            switch (Type)
            {
            case 1:
            {
                string[] data = TB_Code.Text.Trim().Split('.');
                if (data.Length != 4)
                {
                    MessageBox.Show("输入位数不正确!");
                    return;
                }
                TxtData.XMLConfigure.IpAddress = TB_Code.Text.Trim();
                break;
            }

            case 2:
            {
                if (TB_Code.Text.Trim().Length != 6)
                {
                    MessageBox.Show("输入位数不等于6!");
                    return;
                }

                //2014.08.08
                //修改加密方式

                int Ind = TxtData.XMLConfigure.RegCode.ToUpper().IndexOf(TB_Code.Text.Trim().ToUpper());
                if (Ind < 0 || Ind % 6 != 0)
                {
                    MessageBox.Show("输入不正确!");
                    return;
                }

                TxtData.XMLConfigure.RestrictCode = TB_Code.Text.Trim();
                break;
            }
            }

            if (!db.EditIp(TxtData.XMLConfigure.IpAddress, TxtData.XMLConfigure.RestrictCode))
            {
                MessageBox.Show("数据库出错");
                return;
            }
            if (Type == 2)
            {
                // TxtData.XMLConfigure.RestrictCode=
                PublicFunc.ReadXMLConfigure();
            }

            this.Close();
        }
Beispiel #16
0
        //查询是否有其他订单是否换班
        private void EndOtherOrder(string resname)
        {
            MUnStartList      unStartList = new MUnStartList();
            List <COrderList> cOrders     = unStartList.GetUnStartOrderList(resname);

            if (cOrders.Count > 0)
            {
                foreach (COrderList item in cOrders)
                {
                    //查询下一个班次是哪天,第几个班次
                    SqlCommand cmd = PmConnections.SchCmd();
                    cmd.CommandText = "SELECT MAX(dayShift) FROM User_MesDailyData WHERE pmResName = '" + item.PmResName + "' and mesDailyDate ='" + PublicFunc.GetDailyDate(thisresname) + "'";
                    SqlDataReader rd = cmd.ExecuteReader();
                    rd.Read();
                    int maxdayshift = Convert.ToInt32(rd[0]);
                    rd.Close();
                    cmd.Connection.Close();
                    int      nextdayshift;
                    DateTime nextdailydate;
                    if (item.DayShift < maxdayshift)
                    {
                        nextdayshift  = item.DayShift + 1;
                        nextdailydate = PublicFunc.GetDailyDate(thisresname);
                    }
                    else
                    {
                        nextdayshift  = 1;
                        nextdailydate = PublicFunc.GetDailyDate(thisresname).AddDays(1);
                    }
                    //先查找这个设备上的下个班次是否有这个订单
                    cmd = PmConnections.SchCmd();
                    //SELECT COUNT(UID) FROM [sch_test].[dbo].[User_MesDailyData] where pmResName = '纽威立式车床17:2' and  mesDailyDate = '2020-6-20' and workID = '0021905001' and dayShift = 1 and productID = '8311280776' and pmOpName = '精车一'
                    cmd.CommandText = "SELECT COUNT(UID) FROM User_MesDailyData WHERE pmResName = '" + thisresname + "' and mesDailyDate = '" + nextdailydate + "' and dayshift = '" + nextdayshift +
                                      "' and workid = '" + item.WorkID + "' and productid = '" + item.ProductID + "' and pmOpName = '" + item.PmOpName + "'";
                    rd = cmd.ExecuteReader();
                    rd.Read();
                    int hasthisorder = Convert.ToInt32(rd[0]);
                    rd.Close();
                    cmd.Connection.Close();

                    if (hasthisorder < 1)
                    {
                        cmd             = PmConnections.SchCmd();
                        cmd.CommandText = "UPDATE User_MesDailyData SET mesDailyDate = '" + nextdailydate + "', dayshift = '" + nextdayshift + "' WHERE UID = '" + item.OrderUID + "'";
                        cmd.ExecuteNonQuery();
                        cmd.Connection.Close();
                    }
                    else
                    {
                        cmd             = PmConnections.SchCmd();
                        cmd.CommandText = "UPDATE User_MesDailyData SET TaskFinishState = '5' WHERE UID = '" + item.OrderUID + "'";
                        cmd.ExecuteNonQuery();
                        cmd.Connection.Close();
                    }
                }
            }
        }
Beispiel #17
0
        public void CreateTiKu(TiKuMasterModel master)
        {
            if (master != null)
            {
                var parameter = new SqlParameter()
                {
                    DbType        = DbType.String,
                    ParameterName = "@TiKuName",
                    Value         = master.TiKuName
                };
                adonetWrapper.ExecuteSqlCommand(
                    @"declare @masterSysNo int
                          select @masterSysNo = SysNo FROM dbo.TiKuMaster where TiKuName=@TiKuName
                          delete from dbo.TiKuMaster where SysNo = @masterSysNo;
                          delete from dbo.TiKuDetail where MasterSysNo = @masterSysNo"
                    , parameter);

                var insertCount = tiKuRepo.Insert(PublicFunc.EntityMap <TiKuMasterModel, TiKuMaster>(master));
                if (insertCount > 0)
                {
                    var masterSysNo = tiKuRepo.Entities.FirstOrDefault(m => m.TiKuName == master.TiKuName).SysNo;
                    var details     = PublicFunc.EntityMap <List <TiKuDetailModel>, List <TiKuDetail> >(master.Details);
                    if (details != null)
                    {
                        details.ForEach((detail) =>
                        {
                            detail.MasterSysNo = masterSysNo;
                        });

                        tiKuDetailRepo.Insert(details);

                        var names = details.Select(m => m.ProcessName).Distinct().ToList();
                        foreach (var name in names)
                        {
                            var matchDetails = details.Where(m => m.ProcessName == name);
                            if (matchDetails != null)
                            {
                                var initExam = new InitExamModel();
                                initExam.User        = master.User;
                                initExam.ProcessName = name;
                                initExam.NodeTeams   = new List <NodeTeamModel>();

                                foreach (var mDetail in matchDetails)
                                {
                                    initExam.NodeTeams.Add(new NodeTeamModel()
                                    {
                                        NodeName = mDetail.NodeName,
                                        TeamName = mDetail.TeamName
                                    });
                                }
                                taskService.InitExam(initExam);
                            }
                        }
                    }
                }
            }
        }
Beispiel #18
0
        private void BT_P2_Click(object sender, EventArgs e)
        {
            string FileName;

            if ((FileName = PublicFunc.SfD_Show(Application.StartupPath, "PDF文件|*.pdf")) == null)
            {
                return;
            }
            gv2.ExportToPdf(FileName);
        }
Beispiel #19
0
        private void BT_OutPort_Click(object sender, EventArgs e)
        {
            string FileName;

            if ((FileName = PublicFunc.SfD_Show(Application.StartupPath, "XLS文件|*.xls")) == null)
            {
                return;
            }
            gv.ExportToXls(FileName);
        }
Beispiel #20
0
        /// <summary>
        /// 把机器码生成文本
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BBI_SaveToolCodeTxt_ItemClick(object sender, ItemClickEventArgs e)
        {
            string FileName;

            if ((FileName = PublicFunc.SfD_Show("Packaging注册码.txt", "TXT文件(*.txt)|*.txt")) == null)
            {
                return;
            }
            PublicFunc.SaveTxt(FileName, BSI_ToolCode.Caption);
        }
Beispiel #21
0
        /// <summary> RowSelected CROpportunity </summary>
        public void _(Events.RowSelected <CROpportunity> e, PXRowSelected baseMethod)
        {
            baseMethod?.Invoke(e.Cache, e.Args);
            var wgID = (e.Row as CROpportunity).WorkgroupID;
            var role = new PublicFunc().CheckAcessRoleByWP(PXAccess.GetUserID(), wgID);

            if (!role && wgID.HasValue)
            {
                throw new PXException("You don't have right to read this data.");
            }
        }
Beispiel #22
0
        public void ImportTeamUser(TramUserImportListModel data)
        {
            if (data == null)
            {
                throw new BusinessException("无数据");
            }

            string sqlStr = @" DELETE FROM dbo.Team;
                                DELETE A FROM dbo.RoleUser A INNER JOIN dbo.[User] B ON A.UserID = B.UserID WHERE B.UserType = 0;
                                    DELETE FROM dbo.[User] WHERE UserType = 0;
                                    DELETE FROM dbo.UserTeam;";

            adonetWrapper.ExecuteSqlCommand(sqlStr);
            string pwd = PublicFunc.GetConfigByKey_AppSettings("DefaultPWD");

            DateTime now = DateTime.Now;
            int      studentRoleSysNo = int.Parse(PublicFunc.GetConfigByKey_AppSettings("StudentRoleSysNo"));
            IEnumerable <IGrouping <string, TeamUserImportModel> > groupList = data.Lists.GroupBy(m => m.TeamName);

            foreach (var group in groupList)
            {
                teamRepo.Insert(new Team {
                    TeamName = group.Key, InDate = now, InUser = data.User.UserID
                });
                foreach (TeamUserImportModel user in group.ToList())
                {
                    userRepo.Insert(new User
                    {
                        UserID   = user.UserID,
                        UserName = user.UserName,
                        Password = pwd,
                        Status   = 1,
                        InUser   = data.User.UserID,
                        InDate   = now
                    });
                    userTeamRepo.Insert(new UserTeam
                    {
                        TeamName = user.TeamName,
                        UserID   = user.UserID,
                        InDate   = now,
                        InUser   = data.User.UserID
                    });

                    roleUserRepo.Insert(new RoleUser()
                    {
                        InDate    = now,
                        InUser    = data.User.UserID,
                        Status    = 1,
                        UserID    = user.UserID,
                        RoleSysNo = studentRoleSysNo
                    });
                }
            }
        }
Beispiel #23
0
        private void Frm_Main_Load(object sender, EventArgs e)
        {
            BBI_Reg.Enabled       = BET_ToolCode.Enabled = !TxtData.XMLConfigure.Reged;
            BSI_RegStatus.Caption = TxtData.XMLConfigure.Reged ? "已注册" : "未注册";
            BSI_ToolCode.Caption  = PublicFunc.GetDiskVolumeSerialNumber() + PublicFunc.GetCpuSerialNumber();

            BI_RobotImfor_LinkClicked(this, null);


            //  TxtData.XMLConfigure.Login = true;
        }
Beispiel #24
0
        public void SetResUsed(string empid, string resName, string useType, string lockedStartTime, string lockedEndTime, string eventMessage)
        {
            int        pmuid    = PublicFunc.GetMaxUID("S", "wapResLockState", "PMUID");
            string     username = PublicFunc.GetEmpName(Convert.ToInt32(empid));
            SqlCommand cmd      = PmConnections.SchCmd();

            cmd.CommandText = "INSERT INTO wapResLockState (PMUID,ResName,LockedStartTime,LockedEndTime,LockedPerson,ResEventType,ResEventComment) VALUES ('"
                              + pmuid + "','" + resName + "','" + lockedStartTime + "','" + lockedEndTime + "','" + username + "','" + useType + "','" + eventMessage + "')";
            cmd.ExecuteNonQuery();
            cmd.Connection.Close();
        }
Beispiel #25
0
        public void UpdateProcessInfo(ProcessExtendModel pInfo)
        {
            var data = PublicFunc.EntityMap <ProcessExtendModel, ProcessInfo>(pInfo);

            if (data != null)
            {
                data.LastEditUser = pInfo.User.UserID;
                data.LastEditDate = DateTime.Now;
                processInfoRepo.Update(data);
            }
        }
Beispiel #26
0
        public ApiResponse LoadFormList()
        {
            var returnFiles = new List <string>();
            var formDir     = Path.Combine(PublicFunc.GetDeployDirectory(), PublicFunc.GetConfigByKey_AppSettings("Form_Path"));

            if (!string.IsNullOrEmpty(formDir) && Directory.Exists(formDir))
            {
                var files = Directory.GetFiles(formDir, "*.html", SearchOption.AllDirectories);
                files.ForEach(m => returnFiles.Add(PublicFunc.GetConfigByKey_AppSettings("TemplatePrefix") + Path.GetFileName(m)));
            }
            return(ApiOk(returnFiles));
        }
Beispiel #27
0
        /// <summary>
        ///  更新角色权限
        /// </summary>
        /// <param name="json">The json.</param>
        /// Author  : Napoleon
        /// Created : 2015-02-04 20:44:19
        public ActionResult SaveRule(string json)
        {
            json = HttpUtility.UrlDecode(json);
            List <SystemMenuAndRule> list = JsonConvert.DeserializeObject <List <SystemMenuAndRule> >(json);
            int    count = _menuAndRuleService.UpdateRuleMenu(list[0].RuleId, list[0].ProjectId, list);
            string status = "failue", msg, jsons;

            msg    = count > 0 ? "更新成功,请重新登陆!" : "更新失败!";
            status = count > 0 ? "success" : "failue";
            jsons  = PublicFunc.ModelToJson(status, msg);
            return(Content(jsons));
        }
Beispiel #28
0
        private void BT_OutPort_Click(object sender, EventArgs e)
        {
            if ((FileName = PublicFunc.SfD_Show()) == null)
            {
                return;
            }
            TxtData.PublicData.ErrorCode = 0;

            System.Threading.ThreadPool.QueueUserWorkItem(new WaitCallback(PollOutport));
            Frm_Wait frm = new Frm_Wait("", false);

            frm.ShowDialog();
        }
Beispiel #29
0
        /// <summary>
        ///  初始化密码
        /// </summary>
        /// <param name="ids">The ids.</param>
        /// Author  : Napoleon
        /// Created : 2015-01-19 20:39:21
        public ActionResult UpdatePassWord(string ids)
        {
            int    count = _userService.UpdatePassWord(PublicFields.DefaultPw.GetMd5(), ids);
            string status = "failue", msg = "初始化失败", json;

            if (count > 0)
            {
                status = "success";
                msg    = "初始化成功!";
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #30
0
        public ApiResponse ImportUser()
        {
            string uploadPath = Path.Combine(
                PublicFunc.GetDeployDirectory(),
                PublicFunc.GetConfigByKey_AppSettings("Upload_Path"));
            HttpPostedFile file    = HttpContext.Current.Request.Files[0];
            string         strPath = Path.Combine(uploadPath, file.FileName);

            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }
            file.SaveAs(strPath);

            var model = new TramUserImportListModel()
            {
                Lists = new List <TeamUserImportModel>(),
                User  = new UserInfo()
                {
                    //上传文件时,body为空,在ApiJsonMediaTypeFormatter中ReadFromStreamAsync时要出错
                    //在解决该问题之前,现在这里设置一下登录用户的UserID
                    UserID = "0"//ActionContext.Request.Content.Headers.GetValues("UserID").FirstOrDefault()
                }
            };
            var list = model.Lists;

            var ds = Utility.ExcelToDataSet(strPath, "select * from [Sheet1$]");

            if (ds != null && ds.Tables[0] != null)
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    list.Add(new TeamUserImportModel
                    {
                        TeamName = row[0].ToString(),
                        UserID   = row[1].ToString(),
                        UserName = row[2].ToString()
                    });
                }
            }

            if (list.Count > 0)
            {
                userService.ImportTeamUser(model);
            }
            if (File.Exists(strPath))
            {
                File.Delete(strPath);
            }
            return(ApiOk(list));
        }