示例#1
0
        public override int Update(BaseSearchModel model)
        {
            try
            {
                foreach (RWBarcodeModel item in RWBarcodeModels)
                {
                    //修改条码信息
                    ModelAdo<RWBarcodeModel> adoBarcode = new ModelAdo<RWBarcodeModel>();
                    item.Status = Status;
                    adoBarcode.Update(item);

                    //添加条码历史记录
                    ModelAdo<RWHistoryModel> adoBarcodeHistroy = new ModelAdo<RWHistoryModel>();
                    RWHistoryModel historyModel = new RWHistoryModel()
                    {
                        CreateTime = DateTime.Now,
                        BillID = "",
                        BarcodeID = item.ID,
                        Remark = Remark
                    };
                    adoBarcodeHistroy.Insert(historyModel);
                }
            }
            catch (Exception)
            {
                return 0;
            }

            return 1;
        }
示例#2
0
        public override BaseSearchModel Insert()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                //修改条码中对应装箱ID信息
                ModelAdo<RWBarcodeModel> apiBarcode = new ModelAdo<RWBarcodeModel>();
                //添加历史记录
                ModelAdo<RWHistoryModel> adoBarcodeHistroy = new ModelAdo<RWHistoryModel>();
                foreach (RWBarcodeModel item in RWBarcodeModels)
                {
                    item.BoxID = packingModel.ID;
                    apiBarcode.Update(item);

                    //创建条码历史记录【Add】
                    RWHistoryModel historyModel = new RWHistoryModel()
                    {
                        CreateTime = DateTime.Now,
                        BillID = "",
                        BarcodeID = item.ID,
                        Remark = Remark
                    };
                    adoBarcodeHistroy.Insert(historyModel);
                }

                //修改barcode的条码状态
                ModelAdo<PackingModel> apiPacking = new ModelAdo<PackingModel>();
                packingModel.Status = 2;
                apiPacking.Update(packingModel);

                ts.Complete();
            }
            return this;
        }
示例#3
0
        /// <summary>
        /// token 信息,修改token详细信息
        /// </summary>
        /// <param name="accessToken"></param>
        /// <returns></returns>
        public int updateToken(UserTokenModel model)
        {
            int obj = 0;

            userTokenModel = new ModelAdo <Model.UserTokenModel>();
            UserTokenModel token = userTokenModel.GetModel(" uid =?uid ", "", new MySqlParameter("?uid", model.uid));

            if (token != null)
            {
                model.id = token.id;
                obj      = userTokenModel.Update(model);
            }
            else
            {
                obj = userTokenModel.Insert(model);
            }
            return(obj);
        }
        public override void OnLoad(HttpContext context)
        {
            base.OnLoad(context);
            requestBody          = new RequestBody();
            requestBody.userName = context.Request["userName"];
            requestBody.userPwd  = context.Request["userPwd"];
            requestBody.userType = context.Request["userType"];
            if (requestBody.userName == null || requestBody.userPwd == null || requestBody.userType == null)
            {
                SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
            }
            else
            {
                string password = StringHelper.StringToMD5(requestBody.userPwd);

                ModelAdo <UserModel> userModel = new ModelAdo <UserModel>();
                UserModel            model     = userModel.GetModel(" rid=?rid and name =?name", "",
                                                                    new MySqlParameter("?rid", requestBody.userType),
                                                                    new MySqlParameter("?name", requestBody.userName));
                if (model != null)
                {
                    SystemResponse.Output(SystemResponse.TYPE_EXIST, out statusCode, out responseJson);
                }
                else
                {
                    UserModel token = new UserModel();
                    token.rid      = Convert.ToInt32(requestBody.userType);
                    token.name     = requestBody.userName;
                    token.password = password;
                    token.ctime    = StringHelper.ConvertDateTimeInt(DateTime.Now);
                    if (userModel.Insert(token) >= 1)
                    {
                        responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented);
                    }
                    else
                    {
                        SystemResponse.Output(SystemResponse.TYPE_REGISTER_ERROR, out statusCode, out responseJson);
                    }
                }
            }
        }
示例#5
0
        public override BaseSearchModel Insert()
        {
            if (Count >= 1)
            {
                ModelAdo<PackingModel> modelAdo = new ModelAdo<PackingModel>();
                string[] strs = new string[Count];
                List<PackingModel> list = new List<PackingModel>();
                for (int i = 0; i < Count; i++)
                {
                    PackingModel pm = this.MemberwiseClone() as PackingModel;
                    pm.CreateTime = DateTime.Now;
                    pm.Status = 1;
                    strs[i] = pm.ID;
                    modelAdo.Insert(pm);

                    list.Add(pm);
                }
                this.PackingModels = list.ToArray() ;
                this.ReturnID = strs;
            }
            return this;
        }
