コード例 #1
0
        public static string SerializeToJson <T>(this T obj, OutPutType outPutType, bool ignoreNulls = false)
        {
            var jsonString = JsonConvert.SerializeObject(obj);

            if (outPutType == OutPutType.Formatted && ignoreNulls)
            {
                jsonString = JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });
            }
            else if (outPutType == OutPutType.Formatted)
            {
                jsonString = JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.Indented);
            }
            else if (ignoreNulls)
            {
                jsonString = JsonConvert.SerializeObject(obj, new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });
            }

            return(jsonString);
        }
コード例 #2
0
        public static string SerializeToJson <T>(this T obj, OutPutType outPutType)
        {
            var jsonString = JsonConvert.SerializeObject(obj);

            if (outPutType == OutPutType.Formatted)
            {
                jsonString = JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.Indented);
            }
            return(jsonString);
        }
コード例 #3
0
ファイル: DeviceTypeChannel.cs プロジェクト: xdpcxq/ZHYD4
 public DeviceTypeChannel(string deviceTypeId, int portNumber, string portDefaultName, PortType portType, OutPutType outputType, bool outputThreePhase, double outputValue, bool enabled, string sort = null)
     : this()
 {
     DeviceTypeId     = deviceTypeId ?? throw new ArgumentNullException(nameof(deviceTypeId));
     PortNumber       = portNumber;
     PortDefaultName  = portDefaultName ?? throw new ArgumentNullException(nameof(portDefaultName));
     PortType         = portType;
     OutputType       = outputType;
     OutputThreePhase = outputThreePhase;
     OutputValue      = outputValue;
     Enabled          = enabled;
     Sort             = sort;
 }
コード例 #4
0
    public static void Save(RenderTexture toSave, OutPutType format, string name)
    {
        if (toSave == null)
        {
            Debug.LogError("Attempt to save null renderTexture");
        }
        Texture2D screenShot = new Texture2D(toSave.width, toSave.height, TextureFormat.RGB24, false);

        RenderTexture.active = toSave;
        screenShot.ReadPixels(new Rect(0, 0, toSave.width, toSave.height), 0, 0);
        RenderTexture.active = null;
        byte[] bytes;
        string fileEnding = "";

        switch (format)
        {
        case OutPutType.JPEG:
            bytes      = screenShot.EncodeToJPG();
            fileEnding = "jpeg";
            break;

        case OutPutType.PNG:
            bytes      = screenShot.EncodeToPNG();
            fileEnding = "png";
            break;

        default:
            bytes      = screenShot.EncodeToJPG();
            fileEnding = "jpeg";
            break;
        }



        string nameOfTheImage = FileName(name, toSave.width, toSave.height, fileEnding);
        string pathToTheFile  = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/" + UnityEngine.SceneManagement.SceneManager.GetActiveScene().name + "/";

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

        string fileName = pathToTheFile + nameOfTheImage;

        System.IO.File.WriteAllBytes(fileName, bytes);
        Debug.Log("Saved file: " + nameOfTheImage + " in: " + fileName);
    }
 public static IOutputProvider CreateProvider(OutPutType outputType)
 {
     Logger.Log(string.Format("Creating IOutputProvider for type: '{0}'", outputType));
     switch (outputType)
     {
         case OutPutType.YumlReferenceList:
             return new YumlReferenceListOutputProvider();
         case OutPutType.YumlUrl:
             return new YumlUrlOutputProvider();
         case OutPutType.YumlImage:
             return new YumlImageOutputProvider();
         case OutPutType.HtmlDocument:
             return new SinglePageHtmlDocumentOutputProvider();
         default:
             throw new ArgumentOutOfRangeException("outputType");
     }
 }
コード例 #6
0
        public void BatchWriteOutData(OutPutType outPutMode, OutPutMktMode mktMode, string filePath, int cutOffHour)
        {
            switch (outPutMode)
            {
            case OutPutType.FlatFile:
                WriteOutFlatFile(mktMode, filePath, cutOffHour);
                break;

            case OutPutType.Xml:
                break;

            case OutPutType.Binary:
                break;

            case OutPutType.SqlTable:
                break;

            default:
                throw new ArgumentOutOfRangeException("outPutMode");
            }
        }
