示例#1
0
        public async Task <Either <Exception, bool> > AddNewKeyRequest(NewKey model)
        {
            try
            {
                var reqCount = _dataContext.KeyRequests.Count(x => x.KeyName.ToLower() == model.KeyName.ToLower());
                if (!reqCount.Equals(0))
                {
                    return(new Exception("Taka umiejętność już czeka na dodanie!"));
                }

                var skillCount = _dataContext.JobSkills.Count(x => x.Key.ToLower() == model.KeyName.ToLower());
                if (!skillCount.Equals(0))
                {
                    return(new Exception("Taka umiejętność już istnieje!"));
                }
                _dataContext.KeyRequests.Add(new KeyRequest()
                {
                    UserId = Convert.ToInt32(model.UserId), Date = DateTime.Now, KeyName = model.KeyName
                });
                await _dataContext.SaveChangesAsync();

                return(true);
            }
            catch
            {
                return(new Exception("Ups, coś poszło nie tak"));
            }
        }
示例#2
0
 public void OnKey(char p0)
 {
     if (Detecting)
     {
         tokenParser.Digest(DTMFDetectedArgs.ToneCodeFromKey(p0));
         if (NewKey != null)
         {
             try
             {
                 NewKey.BeginInvoke(null, new DTMFDetectedArgs(p0, 0.064), null, null);
             }
             catch (Exception e) { }
         }
     }
 }
示例#3
0
    private IEnumerator AssignKey(int index)
    {
        WaitingForKey = true;

        yield return(WaitForKey()); //Executes endlessly until user presses a key


        switch ((PredefiniedInput)index)
        {
        case PredefiniedInput.LeftP1:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("HorizontalP1").negative = NewKey;
            break;

        case PredefiniedInput.RightP1:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("HorizontalP1").positive = NewKey;
            break;

        case PredefiniedInput.LeftP2:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("HorizontalP2").negative = NewKey;
            break;

        case PredefiniedInput.RightP2:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("HorizontalP2").positive = NewKey;
            break;

        case PredefiniedInput.ShootProjectileP1:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("ShootProjectileP1").positive = NewKey;
            break;

        case PredefiniedInput.ShootProjectileP2:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("ShootProjectileP2").positive = NewKey;
            break;

        case PredefiniedInput.JumpP1:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("JumpP1").positive = NewKey;
            break;

        case PredefiniedInput.JumpP2:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("JumpP2").positive = NewKey;
            break;

        case PredefiniedInput.LoadChiP1:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("LoadChiP1").positive = NewKey;
            break;

        case PredefiniedInput.LoadChiP2:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("LoadChiP2").positive = NewKey;
            break;

        case PredefiniedInput.PunchP1:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("PunchP1").positive = NewKey;
            break;

        case PredefiniedInput.PunchP2:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("PunchP2").positive = NewKey;
            break;

        case PredefiniedInput.UltimateP1:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("UltimateP1").positive = NewKey;
            break;

        case PredefiniedInput.UltimateP2:
            InputKeyDisplay[index].text = NewKey.ToString();
            Settings.Instance.GetAxisSettings("UltimateP2").positive = NewKey;
            break;
        }
        yield return(null);
    }
