예제 #1
0
    public int value;           // 值

    public void Load(BinaryReader reader)
    {
        id = reader.ReadInt32();

        type = (TransferValue)reader.ReadInt32();

        param = (TransferParam)reader.ReadInt32();

        value = reader.ReadInt32();
    }
        public string ReStart(string id, int index = 1, int size = 100, int count = 1000)
        {
            var work_order = db.work_order.FirstOrDefault(a => a.OrderId == id);

            var from         = db.data_source.Find(work_order.InportSourceId);
            var to           = db.data_source.Find(work_order.ExportSourceId);
            var fieldMapping =
                (from a in db.field_mapping
                 join b in db.method on a.MethodId equals b.Id
                 where a.OrderId == work_order.OrderId && a.Creator == "1"
                 select new FieldMappingItem()
            {
                field = a.FieldIn,
                toField = a.FieldOut,
                method = (int)b.Id,
                methodClassName = b.TypeFillName,
                methodDll = b.AssemblyPath,
                methodName = b.MethodName,
            }).ToList();


            if (from == null || to == null || fieldMapping.Count <= 0)
            {
                throw new CheckException("配置不完善");
            }

            var param = new TransferParam
            {
                OrderId        = work_order.OrderId,
                FromConnString = @from.Link,
                FromTable      = @from.TableName,
                FromTypeCode   = @from.TypeCode,
                Where          = work_order.InportWhere,
                OrderBy        = work_order.InportOrderByField,
                ToConnString   = to.Link,
                ToTypeCode     = to.TypeCode,
                ToTable        = to.TableName,
                Index          = index,
                Size           = size,
                Count          = count,
                FieldMapping   = fieldMapping
            };

            TransferEngine.Start(param);


            return("Ok");
        }
예제 #3
0
 public void Begin(string data)
 {
     try
     {
         var param = TransferParam.StrToObject(data);
         if (string.IsNullOrEmpty(param.payload))
         {
             throw new Exception("Payload is null");
         }
         if (string.IsNullOrEmpty(param.FromBank))
         {
             throw new Exception("From Bank is null, frontend have error");
         }
         if (string.IsNullOrEmpty(param.TargetBank))
         {
             throw new Exception("Target bank is null frontend have error");
         }
         if (string.IsNullOrEmpty(param.RecipientAccount))
         {
             throw new Exception("Company account is null");
         }
         if (string.IsNullOrEmpty(param.AccountID))
         {
             throw new Exception("User account is null");
         }
         if (string.IsNullOrEmpty(param.Password))
         {
             throw new Exception("Password is null");
         }
         if (param.Amount == 0)
         {
             throw new Exception("Invalid amount");
         }
         if (param.OTPType <= 0 || param.OTPType > 2)
         {
             throw new Exception("Invalid OTP type");
         }
         param.payload = HttpUtility.UrlDecode(param.payload);
         queue.Add(new SocketItem(Context.ConnectionId, param, Clients));
         Clients.Client(Context.ConnectionId).Receive(JsonResponse.success(null, "你的转账正在排队中请耐心等待哦"));
     }
     catch (Exception ex)
     {
         logger.Error($"Error occur during Hub Start method. {data}. Exception: {ex.Message}");
         Clients.Client(Context.ConnectionId).Receive(JsonResponse.failed("开始初始化列队时出现错误", code: 402));
     }
 }
예제 #4
0
        public BankBase(SocketItem item, DriverToUse driverType = DriverToUse.HTTP)
        {
            try
            {
                driver = new DriverFactory().Create(driverType);
            }
            catch (Exception ex)
            {
                logger.Error($"初始化Web automation driver 异常可能版本问题或driver不存在. Ex - {ex.Message}");
                throw ex;
            }
            socket          = item;
            param           = item.param;
            this.driverType = driverType;
            defaultHandler  = new HttpClientHandler
            {
                AllowAutoRedirect = true,
                UseProxy          = false,
                UseCookies        = true,
            };
            http         = new HttpClient(defaultHandler);
            http.Timeout = TimeSpan.FromMinutes(5);
            logger.Info($"Received account info : {param.ToJson()}");
#if !DEBUG
            try
            {
                bankInfo = JsonConvert.DeserializeObject <BankInfo>(param.payload.DecryptConnectionString());
            }
            catch (Exception ex)
            {
                logger.Error($"添加连队去处理中的列队失败,解析json string 异常导致. Ex - {ex.Message}");
                item.Clients.Client(item.ConnectionId).Receive(JsonResponse.failed(message: "无法转账系统检测到参数加密异常"));
                this.Dispose();
                throw ex;
            }
#endif
        }
        public IHttpActionResult Postwork_order(work_order work_order)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!db.field_mapping.Any(a => a.OrderId == work_order.OrderId && a.State == 0))
            {
                throw  new Exception("请配置字段映射关系");
            }

            var runState = 1;

            if (db.work_order.Any(a => a.InportSourceId == work_order.InportSourceId && a.ExportSourceId == work_order.ExportSourceId && a.State == runState))
            {
                throw new Exception("已存在正在运行的迁移策略.");
            }

            if (work_order.StartTime == default(DateTime))
            {
                work_order.StartTime = DateTime.Now;
            }

            if (work_order.PageIndex <= 0)
            {
                work_order.PageIndex = 1;
            }
            work_order.CreateTime         = DateTime.Now;
            work_order.UserId             = 1;
            work_order.Creator            = "1";
            work_order.EndTime            = DateTime.Now;
            work_order.InportWhere        = work_order.InportWhere ?? string.Empty;
            work_order.Remake             = work_order.Remake ?? string.Empty;
            work_order.InportOrderByField = work_order.InportOrderByField ?? string.Empty;

            work_order.Modifier   = "1";
            work_order.ModifyTime = DateTime.Now;
            work_order.Exception  = string.Empty;

            db.work_order.Add(work_order);
            db.SaveChanges();

            var from         = db.data_source.Find(work_order.InportSourceId);
            var to           = db.data_source.Find(work_order.ExportSourceId);
            var fieldMapping =
                (from a in db.field_mapping
                 join b in db.method on a.MethodId equals b.Id
                 where a.OrderId == work_order.OrderId && a.Creator == "1"
                 select new FieldMappingItem()
            {
                field = a.FieldIn,
                toField = a.FieldOut,
                method = (int)b.Id,
                methodClassName = b.TypeFillName,
                methodDll = b.AssemblyPath,
                methodName = b.MethodName,
            }).ToList();


            if (from == null || to == null || fieldMapping.Count <= 0)
            {
                throw new CheckException("配置不完善");
            }

            var param = new TransferParam
            {
                OrderId        = work_order.OrderId,
                FromConnString = @from.Link,
                FromTable      = @from.TableName,
                FromTypeCode   = @from.TypeCode,
                Where          = work_order.InportWhere,
                OrderBy        = work_order.InportOrderByField,
                ToConnString   = to.Link,
                ToTypeCode     = to.TypeCode,
                ToTable        = to.TableName,
                Size           = work_order.PageSize,
                Count          = (int)work_order.DataCount,
                FieldMapping   = fieldMapping
            };

            TransferEngine.Start(param);

            return(CreatedAtRoute("DefaultApi", new { id = work_order.Id }, work_order));
        }