コード例 #7
0
        /// <summary>
        /// Generate source code for the configuration
        /// </summary>
        /// <param name="destinationPath">
        /// File location to write output to.
        /// Should be a .cs file location when using <see cref="OutPutType.SingleFile"/> otherwise should be a folder
        /// Will overwrite files if they already exist
        /// </param>
        /// <param name="type">Type of output to generate</param>
        public void GenerateConfig(Uri destinationPath, OutPutType type)
        {
            init();
            _namespace.Imports.AddRange(Namespaces.ToArray());
            var root = _configurationSectionXml.Root;

            CreateSectionElement(root);
            if (Provider == null)
            {
                Provider = new CSharpCodeProvider();
            }

            if (type == OutPutType.FilePerClass)
            {
                WriteMultipleFiles(destinationPath);
            }
            else
            {
                WriteSingleFile(destinationPath);
            }
        }
コード例 #8
0
        public static IOutputProvider CreateProvider(OutPutType outputType)
        {
            Logger.Log(string.Format("Creating IOutputProvider for type: '{0}'", outputType));
            switch (outputType)
            {
            case OutPutType.YumlReferenceList:
                return(new YumlReferenceListOutputProvider());

            case OutPutType.YumlUrl:
                return(new YumlUrlOutputProvider());

            case OutPutType.YumlImage:
                return(new YumlImageOutputProvider());

            case OutPutType.HtmlDocument:
                return(new SinglePageHtmlDocumentOutputProvider());

            default:
                throw new ArgumentOutOfRangeException("outputType");
            }
        }
コード例 #9
0
 public void BatchWriteOutData(OutPutType outPutMode, OutPutMktMode mktMode, string filePath, int cutOffHour)
 {
     switch (outPutMode)
     {
         case OutPutType.FlatFile:
             WriteOutFlatFile(mktMode, filePath, cutOffHour);
             break;
         case OutPutType.Xml:
             break;
         case OutPutType.Binary:
             break;
         case OutPutType.SqlTable:
             break;
         default:
             throw new ArgumentOutOfRangeException("outPutMode");
     }
 }
コード例 #10
0
 public void BatchWriteOutData(OutPutType outPutMode)
 {
     BatchWriteOutData(outPutMode, OutPutMktMode.AggregatedMkts, String.Empty, 0);
 }
コード例 #11
0
 public void BatchWriteOutData(OutPutType outPutMode)
 {
     BatchWriteOutData(outPutMode, OutPutMktMode.AggregatedMkts, String.Empty, 0);
 }
