public void CreateOrUpdateInfoItem(InfoDto newInfo)
 {
     using (var transaction = Session.BeginTransaction())
     {
         Info info;
         var  existInfo = Session.Query <Info>().Where(i => i.Name.ToLower() == newInfo.Name.ToLower()).ToFuture();
         if (existInfo.Any())
         {
             info         = existInfo.First();
             info.Name    = newInfo.Name;
             info.Swedish = newInfo.Swedish;
             info.English = newInfo.English;
         }
         else
         {
             info = new Info
             {
                 Name    = newInfo.Name,
                 Swedish = newInfo.Swedish,
                 English = newInfo.English
             };
         }
         Session.SaveOrUpdate(info);
         transaction.Commit();
     }
 }
示例#2
0
        //[Authorize]
        public async Task <IActionResult> PutInfo(int id, InfoDto infoDto)
        {
            Info info;

            try
            {
                info = await _infosRepository.Select.ById(id);
            }
            catch (DataException)
            {
                return(BadRequest());
            }

            info.Name        = infoDto.Name;
            info.ExpiryDate  = infoDto.ExpiryDate;
            info.MapPoint.X  = infoDto.Longitude;
            info.MapPoint.Y  = infoDto.Latitude;
            info.Address     = infoDto.Address;
            info.Description = infoDto.Description;
            info.Category    = infoDto.Category;

            try
            {
                await _infosRepository.Update.One(info, id);
            }
            catch (DataException)
            {
                return(NotFound());
            }

            return(NoContent());
        }
示例#3
0
        public async Task <ActionResult <Info> > PostInfo(InfoDto infoDto)
        {
            var username = User.Identity.Name;
            var account  = await _accountsRepository.SelectByUsername(username);

            var info = new Info
            {
                Name       = infoDto.Name,
                ExpiryDate = infoDto.ExpiryDate,
                MapPoint   = new Point(infoDto.Longitude, infoDto.Latitude)
                {
                    SRID = 4326
                },
                Address      = infoDto.Address,
                Description  = infoDto.Description,
                AuthorId     = account.Id,
                Category     = infoDto.Category,
                CreationDate = DateTime.Now,
            };


            await _infosRepository.Insert.One(info);

            return(CreatedAtAction(nameof(GetInfo), new { id = info.Id }, info));
        }
示例#4
0
        public override void Insert(SqlDataReader reader, SqlConnection sqlCon, InfoDto info, LogInfo logInfo)
        {
            if (reader == null)
            {
                return;
            }

            if (reader.HasRows)
            {
                SqlCommand cmd = new SqlCommand(GetSqlInsert(
                                                    $@"[{nc01}],[{nc02}],[{nc03}],[{nc04}],[{nc05}],[{nc06}],[{nc07}],[{nc08}],[{nc14}],[{nc15}]",
                                                    $@"@{nc01},@{nc02},@{nc03},@{nc04},@{nc05},@{nc06},@{nc07},@{nc08},@{nc14},@{nc15}"
                                                    ), sqlCon);

                AddDefaultParameters(cmd);

                cmd.Parameters.Add($"@{nc01}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc02}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc03}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc04}", SqlDbType.NVarChar, 100);
                cmd.Parameters.Add($"@{nc05}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc06}", SqlDbType.NVarChar, 50);
                cmd.Parameters.Add($"@{nc07}", SqlDbType.NVarChar, 50);
                cmd.Parameters.Add($"@{nc08}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc14}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc15}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{ncId}", SqlDbType.UniqueIdentifier);

                CopyRows(reader, cmd, info, logInfo);
            }
        }
示例#5
0
 private void ReceiveInfo(InfoDto dto)
 {
     if (dto == null)
     {
         return;
     }
     Dispatch(AreaCode.GAME, GameEvent.GAME_SYNC_INFO, dto);
 }
