コード例 #1
0
        public virtual void Execute(ExecutingProcess executingProcess)
        {
            PackageEntity package = (PackageEntity)executingProcess.Data !;

            var args = package.OperationArgs;

            executingProcess.ForEachLine(package.Lines().Where(a => a.FinishTime == null), line =>
            {
                ((T)(object)line.Target).Execute(Symbol, args);
                line.FinishTime = TimeZoneManager.Now;
                line.Save();
            });
        }
コード例 #2
0
        internal async Task <PackageEntity> GetPackage(string packageId)
        {
            PackageEntity packageEntity = await _packageReq.getPackage(packageId);

            if (packageEntity == null)
            {
                PackageEntity pEntity = _nugetDL.GetInfoPackage(packageId);
                await _packageReq.AddIfNotExists(pEntity.PartitionKey, pEntity.ListVPackage, pEntity.Description, pEntity.Authors);

                return(pEntity);
            }

            return(packageEntity);
        }
コード例 #3
0
ファイル: PackageLogic.cs プロジェクト: goldenauge/framework
    public virtual void Execute(ExecutingProcess executingProcess)
    {
        PackageEntity package = (PackageEntity)executingProcess.Data !;

        var args = package.GetOperationArgs();

        executingProcess.ForEachLine(package.Lines().Where(a => a.FinishTime == null), line =>
        {
            ((T)(IEntity)line.Target).Delete(DeleteSymbol, args);

            line.FinishTime = Clock.Now;
            line.Save();
        });
    }
コード例 #4
0
        /// <summary>
        /// 获取实体(异步方式)
        /// </summary>
        /// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
        /// <param name="dict">参数的名/值集合</param>
        /// <returns></returns>
        public virtual async Task <PackageEntity> GetEntityAsync(string strWhere, Dictionary <string, object> dict = null)
        {
            PackageEntity obj    = null;
            string        strSQL = "select top 1 * from Package where 1=1 " + strWhere;

            using (NullableDataReader reader = await Task.Run(() => _DB.GetDataReader(strSQL, dict)))
            {
                if (reader.Read())
                {
                    obj = GetEntityFromrdr(reader);
                }
            }
            return(obj);
        }
コード例 #5
0
ファイル: PackageLogic.cs プロジェクト: goldenauge/framework
    public virtual void Execute(ExecutingProcess executingProcess)
    {
        PackageEntity package = (PackageEntity)executingProcess.Data !;

        var args = package.GetOperationArgs();

        using (OperationLogic.AllowSave <T>())
            executingProcess.ForEachLine(package.Lines().Where(a => a.FinishTime == null), line =>
            {
                ((T)(object)line.Target).Save();
                line.FinishTime = Clock.Now;
                line.Save();
            });
    }
コード例 #6
0
 public static PackageDto ToDto(this PackageEntity package)
 {
     if (package == null)
     {
         return(null);
     }
     return(new PackageDto()
     {
         PackageId = package.PackageId,
         PackageName = package.PackageName,
         PackageTotalPrice = package.PackageTotalPrice,
         //Lines=package.Lines.Select(p=>p.ToDto()).ToList()
     });
 }
コード例 #7
0
        private async Task <NuspecContext> GetNuspecQueryContextAsync(PackageEntity package)
        {
            var nuspecContext = await _nuspecStore.GetNuspecContextAsync(package.PackageRegistration.Id, package.Version);

            if (!nuspecContext.Exists && !package.CatalogPackage.Deleted)
            {
                _logger.LogWarning(
                    "Could not find .nuspec for {Id} {Version}.",
                    package.PackageRegistration.Id,
                    package.Version);
            }

            return(nuspecContext);
        }
