private static SettingSection BuildShootingSection()
        {
            var section = new SettingSection(SystemUtil.GetStringResource("SettingSection_Image"));

            section.Add(new ToggleSetting(
                            new AppSettingData <bool>(SystemUtil.GetStringResource("PostviewTransferSetting"), SystemUtil.GetStringResource("Guide_ReceiveCapturedImage"),
                                                      () => { return(ApplicationSettings.GetInstance().IsPostviewTransferEnabled); },
                                                      enabled => { ApplicationSettings.GetInstance().IsPostviewTransferEnabled = enabled; })));

            section.Add(new ToggleSetting(
                            new AppSettingData <bool>(SystemUtil.GetStringResource("ImmediatePostviewSetting"), SystemUtil.GetStringResource("Guide_ImmediatePostviewSetting"),
                                                      () => { return(ApplicationSettings.GetInstance().ImmediatePostViewEnabled); },
                                                      enabled => { ApplicationSettings.GetInstance().ImmediatePostViewEnabled = enabled; })));

            var limited = (Application.Current as App).IsFunctionLimited;

            var geoGuide = limited ? "TrialMessage" : "AddGeotag_guide";
            AppSettingData <bool> geoSetting = null;

            geoSetting = new AppSettingData <bool>(SystemUtil.GetStringResource("AddGeotag"), SystemUtil.GetStringResource(geoGuide),
                                                   () =>
            {
                if (limited)
                {
                    return(false);
                }
                else
                {
                    return(ApplicationSettings.GetInstance().GeotagEnabled);
                }
            },
                                                   enabled =>
            {
                ApplicationSettings.GetInstance().GeotagEnabled = enabled;
                if (enabled)
                {
                    RequestPermission(geoSetting);
                }
            });
            var geoToggle = new ToggleSetting(geoSetting);

            if (ApplicationSettings.GetInstance().GeotagEnabled)
            {
                RequestPermission(geoSetting);
            }

            if (limited)
            {
                ApplicationSettings.GetInstance().GeotagEnabled = false;
                geoSetting.IsActive = false;
            }
            section.Add(geoToggle);

            section.Add(new ToggleSetting(
                            new AppSettingData <bool>(SystemUtil.GetStringResource("QuickConnectionSetting"), SystemUtil.GetStringResource("Guide_QuickConnection"),
                                                      () => { return(ApplicationSettings.GetInstance().QuickConnectionEnabled); },
                                                      enabled => { ApplicationSettings.GetInstance().QuickConnectionEnabled = enabled; })));

            return(section);
        }
Example #2
0
        public void SourcesCommandTest_AddSource(string source, bool shouldWarn)
        {
            using (SimpleTestPathContext pathContext = new SimpleTestPathContext())
            {
                TestDirectory             workingPath = pathContext.WorkingDirectory;
                SimpleTestSettingsContext settings    = pathContext.Settings;

                // Arrange
                string nugetexe = Util.GetNuGetExePath();
                var    args     = new string[] {
                    "sources",
                    "Add",
                    "-Name",
                    "test_source",
                    "-Source",
                    source,
                    "-ConfigFile",
                    settings.ConfigPath
                };

                // Act
                CommandRunnerResult result = CommandRunner.Run(nugetexe, workingPath, string.Join(" ", args), true);

                // Assert
                Assert.Equal(0, result.ExitCode);
                ISettings      loadedSettings        = Configuration.Settings.LoadDefaultSettings(workingPath, null, null);
                SettingSection packageSourcesSection = loadedSettings.GetSection("packageSources");
                SourceItem     sourceItem            = packageSourcesSection?.GetFirstItemWithAttribute <SourceItem>("key", "test_source");
                Assert.Equal(source, sourceItem.GetValueAsPath());
                Assert.Equal(shouldWarn, result.Output.Contains("WARNING: You are running the 'add source' operation with an 'HTTP' source"));
            }
        }
Example #3
0
        public void Sources_WarnWhenAdding(string source, bool shouldWarn)
        {
            using (SimpleTestPathContext pathContext = new SimpleTestPathContext())
            {
                TestDirectory             workingPath = pathContext.WorkingDirectory;
                SimpleTestSettingsContext settings    = pathContext.Settings;

                // Arrange
                var args = new string[]
                {
                    "nuget",
                    "add",
                    "source",
                    source,
                    "--name",
                    "test_source",
                    "--configfile",
                    settings.ConfigPath
                };

                // Act
                CommandRunnerResult result = _fixture.RunDotnet(workingPath, string.Join(" ", args), ignoreExitCode: true);

                // Assert
                Assert.True(result.Success, result.Output + " " + result.Errors);

                ISettings loadedSettings = Settings.LoadDefaultSettings(root: workingPath, configFileName: null, machineWideSettings: null);

                SettingSection packageSourcesSection = loadedSettings.GetSection("packageSources");
                SourceItem     sourceItem            = packageSourcesSection?.GetFirstItemWithAttribute <SourceItem>("key", "test_source");
                Assert.Equal(source, sourceItem.GetValueAsPath());
                Assert.Equal(shouldWarn, result.Output.Contains("warn : You are running the 'add source' operation with an 'HTTP' source"));
            }
        }
Example #4
0
        private static SettingSection BuildGallerySection()
        {
            var section = new SettingSection(SystemUtil.GetStringResource("SettingSection_ContentsSync"));

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("Setting_PrioritizeOriginalSize"),
                    Guide         = SystemUtil.GetStringResource("Guide_PrioritizeOriginalSize"),
                    StateProvider = () => ApplicationSettings.GetInstance().PrioritizeOriginalSizeContents,
                    StateObserver = enabled => ApplicationSettings.GetInstance().PrioritizeOriginalSizeContents = enabled
                }
            });

            section.Add(new ComboBoxSetting(new AppSettingData <int>()
            {
                Title         = SystemUtil.GetStringResource("ContentTypes"),
                Guide         = SystemUtil.GetStringResource("ContentTypesGuide"),
                StateProvider = () => (int)ApplicationSettings.GetInstance().RemoteContentsSet,
                StateObserver = newValue =>
                {
                    if (newValue != -1)
                    {
                        ApplicationSettings.GetInstance().RemoteContentsSet = (ContentsSet)newValue;
                    }
                },
                Candidates = SettingValueConverter.FromContentsSet(EnumUtil <ContentsSet> .GetValueEnumerable())
            }));

            return(section);
        }
        private static SettingSection BuildGallerySection()
        {
            var section = new SettingSection(SystemUtil.GetStringResource("SettingSection_ContentsSync"));

            section.Add(new ToggleSetting(
                            new AppSettingData <bool>(SystemUtil.GetStringResource("Setting_PrioritizeOriginalSize"), SystemUtil.GetStringResource("Guide_PrioritizeOriginalSize"),
                                                      () => { return(ApplicationSettings.GetInstance().PrioritizeOriginalSizeContents); },
                                                      enabled => { ApplicationSettings.GetInstance().PrioritizeOriginalSizeContents = enabled; })));

            section.Add(new ComboBoxSetting(
                            new AppSettingData <int>(SystemUtil.GetStringResource("ContentTypes"), SystemUtil.GetStringResource("ContentTypesGuide"),
                                                     () => { return((int)ApplicationSettings.GetInstance().RemoteContentsSet); },
                                                     newValue =>
            {
                if (newValue != -1)
                {
                    ApplicationSettings.GetInstance().RemoteContentsSet = (ContentsSet)newValue;
                }
            },
                                                     SettingValueConverter.FromContentsSet(EnumUtil <ContentsSet> .GetValueEnumerable()))));

            section.Add(new ToggleSetting(
                            new AppSettingData <bool>(SystemUtil.GetStringResource("Setting_EnableSaveToOneDrive"), SystemUtil.GetStringResource("Guide_EnableSaveToOneDrive"),
                                                      () => { return(ApplicationSettings.GetInstance().SaveToOneDriveEnabled); },
                                                      enabled => { ApplicationSettings.GetInstance().SaveToOneDriveEnabled = enabled; })));

            return(section);
        }