示例#6
0
        public override void Insert(SqlDataReader reader, SqlConnection sqlCon, InfoDto info, LogInfo logInfo)
        {
            if (reader == null)
            {
                return;
            }

            if (reader.HasRows)
            {
                SqlCommand cmd = new SqlCommand(GetSqlInsert(
                                                    $@"[{nc03}],[{nc04}],[{nc05}],[{ nc11 }],[{nc12}],[{nc13}],[{nc14}],[{nc15}],[{nc16}],[{nc17}],[{nc18}],[{nc19}],[{nc20}],[{nc21}],[{nc22}],[{nc23}],[{nc24}],[{nc25}],
[{nc26}],[{nc27}],[{nc28}],[{nc29}],[{nc30}],[{nc31}],[{nc32}],[{nc33}],[{nc34}],[{nc35}],[{nc36}],[{nc37}],[{nc38}],[{nc39}],[{nc40}],[{nc44}],[{nc46}]",
                                                    $@"@{nc03},@{nc04},@{nc05},@{nc11},@{nc12},@{nc13},@{nc14},@{nc15},@{nc16},@{nc17},@{nc18},@{nc19},@{nc20},@{nc21},@{nc22},@{nc23},@{nc24},@{nc25},
@{nc26},@{nc27},@{nc28},@{nc29},@{nc30},@{nc31},@{nc32},@{nc33},@{nc34},@{nc35},@{nc36},@{nc37},@{nc38},@{nc39},@{nc40},@{nc44},@{nc46}"
                                                    ), sqlCon);

                AddDefaultParameters(cmd);
                cmd.Parameters.Add($"@{nc03}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc04}", SqlDbType.DateTime);
                cmd.Parameters.Add($"@{nc05}", SqlDbType.DateTime);
                cmd.Parameters.Add($"@{nc11}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc12}", SqlDbType.NVarChar, 100);
                cmd.Parameters.Add($"@{nc13}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc14}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc15}", SqlDbType.DateTime);
                cmd.Parameters.Add($"@{nc16}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc17}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc18}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc19}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc20}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc21}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc22}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc23}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc24}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc25}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc26}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc27}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc28}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc29}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc30}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc31}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc32}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc33}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc34}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc35}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc36}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc37}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc38}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc39}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc40}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc44}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc46}", SqlDbType.SmallInt);

                cmd.Parameters.Add($"@{ncId}", SqlDbType.UniqueIdentifier);

                CopyRows(reader, cmd, info, logInfo);
            }
        }
        /// <summary>
        /// Retrieve the installation url for a given workspace app
        /// </summary>
        /// <param name="workspaceType"></param>
        /// <returns>An installation url</returns>
        public async Task <string> GetInstallUrl(string workspaceType)
        {
            string  baseUrl  = ResolveBaseUri(workspaceType);
            InfoDto response = await _http.Get <InfoDto>($"{baseUrl}/info");

            string installUrl = response.InstallUrl;

            return(installUrl);
        }
        public async Task Invoke(HttpContext context)
        {
            try
            {
                await _next(context);
            }
            catch (ValidationException validationException)
            {
                ErrorDto errorDto;
                var      errors = new List <InfoDto>();
                if (validationException.Errors.Any())
                {
                    foreach (var error in validationException.Errors)
                    {
                        errors.Add(new InfoDto
                        {
                            Code       = 0,
                            Message    = error.ErrorMessage,
                            ShowToUser = true
                        });
                    }
                    errorDto = new ErrorDto(null);
                }
                else
                {
                    errorDto = new ErrorDto("Bad Request");
                }

                errorDto.InfoList = errors;
                var executor  = context.RequestServices.GetService <IActionResultExecutor <ObjectResult> >();
                var routeData = context.GetRouteData() ?? EmptyRouteData;

                var actionContext = new ActionContext(context, routeData, EmptyActionDescriptor);
                await WriteLog(context, validationException, 0);

                await executor.ExecuteAsync(actionContext, new ObjectResult(errorDto));
            }
            catch (CustomException customException)
            {
                var infoDto = new InfoDto
                {
                    Message    = customException.Message,
                    ShowToUser = customException.ShowToUser
                };
                var executor      = context.RequestServices.GetService <IActionResultExecutor <ObjectResult> >();
                var routeData     = context.GetRouteData() ?? EmptyRouteData;
                var actionContext = new ActionContext(context, routeData, EmptyActionDescriptor);
                await WriteLog(context, customException, 0);

                await executor.ExecuteAsync(actionContext, new ObjectResult(infoDto));
            }
            catch (Exception ex)
            {
                await WriteLog(context, ex, 0);
            }
        }
        public bool Enabled(InfoDto info)
        {
            if (info.WebSocket)
            {
                return(true);
            }

            Log.Debug($"{nameof(this.Enabled)}: Disabled from server 'websocket'");
            return(false);
        }
