Exemplo n.º 1
0
        public static PackageDirectoryName GetPackageDirectoryName(PackageID packageID)
        {
            var packageFileSystemName = Utilities.GetPackageNuspecFileSystemName(packageID);
            var packageDirectoryName  = packageFileSystemName.Value.AsPackageDirectoryName();

            return(packageDirectoryName);
        }
Exemplo n.º 2
0
        public override int GetHashCode()
        {
            const int prime  = 397;
            int       result = HostAddress.ToLower().GetHashCode(); // package path must be case-insensitive

            result = (result * prime) ^ PackageID.GetHashCode();    // combine the hashes
            return(result);
        }
Exemplo n.º 3
0
        public static NuspecFileName GetNuspecFileName(PackageID packageID)
        {
            var packageFileSystemName          = Utilities.GetPackageNuspecFileSystemName(packageID);
            var nuspecFileNameWithoutExtension = Utilities.GetNuspecFileNameWithoutExtension(packageFileSystemName);
            var nuspecFileName = PathUtilities.GetFileName(nuspecFileNameWithoutExtension, NuspecFileExtension.Instance).AsNuspecFileName();

            return(nuspecFileName);
        }
Exemplo n.º 4
0
        public string OutputLine()
        {
            string lineOut;
            string service;
            var    pkgID = "MDI" + PackageID.PadLeft(9, '0');

            if (Carrier == "UPS")
            {
                switch (ShipMethod)
                {
                case "1DAY":
                    service = "Next Day Air";
                    break;

                case "2DAY":
                    service = "2nd Day Air";
                    break;

                default:
                    service = "Ground";
                    break;
                }

                // Format the output line for UPS package file.
                lineOut = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}," +
                                        "{11},{12},{13},{14},{15},{16},{17},{18},{19}," +
                                        "{20},{21},{22},{23},{24},{25},{26},{27},{28}," +
                                        "{29},{30},{31},{32},{33},{34},{35},{36},{37},{38}",
                                        BaseOrder.Account, PackageOrderNumber, "0", "", "0", itemNum, itemDesc,
                                        CustInfo.FirstName, "", CustInfo.LastName, CustInfo.Address, CustInfo.Address2,
                                        CustInfo.City, CustInfo.State, CustInfo.Zip, "USA", CustInfo.Phone,
                                        DateTime.Now.ToString("M/d/yyyy H:mm"), "S", "", "", "0",
                                        BaseOrder.Gift, pkgID, CustInfo.Attention, Weight, "PACKAGE", "PREPAID", "Y",
                                        service, "UPS", multiItem, signReq, signReq, L, W, H, PackageSubOrderNumber,
                                        BaseOrder.OrderId);
            }
            else
            {
                service = Weight <= 0.8125 ? "@@04" : "@@02";

                // Format the output line for USMail package file.
                lineOut = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}," +
                                        "{11},{12},{13},{14},{15},{16},{17},{18},{19}," +
                                        "{20},{21},{22},{23},{24},{25},{26},{27},{28}," +
                                        "{29},{30},{31},{32},{33},{34},{35},{36},{37},{38},{39}",
                                        BaseOrder.Account, PackageOrderNumber, "0", "", "0", itemNum, itemDesc,
                                        CustInfo.FirstName, "", CustInfo.LastName, CustInfo.Address, CustInfo.Address2,
                                        CustInfo.City, CustInfo.State, CustInfo.Zip, "USA", CustInfo.Phone,
                                        DateTime.Now.ToString("M/d/yyyy H:mm"), "S", "", "", "0",
                                        BaseOrder.Gift, pkgID, CustInfo.Attention, Weight, "PACKAGE", "PREPAID", "Y",
                                        service, "UPS", multiItem, signReq, signReq, L, W, H, "USP",
                                        PackageSubOrderNumber,
                                        BaseOrder.OrderId);
            }

            return(lineOut);
        }
Exemplo n.º 5
0
        public static NupkgFileName GetNupkgFileName(PackageID packageID, Version version)
        {
            var packageFileSystemName         = Utilities.GetPackageNupkgFileSystemName(packageID);
            var versionFileSystemName         = Utilities.GetVersionFileSystemName(version);
            var nupkgFileNameWithoutExtension = Utilities.GetNupkgFileNameWithoutExtension(packageFileSystemName, versionFileSystemName);

            var nupkgFileName = PathUtilities.GetFileName(nupkgFileNameWithoutExtension, FileExtensions.Nupkg).AsNupkgFileName();

            return(nupkgFileName);
        }
Exemplo n.º 6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (RepoName != null ? RepoName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PackageID != null ? PackageID.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Version != null ? Version.GetHashCode() : 0);
         return(hashCode);
     }
 }
        /// <summary>
        /// Overrides Object.GetHashCode.
        /// </summary>
        /// <returns>A suitable hash code for this PackagePathTemplateLocation.</returns>
        public override int GetHashCode()
        {
            const int prime  = 397;
            int       result = PackagePath.ToLower().GetHashCode();       // package path must be case-insensitive

            result = (result * prime) ^ PackageID.GetHashCode();          // combine the hashes
            return(result);

            // NOTE: Object.Equals is overridden in the base class, and therefore
            // does not need not be overridden here.
        }