Example #6
0
        public Tuple <int, int, decimal> GetSystemInfo()
        {
            string  code        = AuthManager.GetCurrentUser().Code;
            var     businessman = businessmanRepository.FindAll(x => x.Code == code).SingleOrDefault();
            decimal smsPrice    = SettingSection.GetInstances().Sms.SmsPrice;

            return(Tuple.Create <int, int, decimal>(businessman.SMS.RemainCount, businessman.SMS.SendCount, smsPrice));
        }
Example #7
0
        public void Sources_WarnWhenUpdatingHttpSource(string updateSource, bool shouldWarn)
        {
            using (TestDirectory configFileDirectory = _fixture.CreateTestDirectory())
            {
                string configFileName = "nuget.config";
                string configFilePath = Path.Combine(configFileDirectory, configFileName);

                var nugetConfig =
                    @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
  <packageSources>
    <add key=""test_source"" value=""http://source.test.initial"" />
  </packageSources>
</configuration>";
                CreateXmlFile(configFilePath, nugetConfig);

                ISettings settings = Settings.LoadDefaultSettings(
                    configFileDirectory,
                    configFileName,
                    null);

                PackageSourceProvider packageSourceProvider = new PackageSourceProvider(settings);
                var sources = packageSourceProvider.LoadPackageSources().ToList();
                Assert.Single(sources);

                PackageSource source = sources.Single();
                Assert.Equal("test_source", source.Name);
                Assert.Equal("http://source.test.initial", source.Source);

                // Arrange
                var args = new string[]
                {
                    "nuget",
                    "update",
                    "source",
                    "test_source",
                    "--source",
                    updateSource,
                    "--configfile",
                    configFilePath
                };

                // Act
                CommandRunnerResult result = _fixture.RunDotnet(configFileDirectory, string.Join(" ", args), ignoreExitCode: true);

                // Assert
                Assert.True(result.Success, result.Output + " " + result.Errors);

                ISettings loadedSettings = Settings.LoadDefaultSettings(root: configFileDirectory, configFileName: null, machineWideSettings: null);

                SettingSection packageSourcesSection = loadedSettings.GetSection("packageSources");
                SourceItem     sourceItem            = packageSourcesSection?.GetFirstItemWithAttribute <SourceItem>("key", "test_source");
                Assert.Equal(updateSource, sourceItem.GetValueAsPath());
                Assert.Equal(shouldWarn, result.Output.Contains("warn : You are running the 'update source' operation with an 'HTTP' source"));
            }
        }
Example #8
0
        private void UpdateAppSettingUserSettings(SettingSection section)
        {
            ClientSettingsSection clientSettingsSection = (ClientSettingsSection)config.GetSection(section.Path);

            foreach (var appSetting in section.Settings)
            {
                var setting = clientSettingsSection.Settings.Get(appSetting.ConfigurationName);
                setting.Value.ValueXml.InnerText = appSetting.Value;
            }
            clientSettingsSection.SectionInformation.ForceSave = true;
        }
Example #9
0
        public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
        {
            string token = string.Empty;

            if (request.Headers.MessageVersion.Envelope == EnvelopeVersion.None)
            {
                token = System.ServiceModel.Web.WebOperationContext.Current.IncomingRequest.Headers["Token"];
            }
            else
            {
                token = GetHeaderValue("Token");
            }

            AuthManager.SaveToken(token);
            CurrentUserInfo user = null;

            if (string.IsNullOrEmpty(token))
            {//控台的认证方式
                var key   = GetHeaderValue("key");
                var suser = GetHeaderValue("user");
                CashbagConfigurationElement setting = SettingSection.GetInstances().Cashbag;
                if (key == "1439e30938174d75a2360e4e3d3c6094" && !string.IsNullOrEmpty(suser))
                {
                    user = new CurrentUserInfo()
                    {
                        CashbagCode = setting.CashbagCode, CashbagKey = setting.CashbagKey, OperatorName = suser, OperatorAccount = suser
                    };
                }
            }
            else
            {
                Logger.WriteLog(LogType.DEBUG, token);
                var result = UserAuthResult <CurrentUserInfo> .Current(token);

                if (result != null)
                {
                    user = result.UserInfo;
                }
            }

            if (user != null)
            {
                AuthManager.SaveUser(user);
            }
            else
            {
                throw new NotAuthException("账户登录超时,请重新登录");
            }
            return(null);
        }
Example #10
0
        public async Task <ActionResult> Basic()
        {
            string userRole     = UsersRoles;
            bool   isSuperAdmin = userRole.ToLowerInvariant().Contains("super admin");

            ViewBag.IsSuperAdmin  = isSuperAdmin;
            ViewBag.IsBasicActive = true;


            List <string> lstBasicKeys = new List <string>
            {
                SettingKeys.AdminEmail
            };

            string json = Newtonsoft.Json.JsonConvert.SerializeObject(lstBasicKeys);

            Dictionary <string, Settings> settings = new Dictionary <string, Settings>();
            SettingManager settingController       = new SettingManager();
            string         settingValue            = await settingController.GetAdminSettings(json);

            await LoadOauth();

            if (!string.IsNullOrEmpty(settingValue))
            {
                settings = Deserialize(settingValue);
            }

            List <SettingSection> lstSections = new List <SettingSection>();

            SettingSection settingSection2 = new SettingSection
            {
                SectionName  = "Emails",
                SettingItems = new List <SettingItem>
                {
                    new SettingItem {
                        SettingKey   = SettingKeys.AdminEmail,
                        SettingLabel = "Admin Email",
                        IsCacheable  = settings[SettingKeys.AdminEmail].IsCacheable,
                        SettingValue = settings[SettingKeys.AdminEmail].Value,
                        InputType    = SettingInputType.TextBox
                    }
                }
            };

            lstSections.Add(settingSection2);


            return(await CommonSetting(lstSections));
        }
        public MainWindow()
        {
            var configuration = new Configuration();
            var fileOperation = new FileOperation();

            _fileNotifier   = new FileNotifier(configuration, fileOperation);
            _settingSection = configuration.SettingSection;

            CultureInfo.CurrentUICulture   =
                CultureInfo.CurrentCulture =
                    new CultureInfo(_settingSection.Culture);
            InitializeComponent();
            InitializeContent();
            _fileNotifier.SendMessage += LogMessage;
        }
Example #12
0
        public string BuySmsByPlatform(int count, decimal smsPrice, string platformCode)
        {
            CurrentUserInfo currentUser = AuthManager.GetCurrentUser();
            string          code        = currentUser.Code;
            var             businessman = businessmanRepository.FindAll(x => x.Code == code).SingleOrDefault();
            var             smsNotify   = SettingSection.GetInstances().Payment.SmsNotify;

            string partnerKey = SettingSection.GetInstances().Cashbag.PartnerKey;
            // decimal smsPrice = SettingSection.GetInstances().Sms.SmsPrice;
            decimal payAmount = Math.Round((count * smsPrice), 2);
            string  payNo     = businessman.BuySms(currentUser.OperatorName, count, EnumPayMethod.Platform, payAmount);

            unitOfWorkRepository.PersistUpdateOf(businessman);
            unitOfWork.Commit();
            return(payMentClientProxy.PaymentByPlatform(currentUser.CashbagCode, currentUser.CashbagKey, payNo, "购买短信", payAmount, platformCode, smsNotify, businessman.Code));
        }