示例#6
0
        public override BaseSearchModel Insert()
        {
            ModelAdo<UserModel> adoUser = new ModelAdo<UserModel>();
            userModel = adoUser.GetModel("UR01003=@loginName and UR01004=@pass", "", new SqlParameter("@loginName", this.LoginName), new SqlParameter("@pass", this.Password));
            if (userModel != null)
            {

                ModelAdo<LoginHistoryModel> adoLH = new ModelAdo<LoginHistoryModel>();
                loginHistoryModel = adoLH.GetModel("UR05002=@id and UR05005=1", "*", new SqlParameter("@id", userModel.ID));
                if (loginHistoryModel != null)
                {
                    this.ErrorMsg = string.Format("用户{0}已在其他{1}终端登录,请先退出", userModel.UserName, loginHistoryModel.LoginType);
                    this.LoginSuccess = false;
                }
                else
                {
                    string id = Guid.NewGuid().ToString();
                    loginHistoryModel = new LoginHistoryModel()
                    {
                        ID = id,
                        LoginTime = DateTime.Now,
                        LogoutTime = DateTime.Now,
                        ComputerName = this.ComputerName,
                        IP = this.IP,
                        LoginStatus = 1,
                        LoginType = this.LoginType,
                        UserID = userModel.ID
                    };
                    int result = adoLH.Insert(loginHistoryModel);
                    if (result == 1)
                    {
                        this.Token = id;
                        this.UserID = userModel.ID;
                        this.LoginSuccess = true;
                    }
                }
            }
            else
            {
                this.LoginSuccess = false;
                this.ErrorMsg = "用户名或密码不正确";
            }
            return this;
        }
