private void configSingleprojectLimits(HttpContext context)
        {
            string json = "";

            try
            {
                List <string> slList = CFunctions.JsonDeserialize <List <string> >(context.Request["SingleprojectLimits"].ToString());
                DaoFactory.BeginTransaction();

                slBLL.Delete(" 1=1 ");

                foreach (string sl in slList)
                {
                    string [] sls     = sl.Split(',');
                    string[]  Limitss = sls[1].Split('+');
                    foreach (string Limits in Limitss)
                    {
                        if (Limits == "")
                        {
                            continue;
                        }
                        TBL_SINGLEPROJECT_LIMITS tsl = new TBL_SINGLEPROJECT_LIMITS();
                        tsl.singleproject_limitid = System.Guid.NewGuid().ToString().ToUpper();
                        tsl.organizationid        = sls[0];
                        tsl.singleprojecttypeid   = Limits;
                        slBLL.Insert(tsl);
                    }
                }

                DaoFactory.CommitTransaction();
                json = "{IsSuccess:'true',Message:'保存成功!'}";
            }
            catch (Exception ex)
            {
                DaoFactory.RollBackTransaction();
                logger.Error(ex.Message);
                json = "{IsSuccess:'false',Message:'服务器交互失败!'}";
            }



            json = JsonConvert.SerializeObject(json);

            context.Response.ContentType = "application/json";
            //返回JSON结果
            context.Response.Write(json);
            context.Response.End();
        }