Example #13
0
        public void SourcesCommandTest_UpdateSource(string source, bool shouldWarn)
        {
            using (TestDirectory configFileDirectory = TestDirectory.Create())
            {
                string nugetexe       = Util.GetNuGetExePath();
                string configFileName = "nuget.config";
                string configFilePath = Path.Combine(configFileDirectory, configFileName);

                var nugetConfig = string.Format(
                    @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
  <packageSources>
    <add key=""test_source"" value=""http://source.test.initial"" />
  </packageSources>
</configuration>", source);
                Util.CreateFile(configFileDirectory, configFileName, nugetConfig);

                // Arrange
                var args = new string[] {
                    "sources",
                    "Update",
                    "-Name",
                    "test_source",
                    "-Source",
                    source,
                    "-ConfigFile",
                    configFilePath
                };

                // Act
                CommandRunnerResult result = CommandRunner.Run(
                    nugetexe,
                    configFileDirectory,
                    string.Join(" ", args),
                    true);

                // Assert
                Assert.Equal(0, result.ExitCode);
                ISettings      loadedSettings        = Configuration.Settings.LoadDefaultSettings(configFileDirectory, configFileName, null);
                SettingSection packageSourcesSection = loadedSettings.GetSection("packageSources");
                SourceItem     sourceItem            = packageSourcesSection?.GetFirstItemWithAttribute <SourceItem>("key", "test_source");
                Assert.Equal(source, sourceItem.GetValueAsPath());
                Assert.Equal(shouldWarn, result.Output.Contains("WARNING: You are running the 'update source' operation with an 'HTTP' source"));
            }
        }
Example #14
0
        public string GetValidateCode(string code, string key)
        {
            var ch         = new CashbagHelper(_webUrl + "GetValidateCodeAccount", "GET");
            var dictionary = new Dictionary <string, string>
            {
                { "code", code },
                { "key", key },
                { "currentTime", DateTime.Now.ToString("yyyyMMddHHmmss") },
                { "account", SettingSection.GetInstances().Sms.smsLKAccount },
                { "password", SettingSection.GetInstances().Sms.smsLKPwd }
            };
            var data   = ch.ParamsURLEncode(dictionary);
            var result = ch.GetBackJsonData(data);

            if (result.status == false)
            {
                throw new CashBagException(result.message.ToString());
            }
            return(result.result);
        }
        private static bool Section_DeepEquals(SettingSection section1, SettingSection section2)
        {
            if (section1.Attributes.Count == section2.Attributes.Count &&
                section1.Items.Count == section2.Items.Count)
            {
                var attributesEquals = section1.Attributes.OrderedEquals(section2.Attributes, data => data.Key, StringComparer.OrdinalIgnoreCase);
                var itemsEquals      = true;

                var items1 = section1.Items.ToList();
                var items2 = section2.Items.ToList();

                for (var i = 0; i < items1.Count; i++)
                {
                    itemsEquals &= DeepEquals(items1[i], items2[i]);
                }

                return(itemsEquals && attributesEquals);
            }

            return(false);
        }
Example #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        /// <param name="action"></param>
        /// <param name="loginIp"></param>
        /// <param name="businessmanType">0:采购,1,后台</param>
        /// <returns></returns>
        public UserAuthResult <CurrentUserInfo> Login(LoginParames user, System.Action <string> action)
        {
            var bussinessMan = businessmanRepository.FindAll(p => p.Code.ToUpper() == user.Code.ToUpper()).FirstOrDefault();

            if (bussinessMan == null)
            {
                throw new AuthException("没有找到商户号为" + user.Code + "的商户信息");
            }
            if (user.BusinessmanType == 0 && (bussinessMan is Supplier || bussinessMan is Carrier))
            {
                throw new AuthException("没有找到商户号为" + user.Code + "的商户信息。");
            }
            if (user.BusinessmanType == 1 && bussinessMan is Buyer)
            {
                throw new AuthException("没有找到商户号为" + user.Code + "的商户信息!");
            }
            if (!bussinessMan.IsEnable)
            {
                throw new AuthException("此商户号已经被冻结,请联系管理员");
            }
            var oper = bussinessMan.GetOperatorByPasswordAndAccount(user.Account.Trim(), user.Password);

            if (oper == null)
            {
                throw new AuthException("用户名或密码错误");
            }
            if (oper.OperatorState == Common.Enums.EnumOperatorState.Frozen)
            {
                throw new AuthException("该用户账号已被冻结");
            }
            if (user.BusinessmanType == 1 && oper.IsAdmin == false && oper.Role == null)
            {
                throw new AuthException("该帐号没有权限登录,请联系管理员!");
            }
            var currentUserInfo = new CurrentUserInfo()
            {
                Type            = bussinessMan.GetType().BaseType.Name,
                OperatorAccount = oper.Account,
                Code            = bussinessMan.Code,
                BusinessmanName = bussinessMan.Name,
                CashbagCode     = bussinessMan.CashbagCode,
                CashbagKey      = bussinessMan.CashbagKey,
                OperatorName    = oper.Realname,
                OperatorPhone   = oper.Phone,
                IsAdmin         = oper.IsAdmin,
                SettingInfo     = new SystemSettingInfo()
                {
                    SmsPrice = SettingSection.GetInstances().Sms.SmsPrice
                }
            };

            if (bussinessMan is Supplier)
            {
                currentUserInfo.CarrierCode = (bussinessMan as Supplier).CarrierCode;
            }
            if (bussinessMan is Buyer)
            {
                currentUserInfo.ContactName = (bussinessMan as Buyer).ContactName;
                currentUserInfo.Phone       = (bussinessMan as Buyer).Phone;
                currentUserInfo.CarrierCode = (bussinessMan as Buyer).CarrierCode;
            }
            if (bussinessMan is Carrier)
            {
                currentUserInfo.ContactName = oper.Realname;
            }
            LoginLog loginLog = new LoginLog
            {
                Code      = bussinessMan.Code,
                Account   = oper.Account,
                LoginIP   = user.LoginIP,
                LoginDate = System.DateTime.Now
            };
            var ur = new UserAuthResult <CurrentUserInfo>(currentUserInfo);

            ur.Save(p =>
            {
                action(currentUserInfo.GetIdentity());
            });
            //引发领域事件
            DomainEvents.Raise(new UserLoginEvent()
            {
                User = ur.UserInfo, LoginLog = loginLog
            });

            return(ur);
        }
Example #17
0
        public async Task <ActionResult> Advanced()
        {
            string userRole     = UsersRoles;
            bool   isSuperAdmin = userRole.ToLowerInvariant().Contains("super admin");

            ViewBag.IsSuperAdmin  = isSuperAdmin;
            ViewBag.IsBasicActive = false;

            List <string> lstAdvancedKeys = new List <string>
            {
                SettingKeys.OptimizeAssets,

                SettingKeys.SMTPServer,
                SettingKeys.SMTPUserName,
                SettingKeys.SMTPPassword,
                SettingKeys.SMTPSSlEnabled,

                SettingKeys.ClientID,
                SettingKeys.ClientSecretKey,

                SettingKeys.EncryptionKey,
                SettingKeys.GUID,
                SettingKeys.ServerCookieExpiration,


                SettingKeys.IdentityUrl,
                SettingKeys.LoggerApiGatewayUrl,
                SettingKeys.APKBuilderHostURL,
                SettingKeys.OnlineStore,
                SettingKeys.DigiSphereApi
            };



            string json = Newtonsoft.Json.JsonConvert.SerializeObject(lstAdvancedKeys);

            Dictionary <string, Settings> settings = new Dictionary <string, Settings>();
            SettingManager settingController       = new SettingManager();
            string         settingValue            = await settingController.GetAdminSettings(json);

            if (!string.IsNullOrEmpty(settingValue))
            {
                settings = Deserialize(settingValue);
            }

            List <SettingSection> lstSections = new List <SettingSection>();

            //SettingSection settingSection1 = new SettingSection
            //{
            //    SectionName = "FTP",
            //    SettingItems = new List<SettingItem>
            //    {
            //        new SettingItem{
            //            SettingKey=SettingKeys.FtpServer,
            //            SettingLabel="Server",
            //            IsCacheable=settings[SettingKeys.FtpServer].IsCacheable,
            //            SettingValue=settings[SettingKeys.FtpServer].Value,
            //            InputType=SettingInputType.TextBox
            //        },
            //        new SettingItem
            //        {
            //            SettingKey=SettingKeys.FtpPort,
            //            SettingLabel="Port",
            //            IsCacheable=settings[SettingKeys.FtpPort].IsCacheable,
            //            SettingValue=settings[SettingKeys.FtpPort].Value,
            //            InputType=SettingInputType.TextBox
            //        },
            //         new SettingItem{
            //            SettingKey=SettingKeys.FtpUserName,
            //            SettingLabel="Username",
            //            IsCacheable=settings[SettingKeys.FtpUserName].IsCacheable,
            //            SettingValue=settings[SettingKeys.FtpUserName].Value,
            //            InputType=SettingInputType.TextBox
            //        },
            //        new SettingItem
            //        {
            //            SettingKey=SettingKeys.FtpPassword,
            //            SettingLabel="Password",
            //            IsCacheable=settings[SettingKeys.FtpPassword].IsCacheable,
            //            SettingValue=settings[SettingKeys.FtpPassword].Value,
            //            InputType=SettingInputType.TextBox
            //        }
            //    }

            //};
            //lstSections.Add(settingSection1);

            SettingSection settingSection1 = new SettingSection
            {
                SectionName  = "Optimize Assets",
                SettingItems = new List <SettingItem>
                {
                    new SettingItem {
                        SettingKey   = SettingKeys.OptimizeAssets,
                        SettingLabel = "Optimize Assets",
                        IsCacheable  = settings[SettingKeys.OptimizeAssets].IsCacheable,
                        SettingValue = settings[SettingKeys.OptimizeAssets].Value,
                        InputType    = SettingInputType.CheckBox
                    }
                }
            };

            lstSections.Add(settingSection1);
            SettingSection settingSection2 = new SettingSection
            {
                SectionName   = "SMTP",
                CustomButtons = @"<div class='sfButtonwrapper'>
                                    <button type='button' class='btn primary btnSaveSettings'>Save</button>
								    <button type='button' class='btn primary' id='btnSaveAndTestSMTP'>Save & Test</button>
                                </div>
                                ",
                SettingItems  = new List <SettingItem>
                {
                    new SettingItem {
                        SettingKey   = SettingKeys.SMTPServer,
                        SettingLabel = "Server",
                        IsCacheable  = settings[SettingKeys.SMTPServer].IsCacheable,
                        SettingValue = settings[SettingKeys.SMTPServer].Value,
                        InputType    = SettingInputType.TextBox
                    },
                    new SettingItem {
                        SettingKey   = SettingKeys.SMTPUserName,
                        SettingLabel = "Username",
                        IsCacheable  = settings[SettingKeys.SMTPUserName].IsCacheable,
                        SettingValue = settings[SettingKeys.SMTPUserName].Value,
                        InputType    = SettingInputType.TextBox
                    },
                    new SettingItem
                    {
                        SettingKey   = SettingKeys.SMTPPassword,
                        SettingLabel = "Password",
                        IsCacheable  = settings[SettingKeys.SMTPPassword].IsCacheable,
                        SettingValue = settings[SettingKeys.SMTPPassword].Value,
                        InputType    = SettingInputType.TextBox
                    },
                    new SettingItem
                    {
                        SettingKey   = SettingKeys.SMTPSSlEnabled,
                        SettingLabel = "Is SSL Enabled?",
                        IsCacheable  = settings[SettingKeys.SMTPSSlEnabled].IsCacheable,
                        SettingValue = settings[SettingKeys.SMTPSSlEnabled].Value,
                        InputType    = SettingInputType.CheckBox
                    }
                }
            };

            lstSections.Add(settingSection2);


            SettingSection settingSection3 = new SettingSection
            {
                SectionName  = "Client",
                SettingItems = new List <SettingItem>
                {
                    new SettingItem {
                        SettingKey   = SettingKeys.ClientID,
                        SettingLabel = "ClientID",
                        IsCacheable  = settings[SettingKeys.ClientID].IsCacheable,
                        SettingValue = settings[SettingKeys.ClientID].Value,
                        InputType    = SettingInputType.TextBox
                    },
                    new SettingItem
                    {
                        SettingKey   = SettingKeys.ClientSecretKey,
                        SettingLabel = "Client Secret Key",
                        IsCacheable  = settings[SettingKeys.ClientSecretKey].IsCacheable,
                        SettingValue = settings[SettingKeys.ClientSecretKey].Value,
                        InputType    = SettingInputType.TextBox
                    }
                }
            };

            lstSections.Add(settingSection3);

            SettingSection settingSection4 = new SettingSection
            {
                SectionName  = "Security",
                SettingItems = new List <SettingItem>
                {
                    new SettingItem {
                        SettingKey   = SettingKeys.EncryptionKey,
                        SettingLabel = "Encryption Key",
                        IsCacheable  = settings[SettingKeys.EncryptionKey].IsCacheable,
                        SettingValue = settings[SettingKeys.EncryptionKey].Value,
                        InputType    = SettingInputType.TextBox
                    },
                    new SettingItem
                    {
                        SettingKey   = SettingKeys.GUID,
                        SettingLabel = "GUID",
                        IsCacheable  = settings[SettingKeys.GUID].IsCacheable,
                        SettingValue = settings[SettingKeys.GUID].Value,
                        InputType    = SettingInputType.TextBox
                    }
                    ,
                    new SettingItem
                    {
                        SettingKey   = SettingKeys.ServerCookieExpiration,
                        SettingLabel = "Server Cookie Expiration",
                        IsCacheable  = settings[SettingKeys.ServerCookieExpiration].IsCacheable,
                        SettingValue = settings[SettingKeys.ServerCookieExpiration].Value,
                        InputType    = SettingInputType.TextBox
                    }
                }
            };

            lstSections.Add(settingSection4);

            SettingSection settingSection5 = new SettingSection
            {
                SectionName  = "API",
                SettingItems = new List <SettingItem>
                {
                    new SettingItem {
                        SettingKey   = SettingKeys.IdentityUrl,
                        SettingLabel = "Identity URL",
                        IsCacheable  = settings[SettingKeys.IdentityUrl].IsCacheable,
                        SettingValue = settings[SettingKeys.IdentityUrl].Value,
                        InputType    = SettingInputType.TextBox
                    },
                    new SettingItem
                    {
                        SettingKey   = SettingKeys.LoggerApiGatewayUrl,
                        SettingLabel = "Logger Gateway URL",
                        IsCacheable  = settings[SettingKeys.LoggerApiGatewayUrl].IsCacheable,
                        SettingValue = settings[SettingKeys.LoggerApiGatewayUrl].Value,
                        InputType    = SettingInputType.TextBox
                    }
                    ,
                    new SettingItem
                    {
                        SettingKey   = SettingKeys.APKBuilderHostURL,
                        SettingLabel = "APK Builder Host URL",
                        IsCacheable  = settings[SettingKeys.APKBuilderHostURL].IsCacheable,
                        SettingValue = settings[SettingKeys.APKBuilderHostURL].Value,
                        InputType    = SettingInputType.TextBox
                    }
                    ,
                    new SettingItem
                    {
                        SettingKey   = SettingKeys.OnlineStore,
                        SettingLabel = "Online Store",
                        IsCacheable  = settings[SettingKeys.OnlineStore].IsCacheable,
                        SettingValue = settings[SettingKeys.OnlineStore].Value,
                        InputType    = SettingInputType.TextBox
                    }
                    ,
                    new SettingItem
                    {
                        SettingKey   = SettingKeys.DigiSphereApi,
                        SettingLabel = "Digi Sphere API",
                        IsCacheable  = settings[SettingKeys.DigiSphereApi].IsCacheable,
                        SettingValue = settings[SettingKeys.DigiSphereApi].Value,
                        InputType    = SettingInputType.TextBox
                    }
                }
            };

            lstSections.Add(settingSection5);

            return(await CommonSetting(lstSections));
        }
        private IObservable <IImmutableList <SettingSection> > settingsSections()
        {
            var sections = new List <IObservable <SettingSection> >();

            var profileSection = Observable.CombineLatest(ViewModel.Name, ViewModel.Email, ViewModel.WorkspaceName,
                                                          (name, email, workspace)
                                                          => new SettingSection(Resources.YourProfile, new ISettingRow[]
            {
                new InfoRow(Resources.Name, name),
                new InfoRow(Resources.EmailAddress, email),
                new NavigationRow(Resources.Workspace, workspace, ViewModel.PickDefaultWorkspace)
            }));

            sections.Add(profileSection);

            var dateTimeSection = Observable.CombineLatest(
                ViewModel.DateFormat,
                ViewModel.UseTwentyFourHourFormat,
                ViewModel.DurationFormat,
                ViewModel.BeginningOfWeek,
                ViewModel.IsGroupingTimeEntries,
                (dateFormat, useTwentyFourHourClock, durationFormat, firstDayOfWeek, groupTEs)
                => new SettingSection(Resources.DateAndTime, new ISettingRow[]
            {
                new NavigationRow(Resources.DateFormat, dateFormat, ViewModel.SelectDateFormat),
                new ToggleRow(Resources.Use24HourClock, useTwentyFourHourClock,
                              ViewModel.ToggleTwentyFourHourSettings),
                new NavigationRow(Resources.DurationFormat, durationFormat, ViewModel.SelectDurationFormat),
                new NavigationRow(Resources.FirstDayOfTheWeek, firstDayOfWeek, ViewModel.SelectBeginningOfWeek),
                new ToggleRow(Resources.GroupTimeEntries, groupTEs, ViewModel.ToggleTimeEntriesGrouping)
            }));

            sections.Add(dateTimeSection);

            var timerDefaultsSection = Observable.CombineLatest(ViewModel.IsManualModeEnabled, ViewModel.SwipeActionsEnabled,
                                                                (isManualModeEnabled, areSwipeActionsEnabled)
                                                                => new SettingSection(Resources.TimerDefaults, new ISettingRow[]
            {
                new ToggleRow(Resources.SwipeActions, areSwipeActionsEnabled, ViewModel.ToggleSwipeActions),
                new ToggleRow(Resources.ManualMode, isManualModeEnabled, ViewModel.ToggleManualMode),
                new AnnotationRow(Resources.ManualModeDescription)
            }));

            sections.Add(timerDefaultsSection);

            if (ViewModel.CalendarSettingsEnabled)
            {
                var calendarSection = new SettingSection(Resources.Calendar, new ISettingRow[]
                {
                    new NavigationRow(Resources.CalendarSettingsTitle, ViewModel.OpenCalendarSettings),
                    new NavigationRow(Resources.SmartReminders, ViewModel.OpenNotificationSettings),
                });

                sections.Add(Observable.Return(calendarSection));
            }

            if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
            {
                var siriSection = new SettingSection(Resources.Siri, new ISettingRow[]
                {
                    new NavigationRow(Resources.SiriShortcuts, ViewModel.OpenSiriShortcuts),
                    new NavigationRow(Resources.SiriWorkflows, ViewModel.OpenSiriWorkflows),
                });

                sections.Add(Observable.Return(siriSection));
            }

            var generalSection = Observable.Return(
                new SettingSection(Resources.General, new ISettingRow[]
            {
                new NavigationRow(Resources.SubmitFeedback, ViewModel.SubmitFeedback),
                new NavigationRow(Resources.About, ViewModel.Version, ViewModel.OpenAboutView),
                new NavigationRow(Resources.Help, ViewModel.OpenHelpView)
            }));

            sections.Add(generalSection);

            var syncStatusObservable = Observable.CombineLatest(
                ViewModel.IsSynced,
                ViewModel.IsRunningSync,
                ViewModel.LoggingOut.SelectValue(true).StartWith(false),
                (synced, syncing, loggingOut) =>
            {
                if (loggingOut)
                {
                    return(SyncStatus.LoggingOut);
                }
                return(syncing ? SyncStatus.Syncing : SyncStatus.Synced);
            });

            var footerSection = syncStatusObservable.Select(syncStatus
                                                            => new SettingSection("", new ISettingRow[]
            {
                new CustomRow <SyncStatus>(syncStatus),
                new ButtonRow(Resources.SettingsDialogButtonSignOut, ViewModel.TryLogout)
            }));

            sections.Add(footerSection);

            return(sections.CombineLatest().Select(list => list.ToImmutableList()));
        }
        /// <summary>
        /// 分销商购买保险
        /// </summary>
        /// <param name="buyCount"></param>
        /// <param name="pwd"></param>
        /// <param name="businessmanCode"></param>
        /// <param name="businessmanName"></param>
        /// <param name="carrierCode"></param>
        /// <param name="payUser"></param>
        public void PurchaseInsuranceFromCarrier(int buyCount, string pwd, EnumPayMethod payMethod, string businessmanCode, string businessmanName, string carrierCode, string operatorCode, string operatorName, CurrentUserInfo payUser, string remark = "")
        {
            var carrier = this._businessmanRepository.FindAll(p => p.Code == carrierCode && p is Carrier).OfType <Carrier>().FirstOrDefault();
            //获取当前运营商保险配置
            var carrierCfg = this._iInsuranceConfigRepository.FindAll(p => p.BusinessmanCode == carrierCode).FirstOrDefault();
            //获取分销商保险配置
            var buyerCfg = this._iInsuranceConfigRepository.FindAll(p => p.BusinessmanCode == businessmanCode).FirstOrDefault();

            if (carrierCfg == null || !carrierCfg.IsOpen)
            {
                throw new CustomException(11114, "运营商保险功能未开启");
            }
            if (buyCount > carrierCfg.LeaveCount)
            {
                string type = payUser == null ? "赠送" : "购买";
                throw new CustomException(11115, "最多仅可" + type + carrierCfg.LeaveCount + "份保险。");
            }
            //单价
            decimal singlePrice = payUser == null ? 0 : carrierCfg.SinglePrice;

            //运营商购买记录
            var logBuiler = AggregationFactory.CreateBuiler <InsurancePurchaseByBussinessmanBuilder>();
            var log       = logBuiler.CreateInsurancePurchaseByBussinessman();

            log.PayNo            = log.GetPayNo();
            log.BeforeLeaveCount = buyerCfg == null ? 0 : buyerCfg.LeaveCount;                                           //购买前剩余
            log.AfterLeaveCount  = log.BeforeLeaveCount + buyCount;                                                      //购买后剩余
            log.DepositCount     = buyCount;                                                                             //购买数量
            log.TotalPrice       = Math.Round((singlePrice * buyCount), 2);                                              //总价
            log.SinglePrice      = singlePrice;                                                                          //单价
            log.BusinessmanCode  = businessmanCode;                                                                      //商户号
            log.BusinessmanName  = businessmanName;                                                                      //商户名称
            log.PayWay           = payMethod;                                                                            //支付类别
            log.RecordType       = payUser == null ? EnumInsurancePurchaseType.Offer : EnumInsurancePurchaseType.Normal; //记录类别
            log.CarrierCode      = carrierCode;
            log.CarrierName      = carrier.Name;
            log.OperatorAccount  = operatorCode;
            log.OperatorName     = operatorName;
            log.Remark           = remark;
            log.PayFee           = Math.Round(log.TotalPrice * SystemConsoSwitch.Rate, 2);

            #region 支付

            DataBill databill = new DataBill();
            CashbagConfigurationElement setting = SettingSection.GetInstances().Cashbag;
            string  moneyDispatch = "";
            decimal infMoney      = databill.Round(log.TotalPrice * carrier.Rate, 2);
            //支出配置,分销商,支出保险全额
            //moneyDispatch += currentUser.CashbagCode + "^" + insuranceOrder.PayMoney + "^" + EnumOperationType.Insurance.ToEnumDesc();
            //收入配置
            moneyDispatch += "|" + carrier.CashbagCode + "^" + log.TotalPrice + "^" + EnumOperationType.InsuranceReceivables.ToEnumDesc();
            //保险手续费支出
            moneyDispatch += "|" + carrier.CashbagCode + "^" + (-infMoney) + "^" + EnumOperationType.InsuranceServer.ToEnumDesc();
            //手续费收入配置
            moneyDispatch += "|" + setting.CashbagCode + "^" + infMoney + "^" + EnumOperationType.InsuranceServer.ToEnumDesc();

            var payResult = string.Empty;

            if (payUser != null)
            {
                if (_iPayMentClientProxy == null)
                {
                    _iPayMentClientProxy = new CashbagPaymentClientProxy();
                }
                switch (log.PayWay)
                {
                //现金账户
                case EnumPayMethod.Account:
                    //    payResult = _iPayMentClientProxy.PaymentByCashAccount(payUser.CashbagCode, payUser.CashbagKey,
                    //log.PayNo, "购买保险", log.TotalPrice, pwd, moneyDispatch);
                    var resultc = _iPayMentClientProxy.PaymentByCashAccount(payUser.CashbagCode, payUser.CashbagKey, log.PayNo, "购买保险", log.TotalPrice, pwd, moneyDispatch);
                    if (resultc.Item1)
                    {
                        //该订单已经被在线支付时写入日志
                        Logger.WriteLog(LogType.INFO, "订单已经支付,交易号为" + resultc.Item2 + "支付方式为" + resultc.Item3);
                        throw new CustomException(0001, "订单已经支付,交易号为" + resultc.Item2 + "支付方式为" + resultc.Item3);
                    }
                    payResult = resultc.Item2;
                    break;

                //信用账户
                case EnumPayMethod.Credit:
                    var result = _iPayMentClientProxy.PaymentByCreditAccount(payUser.CashbagCode, payUser.CashbagKey, log.PayNo, "购买保险", log.TotalPrice, pwd, moneyDispatch);
                    if (result.Item1)
                    {
                        //该订单已经被在线支付时写入日志
                        Logger.WriteLog(LogType.INFO, "订单已经支付,交易号为" + result.Item2 + "支付方式为" + result.Item3);
                        throw new CustomException(0001, "订单已经支付,交易号为" + result.Item2 + "支付方式为" + result.Item3);
                    }
                    payResult = result.Item2;
                    break;
                }
            }
            #endregion

            //如果存在交易号,即支付成功
            if (!string.IsNullOrEmpty(payResult))
            {
                log.OutTradeNo = payResult;                 //设置交易号
                log.BuyState   = EnumInsurancePayStatus.OK; //设置交易状态
                //设置运营商剩余数量
                carrierCfg.LeaveCount -= buyCount;
                this.unitOfWorkRepository.PersistUpdateOf(carrierCfg);
                //设置分销商剩余数量
                if (buyerCfg != null)
                {
                    buyerCfg.LeaveCount = log.AfterLeaveCount;
                    this.unitOfWorkRepository.PersistUpdateOf(buyerCfg);
                }
                else
                {
                    var builder = AggregationFactory.CreateBuiler <InsuranceConfigBuilder>();
                    var m       = builder.CreateInsuranceConfig();
                    m.BusinessmanCode = businessmanCode;
                    m.BusinessmanName = businessmanName;
                    m.IsOpen          = true;
                    m.SinglePrice     = carrierCfg.SinglePrice;
                    m.LeaveCount      = buyCount;
                    m.ConfigType      = EnumInsuranceConfigType.Buyer;
                    this.unitOfWorkRepository.PersistCreationOf(m);
                }
            }
            else if (payUser == null)
            {
                log.BuyState = EnumInsurancePayStatus.Offer;
                //设置运营商剩余数量
                carrierCfg.LeaveCount -= buyCount;
                this.unitOfWorkRepository.PersistUpdateOf(carrierCfg);
                //设置分销商剩余数量
                if (buyerCfg != null)
                {
                    buyerCfg.LeaveCount = log.AfterLeaveCount;
                    this.unitOfWorkRepository.PersistUpdateOf(buyerCfg);
                }
                else
                {
                    var builder = AggregationFactory.CreateBuiler <InsuranceConfigBuilder>();
                    var m       = builder.CreateInsuranceConfig();
                    m.BusinessmanCode = businessmanCode;
                    m.BusinessmanName = businessmanName;
                    m.IsOpen          = true;
                    m.SinglePrice     = carrierCfg.SinglePrice;
                    m.LeaveCount      = buyCount;
                    m.ConfigType      = EnumInsuranceConfigType.Buyer;
                    this.unitOfWorkRepository.PersistCreationOf(m);
                }
            }
            //否则交易失败
            else
            {
                log.BuyState = EnumInsurancePayStatus.NoPay;
            }

            log.BuyTime = DateTime.Now;
            this.unitOfWorkRepository.PersistCreationOf(log);
        }
Example #20
0
        private static SettingSection BuildDisplaySection()
        {
            var section = new SettingSection(SystemUtil.GetStringResource("SettingSection_Display"));

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("DisplayTakeImageButtonSetting"),
                    Guide         = SystemUtil.GetStringResource("Guide_DisplayTakeImageButtonSetting"),
                    StateProvider = () => ApplicationSettings.GetInstance().IsShootButtonDisplayed,
                    StateObserver = enabled => ApplicationSettings.GetInstance().IsShootButtonDisplayed = enabled
                }
            });

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("DisplayHistogram"),
                    Guide         = SystemUtil.GetStringResource("Guide_Histogram"),
                    StateProvider = () => ApplicationSettings.GetInstance().IsHistogramDisplayed,
                    StateObserver = enabled => ApplicationSettings.GetInstance().IsHistogramDisplayed = enabled
                }
            });

            var FocusFrameSetting = new AppSettingData <bool>()
            {
                Title         = SystemUtil.GetStringResource("FocusFrameDisplay"),
                Guide         = SystemUtil.GetStringResource("Guide_FocusFrameDisplay"),
                StateProvider = () => ApplicationSettings.GetInstance().RequestFocusFrameInfo,
                StateObserver = enabled =>
                {
                    ApplicationSettings.GetInstance().RequestFocusFrameInfo = enabled;
                    // todo: support to show focus frames
                    //await SetupFocusFrame(enabled);
                    //if (!enabled) { _FocusFrameSurface.ClearFrames(); }
                }
            };

            section.Add(new ToggleSetting {
                SettingData = FocusFrameSetting
            });

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("LiveviewRotation"),
                    Guide         = SystemUtil.GetStringResource("LiveviewRotation_guide"),
                    StateProvider = () => ApplicationSettings.GetInstance().LiveviewRotationEnabled,
                    StateObserver = enabled =>
                    {
                        ApplicationSettings.GetInstance().LiveviewRotationEnabled = enabled;
                        // todo: support to rotate liveview image
                        //if (enabled && target != null && target.Status != null)
                        //{
                        //    RotateLiveviewImage(target.Status.LiveviewOrientationAsDouble);
                        //}
                        //else
                        //{
                        //    RotateLiveviewImage(0);
                        //}
                    }
                }
            });

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("FramingGrids"),
                    Guide         = SystemUtil.GetStringResource("Guide_FramingGrids"),
                    StateProvider = () => ApplicationSettings.GetInstance().FramingGridEnabled,
                    StateObserver = enabled =>
                    {
                        ApplicationSettings.GetInstance().FramingGridEnabled = enabled;
                        // screen_view_data.FramingGridDisplayed = enabled;
                    }
                }
            });

            var gridTypePanel = new ComboBoxSetting(new AppSettingData <int>()
            {
                Title         = SystemUtil.GetStringResource("AssistPattern"),
                StateProvider = () => (int)ApplicationSettings.GetInstance().GridType - 1,
                StateObserver = setting =>
                {
                    if (setting < 0)
                    {
                        return;
                    }
                    ApplicationSettings.GetInstance().GridType = (FramingGridTypes)(setting + 1);
                },
                Candidates = SettingValueConverter.FromFramingGrid(EnumUtil <FramingGridTypes> .GetValueEnumerable())
            });

            gridTypePanel.SetBinding(VisibilityProperty, new Binding
            {
                Source    = ApplicationSettings.GetInstance(),
                Path      = new PropertyPath(nameof(ApplicationSettings.FramingGridEnabled)),
                Mode      = BindingMode.OneWay,
                Converter = new BoolToVisibilityConverter(),
            });
            section.Add(gridTypePanel);

            var gridColorPanel = new ComboBoxSetting(new AppSettingData <int>()
            {
                Title         = SystemUtil.GetStringResource("FramingGridColor"),
                StateProvider = () => (int)ApplicationSettings.GetInstance().GridColor,
                StateObserver = setting =>
                {
                    if (setting < 0)
                    {
                        return;
                    }
                    ApplicationSettings.GetInstance().GridColor = (FramingGridColors)setting;
                },
                Candidates = SettingValueConverter.FromFramingGridColor(EnumUtil <FramingGridColors> .GetValueEnumerable())
            });

            gridColorPanel.SetBinding(VisibilityProperty, new Binding
            {
                Source    = ApplicationSettings.GetInstance(),
                Path      = new PropertyPath(nameof(ApplicationSettings.FramingGridEnabled)),
                Mode      = BindingMode.OneWay,
                Converter = new BoolToVisibilityConverter(),
            });
            section.Add(gridColorPanel);

            var fibonacciOriginPanel = new ComboBoxSetting(new AppSettingData <int>()
            {
                Title         = SystemUtil.GetStringResource("FibonacciSpiralOrigin"),
                StateProvider = () => (int)ApplicationSettings.GetInstance().FibonacciLineOrigin,
                StateObserver = setting =>
                {
                    if (setting < 0)
                    {
                        return;
                    }
                    ApplicationSettings.GetInstance().FibonacciLineOrigin = (FibonacciLineOrigins)setting;
                },
                Candidates = SettingValueConverter.FromFibonacciLineOrigin(EnumUtil <FibonacciLineOrigins> .GetValueEnumerable())
            });

            fibonacciOriginPanel.SetBinding(VisibilityProperty, new Binding
            {
                Source    = ApplicationSettings.GetInstance(),
                Path      = new PropertyPath(nameof(ApplicationSettings.IsFibonacciSpiralEnabled)),
                Mode      = BindingMode.OneWay,
                Converter = new BoolToVisibilityConverter(),
            });
            section.Add(fibonacciOriginPanel);

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("ForcePhoneView"),
                    Guide         = SystemUtil.GetStringResource("ForcePhoneView_Guide"),
                    StateProvider = () => ApplicationSettings.GetInstance().ForcePhoneView,
                    StateObserver = enabled => ApplicationSettings.GetInstance().ForcePhoneView = enabled
                }
            });

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("ShowKeyCheatSheet"),
                    Guide         = SystemUtil.GetStringResource("ShowKeyCheatSheet_Guide"),
                    StateProvider = () => ApplicationSettings.GetInstance().ShowKeyCheatSheet,
                    StateObserver = enabled => ApplicationSettings.GetInstance().ShowKeyCheatSheet = enabled
                }
            });

            return(section);
        }
