Exemple #1
0
        public string GetModelListByHeaderIDADF(int headerID)
        {
            BaseMessage_Model <List <TBase_Model> > messageModel = new BaseMessage_Model <List <TBase_Model> >();

            try
            {
                List <TBase_Model> modelList = db.GetModelListByHeaderID(headerID);

                if (modelList == null || modelList.Count == 0)
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = "获取" + GetModelChineseName() + "数据列表为空!";
                }
                else
                {
                    messageModel.HeaderStatus = "S";
                    messageModel.ModelJson    = modelList;
                }
                return(JsonConvert.SerializeObject(messageModel));
            }
            catch (Exception ex)
            {
                messageModel.HeaderStatus = "E";
                messageModel.Message      = ex.Message;
                messageModel.ModelJson    = null;
                return(JsonConvert.SerializeObject(messageModel));
            }
        }
Exemple #2
0
        public string UpdateModelListSqlToDBADF(string UserJson, string ModelJson)
        {
            BaseMessage_Model <List <TBase_Model> > model = new BaseMessage_Model <List <TBase_Model> >();

            try
            {
                bool bSucc = false;

                string strError = "";


                if (string.IsNullOrEmpty(UserJson))
                {
                    model.HeaderStatus = "E";
                    model.Message      = "传入用户信息为空!";
                    return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(model));
                }

                User.UserModel user = JSONUtil.JSONHelper.JsonToObject <User.UserModel>(UserJson);

                List <TBase_Model> modelList = GetModelListByJson(UserJson, ModelJson);

                bSucc = db.UpdateModelListBySqlToDB(user, ref modelList, ref strError);

                if (bSucc == false)
                {
                    model.HeaderStatus = "E";
                    model.Message      = strError;
                }
                else
                {
                    model.HeaderStatus = "S";
                    model.TaskNo       = modelList[0].TaskNo;
                    model.Message      = GetSuccessMessage(model.MaterialDoc, modelList[0].TaskNo);
                }

                return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(model));
            }
            catch (Exception ex)
            {
                model.HeaderStatus = "E";
                model.Message      = "更新" + GetModelChineseName() + "失败!" + ex.Message + ex.TargetSite;

                return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(model));
            }
        }
Exemple #3
0
        public string GetModelListByHeaderIDADF(string ModelDetailJson)
        {
            BaseMessage_Model <List <TBase_Model> > messageModel = new BaseMessage_Model <List <TBase_Model> >();

            try
            {
                if (string.IsNullOrEmpty(ModelDetailJson))
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = "业务JSON为空!";
                    return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(messageModel));
                }

                TBase_Model model = GetModelByJson(ModelDetailJson);

                List <TBase_Model> modelList = db.GetModelListByHeaderID(model.HeaderID);

                if (modelList == null || modelList.Count == 0)
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = "获取" + GetModelChineseName() + "数据列表为空!";
                }
                else
                {
                    messageModel.HeaderStatus = "S";
                    messageModel.ModelJson    = modelList;
                }
                return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(messageModel));
            }
            catch (Exception ex)
            {
                messageModel.HeaderStatus = "E";
                messageModel.Message      = ex.Message;
                messageModel.ModelJson    = null;
                return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(messageModel));
            }
        }