示例#10
0
        public override bool Equals(object o)
        {
            InfoDto dto = o as InfoDto;

            if (dto is null)
            {
                return(false);
            }
            return(CompareWithDto(this, dto));
        }
示例#11
0
    /// <summary>
    /// 同步消息
    /// </summary>
    private void SyncInfo(InfoDto dto)
    {
        string msg = dto.message;

        if (dto.Account != string.Empty)
        {
            UserDto tempUserDto = userDtoDict[dto.Account];
            msg = tempUserDto.Name + ":" + msg;
        }
        Dispatch(AreaCode.UI, UIEvent.UI_SET_GAME_INFO, msg);
    }
示例#12
0
        public ActionResult SellerInfo(int sellerID)
        {
            var seller    = new InfoModels().getSellerById(sellerID);
            var sellerDto = new InfoDto();

            sellerDto.CustomerId  = sellerID;
            sellerDto.Name        = seller.Name;
            sellerDto.Email       = seller.Email;
            sellerDto.PhoneNumber = seller.PhoneNumber;
            sellerDto.Address     = seller.WarehouseAddress;
            return(View("Info", sellerDto));
        }
 public IHttpActionResult Post(InfoDto info)
 {
     if (string.IsNullOrWhiteSpace(info.Name) || string.IsNullOrWhiteSpace(info.Swedish) || string.IsNullOrWhiteSpace(info.English))
     {
         return(BadRequest("Fields cannot be emtpy"));
     }
     using (var helper = new DataBaseHelper())
     {
         helper.CreateOrUpdateInfoItem(info);
         return(Ok());
     }
 }
示例#14
0
        public InfoDto GetLastInfo()
        {
            var info = _dbContext.Infoes.LastOrDefault();

            if (info == null)
            {
                return(InfoDto.CreateNewInstance());
            }
            else
            {
                return(info.ToDto());
            }
        }
示例#15
0
        public ActionResult Info(int customerID)
        {
            ViewBag.Info = "Customer";
            var customer    = new InfoModels().getCustomerById(customerID);
            var customerDto = new InfoDto();

            customerDto.CustomerId  = customerID;
            customerDto.Name        = customer.Name;
            customerDto.Email       = customer.Email;
            customerDto.PhoneNumber = customer.PhoneNumber;
            customerDto.Address     = customer.DeliveryAddress;
            return(View(customerDto));
        }
        public IHttpActionResult Edit(InfoDto infoDto)
        {
            var infoDb = _unitOfWork.Info.GetInfo();

            Mapper.Map(infoDto, infoDb);
            infoDb.Images.Clear();
            foreach (var i in infoDto.ImagesId)
            {
                var image = _unitOfWork.Image.GetImage(i);
                infoDb.Images.Add(image);
            }
            _unitOfWork.Complete();
            return(Ok());
        }
示例#17
0
 public ActionResult SellerInfo(InfoDto sellerDto)
 {
     if (ModelState.IsValid)
     {
         var sellerInDb = new InfoModels().getSellerById(sellerDto.CustomerId);
         sellerInDb.Name             = sellerDto.Name;
         sellerInDb.Email            = sellerDto.Email;
         sellerInDb.PhoneNumber      = sellerDto.PhoneNumber;
         sellerInDb.WarehouseAddress = sellerDto.Address;
         if (new InfoModels().UpdateSeller(sellerInDb))
         {
             return(View("Info", sellerDto));
         }
     }
     return(View("Info", sellerDto));
 }
示例#18
0
 public ActionResult Info(InfoDto customerDto)
 {
     if (ModelState.IsValid)
     {
         var customerInDb = new InfoModels().getCustomerById(customerDto.CustomerId);
         customerInDb.Name            = customerDto.Name;
         customerInDb.Email           = customerDto.Email;
         customerInDb.PhoneNumber     = customerDto.PhoneNumber;
         customerInDb.DeliveryAddress = customerDto.Address;
         if (new InfoModels().UpdateCustomer(customerInDb))
         {
             return(View(customerDto));
         }
     }
     return(View(customerDto));
 }
示例#19
0
 public static InfoViewModel ToViewModel(this InfoDto source)
 {
     return(new InfoViewModel
     {
         AboutUs = source.AboutUs,
         Address = source.Address,
         HelpForBuy = source.HelpForBuy,
         InstagramAccount = source.InstagramAccount,
         LawUs = source.LawUs,
         PhoneNumber1 = source.PhoneNumber1,
         PhoneNumber2 = source.PhoneNumber2,
         PhoneNumber3 = source.PhoneNumber3,
         PhoneNumber4 = source.PhoneNumber4,
         TelegramChanal = source.TelegramChanal,
         GarantyCondition = source.GarantyCondition
     });
 }