示例#7
0
        public override BaseSearchModel Insert()
        {
            ModelAdo<WOModel> adoWO = new ModelAdo<WOModel>();
            WOModel modelWO = adoWO.GetModel("MP64001=@wo", "", new SqlParameter("@wo", this.Workorder));
            if (modelWO != null)
            {
                ModelAdo<ReportModel> adoReport = new ModelAdo<ReportModel>();
                List<ReportModel> list = adoReport.GetList("WK02002=@wo", "WK02001", "", new SqlParameter("@wo", this.Workorder));
                if (list.Count == 0)
                {
                    ModelAdo<WOWK01Model> adoWK01 = new ModelAdo<WOWK01Model>();
                    WOWK01Model wk01 = new WOWK01Model()
                    {
                        WorkOrder=modelWO.WorkOrder,
                        StockCode=modelWO.StockCode,
                        StockName=modelWO.StockName,
                        QTY=modelWO.PlanQTY,
                        Status=1,
                        TotalHour=0
                    };
                    adoWK01.Insert(wk01);

                    ModelAdo<WOLineNoGroupModel> adoWOLine = new ModelAdo<WOLineNoGroupModel>();
                    List<WOLineNoGroupModel> wolineList = adoWOLine.GetList("MP65001=@wo", "MP65003", "", new SqlParameter("@wo", this.Workorder));
                    int i = 0;
                    string op = "";
                    foreach (WOLineNoGroupModel item in wolineList)
                    {
                        if (op != item.OperationNO)
                            i = 0;
                        i++;
                        ReportModel modelReport = new ReportModel()
                        {
                            BOMOP = item.OperationNO,
                            BOMOPINDEX = i + "",
                            DeQTY = item.PlanQTY,
                            HadDe = 0,
                            HadDeQTY = 0,
                            StockCode = item.StockCode,
                            StockName = item.StockName,
                            Workorder = item.WO,
                            LineNumber = item.Number,
                            ReportNumber = item.ReportNumber,
                            DeDate = System.DateTime.Now,
                            Warehouse=item.Warehouse
                        };
                        adoReport.Insert(modelReport);
                    }
                }
                //                if (!string.IsNullOrEmpty(this.RWID))
                //                {
                //                    ModelAdo<RWBarcodeModel> adoRW = new ModelAdo<RWBarcodeModel>();
                //                    RWBarcodeModel rwModel = adoRW.GetModelByID(this.RWID);
                //                    if (rwModel != null)
                //                    {
                //                        if (this.DeQTY > (float)rwModel.StockUnitQty)
                //                            throw new Exception("汇报数量超出条码数量");

                //                        string sql = @"
                //update RW01 set RW01006=RW01006-@deqty where RW01001=@bid
                //
                //insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011)
                //select RW01001,getdate(),@userid,@username,@dj,N'扣料 工单号'+@wo+' 数量'+convert(varchar(10),@deqty) from RW01 where RW01001=@bid
                //
                //update WK02 set WK02002=
                //";
                //                    }
                //                    else
                //                        throw new Exception("无效原材料条码");
                //                }
                list = adoReport.GetList("WK02002=@wo", "WK02001", "", new SqlParameter("@wo", this.Workorder));
                this.ReturnReportList = list;
                return this;
            }
            else
                throw new Exception("无效工单,请重新确认工单");
        }
        public override void OnLoad(HttpContext context)
        {
            base.OnLoad(context);
            requestBody             = new RequestBody();
            requestBody.accessToken = context.Request["accessToken"];
            requestBody.uTo         = Convert.ToInt32(context.Request["to"]);
            requestBody.content     = context.Request["content"];

            if (requestBody.content.Length == 0 || requestBody.accessToken.Trim().Length == 0 || requestBody.uTo == 0)
            {
                SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
            }
            else
            {
                //验证用户
                TokenHelper    token     = new TokenHelper();
                UserTokenModel fromModel = token.getUserToken(requestBody.accessToken);
                UserTokenModel toModel   = token.getUserToken(requestBody.uTo);
                if (fromModel == null)
                {
                    SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson);
                }
                else
                {
                    int msgstatus = 0;

                    #region 入库至本地
                    ModelAdo <MsgModel> modelAdo = new ModelAdo <MsgModel>();
                    MsgModel            msg      = new MsgModel();
                    msg.ufrom      = Convert.ToInt32(fromModel.uid);
                    msg.uto        = requestBody.uTo;
                    msg.content    = requestBody.content;
                    msg.createTime = StringHelper.ConvertDateTimeInt(DateTime.Now);
                    msg.status     = msgstatus;
                    if (modelAdo.Insert(msg) >= 1)
                    {
                        #region 百度推送
                        if (toModel != null && toModel.bpuserId.Length >= 1 && toModel.channelId.Length >= 1)
                        {
                            //获取插入本地数据
                            MsgModel msgPush = modelAdo.GetModel("ufrom=?ufrom AND uto=?uto AND createTime=?createTime AND status=0", "",
                                                                 new MySqlParameter("?ufrom", msg.ufrom),
                                                                 new MySqlParameter("?uto", msg.uto),
                                                                 new MySqlParameter("?createTime", msg.createTime));
                            if (msgPush != null)
                            {
                                try
                                {
                                    //百度配置信息
                                    string secretKey    = ConfigurationManager.AppSettings["baidu_secret_key"];
                                    string apiKey       = ConfigurationManager.AppSettings["baidu_api_key"];
                                    uint   depolyStatus = uint.Parse(ConfigurationManager.AppSettings["baidu_depoly_status"]);

                                    String    messages     = "";
                                    TimeSpan  ts           = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
                                    uint      unixTime     = (uint)ts.TotalSeconds;
                                    string    messageksy   = "api";
                                    uint      message_type = 1;
                                    BaiduPush Bpush        = new BaiduPush("POST", secretKey);



                                    if (toModel.deviceType == 1)
                                    {
                                        message_type       = 1;
                                        toModel.deviceType = 4;
                                        IOSNotification notifaction = new IOSNotification();
                                        notifaction.id         = msgPush.id;
                                        notifaction.ufrom      = msgPush.ufrom;
                                        notifaction.uto        = msgPush.uto;
                                        notifaction.content    = msgPush.content.Trim();
                                        notifaction.createTime = string.Format("{0:yyyy/MM/dd HH:mm:ss}", System.DateTime.Now);
                                        notifaction.type       = msgPush.type;
                                        notifaction.status     = 1;
                                        IOSAPS aps = new IOSAPS()
                                        {
                                            alert = "收到一条新消息",
                                        };
                                        notifaction.aps = aps;
                                        messages        = notifaction.getJsonString();
                                    }
                                    else
                                    {
                                        message_type       = 0;
                                        toModel.deviceType = 3;
                                        BaiduPushNotification notifaction = new BaiduPushNotification();
                                        notifaction.title = "";
                                        //构建custom_content信息
                                        BaiduDescription bdMsg = new BaiduDescription();
                                        bdMsg.id                   = msgPush.id;
                                        bdMsg.ufrom                = msgPush.ufrom;
                                        bdMsg.uto                  = msgPush.uto;
                                        bdMsg.content              = msgPush.content;
                                        bdMsg.createTime           = string.Format("{0:yyyy/MM/dd HH:mm:ss}", System.DateTime.Now);
                                        bdMsg.type                 = msgPush.type;
                                        bdMsg.status               = 1;
                                        notifaction.description    = "收到一条新消息";
                                        notifaction.custom_content = bdMsg;
                                        messages                   = notifaction.getJsonString();
                                    }



                                    PushOptions pOpts = new PushOptions("push_msg", apiKey, toModel.bpuserId.ToString(),
                                                                        toModel.channelId.ToString(), Convert.ToUInt32(toModel.deviceType), messages, messageksy, unixTime);
                                    pOpts.message_type  = message_type;
                                    pOpts.deploy_status = depolyStatus;
                                    pOpts.push_type     = 1;
                                    string response = Bpush.PushMessage(pOpts);
                                    responseJson = response;
                                    msgstatus    = 1;

                                    //处理数据为已读
                                    if (msg.status == 0)
                                    {
                                        msgPush.status = 1;
                                        modelAdo.Update(msgPush);
                                    }

                                    //SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson);
                                    //responseJson = strBDMsg;
                                }
                                catch (Exception ex)
                                {
                                    responseJson = ex.ToString();
                                    SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson);
                                }
                            }
                            #endregion
                        }
                        else
                        {
                            SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson);
                        }
                        #endregion
                    }
                }
            }
        }