Exemplo n.º 8
0
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     unchecked
     {
         int result = base.GetHashCode();
         result = (result * 397) ^ Distro?.GetHashCode() ?? 0;
         result = (result * 397) ^ PackageID?.GetHashCode() ?? 0;
         result = (result * 397) ^ Size.GetHashCode();
         result = (result * 397) ^ ConfirmationQuestion?.GetHashCode() ?? 0;
         return(result);
     }
 }
Exemplo n.º 9
0
        public bool RegPack(PackageID id, Type t)
        {
            //查看是否存在于
            if (mPackageMap.ContainsKey(id))
            {
                Debug.WriteLine("[erro]重复注册packid.");
                return(false);
            }

            mPackageMap.Add(id, t);

            return(true);
        }
Exemplo n.º 10
0
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     unchecked
     {
         int result = base.GetHashCode();
         if (Distro != null)
         {
             result = (result * 397) ^ Distro.GetHashCode();
         }
         if (PackageID != null)
         {
             result = (result * 397) ^ PackageID.GetHashCode();
         }
         result = (result * 397) ^ Size.GetHashCode();
         if (ConfirmationQuestion != null)
         {
             result = (result * 397) ^ ConfirmationQuestion.GetHashCode();
         }
         return(result);
     }
 }
Exemplo n.º 11
0
        public static void Save()
        {
            if (appSettings["PackageID"] == null)
            {
                appSettings.Add("PackageID", PackageID.ToString());
            }
            else
            {
                appSettings.Set("PackageID", PackageID.ToString());
            }

            if (appSettings["USMailPackage"] == null)
            {
                appSettings.Add("USMailPackage", USMailPackageFile);
            }
            else
            {
                appSettings.Set("USMailPackage", USMailPackageFile);
            }

            if (appSettings["USMailManifest"] == null)
            {
                appSettings.Add("USMailManifest", USMailManifestFile);
            }
            else
            {
                appSettings.Set("USMailManifest", USMailManifestFile);
            }

            if (appSettings["UPSPackage"] == null)
            {
                appSettings.Add("UPSPackage", UPSPackageFile);
            }
            else
            {
                appSettings.Set("UPSPackage", UPSPackageFile);
            }

            if (appSettings["UPSManifest"] == null)
            {
                appSettings.Add("UPSManifest", UPSManifestFile);
            }
            else
            {
                appSettings.Set("UPSManifest", UPSManifestFile);
            }

            if (appSettings["LoggingEnabled"] == null)
            {
                appSettings.Add("LoggingEnabled", LoggingEnabled.ToString());
            }
            else
            {
                appSettings.Set("LoggingEnabled", LoggingEnabled.ToString());
            }

            if (appSettings["LogFileName"] == null)
            {
                appSettings.Add("LogFileName", LogFileName);
            }
            else
            {
                appSettings.Set("LogFileName", LogFileName);
            }

            if (appSettings["LoggingLevel"] == null)
            {
                appSettings.Add("LoggingLevel", LoggingLevel.ToString());
            }
            else
            {
                appSettings.Set("LoggingLevel", LoggingLevel.ToString());
            }

            //       ' Save the changes.
            //       _cfg.Save()
        }
        public static NupkgFilePath Pack(FilePath dotnetExecutableFilePath, ProjectFilePath projectFilePath, DirectoryPath outputDirectoryPath, PackageID packageID, IEnumerable <string> sources, ILogger logger)
        {
            // Determine the project version.
            var projectVersion = VsUtilities.GetVersion(projectFilePath);

            var packageFileName = NugetIoUtilities.GetNupkgFileName(packageID, projectVersion);

            // Determine the .nupkg file-name and file-path (using output directory-path, project ID, project version, and .nupkg file-extension).
            var packageFilePath = PathUtilitiesExtra.GetFilePath(outputDirectoryPath, packageFileName).AsNupkgFilePath();

            logger.LogDebug($"{projectFilePath} - Packing project to:\n{packageFilePath}");

            var arguments = $@"pack ""{projectFilePath}"" --output ""{outputDirectoryPath}"" -p:PackageID={packageID}";

            if (sources.Count() > 0)
            {
                foreach (var source in sources)
                {
                    arguments = arguments.Append($@" --source ""{source}""");
                }
            }

            var outputCollector = ProcessRunner.Run(dotnetExecutableFilePath.Value, arguments);

            // Test for success.
            var lastLine = outputCollector.GetOutputLines().Last().Trim();

            var expectedLastLine = $"Successfully created package '{packageFilePath}'.";

            if (expectedLastLine != lastLine)
            {
                throw new Exception($"dotnet automation error. Command:\n{ ProcessRunner.GetCommandLineIncantation(dotnetExecutableFilePath.Value, arguments) }\n\nOutput:\n{ outputCollector.GetOutputText()}\n\nError:\n{ outputCollector.GetErrorText()}\n");
            }

            logger.LogInformation($"{projectFilePath} - Packed project to:\n{packageFilePath}");

            return(packageFilePath);
        }
        public static PackageID AsPackageID(this string value)
        {
            var packageID = new PackageID(value);

            return(packageID);
        }
        public static NupkgFilePath Pack(this DotnetCommand command, ProjectFilePath projectFilePath, DirectoryPath outputDirectoryPath, PackageID packageID, IEnumerable <string> sources)
        {
            var packageFilePath = DotnetCommandServicesProvider.Pack(command.DotnetExecutableFilePath, projectFilePath, outputDirectoryPath, packageID, sources, command.Logger);

            return(packageFilePath);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Value is the lower-case version of the package ID.
        /// </summary>
        public static PackageFileSystemName GetPackageNuspecFileSystemName(PackageID packageID)
        {
            var packageFileSystemName = packageID.Value.ToLowerInvariant().AsPackageFileSystemName();

            return(packageFileSystemName);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Value is the same as the package ID.
        /// </summary>
        public static PackageFileSystemName GetPackageNupkgFileSystemName(PackageID packageID)
        {
            var packageFileSystemName = packageID.Value.AsPackageFileSystemName();

            return(packageFileSystemName);
        }
Exemplo n.º 17
0
 public bool RegPack(PackageID id)
 {
     return(RegPack(id, null));
 }
Exemplo n.º 18
0
        void Handle_RecivePackage(WazSession s, byte[] data, int size)
        {
            PackRecHelper recHelper;

            if (!mSessionRecHelpers.TryGetValue(s.Handle, out recHelper))
            {
                return;
            }

            //将data 放入读取stream末尾
            recHelper.Stream.Write(data, 0, size);
            recHelper.Stream.Seek(recHelper.PreReadStreamOffset, SeekOrigin.Begin);
            bool havePackageCut = false;

            //开始读取.
            while (recHelper.Stream.Position < recHelper.Stream.Length - 1)
            {
                long   posStartRead = recHelper.Stream.Position;
                object objPack;
                Type   typePack;
                try
                {
                    //读包头
                    byte head = recHelper.Reader.ReadByte();
                    if (head != mPackHead)
                    {
                        continue;
                    }
                    //读长度(实际为到包尾offset)
                    PackageOffsetToEnd offsetToEnd = recHelper.Reader.ReadUInt16();

                    //判断超出当前流(一个包在两段流中)
                    if (recHelper.Stream.Position + offsetToEnd + 1 > recHelper.Stream.Length)
                    {
                        recHelper.PreReadStreamOffset = posStartRead;
                        havePackageCut = true;
                        break;
                    }

                    //判断包尾是否正确
                    long posTmp = recHelper.Stream.Position;
                    recHelper.Stream.Seek(offsetToEnd, SeekOrigin.Current);
                    byte end = recHelper.Reader.ReadByte();
                    recHelper.Stream.Position = posTmp;//还原pos到读位置之后
                    if (end != mPackEnd)
                    {
                        continue;
                    }

                    //读命令id
                    PackageID pID = recHelper.Reader.ReadUInt16();

                    if (!mPackageMap.TryGetValue(pID, out typePack))
                    {
                        Debug.WriteLine("[erro]解析包时出现未注册包ID");
                        continue;
                    }

                    //正式开始数据
                    objPack = Activator.CreateInstance(typePack);
                    FieldInfo[] packFields = typePack.GetFields();
                    foreach (FieldInfo f in packFields)
                    {
                        f.SetValue(objPack, WazSerializerHelper.Read(recHelper.Reader, f.FieldType));
                    }

                    //跳过包尾
                    recHelper.Stream.Seek(1, SeekOrigin.Current);
                }
                catch (Exception e)
                {
                    //					recHelper.PreReadStreamOffset = posStartRead;
                    //					havePackageCut = true;
                    Debug.WriteLine("[erro]接收数据包异常.可能出现错误包 \r\n" + e.ToString());
                    break;
                }

                if (objPack != null)
                {
                    if (EvtRecevicePack != null)
                    {
                        EvtRecevicePack(s, objPack);
                    }

                    //触发pack绑定处理函数
                    Action <WazSession, object> packBindHanlders;
                    if (mPackDispathToAllSessionMap.TryGetValue(typePack, out packBindHanlders))
                    {
                        packBindHanlders(s, objPack);
                    }

                    //触发session,pack绑定处理函数
                    Dictionary <Type, Action <object> > typePackMap;
                    if (mPackDispatchMap.TryGetValue(s.Handle, out typePackMap))
                    {
                        Action <object> handler;
                        if (typePackMap.TryGetValue(typePack, out handler))
                        {
                            handler(objPack);
                        }
                    }
                }
            }

            //证明完成读包,重置缓冲区
            if (!havePackageCut)
            {
                recHelper.PreReadStreamOffset = 0;
                recHelper.Stream.Position     = 0;
                recHelper.Stream.SetLength(0);
            }
        }
Exemplo n.º 19
0
 public Packable(PackageID id)
 {
     ID = id;
 }