示例#20
0
        private void AssemblyInfo_Load(object sender, EventArgs e)
        {
            List <InfoDto> listassmebly = new List <InfoDto>();

            System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);
            string path = Directory.GetCurrentDirectory(); // ".";

            string[] files = Directory.GetFileSystemEntries(path, "*.dll");
            foreach (string file in files)
            {
                Assembly ass  = Assembly.LoadFrom(file);
                InfoDto  info = new InfoDto();
                info.Info  = ass.FullName;
                info.Value = ass.GetName().Version.ToString();
                listassmebly.Add(info);
            }
            infoDtoBindingSource.DataSource = listassmebly;
        }
        private int CheckAndCreateTable(string tableName, string sqlCreate, InfoDto info)
        {
            int maxId = 0;

            SqlCommand cmd =
                new SqlCommand($@"SELECT Count(*) FROM [sysobjects] WHERE xtype = 'U' AND name = '{tableName}'",
                               DesSqlCon);

            try
            {
                var tabCount = (Int32)cmd.ExecuteScalar();
                if (tabCount == 0)
                {
                    cmd.CommandText = sqlCreate;

                    cmd.ExecuteNonQuery();
                }
                else
                {
                    cmd.CommandText = $@"SELECT MAX(OldId) FROM [{tableName}]";
                    var result = cmd.ExecuteScalar().ToString();
                    if (string.IsNullOrEmpty(result))
                    {
                        maxId = 0;
                    }
                    else
                    {
                        Int32.TryParse(result, out maxId);
                    }

                    if (maxId > 0)
                    {
                        info.Info = $"Last Id: {maxId}";
                    }
                }
            }
            catch (Exception ex)
            {
                info.Info = ex.Message;
                return(-1);
            }

            return(maxId);
        }
示例#22
0
        public bool Enabled(InfoDto info)
        {
            // BUG: this transport is timing out
            // disabled due to above bug
            return(false);
//            return XhrCorsObject.Enabled;

            /* NOT RUNNING IN BROWSER
             * if (info.nullOrigin) {
             * return false;
             * }
             * // Opera doesn't support xhr-streaming #60
             * // But it might be able to #92
             * if (browser.isOpera()) {
             * return false;
             * }
             *
             * return XHRCorsObject.enabled;
             */
        }
        public override void Insert(SqlDataReader reader, SqlConnection sqlCon, InfoDto info, LogInfo logInfo)
        {
            if (reader == null)
            {
                return;
            }

            if (reader.HasRows)
            {
                SqlCommand cmd = new SqlCommand(GetSqlInsert($@"[{nc01}],[{nc02}]", $@"@{nc01},@{nc02}"), sqlCon);

                AddDefaultParameters(cmd);

                cmd.Parameters.Add($"@{nc01}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc02}", SqlDbType.Int);
                cmd.Parameters.Add($"@{ncId}", SqlDbType.UniqueIdentifier);

                CopyRows(reader, cmd, info, logInfo);
            }
        }
示例#24
0
    void Awake()
    {
        Bind(GameEvent.GAME_PLAYER_ADD, GameEvent.GAME_PLAYER_SPAWN,
             GameEvent.GAME_SYNC_TRANS, GameEvent.GAME_PLAYER_EXIT,
             GameEvent.GAME_UPLOAD_TRANS, GameEvent.GAME_SYNC_HP,
             GameEvent.GAME_SYNC_HG, GameEvent.GAME_SYNC_KILL,
             GameEvent.GAME_SYNC_INFO, GameEvent.GAME_REDUCE_HP,
             GameEvent.GAME_AUGMENT_HP, GameEvent.GAME_PLAYER_DEATH,
             GameEvent.GAME_CREAT_PROPS, GameEvent.GAME_REMOVE_PROPS,
             GameEvent.GAME_REMOVE_PROPS_SEND, GameEvent.GAME_DOSKILL,
             GameEvent.GAME_STOPSKILL, GameEvent.GAME_REDUCE_HG,
             GameEvent.GAME_AUGMENT_HG
             );

        localAcc = PlayerPrefs.GetString("ID");

        smg           = new SocketMessage();
        animationMesg = new AnimationMesg();
        hpDto         = new HpDto();
        hgDto         = new HgDto();
        infoDto       = new InfoDto();
    }