Example #21
0
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        static void Main()
        {
            #region MyCode

            //Stopwatch watch = new Stopwatch();
            //watch.Start();

            Func <Type[]> funcs = new Func <Type[]>(() =>
            {
                Type[] types =
                {
                    typeof(DateTimeService),
                    typeof(LoginService),
                    typeof(PublisherService),
                    typeof(BusinessmanService),
                    typeof(OrderService),
                    typeof(PlatformRefundOrderService),
                    typeof(AccountService),
                    typeof(FundService),
                    typeof(FinancialService),
                    typeof(RiskControlService),
                    typeof(TPosService),
                    typeof(FlightDestineService),
                    typeof(TravelPaperService),
                    typeof(PlatformCfgService),
                    typeof(DeductionGroupService),
                    typeof(BehaviorStatService),
                    typeof(PidService),
                    typeof(FrePasserService),
                    typeof(ConsoLocalPolicyService),
                    typeof(InsuranceService),
                    typeof(NoticeService),
                    typeof(MemoryService),
                    typeof(MyMessageService),
                    typeof(PlatformPointGroupService),
                    typeof(OperationLogService)
                };           // 这里耗时最多。
                return(types);
            });

            IAsyncResult result = funcs.BeginInvoke(new AsyncCallback(Callback), funcs);
            BootStrapper.Boot(); // 耗时!


            while (true)
            {
                if (isGoOn)
                {
                    var        ser    = SettingSection.GetInstances().HttpServer;
                    HttpServer server = new HttpServer(ser.Host, ser.Port);
                    server.Start();
                    Console.WriteLine("Web服务启动成功");
                    //1106
                    //JoveZhao.Framework.DDD.Events.DomainEvents.Raise(new BPiaoBao.DomesticTicket.Domain.Models.RefundEvent.RefundTicketEvent() { SaleOrderId = 3797 });
                    while (true)
                    {
                        Console.WriteLine("请输入命令数字:");
                        EnumMessageCommand command = (EnumMessageCommand)int.Parse(Console.ReadLine());
                        Console.WriteLine("请输入商户号:");
                        string code = Console.ReadLine();
                        Console.WriteLine("请输入发送内容");
                        string content = Console.ReadLine();
                        WebMessageManager.GetInstance().Send(command, code, content);
                        MessagePushManager.SendMsgByBuyerCodes(new string[] { code }, (Common.Enums.EnumPushCommands)(command), content, true);
                        Console.WriteLine("消息已发送");
                    }
                }
            }

            #endregion



            #region OldCode
            //ServiceBase[] ServicesToRun;
            //ServicesToRun = new ServiceBase[]
            //{
            //    new Service1()
            //};
            //ServiceBase.Run(ServicesToRun);

            //Stopwatch watch = new Stopwatch();
            //watch.Start();
            //BootStrapper.Boot();
            //Type[] types = {
            //                  typeof(DateTimeService),
            //                  typeof(LoginService),
            //                  typeof(PublisherService),
            //                  typeof(BusinessmanService),
            //                  typeof(OrderService),
            //                  typeof(PlatformRefundOrderService),
            //                  typeof(AccountService),
            //                  typeof(FundService),
            //                  typeof(FinancialService),
            //                  typeof(RiskControlService),
            //                  typeof(TPosService),
            //                  typeof(FlightDestineService),
            //                  typeof(TravelPaperService),
            //                  typeof(PlatformCfgService),
            //                  typeof(DeductionGroupService),
            //                  typeof(BehaviorStatService),
            //                  typeof(PidService),
            //                  typeof(FrePasserService),
            //                  typeof(ConsoLocalPolicyService),
            //                  typeof(InsuranceService),
            //                  typeof(NoticeService)
            //              };
            //watch.Stop();
            //var c = watch.ElapsedMilliseconds;  // 反射耗时:6486(ms)  = 6.486(s)

            //foreach (var t in types)
            //{
            //    ServiceHost host = new ServiceHost(t);
            //    host.Opened += (p, q) =>
            //    {
            //        Console.WriteLine(t.Name + "启动成功");
            //    };
            //    host.Open();
            //}


            //AutoIssueManage.Start();
            //Console.WriteLine("自动出票服务启动");
            //DomesticService domesticService = ObjectFactory.GetInstance<DomesticService>();
            //domesticService.AutoIssue("04654475181900151211");



            //while (true)
            //{
            //    Console.WriteLine("清输入命令[数字]:");
            //    string inputCommand = Console.ReadLine();
            //    Console.WriteLine("输入发送内容:");
            //    string inputContent = Console.ReadLine();
            //    Console.WriteLine("请输入发送商户号");
            //    string code = Console.ReadLine();
            //    MessagePushManager.SendMsgByBuyerCodes(new string[] { code }, (Common.Enums.EnumPushCommands)(inputCommand.ToInt
            //        ()), inputContent, true);
            //    Console.WriteLine("消息已发送");
            //}

            //while (true)
            //{
            //    Console.WriteLine("请输入Token:");
            //    string token = Console.ReadLine();
            //    MemAuthInfoStroage mi = new MemAuthInfoStroage();
            //    var u = mi.GetUserByToken(token);
            //    Console.WriteLine(u.ToJson());
            //}

            #endregion
        }