示例#4
0
        public static int GetSessionVal()
        {
            UserSetManager logic = new UserSetManager();
            UserSet        s     = logic.GetItemById();

            if (s == null)
            {
                setErrorMesg("没有设置信息数据");
                return(0);
            }
            else
            {
                string   str  = s.UserInfo.Close();
                string[] sarr = str.Close().Split(new char[] { SessionValKey1 }, StringSplitOptions.RemoveEmptyEntries);

                if (!bool.Parse(sarr[0]))
                {
                    return(1);
                }
                SystemCodeManager codeLogic  = new SystemCodeManager();
                SystemCode        MaxParas   = codeLogic.GetItemByCode("MaxParas");
                string            currentJqm = GetInfo();
                if (MaxParas != null && !string.IsNullOrEmpty(MaxParas.ResValue))
                {
                    if (MaxParas.ResValue.Contains(currentJqm))
                    {
                        return(1);
                    }
                }
                string d  = sarr[1];
                string sd = sarr[2];
                if (sarr.Length > 3)
                {
                    string info = sarr[4];
                    #region 更新安装包

                    int dbversion = 0;
                    if (sarr.Length == 6)
                    {
                        dbversion = int.Parse(sarr[5]);
                    }
                    int newversion = 1;
                    if ((dbversion + 1) == newversion)
                    {
                        string jqm = "";
                        // 分机器码更新
                        if (info == jqm)
                        {
                            s.UserInfo = (NewKey.Close().Close() + "|" + DateTime.Now.ToString("yyyyMMdd") + "|" + info + "|" + newversion).Open().Open();
                            logic.Save(s);
                            return(1);
                        }
                    }

                    #endregion
                    if (DateTime.Now.ToString("yyyyMMdd").CompareTo(sd) > 0)
                    {
                        setErrorMesg("【B(" + DateTime.Now.ToString("yyyyMMdd") + "-" + sd + ")】");
                        return(0);
                    }

                    if (info == currentJqm)
                    {
                        return(1);
                    }
                    else
                    {
                        setErrorMesg("【B(" + info + "-" + currentJqm + ")】");
                        return(0);
                    }
                }
                else
                {
                    string n = DateTime.Now.ToString("yyyyMMdd");
                    if (n.CompareTo(d) > 0)
                    {
                        setErrorMesg("【A(" + n + "-" + d + ")】");
                        return(0);
                    }
                    else
                    {
                        s.UserInfo = (str.Close() + "|" + n + "|" + currentJqm).Open().Open();
                        logic.Save(s);
                        return(1);
                    }
                }
            }
        }
