Example #1
0
        /// <summary>
        /// 登陆
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <param name="softId">软件ID</param>
        /// <param name="rsaPublicKey">Rsa公钥</param>
        /// <returns>登陆结果</returns>
        public static string login
        (
            string username,
            string password,
            string softId,
            string rsaPublicKey
        )
        {
            string passwordEncrypt = VerifyApiLaunch.RsaEncrypt(password, rsaPublicKey);
            string machineCode     = VerifyApiLaunch.RsaEncrypt(VerifyApiLaunch.machineCode, rsaPublicKey);

            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("username", username);
            data.Add("password", passwordEncrypt);
            data.Add("softId", softId);
            data.Add("code", machineCode);
            data.Add("publicKey", rsaPublicKey);

            string api = VerifyApiLaunch.site + "/account/login";

            string response = OrangeRequest.Post(api).AddData(data).LaunchToString();

            JObject resultJson = (JObject)JsonConvert.DeserializeObject(response);

            int code = (int)resultJson["code"];

            if (code == 100)
            {
                return("登陆成功");
            }

            return((string)resultJson["msg"]);
        }
Example #2
0
        /// <summary>
        /// 取卡密期限
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <param name="softId">软件ID</param>
        /// <param name="startDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        public static void getCardTimeLimit
        (
            string username,
            string password,
            string softId,
            out string startDate,
            out string endDate
        )
        {
            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("username", username);
            data.Add("password", password);
            data.Add("softId", softId);

            string api = VerifyApiLaunch.site + "/card/getCardTimeLimit";

            string response = OrangeRequest.Post(api).AddData(data).LaunchToString();

            JObject resultJson = (JObject)JsonConvert.DeserializeObject(response);

            int code = (int)resultJson["code"];

            if (code == 9)
            {
                startDate = DateOperation.GetDateTime((long)resultJson["data"]["startDate"]);
                endDate   = DateOperation.GetDateTime((long)resultJson["data"]["endDate"]);
            }
            else
            {
                throw (new Exception((string)resultJson["msg"]));
            }
        }
Example #3
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">新密码</param>
        /// <param name="softId">软件ID</param>
        /// <param name="securityCode">安全码</param>
        /// <returns></returns>
        public static string updatePassword
        (
            string username,
            string password,
            string softId,
            string securityCode
        )
        {
            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("username", username);
            data.Add("password", password);
            data.Add("softId", softId);
            data.Add("securityCode", securityCode);

            string api = VerifyApiLaunch.site + "/account/updatePassword";

            string response = OrangeRequest.Post(api).AddData(data).LaunchToString();

            JObject resultJson = (JObject)JsonConvert.DeserializeObject(response);

            int code = (int)resultJson["code"];

            if (code == 105)
            {
                return("修改密码成功");
            }

            return((string)resultJson["msg"]);
        }
Example #4
0
        /// <summary>
        /// 取验证码
        /// </summary>
        /// <param name="rsaPublicKey">Rsa公钥</param>
        /// <returns></returns>
        public static Image getVerificationCode(string rsaPublicKey)
        {
            string api = VerifyApiLaunch.site + "/account/getVerificationCode?publicKey=" + rsaPublicKey;

            Image image = OrangeRequest.Get(api).LaunchToImage();

            return(image);
        }
Example #5
0
        /// <summary>
        /// 获取Rsa公钥
        /// </summary>
        /// <returns>返回公钥</returns>
        public static string getRsaPublicKey()
        {
            string api = VerifyApiLaunch.site + "/account/getPublicKey";

            string response = OrangeRequest.Post(api).LaunchToString();

            JObject resultJson = (JObject)JsonConvert.DeserializeObject(response);

            int code = (int)resultJson["code"];

            if (code == 9)
            {
                return((String)resultJson["data"]);
            }
            else
            {
                throw (new Exception((string)resultJson["msg"]));
            }
        }