コード例 #8
0
        public async Task PackageId(string id, string packageId)
        {
            try
            {
                await PackageEntity.ValidatePackageId(packageId);

                await ShipmentEntity.ValidateId(id);

                await ShipmentDAO.Methods.UpdateSet.PackageId(id, packageId);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public PackageDTO CalculatePrice(int packageId, string additionalServices)
        {
            var package = new BuyPackageBusinessLayer();

            additionalServices = additionalServices != "0" ? additionalServices : string.Empty;
            var additionalServicesAux = !string.IsNullOrEmpty(additionalServices) ? additionalServices.Split(',').Select(x => Convert.ToInt32(x)).ToList() : new List <int>();
            var price         = package.CalculatePrice(packageId, additionalServicesAux);
            var packageEntity = new PackageEntity()
            {
                PackageId = packageId,
                Price     = price
            };

            return(Mapper.Map <PackageDTO>(packageEntity));
        }
コード例 #10
0
        /// <summary>
        /// 更新一条记录(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <bool> UpdateAsync(PackageEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);
            string strSQL = "Update Package SET " +
                            "PackageName = @PackageName," +
                            "PackageWeight = @PackageWeight," +
                            "GoodsWeightMin = @GoodsWeightMin," +
                            "GoodsWeightMax = @GoodsWeightMax" +
                            " WHERE " +

                            "PackageID = @PackageID";

            return(await Task.Run(() => _DB.ExeSQLResult(strSQL, dict)));
        }
コード例 #11
0
        public async Task <bool> DeleteIfExists(string packageId)
        {
            TableOperation retrieveOperation = TableOperation.Retrieve <PackageEntity>(packageId, "blbl");
            TableResult    retrieved         = await AManager.PackagesTable.ExecuteAsync(retrieveOperation);

            if (retrieved.Result == null)
            {
                return(false);
            }

            PackageEntity  p = (PackageEntity)retrieved.Result;
            TableOperation removeOperation = TableOperation.Delete(p);
            await AManager.PackagesTable.ExecuteAsync(removeOperation);

            return(true);
        }
コード例 #12
0
 public static Package ToDomain(this PackageEntity package)
 {
     return(package == null
                    ? null
                    : new Package(
                id: package.PackageId,
                size: package.Size,
                weight: package.Weight,
                isFragile: package.IsFragile,
                valueToPay: package.ValueToPay,
                trackingCode: package.TrackingCode,
                shipment: package.Shipment.ToDomain(),
                version: package.Version,
                createdAt: package.CreatedAt,
                updatedAt: package.UpdatedAt));
 }
コード例 #13
0
    static public PackageEntity BuildQueryAllCommonTypes(this PackageEntity entity)
    {
        var pe = new PackageEntity()
                 .SetVersion("29.0")
                 .AddGlobal("ApexClass")
                 .AddGlobal("ApexPage")
                 .AddGlobal("ApexComponent")
                 .AddGlobal("ApexTrigger")
                 .AddGlobal("ApprovalProcess")
                 .AddGlobal("CustomLabels")
                 .AddGlobal("StaticResource")
                 .AddGlobal("Layouts")
                 .AddGlobal("CustomObject")
                 .AddGlobal("Workflow");

        return(pe);
    }
コード例 #14
0
 public bool AddPackage(PackageEntity package, int lineId)
 {
     try
     {
         using (var context = new CellularDbContext())
         {
             var line = (from l in context.Lines
                         where l.LineId == lineId
                         select l).FirstOrDefault();
             line.Packages.Add(package);
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #15
0
        public async Task <bool> AddIfNotExists(string packageId, List <string> versions, string description, List <string> authors)
        {
            TableOperation retrieveOperation = TableOperation.Retrieve(packageId, "blbl");
            TableResult    retrieved         = await AManager.PackagesTable.ExecuteAsync(retrieveOperation);

            if (retrieved.Result != null)
            {
                return(false);
            }

            PackageEntity p = new PackageEntity(packageId);

            p.ListVPackage = versions;
            TableOperation insertOperation = TableOperation.Insert(p);
            await AManager.PackagesTable.ExecuteAsync(insertOperation);

            return(true);
        }
コード例 #16
0
        /// <summary>
        /// 增加一条记录,返回新的ID号。需要有一个单一主键,并且开启有标识符属性
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual int Insert(PackageEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);

            string strSQL = "insert into Package (" +
                            "PackageName," +
                            "PackageWeight," +
                            "GoodsWeightMin," +
                            "GoodsWeightMax) " +
                            "values(" +
                            "@PackageName," +
                            "@PackageWeight," +
                            "@GoodsWeightMin," +
                            "@GoodsWeightMax)";

            return(_DB.ReturnID(strSQL, dict));
        }
コード例 #17
0
        /// <summary>
        /// 增加一条记录,返回新的ID号。需要有一个单一主键,并且开启有标识符属性(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <int> InsertAsync(PackageEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);

            string strSQL = "insert into Package (" +
                            "PackageName," +
                            "PackageWeight," +
                            "GoodsWeightMin," +
                            "GoodsWeightMax) " +
                            "values(" +
                            "@PackageName," +
                            "@PackageWeight," +
                            "@GoodsWeightMin," +
                            "@GoodsWeightMax)";

            return(await Task.Run(() => _DB.ReturnID(strSQL, dict)));
        }
コード例 #18
0
ファイル: EmailPackageLogic.cs プロジェクト: ywscr/extensions
        public virtual void Execute(ExecutingProcess executingProcess)
        {
            PackageEntity package = (PackageEntity)executingProcess.Data !;

            var args     = package.OperationArgs;
            var template = args.GetArg <Lite <EmailTemplateEntity> >();

            executingProcess.ForEachLine(package.Lines().Where(a => a.FinishTime == null), line =>
            {
                var emails = template.CreateEmailMessage(line.Target).ToList();
                foreach (var email in emails)
                {
                    email.SendMailAsync();
                }

                line.Result     = emails.Only()?.ToLite();
                line.FinishTime = TimeZoneManager.Now;
                line.Save();
            });
        }
コード例 #19
0
ファイル: PackageLogic.cs プロジェクト: crazyants/extensions
        public virtual void Execute(ExecutingProcess executingProcess)
        {
            PackageEntity package = (PackageEntity)executingProcess.Data;

            var args = package.OperationArgs;

            executingProcess.ForEachLine(package.Lines().Where(a => a.FinishTime == null), line =>
            {
                var result = ((F)(object)line.Target).ConstructFrom(Symbol, args);
                if (result.IsNew)
                {
                    result.Save();
                }

                line.Result = ((Entity)(IEntity)result).ToLite();

                line.FinishTime = TimeZoneManager.Now;
                line.Save();
            });
        }
コード例 #20
0
        public async Task <IEnumerable <int> > Import(int id)
        {
            var packages = await GetAllPackages(id);

            if (packages == null || !packages.Any())
            {
                return(null);
            }

            List <int> ids = new List <int>();

            foreach (var entry in packages)
            {
                PackageEntity package = _mapper.Map <PackageEntity>(entry);
                package.RepositoryId = id;
                ids.Add(await _packageManager.Import(package));
            }

            return(ids);
        }
コード例 #21
0
        public PackageEntity GetInfoPackage(string packageId)
        {
            PackageEntity pEntity = new PackageEntity(packageId);

            List <IPackage> packages = _repo.FindPackagesById(packageId).ToList();

            pEntity.Authors     = (packages.Count > 0 ? packages.Last().Authors.ToList():new List <string>());
            pEntity.Description = (packages.Count > 0 ? packages.Last().Description : String.Empty);

            List <string> vpackages = new List <string>();

            packages.Reverse();
            foreach (IPackage item in packages)
            {
                vpackages.Add(item.Version.ToString());
            }
            pEntity.ListVPackage = vpackages;

            return(pEntity);
        }
コード例 #22
0
        protected PackageSourceCodeDiscountEntity(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            if (SerializationHelper.Optimization != SerializationOptimization.Fast)
            {
                _coupons = (CouponsEntity)info.GetValue("_coupons", typeof(CouponsEntity));
                if (_coupons != null)
                {
                    _coupons.AfterSave += new EventHandler(OnEntityAfterSave);
                }
                _package = (PackageEntity)info.GetValue("_package", typeof(PackageEntity));
                if (_package != null)
                {
                    _package.AfterSave += new EventHandler(OnEntityAfterSave);
                }

                base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance());
            }

            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
コード例 #23
0
        protected HospitalPartnerPackageEntity(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            if (SerializationHelper.Optimization != SerializationOptimization.Fast)
            {
                _hospitalPartner = (HospitalPartnerEntity)info.GetValue("_hospitalPartner", typeof(HospitalPartnerEntity));
                if (_hospitalPartner != null)
                {
                    _hospitalPartner.AfterSave += new EventHandler(OnEntityAfterSave);
                }
                _package = (PackageEntity)info.GetValue("_package", typeof(PackageEntity));
                if (_package != null)
                {
                    _package.AfterSave += new EventHandler(OnEntityAfterSave);
                }

                base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance());
            }

            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
 public RetrieveRequest[] ConvertPackageToRequests(PackageEntity package)
 {
     return(package.Types.Select(t =>
     {
         RetrieveRequest retrieveRequest = new RetrieveRequest
         {
             apiVersion = double.Parse(package.Version, CultureInfo.InvariantCulture),
             unpackaged = new Package()
             {
                 types = new[]
                 {
                     new PackageTypeMembers()
                     {
                         name = t.Name,
                         members = t.Members
                     }
                 }
             }
         };
         return retrieveRequest;
     }).ToArray());
 }
コード例 #25
0
        private void BuildQRCode(string keyValue)
        {
            PackageEntity packageEntity = packagebll.GetEntity(keyValue);
            FileInfoBLL   fileBll       = new FileInfoBLL();
            var           filelist      = fileBll.GetFilesByRecIdNew(keyValue);

            if (packageEntity == null)
            {
                throw new ArgumentException("无APP应用程序信息");
            }
            if (filelist == null || filelist.Count == 0)
            {
                throw new ArgumentException("无APP应用程序文件");
            }

            string staticFileName = string.Empty;

            staticFileName = packageEntity.PackType == 0 ? "bzapp.apk" : "bzzdapp.apk";

            string url = string.Format("http://{0}{1}/{2}", HttpContext.Request.Url.Host, HttpContext.Request.ApplicationPath, string.Format("/Resource/Package/{0}/{1}", packageEntity.PackType, staticFileName));
            //判断当前二维码路径存不存在
            string filePath = Server.MapPath(string.Format("~/Resource/Package/{0}", packageEntity.PackType));

            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }

            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();

            qrCodeEncoder.QRCodeVersion         = 10;
            qrCodeEncoder.QRCodeScale           = 2;
            qrCodeEncoder.QRCodeForegroundColor = Color.Black;
            Bitmap bmp = qrCodeEncoder.Encode(url, Encoding.UTF8);//指定utf-8编码, 支持中文

            bmp.Save(Path.Combine(filePath, "Download.jpg"));
            bmp.Dispose();
        }
コード例 #26
0
        public static async Task RunAsync(
            [NuGetCatalogTrigger(CursorBlobName = "catalogCursor.json", UseBatchProcessor = true)] PackageOperation packageOperation,
            [Queue(Constants.IndexingQueue, Connection = Constants.IndexingQueueConnection)] ICollector <PackageOperation> indexingQueueCollector,
            [Queue(Constants.DownloadingQueue, Connection = Constants.DownloadingQueueConnection)] ICollector <PackageOperation> downloadingQueueCollector,
            [Table("packages")] CloudTable outputTable,
            ILogger log)
        {
            // Log
            log.LogInformation("Appending package {action} operation for {packageId}@{packageVersionNormalized}...", packageOperation.Action, packageOperation.Id, packageOperation.Version);

            // Append to queues
            indexingQueueCollector.Add(packageOperation);
            downloadingQueueCollector.Add(packageOperation);

            // Store (or delete) from table
            var entity = new PackageEntity
            {
                Id                = packageOperation.Id,
                Version           = packageOperation.Version,
                VersionVerbatim   = packageOperation.VersionVerbatim,
                VersionNormalized = packageOperation.VersionNormalized,
                Published         = packageOperation.Published,
                Url               = packageOperation.PackageUrl,
                IsListed          = packageOperation.IsListed,
                Timestamp         = DateTimeOffset.UtcNow
            };

            if (packageOperation.IsAdd())
            {
                await outputTable.ExecuteAsync(TableOperation.InsertOrMerge(entity));
            }
            else
            {
                await outputTable.ExecuteAsync(TableOperation.Delete(entity));
            }

            log.LogInformation("Finished appending package {action} operation for {packageId}@{packageVersionNormalized}.", packageOperation.Action, packageOperation.Id, packageOperation.Version);
        }
コード例 #27
0
        public async Task <PackageDto> CreatePackage(PackageDto package)
        {
            using (CellularCompanyContext db = new CellularCompanyContext())
            {
                try
                {
                    if (package != null)
                    {
                        PackageEntity entity = package.ToModel();
                        db.Packages.Add(entity);
                        await db.SaveChangesAsync();

                        return(entity.ToDto());
                    }
                    return(null);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    return(null);
                }
            }
        }
コード例 #28
0
        public static async Task CreateNewShipment(NewShipmentRequest request)
        {
            try
            {
                var package = PackageFactory.CreatePackage(request.PackageData);
                await PackageEntity.ValidateNew(package);

                var shipment = ShipmentFactory.CreateShipment(request);
                await ShipmentEntity.ValidateNew(shipment);

                await PackageUseCases.RegisterPackage.Execute(package);

                await ShipmentUseCases.RegisterShipment.Execute(shipment);

                await ShipmentUseCases.Set.PackageId(shipment.Id.ToString(), package.Id.ToString());

                await ShipmentUseCases.UpdateShipmentWithBoundry(shipment);
            }
            catch (Exception e)
            {
                throw;
            }
        }
コード例 #29
0
ファイル: PackageLogic.cs プロジェクト: goldenauge/framework
    public virtual void Execute(ExecutingProcess executingProcess)
    {
        PackageEntity package = (PackageEntity)executingProcess.Data !;

        var args = package.GetOperationArgs();

        executingProcess.ForEachLine(package.Lines().Where(a => a.FinishTime == null), line =>
        {
            var result = ((F)(object)line.Target).ConstructFrom(Symbol, args);
            if (result != null)
            {
                if (result.IsNew)
                {
                    using (OperationLogic.AllowSave <T>())
                        result.Save();
                }

                line.Result = ((Entity)(IEntity)result).ToLite();
            }

            line.FinishTime = Clock.Now;
            line.Save();
        });
    }
コード例 #30
0
        private static void ParsePackage(FileInfo package, DirectoryEntity parent, HashProvider hashProvider, IProgress <int> progress)
        {
            PackageEntity root = new PackageEntity(package.Name);

            parent.Add(root);
            bool computeHash = hashProvider != null;

            using (ZipArchive archive = ZipFile.OpenRead(package.FullName))
            {
                foreach (ZipArchiveEntry entry in archive.Entries)
                {
                    // Directory
                    if (entry.Length == 0)
                    {
                        continue;
                    }

                    string     relativePath = entry.FullName.Substring(0, entry.FullName.Length - entry.Name.Length);
                    FileEntity file         = computeHash ? new FileEntity(entry.Name, hashProvider.FromStream(entry.Open()) + entry.FullName.GetHashCode(), entry.Length) : new FileEntity(entry.Name, entry.Length);
                    (root.GetEntityFromRelativePath(relativePath, true) as DirectoryEntity).Add(file);
                    progress?.Report(1);
                }
            }
        }