Пример #2
0
        private void del(HttpContext context)
        {
            string json = "{IsSuccess:'true',Message:'删除成功!'}";
            string materialapplicationid = context.Request["materialapplicationid"];
            string processnumber         = context.Request["processnumber"];
            List <TBL_MATERIALAPPLICATION_PROJECT> mapList = mapBLL.GetList(" and materialapplicationid='" + materialapplicationid + "' ").ToList <TBL_MATERIALAPPLICATION_PROJECT>();


            try
            {
                WorkFlow.Model.FLOW_TASK tasks = WorkFlow.BLL.Operate.GetTask(processnumber);
                if (tasks == null)
                {
                    DaoFactory.BeginTransaction();

                    foreach (TBL_MATERIALAPPLICATION_PROJECT map in mapList)
                    {
                        madBLL.Delete("  materialapplicationprojectid='" + map.materialapplicationprojectid + "'  ");

                        mapBLL.Delete("  materialapplicationprojectid='" + map.materialapplicationprojectid + "'  ");
                    }

                    maBLL.Delete(" materialapplicationid='" + materialapplicationid + "' ");
                    DaoFactory.CommitTransaction();
                }
                else
                {
                    json = "{IsSuccess:'false',Message:'单号已经提交流程不能删除!'}";
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                json = "{IsSuccess:'false',Message:'删除失败!'}";
                DaoFactory.RollBackTransaction();
            }

            json = JsonConvert.SerializeObject(json);
            context.Response.ContentType = "application/json";
            //返回JSON结果
            context.Response.Write(json);
            context.Response.End();
        }
Пример #3
0
        private void add(HttpContext context)
        {
            string json = "{IsSuccess:'true',Message:'保存成功!'}";
            //List<TBL_MATERIALAPPLICATION_PROJECT> pList = new List<TBL_MATERIALAPPLICATION_PROJECT>();
            //TBL_MATERIALAPPLICATION ma = new TBL_MATERIALAPPLICATION();
            //ma.materialapplicationid = System.Guid.NewGuid().ToString().ToUpper();
            //ma.processnumber = context.Request["processnumber"];
            //ma.organizationid = context.Request["organizationid"];
            //ma.applicantname = context.Request["applicantname"];
            //ma.useinstructions = context.Request["useinstructions"];
            //ma.submitdate = context.Request["submitdate"];
            string flowstate = context.Request["flowstate"];

            try
            {
                TBL_MATERIALAPPLICATION ma = CFunctions.JsonDeserialize <TBL_MATERIALAPPLICATION>(context.Request["materialapply"].ToString());
                ma.materialapplicationid = System.Guid.NewGuid().ToString().ToUpper();
                WorkFlow.Model.FLOW_TASK tasks = WorkFlow.BLL.Operate.GetTask(ma.processnumber);
                if (tasks == null)
                {
                    DaoFactory.BeginTransaction();


                    List <TBL_MATERIALAPPLICATION> maList = maBLL.GetList(" and processnumber='" + ma.processnumber + "' ").ToList <TBL_MATERIALAPPLICATION>();
                    if (maList.Count == 0)
                    {
                        if (maBLL.Insert(ma))
                        {
                            foreach (TBL_MATERIALAPPLICATION_PROJECT map in ma.projects)
                            {
                                map.materialapplicationid        = ma.materialapplicationid;
                                map.materialapplicationprojectid = System.Guid.NewGuid().ToString().ToUpper();
                                if (mapBLL.Insert(map))
                                {
                                    foreach (TBL_MATERIALAPPLICATION_DETAIL mad in map.madetail)
                                    {
                                        mad.materialapplicationdetailid  = System.Guid.NewGuid().ToString().ToUpper();
                                        mad.materialapplicationprojectid = map.materialapplicationprojectid;
                                        madBLL.Insert(mad);
                                    }
                                }
                                else
                                {
                                    json = "{IsSuccess:'false',Message:'保存失败!'}";
                                    DaoFactory.RollBackTransaction();
                                    break;
                                }
                            }


                            if (flowstate == "1")
                            {
                                WorkFlow.Model.FLOW_TASK task = new WorkFlow.Model.FLOW_TASK();
                                task.TASK_ID     = Guid.NewGuid().ToString().ToUpper();
                                task.DEFINE_CODE = "LCBM20161208100520";
                                task.TASK_CODE   = ma.processnumber;
                                task.TASK_TILTE  = "材料申请" + DateTime.Now.ToString("yyyyMMddHHmmss");
                                task.STATUS      = "0";
                                task.TASK_TYPE   = "8CF337E8-08C0-45E7-97C4-1C2E617D06CC";
                                task.ADD_EMP     = CFunctions.getUserId(context);
                                task.TASK_JSON   = JsonConvert.SerializeObject(ma);
                                bool s = createFlow(task);
                                s    = sendFlow(task.TASK_CODE, task.DEFINE_CODE, task.ADD_EMP);
                                json = "{IsSuccess:'true',Message:'提交成功!'}";
                            }

                            DaoFactory.CommitTransaction();
                        }
                        else
                        {
                            json = "{IsSuccess:'false',Message:'保存失败!'}";
                            DaoFactory.RollBackTransaction();
                        }
                    }
                    else
                    {
                        if (flowstate == "1")
                        {
                            WorkFlow.Model.FLOW_TASK task = new WorkFlow.Model.FLOW_TASK();
                            task.TASK_ID     = Guid.NewGuid().ToString().ToUpper();
                            task.DEFINE_CODE = "LCBM20161208100520";
                            task.TASK_CODE   = ma.processnumber;
                            task.TASK_TILTE  = "材料申请" + DateTime.Now.ToString("yyyyMMddHHmmss");
                            task.STATUS      = "0";
                            task.TASK_TYPE   = "8CF337E8-08C0-45E7-97C4-1C2E617D06CC";
                            task.ADD_EMP     = CFunctions.getUserId(context);
                            task.TASK_JSON   = JsonConvert.SerializeObject(ma);
                            bool s = createFlow(task);
                            s    = sendFlow(task.TASK_CODE, task.DEFINE_CODE, task.ADD_EMP);
                            json = "{IsSuccess:'true',Message:'提交成功!'}";
                        }
                        else
                        {
                            json = "{IsSuccess:'false',Message:'申请单号存在!'}";
                        }
                    }
                }
                else
                {
                    json = "{IsSuccess:'true',Message:'此单号已经提交!'}";
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                json = "{IsSuccess:'false',Message:'保存失败!'}";
                DaoFactory.RollBackTransaction();
            }

            json = JsonConvert.SerializeObject(json);
            context.Response.ContentType = "application/json";
            //返回JSON结果
            context.Response.Write(json);
            context.Response.End();
        }