コード例 #12
0
ファイル: CommonTools.cs プロジェクト: cleanmgr112/oms
        /// <summary>
        /// 获取导出模板
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, string> OutPutTemplate(OutPutType outPutType)
        {
            Dictionary <string, string> columnNames = new Dictionary <string, string>();

            switch (outPutType)
            {
            case OutPutType.B2C:
                columnNames = new Dictionary <string, string>()
                {
                    { "创建时间", "CreatedTime" },
                    { "发货时间", "DeliveryDate" },
                    { "店铺", "ShopName" },
                    { "订单号", "SerialNumber" },
                    { "收货人", "CustomerName" },
                    { "订单状态", "StateName" },
                    { "平台订单号", "PSerialNumber" },
                    { "原订单号", "OrgionSerialNumber" },
                    { "支付方式", "PayTypeName" },
                    { "昵称", "UserName" },
                    { "手机号", "CustomerPhone" },
                    { "地址", "Address" },
                    { "优惠前总价", "SumOrginPrice" },
                    { "订单均摊金额", "SumAvgPrice" },
                    { "订单已付款金额", "PayPrice" },
                    { "平台积分", "IntegralValue" },
                    { "平台优惠券", "ProductCoupon" },
                    { "付款状态", "PayStateName" },
                    { "付款时间", "PayDate" },
                    { "快递公司", "DeliveryTypeName" },
                    { "物流单号", "DeliveryNumber" },
                    { "发票类型", "InvoiceTypeName" },
                    { "发票号", "InvoiceNumber" },
                    { "发票抬头", "InvoiceHead" },
                    { "客服备注", "AdminMark" },
                    { "订单备注", "OrderMark" },
                    { "给仓库留言", "ToWareHouseMark" }
                };
                break;

            case OutPutType.B2CDetail:
                columnNames = new Dictionary <string, string>()
                {
                    { "创建时间", "CreatedTime" },
                    { "发货时间", "DeliveryDate" },
                    { "店铺", "ShopName" },
                    { "订单号", "SerialNumber" },
                    { "收货人", "CustomerName" },
                    { "商品编码", "ProductCode" },
                    { "商品名称", "ProductName" },
                    { "单价", "UnitPrice" },
                    { "数量", "Quantity" },
                    { "均摊金额", "AvgPrice" },
                    { "订单状态", "StateName" },
                    { "平台订单号", "PSerialNumber" },
                    { "原订单号", "OrgionSerialNumber" },
                    { "支付方式", "PayTypeName" },
                    { "昵称", "UserName" },
                    { "手机号", "CustomerPhone" },
                    { "地址", "Address" },
                    { "优惠前总价", "SumOrginPrice" },
                    { "订单均摊金额", "SumAvgPrice" },
                    { "订单已付款金额", "PayPrice" },
                    { "平台积分", "IntegralValue" },
                    { "平台优惠券", "ProductCoupon" },
                    { "付款状态", "PayStateName" },
                    { "付款时间", "PayDate" },
                    { "快递公司", "DeliveryTypeName" },
                    { "物流单号", "DeliveryNumber" },
                    { "发票类型", "InvoiceTypeName" },
                    { "发票号", "InvoiceNumber" },
                    { "发票抬头", "InvoiceHead" },
                    { "客服备注", "AdminMark" },
                    { "订单备注", "OrderMark" },
                    { "给仓库留言", "ToWareHouseMark" },
                    { "标准价", "OrginPrice" },
                    { "仓库", "WareHouseName" },
                    { "现金支付金额", "PayMoneyPrice" }
                };
                break;

            case OutPutType.B2B:
                columnNames = new Dictionary <string, string>()
                {
                    { "创建时间", "CreatedTime" },
                    { "发货时间", "DeliveryDate" },
                    { "店铺", "ShopName" },
                    { "订单号", "SerialNumber" },
                    { "业务员", "SalesManName" },
                    { "客户", "ClientName" },
                    { "客户类型", "UserTypeName" },
                    { "收货人", "CustomerName" },
                    { "订单状态", "StateName" },
                    { "平台订单号", "PSerialNumber" },
                    { "原订单号", "OrgionSerialNumber" },
                    { "支付方式", "PayTypeName" },
                    { "昵称", "UserName" },
                    { "手机号", "CustomerPhone" },
                    { "地址", "Address" },
                    { "优惠前总价", "SumOrginPrice" },
                    { "订单均摊金额", "SumAvgPrice" },
                    { "订单已付款金额", "PayPrice" },
                    { "平台积分", "IntegralValue" },
                    { "平台优惠券", "ProductCoupon" },
                    { "付款状态", "PayStateName" },
                    { "付款时间", "PayDate" },
                    { "快递公司", "DeliveryTypeName" },
                    { "物流单号", "DeliveryNumber" },
                    { "发票类型", "InvoiceTypeName" },
                    { "发票号", "InvoiceNumber" },
                    { "发票抬头", "InvoiceHead" },
                    { "客服备注", "AdminMark" },
                    { "订单备注", "OrderMark" },
                    { "给仓库留言", "ToWareHouseMark" }
                };
                break;

            case OutPutType.B2BDetail:
                columnNames = new Dictionary <string, string>()
                {
                    { "创建时间", "CreatedTime" },
                    { "发货时间", "DeliveryDate" },
                    { "店铺", "ShopName" },
                    { "订单号", "SerialNumber" },
                    { "业务员", "SalesManName" },
                    { "客户", "ClientName" },
                    { "客户类型", "UserTypeName" },
                    { "收货人", "CustomerName" },
                    { "商品编码", "ProductCode" },
                    { "商品名称", "ProductName" },
                    { "单价", "UnitPrice" },
                    { "数量", "Quantity" },
                    { "均摊金额", "AvgPrice" },
                    { "订单状态", "StateName" },
                    { "平台订单号", "PSerialNumber" },
                    { "原订单号", "OrgionSerialNumber" },
                    { "支付方式", "PayTypeName" },
                    { "昵称", "UserName" },
                    { "手机号", "CustomerPhone" },
                    { "地址", "Address" },
                    { "优惠前总价", "SumOrginPrice" },
                    { "订单均摊金额", "SumAvgPrice" },
                    { "订单已付款金额", "PayPrice" },
                    { "平台积分", "IntegralValue" },
                    { "平台优惠券", "ProductCoupon" },
                    { "付款状态", "PayStateName" },
                    { "付款时间", "PayDate" },
                    { "快递公司", "DeliveryTypeName" },
                    { "物流单号", "DeliveryNumber" },
                    { "发票类型", "InvoiceTypeName" },
                    { "发票号", "InvoiceNumber" },
                    { "发票抬头", "InvoiceHead" },
                    { "客服备注", "AdminMark" },
                    { "订单备注", "OrderMark" },
                    { "给仓库留言", "ToWareHouseMark" },
                    { "标准价", "OrginPrice" },
                    { "仓库", "WareHouseName" },
                    { "现金支付金额", "PayMoneyPrice" }
                };
                break;

            default:
                break;
            }
            return(columnNames);
        }