示例#25
0
        public IQueryable <InfoDto> Get()
        {
            var i1 = new InfoDto
            {
                id         = 1,
                content    = "The hackathon has been moved to room 202 because someone in 201 had broccoli for lunch.",
                created_at = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture),
                updated_at = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)
            };
            var i2 = new InfoDto
            {
                id         = 2,
                content    = "'Building VB6 WebSites' has been canceled due to lack of feasibility and interest. It has been replaced with 'PHP90X - How to build apps and biceps'",
                created_at = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture),
                updated_at = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)
            };

            var infos = new List <InfoDto> {
                i1, i2
            }.AsQueryable();

            return(infos);
        }
示例#26
0
        public override void Insert(SqlDataReader reader, SqlConnection sqlCon, InfoDto info, LogInfo logInfo)
        {
            if (reader == null)
            {
                return;
            }

            if (reader.HasRows)
            {
                SqlCommand cmd = new SqlCommand(GetSqlInsert(
                                                    $@"[{nc01}],[{nc02}],[{nc03}],[{nc04}],[{nc06}],[{nc10}],[{nc11}],[{nc12}],[{nc13}],[{nc38}],[{nc39}],[{nc40}],
 [{nc41}],[{nc42}],[{nc43}],[{nc45}],[{nc46}],[{nc47}],[{nc48}],[{nc49}],[{nc50}],[{nc51}],[{nc66}],[{nc67}],[{nc68}],[{nc69}],
 [{nc70}],[{nc71}],[{nc72}],[{nc73}],[{nc74}],[{nc75}],[{nc76}],[{nc77}],[{nc78}],[{nc79}],[{nc80}],[{nc81}],[{nc82}],[{nc83}],
 [{nc85}],[{nc86}],[{nc87}],[{nc88}],[{nc89}],[{nc90}],[{nc91}],[{nc92}],[{nc93}],[{nc94}],[{nc95}],[{nc96}],[{nc97}],[{nc98}],[{nc991}],[{nc992}]",
                                                    $@"@{nc01},@{nc02},@{nc03},@{nc04},@{nc06},@{nc10},@{nc11},@{nc12},@{nc13},@{nc38},@{nc39},@{nc40},
 @{nc41},@{nc42},@{nc43},@{nc45},@{nc46},@{nc47},@{nc48},@{nc49},@{nc50},@{nc51},@{nc66},@{nc67},@{nc68},@{nc69},
 @{nc70},@{nc71},@{nc72},@{nc73},@{nc74},@{nc75},@{nc76},@{nc77},@{nc78},@{nc79},@{nc80},@{nc81},@{nc82},@{nc83},
 @{nc85},@{nc86},@{nc87},@{nc88},@{nc89},@{nc90},@{nc91},@{nc92},@{nc93},@{nc94},@{nc95},@{nc96},@{nc97},@{nc98},@{nc991},@{nc992}"), sqlCon);

                AddDefaultParameters(cmd);

                cmd.Parameters.Add($"@{nc01}", SqlDbType.NVarChar, 50);
                cmd.Parameters.Add($"@{nc02}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc03}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc04}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc06}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc10}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc11}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc12}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc13}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc38}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc39}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc40}", SqlDbType.NVarChar, 50);
                cmd.Parameters.Add($"@{nc41}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc42}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc43}", SqlDbType.NVarChar, 100);
                cmd.Parameters.Add($"@{nc45}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc46}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc47}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc48}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc49}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc50}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc51}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc66}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc67}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc68}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc69}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc70}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc71}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc72}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc73}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc74}", SqlDbType.Float);
                cmd.Parameters.Add($"@{nc75}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc76}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc77}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc78}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc79}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc80}", SqlDbType.NVarChar, 50);
                cmd.Parameters.Add($"@{nc81}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc82}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc83}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc85}", SqlDbType.SmallInt);
                cmd.Parameters.Add($"@{nc86}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc87}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc88}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc89}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc90}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc91}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc92}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc93}", SqlDbType.NVarChar, 30);
                cmd.Parameters.Add($"@{nc94}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc95}", SqlDbType.SmallDateTime);
                cmd.Parameters.Add($"@{nc96}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc97}", SqlDbType.NText);
                cmd.Parameters.Add($"@{nc98}", SqlDbType.NVarChar, 30);
                cmd.Parameters.Add($"@{nc991}", SqlDbType.Int);
                cmd.Parameters.Add($"@{nc992}", SqlDbType.Int);
                cmd.Parameters.Add($"@{ncId}", SqlDbType.UniqueIdentifier);

                CopyRows(reader, cmd, info, logInfo);
            }
        }
        public bool Create(
            string syncId,
            IEnumerable <TDataItem> items,
            int pageSize,
            IDictionary <string, object> metadata)
        {
            var util = new TransferUtility(_client);

            int       count       = 0;
            int       page        = 0;
            var       readOffset  = 0;
            const int CHUNCK_SIZE = 1024 * 1024;//1MB
            string    rootFolder  = $"{Path.GetTempPath()}/{syncId}";

            Directory.CreateDirectory(rootFolder);

            try
            {
                using (var buffer = new MemoryStream())
                {
                    foreach (var item in items)
                    {
                        count++;

                        if (item is string)
                        {
                            var bytes = Encoding.UTF8.GetBytes(item as string);
                            buffer.Write(bytes, 0, bytes.Length);
                            readOffset += bytes.Length;
                        }
                        else
                        {
                            var bytes = Encoding.UTF8.GetBytes(System.Text.Json.JsonSerializer.Serialize(item));
                            buffer.Write(bytes, 0, bytes.Length);
                            readOffset += bytes.Length;
                        }

                        //加上換行符號
                        buffer.WriteByte(10);
                        readOffset++;

                        if (count % pageSize == 0)
                        {
                            using (var m = new MemoryStream(buffer.GetBuffer(), 0, readOffset))
                                using (var f = new FileStream($"{rootFolder}/{page}.json", FileMode.Append))
                                {
                                    //將剩於的資料寫入檔案,在以檔案上傳至S3
                                    m.CopyTo(f);
                                }
                            using (var f = new FileStream($"{rootFolder}/{page}.json", FileMode.Open))
                            {
                                util.Upload(f, _bucketName, $"{syncId}/{page}.json");
                            }
                            page            = count / pageSize;
                            readOffset      = 0;
                            buffer.Position = 0;
                        }

                        //buffer如果滿了,先FLUSH
                        if (readOffset > CHUNCK_SIZE)
                        {
                            using (var m = new MemoryStream(buffer.GetBuffer(), 0, readOffset))
                                using (var f = new FileStream($"{rootFolder}/{page}.json", FileMode.Append))
                                {
                                    m.CopyTo(f);
                                }
                            readOffset      = 0;
                            buffer.Position = 0;
                        }
                    }

                    if (readOffset > 0)
                    {
                        page = count / pageSize;
                        using (var m = new MemoryStream(buffer.GetBuffer(), 0, readOffset))
                            using (var f = new FileStream($"{rootFolder}/{page}.json", FileMode.Append))
                            {
                                m.CopyTo(f);
                            }
                        using (var f = new FileStream($"{rootFolder}/{page}.json", FileMode.Open))
                        {
                            util.Upload(f, _bucketName, $"{syncId}/{page}.json");
                        }
                        readOffset      = 0;
                        buffer.Position = 0;
                    }
                }

                var info = new InfoDto()
                {
                    PageSize  = pageSize,
                    TotalPage = (int)Math.Ceiling((double)count / pageSize),
                    TotalItem = count,
                    Metadata  = metadata
                };

                var infoBytes = Encoding.UTF8.GetBytes(System.Text.Json.JsonSerializer.Serialize(info));
                using (var ms = new MemoryStream(infoBytes))
                {
                    util.Upload(ms, _bucketName, $"{syncId}/index.json");
                }
            }
            finally
            {
                Directory.Delete(rootFolder, true);
            }

            return(true);
        }
示例#28
0
 public bool Enabled(InfoDto info) => true;
示例#29
0
 private static bool CompareWithDto(InfoGetDto getDto, InfoDto dto)
 {
     //if (getDto is null || dto is null) return false;
     //if (getDto.ExpiryDate != dto.ExpiryDate) return false;
     return(true);
 }
示例#30
0
 public ServiceResult SaveInfo(InfoDto dto)
 {
     Insert(dto.ToEntity());
     return(Save("عملیات با موفقیت صورت گرفت"));
 }