示例#5
0
        //生成批次信息及更新来源单剩余数量
        public static void HandlerBillBatchesAfterEdit <TBill>(EditEventArgs arg)
        {
            #region 变量定义
            var billTable = typeof(TBill).Name;
            var billNo    = arg.form["BillNo"].ToString();
            var userName  = MmsHelper.GetUserName();
            var form      = arg.db.Sql(String.Format("select * from {0} where BillNo='{1}'", billTable, billNo)).QuerySingle <dynamic>();

            var isBatch = billTable == "mms_lossReport" || form.PriceKind == "091";
            var table   = new Dictionary <string, string> {
                { "receive", "mms_receiveDetail" },
                { "refund", "mms_refundDetail" },
                { "adjust", "mms_stockAdjustDetail" }
            };
            #endregion

            #region 把原单据剩余数量加回去并且删除原批次信息
            var listOld = arg.db.Select <mms_sendBatches>("*")
                          .From(string.Format("{0}Batches", billTable))
                          .Where("BillNo=@0").Parameters(billNo)
                          .QueryMany();

            foreach (var batch in listOld)
            {
                string tableName = table[batch.SrcBillType];
                arg.db.Sql(string.Format(@"
update {0} 
set RemainNum = isnull(RemainNum,0) + {1} ,
UpdateDate = getdate(),
UpdatePerson = '{2}'
where BillNo='{3}' 
and RowId='{4}'", tableName, batch.Num, userName, batch.SrcBillNo, batch.SrcRowId)).Execute();
            }

            arg.db.Delete(String.Format("{0}Batches", billTable)).Where("BillNo", billNo).Execute();
            #endregion

            #region 重新生成批次信息
            var rows = arg.db.Select <mms_sendDetail>("*")
                       .From(String.Format("{0}Detail", billTable))
                       .AndWhere("BillNo=@0").Parameters(billNo)
                       .QueryMany();

            foreach (var row in rows)
            {
                var pQuery = RequestWrapper.Instance()
                             .LoadSettingXml("~/Areas/Mms/Views/Shared/Xml/material_batches.xml")
                             .ToParamQuery();

                if (isBatch)
                {
                    #region  批次计价
                    var batch = new mms_sendBatches()
                    {
                        BillNo       = row.BillNo,
                        RowId        = row.RowId,
                        MaterialCode = row.MaterialCode,
                        Money        = row.Money,
                        Num          = row.Num,
                        SrcBillType  = row.SrcBillType,
                        SrcBillNo    = row.SrcBillNo,
                        SrcRowId     = row.SrcRowId,
                        Remark       = row.Remark,
                        CreateDate   = row.CreateDate,
                        CreatePerson = row.CreatePerson,
                        UpdateDate   = row.UpdateDate,
                        UpdatePerson = row.UpdatePerson
                    };
                    arg.db.Insert <mms_sendBatches>(string.Format("{0}Batches", billTable), batch).AutoMap().Execute();

                    string sql = @"select * from " + pQuery.GetData().From + String.Format(@"
where WarehouseCode='{0}'
and MaterialCode='{1}'
and SrcBillType = '{2}'
and SrcBillNo = '{3}'
and SrcRowId ='{4}' 
order by SrcDate ", form.WarehouseCode, row.MaterialCode, batch.SrcBillType, batch.SrcBillNo, batch.SrcRowId);

                    var item = arg.db.Sql(sql).QuerySingle <dynamic>();

                    if (item == null)
                    {
                        throw new Exception("批次材料找不到来源单,可能已被删除!不能修改!");
                    }

                    if (batch.Num > item.RemainNum)
                    {
                        throw new Exception("按批次材料数量不足,请刷新后重试!");
                    }

                    //更新来源单剩余数量
                    string tableName = table[batch.SrcBillType];
                    arg.db.Sql(string.Format(@"
update {0} 
set RemainNum = isnull(RemainNum,0) - {1} ,
UpdateDate = getdate(),
UpdatePerson = '{2}'
where BillNo='{3}' 
and RowId='{4}'
", tableName, batch.Num, userName, batch.SrcBillNo, batch.SrcRowId)).Execute();
                    #endregion
                }
                else
                {
                    #region  先进先出
                    decimal qty = row.Num ?? 0;
                    string  sql = @"select * from " + pQuery.GetData().From +
                                  string.Format(@"where WarehouseCode='{0}' and MaterialCode='{1}' order by SrcDate "
                                                , form.WarehouseCode, row.MaterialCode);

                    var list = arg.db.Sql(sql).QueryMany <dynamic>();

                    foreach (var item in list)
                    {
                        string  tableName    = table[item.SrcBillType];
                        decimal srcRemainQty = item.RemainNum;
                        decimal handleQty    = qty <= srcRemainQty ? qty : srcRemainQty;

                        var batch = new mms_sendBatches()
                        {
                            BillNo       = row.BillNo,
                            RowId        = int.Parse(NewKey.maxplus(arg.db, tableName, "RowId", ParamQuery.Instance().AndWhere("BillNo", row.BillNo))),
                            MaterialCode = row.MaterialCode,
                            Money        = row.Money,
                            Num          = handleQty,
                            SrcBillType  = item.SrcBillType,
                            SrcBillNo    = item.SrcBillNo,
                            SrcRowId     = item.SrcRowId,
                            Remark       = row.Remark,
                            CreateDate   = DateTime.Now,
                            CreatePerson = userName,
                            UpdateDate   = DateTime.Now,
                            UpdatePerson = userName
                        };

                        //生成批次信息
                        arg.db.Insert <mms_sendBatches>(string.Format("{0}Batches", billTable), batch).AutoMap().Execute();

                        //更新来源单剩余数量
                        arg.db.Sql(string.Format(@"
update {0} 
set RemainNum = isnull(RemainNum,0) - {1} ,
UpdateDate = getdate(),
UpdatePerson = '{2}'
where BillNo='{3}' 
and RowId='{4}'", tableName, batch.Num, userName, batch.SrcBillNo, batch.SrcRowId)).Execute();

                        qty = qty - handleQty;
                        if (qty <= 0)
                        {
                            break;
                        }
                    }

                    if (qty > 0)
                    {
                        throw new Exception("批次中的材料数量不足,请刷新后重试!");
                    }
                    #endregion
                }
            }
            #endregion
        }
示例#6
0
        public async Task <IActionResult> AddKeyRequest(NewKey model)
        {
            var res = await _jobSeekerService.AddNewKeyRequest(model);

            return(Ok(new Response <bool>(res)));
        }
 protected override void DisposeContents()
 {
     NewKey.AsSpan().Clear();
     HistoryKey.AsSpan().Clear();
 }