示例#1
0
        public static void CheckToken(string Token)
        {
            try
            {
                IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";

                AchieveDBEntities myDbContext = new AchieveDBEntities();
                tbUserToken       temp        = myDbContext.tbUserToken.Where(p => p.Token == Token).FirstOrDefault();
                if (temp != null)
                {
                    if (temp.UpdateTime > DateTime.Now.AddHours(-1) && temp.CreateTime > DateTime.Now.AddHours(-12))
                    {
                        temp.UpdateTime = DateTime.Now;
                        myDbContext.SaveChanges();
                    }
                    else if (temp.IsLoginOut == 1)
                    {
                        throw new Exception("用户已退出系统");
                    }
                    else
                    {
                        throw new Exception("验证Token已过期");
                    }
                }
                else
                {
                    throw new Exception("验证Token已过期");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#2
0
        public static string GetUserLogininfoByToken(string Token)
        {
            string str = string.Empty;

            try
            {
                IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";

                AchieveDBEntities  myDbContext = new AchieveDBEntities();
                List <tbUserToken> templist    = myDbContext.tbUserToken.Where(p => p.Token == Token).ToList();
                if (templist != null && templist.Count > 0)
                {
                    tbUserToken tempUser = templist[0];
                    if (tempUser.UpdateTime > DateTime.Now.AddHours(-1) && tempUser.CreateTime > DateTime.Now.AddHours(-12))
                    {
                        str = ResponseHelper.ResponseMsg("1", "验证Token成功", str);
                    }
                    else
                    {
                        str = ResponseHelper.ResponseMsg("-1", "验证Token已过期", str);
                    }
                }
                else
                {
                    str = ResponseHelper.ResponseMsg("-1", "Token不存在", str);
                }
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#3
0
        public static string GetNoticeById(string Code)
        {
            string str = string.Empty;

            try
            {
                IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                tbRole temp = new tbRole();
                //NoticeModel returnModel = new NoticeModel();
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                tbNotice          main        = myDbContext.tbNotice.Where(p => p.Code == Code).ToList().FirstOrDefault();



                if (main != null)
                {
                    str = JsonConvert.SerializeObject(main, Formatting.Indented, timeFormat);
                    str = ResponseHelper.ResponseMsg("1", "取数成功", str);
                }
                else
                {
                    str = JsonConvert.SerializeObject(main, Formatting.Indented, timeFormat);
                    str = ResponseHelper.ResponseMsg("-1", "通知信息不存在", str);
                }
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#4
0
        public static List <MenuTreeModel> GetChildMenu(int userID, int ParentId)
        {
            AchieveDBEntities    myDbContext = new AchieveDBEntities();
            List <MenuTreeModel> listTemp    = new List <MenuTreeModel>();
            var query = from ur in myDbContext.tbUserRole
                        join rmb in myDbContext.tbRoleMenu on ur.RoleId equals rmb.RoleId
                        join m in myDbContext.tbMenu on rmb.MenuId equals m.Id
                        where ur.UserId == userID &&
                        m.ParentId == ParentId
                        orderby m.ParentId, m.Sort
            select m;

            if (query != null)
            {
                foreach (var tp in query)
                {
                    MenuTreeModel m = new MenuTreeModel();
                    m.Id       = tp.Id.ToString();
                    m.Icon     = tp.Icon;
                    m.MenuName = tp.Name;
                    m.ParentId = tp.ParentId.ToString();
                    m.Url      = tp.LinkAddress;
                    m.Node     = GetChildMenu(userID, tp.Id);
                    listTemp.Add(m);
                }
            }

            return(listTemp);
        }
示例#5
0
        public static string GetParameterById(int Id)
        {
            string str = string.Empty;

            try
            {
                IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                tbParameter        temp        = new tbParameter();
                AchieveDBEntities  myDbContext = new AchieveDBEntities();
                List <tbParameter> templist    = myDbContext.tbParameter.Where(p => p.id == Id).ToList();
                if (templist != null && templist.Count > 0)
                {
                    temp = templist[0];
                    str  = JsonConvert.SerializeObject(temp, Formatting.Indented, timeFormat);
                    str  = ResponseHelper.ResponseMsg("1", "取数成功", str);
                }
                else
                {
                    str = JsonConvert.SerializeObject(temp, Formatting.Indented, timeFormat);
                    str = ResponseHelper.ResponseMsg("-1", "数据不存在", str);
                }
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#6
0
        public static string UpdateRole(string Rolestr)
        {
            string str = string.Empty;

            try
            {
                tbRole            tb          = JsonConvert.DeserializeObject <tbRole>(Rolestr);
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                tbRole            data        = myDbContext.tbRole.Where(p => p.Id == tb.Id).FirstOrDefault();

                data.Description = tb.Description;
                data.RoleName    = tb.RoleName;
                data.UpdateBy    = tb.UpdateBy;
                data.UpdateTime  = DateTime.Now;


                int DataCount = myDbContext.tbRole.Where(p => p.RoleName == data.RoleName && p.Id != data.Id).Count <tbRole>();
                if (DataCount > 0)
                {
                    throw new Exception(string.Format("角色名:{0}重复,请重新输入", data.RoleName));
                }


                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "更新成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#7
0
        public static string AddRole(string Rolestr)
        {
            string str = string.Empty;

            try
            {
                tbRole tb = JsonConvert.DeserializeObject <tbRole>(Rolestr);

                tbRole newtb = new tbRole()
                {
                    RoleName    = tb.RoleName,
                    CreateBy    = tb.CreateBy,
                    CreateTime  = DateTime.Now,
                    Description = tb.Description,
                    UpdateTime  = DateTime.Now,
                    UpdateBy    = tb.CreateBy
                };
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                int DataCount = myDbContext.tbRole.Where(p => p.RoleName == newtb.RoleName).Count <tbRole>();
                if (DataCount > 0)
                {
                    throw new Exception(string.Format("角色名:{0}重复,请重新输入", newtb.RoleName));
                }

                myDbContext.tbRole.Add(newtb);
                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "保存成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#8
0
        public static bool CheckChildNode(AchieveDBEntities myDbContext, int MenuId, string[] Childlist)
        {
            bool findbj = false;

            if (string.IsNullOrEmpty(Childlist[0]))
            {
                return(findbj);
            }

            List <tbMenu> menuList = myDbContext.tbMenu.Where(p => p.ParentId == MenuId).ToList();

            if (menuList != null && menuList.Count > 0)
            {
                foreach (tbMenu temp in menuList)
                {
                    foreach (string st in Childlist)
                    {
                        if (temp.Id.ToString() == st)
                        {
                            findbj = true;
                            return(findbj);
                        }
                    }
                    findbj = CheckChildNode(myDbContext, temp.Id, Childlist);
                    if (findbj)
                    {
                        return(findbj);
                    }
                }
            }
            return(findbj);
        }
示例#9
0
        public static string UpdateParameter(string Parameterstr)
        {
            string str = string.Empty;

            try
            {
                tbParameter       tb          = JsonConvert.DeserializeObject <tbParameter>(Parameterstr);
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                tbParameter       data        = myDbContext.tbParameter.Where(p => p.id == tb.id).FirstOrDefault();
                if (data != null)
                {
                    int DataCount = myDbContext.tbParameter.Where(p => p.Code == tb.Code && p.id != tb.id).Count <tbParameter>();
                    if (DataCount > 0)
                    {
                        throw new Exception(string.Format("Code:{0}重复,请重新输入", data.Code));
                    }
                    string[] keys = { "id" };
                    ObjectHelper.CopyValueNotKey(tb, data, keys);
                }
                else
                {
                    throw new Exception(string.Format("Key:{0}找不到相关数据", tb.id));
                }


                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "更新成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#10
0
        public static string GetFlowInfoByMenuId(int MenuId)
        {
            string str = string.Empty;


            try
            {
                IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";

                AchieveDBEntities     myDbContext = new AchieveDBEntities();
                List <v_FlowViewInfo> tblist      = new List <v_FlowViewInfo>();


                int DataCount = 0;

                tblist = myDbContext.v_FlowViewInfo.Where(p => p.MenuId == MenuId).ToList();
                if (tblist != null && tblist.Count > 0)
                {
                    str = JsonConvert.SerializeObject(tblist, Formatting.Indented, timeFormat);
                    str = ResponseHelper.ResponseMsg("1", "取数成功", str, DataCount);
                }
                else
                {
                    str = JsonConvert.SerializeObject(tblist, Formatting.Indented, timeFormat);
                    str = ResponseHelper.ResponseMsg("-1", "无流程信息", str, DataCount);
                }
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#11
0
        public static string DeleteBillNo(string[] BillNoList)
        {
            string str = string.Empty;

            try
            {
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                foreach (string temp in BillNoList)
                {
                    int             delId   = Convert.ToInt32(temp);
                    List <tbBillNo> delList = myDbContext.tbBillNo.Where(p => p.Id == delId).ToList();
                    if (delList != null && delList.Count > 0)
                    {
                        myDbContext.tbBillNo.Remove(delList[0]);
                    }
                }



                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "删除成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#12
0
        public static string GetDeptAllCount()
        {
            string str1 = string.Empty;

            try
            {
                IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";

                AchieveDBEntities myDbContext = new AchieveDBEntities();


                int Count = myDbContext.tbDepartment.Count <tbDepartment>();



                str1 = ResponseHelper.ResponseMsg("1", "取数成功", Count.ToString());
            }
            catch (Exception ex)
            {
                str1 = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str1);
        }
示例#13
0
        public static string AddMenu(string Menustr)
        {
            string str = string.Empty;

            try
            {
                tbMenu tb    = JsonConvert.DeserializeObject <tbMenu>(Menustr);
                tbMenu newtb = new tbMenu()
                {
                    Code        = tb.Code,
                    CreateTime  = DateTime.Now,
                    LinkAddress = tb.LinkAddress,
                    CreateBy    = tb.CreateBy,
                    Icon        = tb.Icon,
                    Name        = tb.Name,
                    ParentId    = tb.ParentId,
                    Sort        = tb.Sort,
                    UpdateBy    = tb.CreateBy,
                    UpdateTime  = DateTime.Now
                };
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                myDbContext.tbMenu.Add(newtb);
                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "取数成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#14
0
        public static string UpdateBlackList(string BlackListStr)
        {
            string str = string.Empty;

            try
            {
                tbBlackList       tb          = JsonConvert.DeserializeObject <tbBlackList>(BlackListStr);
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                tbBlackList       data        = myDbContext.tbBlackList.Where(p => p.Id == tb.Id).FirstOrDefault();
                //data.Address = tb.Address;
                //data.CreateTime = tb.CreateTime;
                //data.IsAble = tb.IsAble;
                //data.Notes = tb.Notes;
                //data.Port = tb.Port;
                string [] keys = { "Id" };
                ObjectHelper.CopyValueNotKey(tb, data, keys);

                int DataCount = myDbContext.tbBlackList.Where(p => p.Address == data.Address && p.Id != data.Id).Count <tbBlackList>();
                if (DataCount > 0)
                {
                    throw new Exception(string.Format("黑名单IP:{0}重复,请重新输入", data.Address));
                }


                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "更新成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#15
0
        public static string UpdateDept(string Deptstr)
        {
            string str = string.Empty;

            try
            {
                tbDepartment      tb          = JsonConvert.DeserializeObject <tbDepartment>(Deptstr);
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                tbDepartment      data        = myDbContext.tbDepartment.Where(p => p.Id == tb.Id).FirstOrDefault();
                data.DepartmentName = tb.DepartmentName;
                data.ParentId       = tb.ParentId;
                data.Sort           = tb.Sort;
                data.UpdateBy       = tb.UpdateBy;
                data.UpdateTime     = DateTime.Now;


                int DataCount = myDbContext.tbDepartment.Where(p => p.DepartmentName == data.DepartmentName && p.Id != data.Id).Count <tbDepartment>();
                if (DataCount > 0)
                {
                    throw new Exception(string.Format("部门名:{0}重复,请重新输入", data.DepartmentName));
                }


                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "更新成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#16
0
        public static string GetAllParameterInfo(string ParameterStr, int PageSize, int CurrentPage)
        {
            string str = string.Empty;


            try
            {
                List <FilterModel> whereList = new List <FilterModel>();
                if (!string.IsNullOrEmpty(ParameterStr))
                {
                    whereList = JsonConvert.DeserializeObject <List <FilterModel> >(ParameterStr);
                }
                IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";

                AchieveDBEntities  myDbContext = new AchieveDBEntities();
                List <tbParameter> templist    = new List <tbParameter>();

                int DataCount = 0;
                if (whereList.Count > 0)
                {
                    var wherevar = LinqHelper.GetFilterExpression <tbParameter>(whereList).Compile();
                    DataCount = myDbContext.tbParameter.Where(wherevar).Count <tbParameter>();
                }
                else
                {
                    DataCount = myDbContext.tbParameter.Count <tbParameter>();
                }
                if (whereList.Count > 0)
                {
                    templist = myDbContext.tbParameter.Where(LinqHelper.GetFilterExpression <tbParameter>(whereList).Compile()).OrderByDescending(p => p.UpdateTime).Skip((CurrentPage - 1) * PageSize).Take(PageSize).ToList();
                    if (templist == null)
                    {
                        templist = new List <tbParameter>();
                    }
                }
                else
                {
                    templist = myDbContext.tbParameter.OrderByDescending(p => p.UpdateTime).Skip((CurrentPage - 1) * PageSize).Take(PageSize).ToList();
                }


                if (templist != null && templist.Count > 0)
                {
                    str = JsonConvert.SerializeObject(templist, Formatting.Indented, timeFormat);
                    str = ResponseHelper.ResponseMsg("1", "取数成功", str, DataCount);
                }
                else
                {
                    str = JsonConvert.SerializeObject(templist, Formatting.Indented, timeFormat);
                    str = ResponseHelper.ResponseMsg("-1", "信息不存在", str, DataCount);
                }
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#17
0
        public static string UpdateMenu(string Menustr)
        {
            string str = string.Empty;

            try
            {
                tbMenu            tb          = JsonConvert.DeserializeObject <tbMenu>(Menustr);
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                tbMenu            data        = myDbContext.tbMenu.Where(p => p.Id == tb.Id).FirstOrDefault();


                data.Code        = tb.Code;
                data.LinkAddress = tb.LinkAddress;

                data.Icon       = tb.Icon;
                data.Name       = tb.Name;
                data.ParentId   = tb.ParentId;
                data.Sort       = tb.Sort;
                data.UpdateBy   = tb.UpdateBy;
                data.UpdateTime = DateTime.Now;



                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "更新成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#18
0
        public static string UpdateBillNo(string tbBillNoStr)
        {
            string str = string.Empty;

            try
            {
                tbBillNo          tb          = JsonConvert.DeserializeObject <tbBillNo>(tbBillNoStr);
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                tbBillNo          data        = myDbContext.tbBillNo.Where(p => p.Id == tb.Id).FirstOrDefault();

                string[] keys = { "Id", "CurrentId", "CurrentBillNo", "CurrentTime" };
                ObjectHelper.CopyValueNotKey(tb, data, keys);
                data.UpdateTime = DateTime.Now;
                int DataCount = myDbContext.tbBillNo.Where(p => p.Code == data.Code && p.Id != data.Id).Count <tbBillNo>();
                if (DataCount > 0)
                {
                    throw new Exception(string.Format("单据编号:{0}重复,请重新输入", data.Code));
                }


                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "更新成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#19
0
        public static string UpdateFlowStatus(string Code, int oldStatus, int newStatus, string UpdateBy)
        {
            string str = string.Empty;

            try
            {
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                tbFlow            main        = myDbContext.tbFlow.Where(p => p.Code == Code).ToList().FirstOrDefault();
                if (main == null)
                {
                    throw new Exception("未找到相关数据!");
                }
                if (main.status != oldStatus)
                {
                    throw new Exception("数据已经被其它人操作,请刷新!");
                }
                main.status     = newStatus;
                main.UpdateTime = DateTime.Now;
                main.UpdateBy   = UpdateBy;
                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "保存成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#20
0
        public static string AddParameter(string Parameterstr)
        {
            string str = string.Empty;

            try
            {
                tbParameter tb = JsonConvert.DeserializeObject <tbParameter>(Parameterstr);
                tb.CreateTime = DateTime.Now;
                tb.UpdateTime = DateTime.Now;
                string[]    keys  = { "id" };
                tbParameter newtb = new tbParameter();
                ObjectHelper.CopyValueNotKey(tb, newtb, keys);
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                int DataCount = myDbContext.tbParameter.Where(p => p.Code == tb.Code).Count <tbParameter>();
                if (DataCount > 0)
                {
                    throw new Exception(string.Format("Code:{0}重复,请重新输入", tb.Code));
                }
                myDbContext.tbParameter.Add(newtb);
                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "保存成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#21
0
        public static string GetBillNo(AchieveDBEntities DbContext, string Code)
        {
            string str = string.Empty;

            try
            {
                tbBillNo temp = DbContext.tbBillNo.Where(p => p.Code == Code).FirstOrDefault();
                if (temp == null)
                {
                    throw  new Exception("单据编码信息未找到");
                }
                if (temp.EndLength < 0)
                {
                    throw new Exception("单据编码流水异常");
                }
                int      nextnum     = Convert.ToInt32(temp.CurrentId) + 1;
                DateTime now         = DateTime.Now;
                DateTime CurrentTime = temp.CurrentTime == null ? now : Convert.ToDateTime(temp.CurrentTime);
                int      CurrentId   = Convert.ToInt32(temp.CurrentId);
                string   ymd         = string.Empty;
                switch (temp.MaskInfo)
                {
                case "yyyy":
                    if (now.Year != CurrentTime.Year)
                    {
                        CurrentId = 0;
                    }
                    ymd = now.ToString("yyyy");
                    break;

                case "yyyyMM":
                    if (now.Year != CurrentTime.Year || now.Month != CurrentTime.Month)
                    {
                        CurrentId = 0;
                    }
                    ymd = now.ToString("yyyyMM");
                    break;

                case "yyyyMMdd":
                    if (now.Year != CurrentTime.Year || now.Month != CurrentTime.Month || now.Day != CurrentTime.Day)
                    {
                        CurrentId = 0;
                    }
                    ymd = now.ToString("yyyyMMdd");
                    break;
                }
                CurrentId++;
                str = string.Concat(temp.Code, ymd, CurrentId.ToString().PadLeft(temp.EndLength, '0'));
                temp.CurrentTime   = now;
                temp.CurrentId     = CurrentId;
                temp.CurrentBillNo = str;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(str);
        }
示例#22
0
        public static string AddFlow(string Flowstr)
        {
            string str = string.Empty;

            try
            {
                DateTime          now         = DateTime.Now;
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                FlowModel         tb          = JsonConvert.DeserializeObject <FlowModel>(Flowstr);
                tbFlow            Flow        = new tbFlow();
                ObjectHelper.CopyValue(tb.Flow, Flow);
                List <tbFlowStep>             FlowStep     = tb.FlowStep;
                List <v_FlowStepUserViewInfo> FlowStepUser = tb.FlowStepUser;
                if (tb == null)
                {
                    throw new Exception("流程数据异常!");
                }
                if (FlowStep == null || FlowStep.Count <= 0)
                {
                    throw new Exception("流程步骤数据异常!");
                }
                //if (FlowStepUser == null || FlowStepUser.Count <= 0)
                //{
                //    throw new Exception("流程步骤数据异常!");
                //}
                //string Code = Guid.NewGuid().ToString();
                string No = BillNoBill.GetBillNo(myDbContext, "LC");

                Flow.CreateTime = now;
                Flow.UpdateTime = now;
                Flow.status     = 0;
                //Flow.Code = Code;
                Flow.No = No;
                myDbContext.tbFlow.Add(Flow);
                foreach (var st in FlowStep)
                {
                    st.CreateTime = now;
                    st.UpdateTime = now;
                    myDbContext.tbFlowStep.Add(st);
                }
                foreach (var st in FlowStepUser)
                {
                    st.CreateTime = now;
                    st.UpdateTime = now;
                    tbFlowStepUser temp = new tbFlowStepUser();
                    string[]       keys = { "Id" };
                    ObjectHelper.CopyValue(st, temp);
                    myDbContext.tbFlowStepUser.Add(temp);
                }
                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "保存成功", Flow.Code);
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#23
0
        public static string DeleteMenu(string[] MenuList)
        {
            string str = string.Empty;

            try
            {
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                foreach (string temp in MenuList)
                {
                    int           delId   = Convert.ToInt32(temp);
                    List <tbMenu> delList = myDbContext.tbMenu.Where(p => p.Id == delId).ToList();
                    if (delList != null && delList.Count > 0)
                    {
                        myDbContext.tbMenu.Remove(delList[0]);
                    }
                    List <tbMenuButton> delMenuButtonList = new List <tbMenuButton>();
                    delMenuButtonList = myDbContext.tbMenuButton.Where(p => p.MenuId == delId).ToList();
                    if (delMenuButtonList != null && delMenuButtonList.Count > 0)
                    {
                        foreach (var t in delMenuButtonList)
                        {
                            myDbContext.tbMenuButton.Remove(t);
                        }
                    }
                    List <tbRoleMenu> delRoleMenuList = new List <tbRoleMenu>();
                    delRoleMenuList = myDbContext.tbRoleMenu.Where(p => p.MenuId == delId).ToList();
                    if (delRoleMenuList != null && delRoleMenuList.Count > 0)
                    {
                        foreach (var t in delRoleMenuList)
                        {
                            myDbContext.tbRoleMenu.Remove(t);
                        }
                    }
                    List <tbRoleMenuButton> delRoleMenuButtonList = new List <tbRoleMenuButton>();
                    delRoleMenuButtonList = myDbContext.tbRoleMenuButton.Where(p => p.MenuId == delId).ToList();

                    if (delRoleMenuButtonList != null && delRoleMenuButtonList.Count > 0)
                    {
                        foreach (var t in delRoleMenuButtonList)
                        {
                            myDbContext.tbRoleMenuButton.Remove(t);
                        }
                    }
                }



                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "取数成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#24
0
        public static string GetUserMenu(int userID, string token)
        {
            string str = string.Empty;

            try
            {
                IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                tbUser            temp        = new tbUser();
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                int count = myDbContext.tbUserToken.Where(p => p.UserId == userID && p.Token == token).Count <tbUserToken>();
                if (count <= 0)
                {
                    throw new Exception("帐号异常,请退出系统!");
                }
                List <tbUser> templist = myDbContext.tbUser.Where(p => p.ID == userID).ToList();
                if (templist != null && templist.Count > 0)
                {
                    var query = from ur in myDbContext.tbUserRole
                                join rmb in myDbContext.tbRoleMenu on ur.RoleId equals rmb.RoleId
                                join m in myDbContext.tbMenu on rmb.MenuId equals m.Id
                                where ur.UserId == userID &&
                                m.ParentId == 0
                                orderby m.ParentId, m.Sort
                    select m;
                    List <MenuTreeModel> list = new List <MenuTreeModel>();
                    if (query != null)
                    {
                        foreach (var tp in query)
                        {
                            MenuTreeModel m = new MenuTreeModel();
                            m.Id       = tp.Id.ToString();
                            m.Icon     = tp.Icon;
                            m.MenuName = tp.Name;
                            m.ParentId = tp.ParentId.ToString();
                            m.Url      = tp.LinkAddress;
                            m.Node     = GetChildMenu(userID, tp.Id);
                            list.Add(m);
                        }
                    }

                    str = JsonConvert.SerializeObject(list, Formatting.Indented, timeFormat);
                    str = ResponseHelper.ResponseMsg("1", "取数成功", str);
                }
                else
                {
                    str = JsonConvert.SerializeObject(temp, Formatting.Indented, timeFormat);
                    str = ResponseHelper.ResponseMsg("-1", "用户ID不存在", str);
                }
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#25
0
        public static string GetNoticeItemById(string Code)
        {
            string str = string.Empty;

            try
            {
                IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                tbRole temp = new tbRole();
                //NoticeModel returnModel = new NoticeModel();
                AchieveDBEntities myDbContext = new AchieveDBEntities();



                var query = from nu in myDbContext.tbNoticeUser
                            join u in myDbContext.tbUser on nu.UserId equals u.ID
                            where nu.NoticeCode == Code
                            orderby nu.id
                            select new NoticeUserModel
                {
                    AccountName = u.AccountName,
                    CreateBy    = nu.CreateBy,
                    CreateTime  = nu.CreateTime,
                    id          = nu.id,
                    NoticeCode  = nu.NoticeCode,
                    SendFlag    = nu.SendFlag,
                    SendTime    = nu.SendTime,
                    UpdateBy    = nu.UpdateBy,
                    UpdateTime  = nu.UpdateTime,
                    UserId      = nu.UserId,
                    RealName    = u.RealName
                };

                List <NoticeUserModel> item = new List <NoticeUserModel>();
                if (query != null)
                {
                    item = query.ToList();



                    str = JsonConvert.SerializeObject(item, Formatting.Indented, timeFormat);
                    str = ResponseHelper.ResponseMsg("1", "取数成功", str);
                }
                else
                {
                    str = JsonConvert.SerializeObject(item, Formatting.Indented, timeFormat);
                    str = ResponseHelper.ResponseMsg("-1", "通知信息不存在", str, 0);
                }
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#26
0
        public static string GetTreeUserAll()
        {
            string str1 = string.Empty;

            try
            {
                IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";

                AchieveDBEntities myDbContext = new AchieveDBEntities();


                var query = from m in myDbContext.tbUser

                            orderby m.ID
                            select m;
                List <string> listtemp = new List <string>();
                string        temp     = string.Empty;
                if (query != null)
                {
                    foreach (var tp in query)
                    {
                        string str = "{\"id\":\"all-0-" + tp.ID.ToString() + "\" , \"label\":\"" + tp.AccountName + "\",\"RealName\":\"" + tp.RealName + "\",\"value\":\"all-0-" + tp.ID.ToString() + "\" , \"key\":\"all-0-" + tp.ID.ToString() + "\",\"title\":\"" + tp.RealName + "\"}";
                        listtemp.Add(str);
                    }

                    for (int i = 0; i < listtemp.Count; i++)
                    {
                        if (i != listtemp.Count - 1)
                        {
                            temp = string.Concat(temp, listtemp[i], ",");
                        }
                        else
                        {
                            temp = string.Concat(temp, listtemp[i]);
                        }
                    }
                }
                else
                {
                    temp = "";
                }


                str1 = "[" + temp + "]";
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(str1);
        }
示例#27
0
        public static string AddUser(string Userstr)
        {
            string str = string.Empty;

            try
            {
                tbUser tb       = JsonConvert.DeserializeObject <tbUser>(Userstr);
                string passWord = Base64Helper.DecodeBase64(tb.Password);
                string password = Md5Helper.GetMD5String(passWord);
                tbUser newtb    = new tbUser()
                {
                    AccountName = tb.AccountName,
                    CreateBy    = tb.CreateBy,
                    CreateTime  = DateTime.Now,
                    Description = tb.Description,
                    Email       = tb.Email,
                    IfChangePwd = tb.IfChangePwd,
                    IsAble      = tb.IsAble,
                    MobilePhone = tb.MobilePhone,
                    Password    = password,
                    RealName    = tb.RealName,
                    UpdateTime  = DateTime.Now,
                    UpdateBy    = tb.CreateBy
                };
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                int DataCount = myDbContext.tbUser.Where(p => p.AccountName == newtb.AccountName).Count <tbUser>();
                if (DataCount > 0)
                {
                    throw new Exception(string.Format("帐号名:{0}重复,请重新输入", newtb.AccountName));
                }
                DataCount = myDbContext.tbUser.Where(p => p.Email == newtb.Email).Count <tbUser>();
                if (DataCount > 0)
                {
                    throw new Exception(string.Format("邮箱:{0}重复,请重新输入", newtb.Email));
                }
                DataCount = myDbContext.tbUser.Where(p => p.MobilePhone == newtb.MobilePhone).Count <tbUser>();
                if (DataCount > 0)
                {
                    throw new Exception(string.Format("手机号:{0}重复,请重新输入", newtb.MobilePhone));
                }
                myDbContext.tbUser.Add(newtb);
                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "保存成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#28
0
        public static string DeleteFlow(string[] FlowList)
        {
            string str = string.Empty;

            try
            {
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                int i = 0;
                foreach (string temp in FlowList)
                {
                    tbFlow deltbFlow = myDbContext.tbFlow.Where(p => p.Code == temp).FirstOrDefault();
                    if (deltbFlow == null)
                    {
                        continue;
                    }
                    if (deltbFlow.status != 0)
                    {
                        continue;
                    }
                    myDbContext.tbFlow.Remove(deltbFlow);
                    List <tbFlowStep> delFlowStep = myDbContext.tbFlowStep.Where(p => p.FlowCode == temp).ToList();
                    if (delFlowStep != null && delFlowStep.Count > 0)
                    {
                        foreach (var st in delFlowStep)
                        {
                            myDbContext.tbFlowStep.Remove(st);
                        }
                    }
                    List <tbFlowStepUser> delFlowStepUser = myDbContext.tbFlowStepUser.Where(p => p.FlowCode == temp).ToList();
                    if (delFlowStepUser != null && delFlowStepUser.Count > 0)
                    {
                        foreach (var st in delFlowStepUser)
                        {
                            myDbContext.tbFlowStepUser.Remove(st);
                        }
                    }
                }



                myDbContext.SaveChanges();
                string msg = string.Format("提交{0}条数据,成功删除{1}条", FlowList.Length, i);
                str = ResponseHelper.ResponseMsg("1", msg, "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#29
0
        public static string UpdateUserAllinfo(string Userstr)
        {
            string str = string.Empty;

            try
            {
                tbUser            tb          = JsonConvert.DeserializeObject <tbUser>(Userstr);
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                tbUser            data        = myDbContext.tbUser.Where(p => p.ID == tb.ID).FirstOrDefault();
                string            passWord    = Base64Helper.DecodeBase64(tb.Password);
                string            password    = Md5Helper.GetMD5String(passWord);
                data.AccountName = tb.AccountName;
                data.Description = tb.Description;
                data.Email       = tb.Email;
                data.IfChangePwd = tb.IfChangePwd;
                data.IsAble      = tb.IsAble;
                data.MobilePhone = tb.MobilePhone;
                data.Password    = password;
                data.RealName    = tb.RealName;
                data.UpdateBy    = tb.UpdateBy;
                data.UpdateTime  = DateTime.Now;


                int DataCount = myDbContext.tbUser.Where(p => p.AccountName == data.AccountName && p.ID != data.ID).Count <tbUser>();
                if (DataCount > 0)
                {
                    throw new Exception(string.Format("帐号名:{0}重复,请重新输入", data.AccountName));
                }
                DataCount = myDbContext.tbUser.Where(p => p.Email == data.Email && p.ID != data.ID).Count <tbUser>();
                if (DataCount > 0)
                {
                    throw new Exception(string.Format("邮箱:{0}重复,请重新输入", data.Email));
                }
                DataCount = myDbContext.tbUser.Where(p => p.MobilePhone == data.MobilePhone && p.ID != data.ID).Count <tbUser>();
                if (DataCount > 0)
                {
                    throw new Exception(string.Format("手机号:{0}重复,请重新输入", data.MobilePhone));
                }

                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "更新成功", "");
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#30
0
        public static string AddNotice(string Noticetstr)
        {
            string str = string.Empty;

            try
            {
                AchieveDBEntities      myDbContext = new AchieveDBEntities();
                NoticeModel            tb          = JsonConvert.DeserializeObject <NoticeModel>(Noticetstr);
                string                 Code        = Guid.NewGuid().ToString();
                string                 BillNo      = BillNoBill.GetBillNo(myDbContext, "TZ");
                tbNotice               main        = tb.Main;
                List <NoticeUserModel> item        = tb.Item;
                main.CreateTime = DateTime.Now;
                main.UpdateTime = DateTime.Now;
                main.NoticeTime = DateTime.Now;
                main.status     = 0;
                main.Code       = Code;
                main.No         = BillNo;
                if (item != null && item.Count > 0)
                {
                    foreach (var st in item)
                    {
                        st.NoticeCode = Code;
                        st.SendFlag   = 0;
                        st.UpdateTime = DateTime.Now;
                        st.CreateTime = DateTime.Now;
                    }
                }

                myDbContext.tbNotice.Add(main);
                foreach (var st in item)
                {
                    tbNoticeUser temp = new tbNoticeUser();
                    string[]     keys = { "id" };
                    ObjectHelper.CopyValueNotKey(st, temp, keys);
                    myDbContext.tbNoticeUser.Add(temp);
                }
                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "保存成功", Code);
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }