示例#1
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);
        }
示例#2
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);
        }