Example #22
0
        private static SettingSection BuildShootingSection()
        {
            var section = new SettingSection(SystemUtil.GetStringResource("SettingSection_Image"));

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("PostviewTransferSetting"),
                    Guide         = SystemUtil.GetStringResource("Guide_ReceiveCapturedImage"),
                    StateProvider = () => ApplicationSettings.GetInstance().IsPostviewTransferEnabled,
                    StateObserver = enabled => ApplicationSettings.GetInstance().IsPostviewTransferEnabled = enabled
                }
            });

            var limited = (Application.Current as App).IsFunctionLimited;

            var geoGuide = limited ? "TrialMessage" : "AddGeotag_guide";
            AppSettingData <bool> geoSetting = null;

            geoSetting = new AppSettingData <bool>()
            {
                Title         = SystemUtil.GetStringResource("AddGeotag"),
                Guide         = SystemUtil.GetStringResource(geoGuide),
                StateProvider = () =>
                {
                    if (limited)
                    {
                        return(false);
                    }
                    else
                    {
                        return(ApplicationSettings.GetInstance().GeotagEnabled);
                    }
                },
                StateObserver = enabled =>
                {
                    ApplicationSettings.GetInstance().GeotagEnabled = enabled;
                    if (enabled)
                    {
                        RequestPermission(geoSetting);
                    }
                }
            };
            var geoToggle = new ToggleSetting {
                SettingData = geoSetting
            };

            if (ApplicationSettings.GetInstance().GeotagEnabled)
            {
                RequestPermission(geoSetting);
            }

            if (limited)
            {
                ApplicationSettings.GetInstance().GeotagEnabled = false;
                geoSetting.IsActive = false;
            }
            section.Add(geoToggle);

            return(section);
        }