Exemple #4
0
        public string SaveModelListSqlToDBADF(User.UserModel user, List <TBase_Model> modelList)
        {
            BaseMessage_Model <List <TBase_Model> > model = new BaseMessage_Model <List <TBase_Model> >();

            try
            {
                bool bSucc = false;

                string strError = "";


                if (user == null)
                {
                    model.HeaderStatus = "E";
                    model.Message      = "传入用户信息为空!";
                    JsonConvert.SerializeObject(model);
                }


                if (CheckModelBeforeSave(modelList, ref strError) == false)
                {
                    model.HeaderStatus = "E";
                    model.Message      = strError;
                    JsonConvert.SerializeObject(model);
                }

                T_Interface_Func tfunc   = new T_Interface_Func();
                string           ERPJson = GetModelListByJsonToERP(user, modelList);//JSONUtil.JSONHelper.ObjectToJson<List<TBase_Model>>(modelList);

                LogNet.LogInfo("ERPJsonBefore:" + ERPJson);
                string interfaceJson = tfunc.PostModelListToInterface(ERPJson);

                model = JSONUtil.JSONHelper.JsonToObject <BaseMessage_Model <List <TBase_Model> > >(interfaceJson);

                LogNet.LogInfo("ERPJsonAfter:" + JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(model));

                //过账失败直接返回
                if (model.HeaderStatus == "E" && !string.IsNullOrEmpty(model.Message))
                {
                    return(interfaceJson);
                }
                else if (model.HeaderStatus == "S" && !string.IsNullOrEmpty(model.MaterialDoc)) //过账成功,并且生成了凭证要记录数据库
                {
                    modelList.ForEach(t => t.MaterialDoc = model.MaterialDoc);
                }

                //LogNet.LogInfo("ERPJson:" + JSONUtil.JSONHelper.ObjectToJson<List<TBase_Model>>(modelList));

                bSucc = db.SaveModelListBySqlToDB(user, ref modelList, ref strError);

                if (bSucc == false)
                {
                    model.HeaderStatus = "E";
                    model.Message      = strError;
                }
                else
                {
                    model.HeaderStatus = "S";
                    model.TaskNo       = modelList[0].TaskNo;
                    model.Message      = GetSuccessMessage(model.MaterialDoc, modelList[0].TaskNo);
                }

                return(JsonConvert.SerializeObject(model));
            }
            catch (Exception ex)
            {
                model.HeaderStatus = "E";
                model.Message      = "保存" + GetModelChineseName() + "失败!" + ex.Message + ex.TargetSite;

                return(JsonConvert.SerializeObject(model));
            }
        }
Exemple #5
0
        public string GetModelListADF(User.UserModel user, TBase_Model baseModel)
        {
            BaseMessage_Model <List <TBase_Model> > messageModel = new BaseMessage_Model <List <TBase_Model> >();

            try
            {
                string strError = string.Empty;

                List <TBase_Model> modelList = new List <TBase_Model>();
                if (user == null)
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = "用户对象为空!";
                    //return JSONUtil.JSONHelper.ObjectToJson<BaseMessage_Model<List<TBase_Model>>>(messageModel);
                    return(JsonConvert.SerializeObject(messageModel));
                }


                if (baseModel == null)
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = "业务对象为空!";
                    //return JSONUtil.JSONHelper.ObjectToJson<BaseMessage_Model<List<TBase_Model>>>(messageModel);
                    return(JsonConvert.SerializeObject(messageModel));
                }

                //TBase_Model model = GetModelByJson(ModelJson);

                if (!string.IsNullOrEmpty(baseModel.ErpVoucherNo))
                {
                    //请求ERP数据
                    if (Sync(baseModel, ref strError) == false)
                    {
                        messageModel.HeaderStatus = "E";
                        messageModel.Message      = "获取" + GetModelChineseName() + "ERP数据失败!" + strError;
                        //return JSONUtil.JSONHelper.ObjectToJson<BaseMessage_Model<List<TBase_Model>>>(messageModel);
                        return(JsonConvert.SerializeObject(messageModel));
                    }
                }


                modelList = db.GetModelListADF(user, baseModel);

                if (modelList == null || modelList.Count == 0)
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = "获取" + GetModelChineseName() + "数据列表为空!";
                }
                else
                {
                    messageModel.HeaderStatus = "S";
                    messageModel.ModelJson    = modelList;
                }
                //return JSONUtil.JSONHelper.ObjectToJson<BaseMessage_Model<List<TBase_Model>>>(messageModel);
                return(JsonConvert.SerializeObject(messageModel));
            }
            catch (Exception ex)
            {
                messageModel.HeaderStatus = "E";
                messageModel.Message      = ex.Message;
                messageModel.ModelJson    = null;
                //return JSONUtil.JSONHelper.ObjectToJson<BaseMessage_Model<List<TBase_Model>>>(messageModel);
                return(JsonConvert.SerializeObject(messageModel));
            }
        }