Example #6
0
        /// <summary>
        /// 获取软件信息
        /// </summary>
        /// <param name="softId">软件ID</param>
        /// <param name="notice">公告</param>
        /// <param name="name">软件名称</param>
        /// <param name="dosingStrategy">多开策略</param>
        /// <param name="registerStatus">注册状态</param>
        /// <param name="registeCloseMsg">关闭注册公告</param>
        /// <param name="serviceStatus">软件服务状态</param>
        /// <param name="serviceCloseMsg">关闭服务公告</param>
        /// <param name="changeStrategy">是否支持换绑定机器</param>
        public static void getSoftDesc
        (
            string softId,
            out string notice,
            out string name,
            out int dosingStrategy,
            out int registerStatus,
            out string registeCloseMsg,
            out int serviceStatus,
            out string serviceCloseMsg,
            out int changeStrategy
        )
        {
            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("softId", softId);

            string api = VerifyApiLaunch.site + "/soft/getSoftDesc";

            string response = OrangeRequest.Post(api).AddData(data).LaunchToString();

            JObject resultJson = (JObject)JsonConvert.DeserializeObject(response);

            int code = (int)resultJson["code"];

            if (code == 9 || code == 907)
            {
                notice          = (string)resultJson["data"]["notice"];
                name            = (string)resultJson["data"]["name"];
                dosingStrategy  = (int)resultJson["data"]["dosingStrategy"];
                registerStatus  = (int)resultJson["data"]["registerStatus"];
                registeCloseMsg = (string)resultJson["data"]["registeCloseMsg"];
                serviceStatus   = (int)resultJson["data"]["serviceStatus"];
                serviceCloseMsg = (string)resultJson["data"]["serviceCloseMsg"];
                changeStrategy  = (int)resultJson["data"]["changeStrategy"];
            }
            else
            {
                throw (new Exception((string)resultJson["msg"]));
            }
        }
        static async Task Main(string[] args)
        {
            var prKeyPath = "F:\\tmp\\API\\private_key.xml";
            var certPath  = "F:\\tmp\\API\\client.pfx";
            var certPass  = "******";

            var dummyOrangeRequest = new OrangeRequest(prKeyPath, certPath, certPass);

            var dummyCreateCheckRequest = new ReqCreateCheck
            {
                Id      = "66549876216",
                INN     = "5001104058",
                Content = new Content
                {
                    Type       = DocTypeEnum.In,
                    AgentType  = AgentTypeEnum.PayingAgent,
                    CheckClose = new CheckClose
                    {
                        Payments = new[]
                        {
                            new Payment
                            {
                                Amount = 132.35m,
                                //Amount = 1.35m,
                                Type = PaymentTypeEnum.Cash
                            }
                        },
                        TaxationSystem = TaxationSystemEnum.Simplified
                    },
                    Positions = new []
                    {
                        new Position
                        {
                            Price              = 123.45m,
                            Quantity           = 1m,
                            Tax                = VATRateEnum.NONE,
                            Text               = "Булка",
                            PaymentMethodType  = PaymentMethodTypeEnum.Full,
                            PaymentSubjectType = PaymentSubjectTypeEnum.Product
                        },
                        new Position
                        {
                            Price              = 4.45m,
                            Quantity           = 2m,
                            Tax                = VATRateEnum.VAT110,
                            Text               = "Спички",
                            PaymentMethodType  = PaymentMethodTypeEnum.Full,
                            PaymentSubjectType = PaymentSubjectTypeEnum.Product
                        }
                    },
                    CustomerContact = "*****@*****.**"
                }
            };

            var dummyCreateCorrectionCheckRequest = new ReqCreateCorrectionCheck
            {
                Id      = "66549876216",
                INN     = "5001104058",
                Content = new CorrectionContent
                {
                    Type                = DocTypeEnum.In,
                    CashSum             = 2000,
                    TaxationSystem      = TaxationSystemEnum.Common,
                    Tax4Sum             = 2000,
                    Description         = "Тестовая коррекция",
                    CauseDocumentDate   = DateTime.UtcNow.Date,
                    CauseDocumentNumber = "21"
                }
            };
            var res1 = await dummyOrangeRequest.CreateCheckAsync(dummyCreateCheckRequest);

            var res2 = await dummyOrangeRequest.GetCheckStateAsync("5001104058", "12345678990");

            var res3 = await dummyOrangeRequest.CreateCorrectionCheckAsync(dummyCreateCorrectionCheckRequest);

            var res4 = await dummyOrangeRequest.GetCorrectionCheckStateAsync("5001104058", "12345678990");

            Console.ReadKey();
        }