Example #23
0
        public override object Execute()
        {
            //string cashbagCode = getParame("Code").ToString();
            string cashbagCode     = getParame("cashbagCode").ToString();
            string cashbagKey      = getParame("cashbagKey").ToString();
            string collaboratorKey = getParame("collaboratorKey").ToString();
            string operatorName    = getParame("operatorName").ToString();

            string  platformCode = getParame("platformCode").ToString();
            decimal payMoney     = order.OrderPay.PayMoney;//本次需要支付的总金额

            //if (order.OrderStatus == EnumOrderStatus.PaymentInWaiting)
            //    throw new OrderCommException("该订单(" + order.OrderId + ")正在支付中,请稍后。。。");
            if (order.OrderPay.PayStatus == EnumPayStatus.OK)
            {
                throw new OrderCommException("该订单(" + order.OrderId + ")已经支付成功,不能重复支付同一个订单");
            }
            //其他参数
            var                 ticketNotify = SettingSection.GetInstances().Payment.TicketNotify;
            EnumPayMethod       payType      = (EnumPayMethod)getParame("payType");
            IPaymentClientProxy client       = new CashbagPaymentClientProxy();

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

            foreach (PayBillDetail item in order.OrderPay.PayBillDetails)
            {
                if (item.OpType != EnumOperationType.PayMoney && item.OpType != EnumOperationType.Insurance && item.Money != 0)
                {
                    //接口
                    if (order.Policy.PolicySourceType == EnumPolicySourceType.Interface)
                    {
                        if (item.OpType != EnumOperationType.Receivables)
                        {
                            ProfitDetailList.Add(item.CashbagCode + "^" + item.Money + "^" + item.OpType.ToEnumDesc());
                        }
                    }
                    else
                    {
                        //非接口
                        ProfitDetailList.Add(item.CashbagCode + "^" + item.Money + "^" + item.OpType.ToEnumDesc());
                    }
                }
            }
            //分润明细
            string ProfitDetail = string.Join("|", ProfitDetailList.ToArray());

            Logger.WriteLog(LogType.INFO, "支付分润 时间:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " OrderId=" + order.OrderId + " ProfitDetail=" + ProfitDetail + "\r\n");
            order.OrderPay.PayMethod = payType;
            object r = null;

            if (payType == EnumPayMethod.Bank)
            {
                string bank = getParame("bank").ToString();
                order.OrderPay.PayMethodCode = bank;
                order.ChangeStatus(EnumOrderStatus.PaymentInWaiting);
                r = client.PaymentByBank(cashbagCode, cashbagKey, order.OrderId, "机票订单", payMoney, bank, ticketNotify, operatorName, ProfitDetail, GetPnrAndPassenger());
            }
            else if (payType == EnumPayMethod.Platform)
            {
                string platform = getParame("platform").ToString();
                order.OrderPay.PayMethodCode = platform;
                switch (platform.ToLower())
                {
                case "tenpay":
                    payType = EnumPayMethod.TenPay;
                    break;

                case "alipay":
                    payType = EnumPayMethod.AliPay;
                    break;
                }
                order.ChangeStatus(EnumOrderStatus.PaymentInWaiting);
                r = client.PaymentByPlatform(cashbagCode, cashbagKey, order.OrderId, "机票订单", payMoney, platform, ticketNotify, operatorName, ProfitDetail, GetPnrAndPassenger());
                order.OrderPay.PayMethod = payType;
            }
            else
            {
                string serialNumber = "";
                try
                {
                    string payPassword = getParame("payPassword").ToString();
                    if (payType == EnumPayMethod.Credit)
                    {
                        order.OrderPay.PayMethodCode = "信用账户";
                        //验证是否在风控范围内,允许使用信用账户购买
                        //serialNumber = client.PaymentByCreditAccount(cashbagCode, cashbagKey, order.OrderId, "机票订单", payMoney, payPassword, ProfitDetail, GetPnrAndPassenger());
                        var result = client.PaymentByCreditAccount(cashbagCode, cashbagKey, order.OrderId, "机票订单",
                                                                   payMoney, payPassword, ProfitDetail, GetPnrAndPassenger());
                        if (!result.Item1)
                        {
                            serialNumber = result.Item2;
                        }
                        else
                        {
                            //该订单已经被在线支付时写入日志
                            Logger.WriteLog(LogType.INFO,
                                            "订单号" + order.OrderId + "已经支付,交易号为" + result.Item2 + "支付方式为" + result.Item3);
                            //如果查询结果已经支付,则恢复订单支付方式
                            switch (result.Item3.ToLower())
                            {
                            case "tenpay":
                                order.OrderPay.PayMethod = EnumPayMethod.TenPay;
                                break;

                            case "alipay":
                                order.OrderPay.PayMethod = EnumPayMethod.AliPay;
                                break;

                            case "internetbank":
                                order.OrderPay.PayMethod = EnumPayMethod.Bank;
                                break;
                            }
                        }
                    }
                    else if (payType == EnumPayMethod.Account)
                    {
                        order.OrderPay.PayMethodCode = "现金账户";
                        //serialNumber = client.PaymentByCashAccount(cashbagCode, cashbagKey, order.OrderId, "机票订单", payMoney, payPassword, ProfitDetail, GetPnrAndPassenger());
                        var result = client.PaymentByCashAccount(cashbagCode, cashbagKey, order.OrderId, "机票订单",
                                                                 payMoney, payPassword, ProfitDetail, GetPnrAndPassenger());
                        if (!result.Item1)
                        {
                            serialNumber = result.Item2;
                        }
                        else
                        {
                            //该订单已经被在线支付时写入日志
                            Logger.WriteLog(LogType.INFO,
                                            "订单号" + order.OrderId + "已经支付,交易号为" + result.Item2 + "支付方式为" + result.Item3);
                            //如果查询结果已经支付,则恢复订单支付方式
                            switch (result.Item3.ToLower())
                            {
                            case "tenpay":
                                order.OrderPay.PayMethod = EnumPayMethod.TenPay;
                                break;

                            case "alipay":
                                order.OrderPay.PayMethod = EnumPayMethod.AliPay;
                                break;

                            case "internetbank":
                                order.OrderPay.PayMethod = EnumPayMethod.Bank;
                                break;
                            }
                        }
                    }
                    else if (payType == EnumPayMethod.AliPay)
                    {
                        string quikalipay = payType.ToEnumDesc();
                        order.OrderPay.PayMethodCode = quikalipay;
                        order.ChangeStatus(EnumOrderStatus.PaymentInWaiting);
                        r = client.PaymentByQuikAliPay(cashbagCode, cashbagKey, order.OrderId, "机票订单", payMoney, quikalipay, ticketNotify, operatorName, payPassword, ProfitDetail, GetPnrAndPassenger());
                        if (r.ToString() != "True")
                        {
                            serialNumber = r.ToString();
                        }
                    }
                }
                catch (Exception ex)
                {
                    //支付失败的日志
                    //抛出异常
                    order.WriteLog(new OrderLog()
                    {
                        OperationPerson   = operatorName,
                        OperationDatetime = DateTime.Now,
                        OperationContent  = "使用" + payType.ToEnumDesc() + "支付失败",
                        IsShowLog         = true
                    });
                    Logger.WriteLog(LogType.INFO,
                                    "支付失败 时间:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " OrderId=" +
                                    order.OrderId + " 异常信息=" + ex.Message + "\r\n");
                    throw new CustomException(00001, ex.Message);
                }
                if (!string.IsNullOrEmpty(serialNumber))
                {
                    //支付成功后,修改日志。改变状态,进行代付
                    order.PayToPaid(operatorName, payType, order.OrderPay.PayMethodCode, serialNumber, "支付");
                }
            }
            return(r);
        }