Beispiel #1
0
        private static async Task <List <ServiceAccount>?> ParseSvcAccts(string serviceAccountDirectory)
        {
            var accountCollections = new List <ServiceAccount>();

            if (!Directory.Exists(serviceAccountDirectory))
            {
                return(null);
            }

            IEnumerable <string> filePaths = Directory.EnumerateFiles(serviceAccountDirectory, "*", new EnumerationOptions()
            {
                RecurseSubdirectories = true
            });

            foreach (string filePath in filePaths)
            {
                if (!filePath.ToLower().EndsWith(".json"))
                {
                    continue;
                }

                using (var streamReader = new StreamReader(filePath))
                {
                    string fileJson = await streamReader.ReadToEndAsync();

                    ServiceAccount account = JsonConvert.DeserializeObject <ServiceAccount>(fileJson) ?? throw new ArgumentException("service account file structure is bad");
                    account.FilePath = filePath;

                    accountCollections.Add(account);
                }
            }

            return(accountCollections);
        }
        private void TryToLoadRunAsUserSettings(Assembly serviceAssembly = null)
        {
            var config = ConfigurationManager.OpenExeConfiguration(serviceAssembly?.Location ?? Assembly.GetEntryAssembly().Location);

            var configSection = config.GetSection(ServiceInstallerSettingsSectionName);

            if (configSection == null)
            {
                return;
            }

            string serviceAccount = null;

            var configSectionElement = XElement.Parse(configSection.SectionInformation.GetRawXml());

            foreach (var item in configSectionElement.XPathSelectElements("add").Where(item => item.Attribute(XName.Get("key")) != null))
            {
                if (item.Attribute(XName.Get("key"))?.Value == RunAsUserNameFieldName)
                {
                    _userName = item.Attribute(XName.Get("value"))?.Value;
                }

                if (item.Attribute(XName.Get("key"))?.Value == RunAsUserPasswordFieldName)
                {
                    _password = item.Attribute(XName.Get("value"))?.Value;
                }

                if (item.Attribute(XName.Get("key"))?.Value == ServiceAccountFieldName)
                {
                    serviceAccount = item.Attribute(XName.Get("value"))?.Value;
                }
            }

            _serviceAccount = !IsRunAsUserSet() ? TryParseServiceAccountFieldData(serviceAccount) : ServiceAccount.User;
        }
Beispiel #3
0
        /// <summary>
        /// Installs the service.
        /// </summary>
        /// <param name="accountType">Type of the account under which to run this service application.</param>
        /// <param name="userName">The user account under which the service application will run.</param>
        /// <param name="password">The password associated with the user account under which the service application will run.</param>
        public void InstallService(ServiceAccount accountType = ServiceAccount.NetworkService, string userName = null, string password = null)
        {
            if (ServiceController.GetServices().FirstOrDefault(s => s.ServiceName.Equals(ServiceName, StringComparison.OrdinalIgnoreCase)) != null)
            {
                return;
            }

            using (var processInstaller = new ServiceProcessInstaller())
            {
                processInstaller.Account  = accountType;
                processInstaller.Username = userName;
                processInstaller.Password = password;

                using (var serviceInstaller = new ServiceInstaller {
                    Parent = processInstaller
                })
                {
                    serviceInstaller.StartType   = ServiceStartMode.Automatic;
                    serviceInstaller.ServiceName = ServiceName;
                    serviceInstaller.DisplayName = ServiceDisplayName;
                    serviceInstaller.Description = ServiceDescription;

                    string[] commandLine = { $"/assemblypath={Assembly.GetEntryAssembly().Location}" };
                    serviceInstaller.Context = new InstallContext(null, commandLine);

                    var state = new ListDictionary();
                    serviceInstaller.Install(state);
                }
            }
        }
        private void LogOnMenu()
        {
            string login    = "";
            string password = "";
            string message  = "";

            Console.Write("Enter Login: "******"Enter Password: ");
            password = Console.ReadLine();
            ServiceUser susr = new ServiceUser();

            user = susr.LogOn(login, password, out message);
            if (user != null)
            {
                ServiceAccount sa = new ServiceAccount();
                user.Accounts = sa.GetAccounts(user.id);
                AuthoriseUserMenu();
            }
            else
            {
                Console.WriteLine(message);
                Thread.Sleep(1000);
                MainMenu();
            }
        }
Beispiel #5
0
        public bool ChangeServiceAccountDisplayName(string newName, string gameCode, ServiceAccount account)
        {
            if (newName == null || newName == "" || account == null || newName == account.sname)
            {
                return(false);
            }
            NameValueCollection payload = new NameValueCollection();

            payload.Add("strFunction", "ChangeServiceAccountDisplayName");
            payload.Add("sl", gameCode);
            payload.Add("said", account.sid);
            payload.Add("nsadn", newName);

            string response = this.UploadString($"https://{ App.LoginRegion.ToLower() }.beanfun.com/{ (App.LoginRegion == "HK" ? "beanfun_block/" : "") }generic_handlers/gamezone.ashx", payload);

            if (response == "")
            {
                return(false);
            }
            JObject jsonData = JObject.Parse(response);

            if (jsonData["intResult"] == null || (int)jsonData["intResult"] != 1)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        public ActionResult UnDelete(int id)
        {
            ServiceAccountGDSAccessRight serviceAccountGDSAccessRight = new ServiceAccountGDSAccessRight();

            serviceAccountGDSAccessRight = serviceAccountGDSAccessRightRepository.GetServiceAccountGDSAccessRight(id);

            //Check Exists
            if (serviceAccountGDSAccessRight == null)
            {
                ViewData["ActionMethod"] = "DeleteGet";
                return(View("RecordDoesNotExistError"));
            }

            //Check AccessRights
            if (!rolesRepository.HasWriteAccessToServiceAccounts())
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            ServiceAccountGDSAccessRightVM serviceAccountGDSAccessRightVM = new ServiceAccountGDSAccessRightVM();

            //System User
            ServiceAccount serviceAccount = new ServiceAccount();

            serviceAccount = serviceAccountRepository.GetServiceAccount(serviceAccountGDSAccessRight.ServiceAccountId);
            if (serviceAccount != null)
            {
                serviceAccountGDSAccessRightVM.ServiceAccount = serviceAccount;
            }

            serviceAccountGDSAccessRightVM.ServiceAccountGDSAccessRight = serviceAccountGDSAccessRight;

            return(View(serviceAccountGDSAccessRightVM));
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            if (EventType != global::Google.Cloud.SecurityCenter.V1P1Beta1.NotificationConfig.Types.EventType.Unspecified)
            {
                hash ^= EventType.GetHashCode();
            }
            if (PubsubTopic.Length != 0)
            {
                hash ^= PubsubTopic.GetHashCode();
            }
            if (ServiceAccount.Length != 0)
            {
                hash ^= ServiceAccount.GetHashCode();
            }
            if (notifyConfigCase_ == NotifyConfigOneofCase.StreamingConfig)
            {
                hash ^= StreamingConfig.GetHashCode();
            }
            hash ^= (int)notifyConfigCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
 public ChoServiceInstallerSettings RunAsPrompt()
 {
     Account  = ServiceAccount.User;
     UserName = null;
     Password = null;
     return(this);
 }
 /// <summary>
 /// 安装服务
 /// </summary>
 /// <param name="serviceName">服务名</param>
 /// <param name="displayName">友好名称</param>
 /// <param name="description">服务描述</param>
 /// <param name="binaryFilePath">映像文件路径,可带参数</param>
 /// <param name="startType">启动类型</param>
 /// <param name="account">启动账户</param>
 /// <param name="dependencies">依赖服务</param>
 public static void Install(string serviceName, string displayName, string description, string binaryFilePath, ServiceStartType startType, ServiceAccount account = ServiceAccount.LocalSystem, string[] dependencies = null)
 {
     IntPtr scm = OpenSCManager();
     IntPtr service = IntPtr.Zero;
     try
     {
         service = Win32Class.CreateService(scm, serviceName, displayName, Win32Class.SERVICE_ALL_ACCESS, Win32Class.SERVICE_WIN32_OWN_PROCESS, startType, Win32Class.SERVICE_ERROR_NORMAL, binaryFilePath, null, IntPtr.Zero, ProcessDependencies(dependencies), GetServiceAccountName(account), null);
         if (service == IntPtr.Zero)
         {
             if (Marshal.GetLastWin32Error() == 0x431)//ERROR_SERVICE_EXISTS
             { throw new ApplicationException("服务已存在!"); }
             throw new ApplicationException("服务安装失败!");
         }
         //设置服务描述
         Win32Class.SERVICE_DESCRIPTION sd = new Win32Class.SERVICE_DESCRIPTION();
         try
         {
             sd.description = Marshal.StringToHGlobalUni(description);
             Win32Class.ChangeServiceConfig2(service, 1, ref sd);
         }
         finally
         {
             Marshal.FreeHGlobal(sd.description); //释放
         }
     }
     finally
     {
         if (service != IntPtr.Zero)
         {
             Win32Class.CloseServiceHandle(service);
         }
         Win32Class.CloseServiceHandle(scm);
     }
 }
Beispiel #10
0
        // This function contains all the logic to get the username and password
        // from some combination of command line arguments, hard-coded values,
        // and dialog box responses.  This function is called the first time
        // the Username, Password, or RunUnderSystemAccout property is retrieved.
        private void GetLoginInfo()
        {
            // if we're in design mode we won't have a context, etc.
            if (!this.DesignMode)
            {
                if (haveLoginInfo)
                {
                    return;
                }

                haveLoginInfo = true;

                // ask for the account to run under if necessary
                if (serviceAccount == ServiceAccount.User)
                {
                    if (Context.Parameters.ContainsKey("username"))
                    {
                        username = Context.Parameters["username"];
                    }
                    if (Context.Parameters.ContainsKey("password"))
                    {
                        password = Context.Parameters["password"];
                    }
                    if (username == null || username.Length == 0 || password == null)
                    {
                        //display the dialog if we are not under unattended setup
                        if (!Context.Parameters.ContainsKey("unattended"))
                        {
                            using (ServiceInstallerDialog dlg = new ServiceInstallerDialog()) {
                                if (username != null)
                                {
                                    dlg.Username = username;
                                }
                                dlg.ShowDialog();
                                switch (dlg.Result)
                                {
                                case ServiceInstallerDialogResult.Canceled:
                                    throw new InvalidOperationException(Res.GetString(Res.UserCanceledInstall, Context.Parameters["assemblypath"]));

                                case ServiceInstallerDialogResult.UseSystem:
                                    username       = null;
                                    password       = null;
                                    serviceAccount = ServiceAccount.LocalSystem;
                                    break;

                                case ServiceInstallerDialogResult.OK:
                                    username = dlg.Username;
                                    password = dlg.Password;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            throw new InvalidOperationException(Res.GetString(Res.UnattendedCannotPrompt, Context.Parameters["assemblypath"]));
                        }
                    }
                }
            }
        }
Beispiel #11
0
        public static void InitWeiXin(string serviceAccountCode, IWeiXinDebugger debugger, IWeiXinResponseMessage responser, IWeiXinRequestMessage requester, IWeiXinDispatchMessage dispatcher)
        {
            TheServiceAccount = BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).Load <ServiceAccount, ServiceAccountPK>(new ServiceAccountPK {
                AccountCode = serviceAccountCode
            });
            var items = BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).ListStringObjectDictionary("GetMapAPIOfInverseAdressParse");

            if (items.Count > 0)
            {
                foreach (var item in items)
                {
                    TheMapAPIOfInverseAdressParse.Add(TypeConverter.ChangeString(item["ItemId"]), TypeConverter.ChangeString(item["ItemValue"]));
                }
            }
            TheWeiXinAPIOfV1.Add(APIGETKey_Bas_GetAccessToken, "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}");
            TheWeiXinAPIOfV1.Add(APIPOSTKey_Cmu_CreateCustomMenu, "https://api.weixin.qq.com/cgi-bin/menu/create?access_token={0}");
            TheWeiXinAPIOfV1.Add(APIGETKey_Cmu_DeleteCustomMenu, "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token={0}");
            TheWeiXinAPIOfV1.Add(APIGETKey_Meb_GetInfoOfNormalAccount, "https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN");
            TheWeiXinAPIOfV1.Add(APIPOSTKey_Msg_SendCustomMessage, "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}");
            TheWeiXinAPIOfV1.Add(APIGETKey_OAuth2_GetAccessToken, "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code");
            TheWeiXinDebugger   = debugger;
            TheWeiXinResponser  = responser;
            TheWeiXinRequester  = requester;
            TheWeiXinDispatcher = dispatcher;
        }
Beispiel #12
0
        public ActionResult Index()
        {
            ViewData["Name"]    = sAccount.getUser(User.Identity.GetUserId()).Name;
            ViewData["Picture"] = sAccount.getUser(User.Identity.GetUserId()).ImagePath;

            string role = null;

            ViewData["Role"] = "";
            IEnumerable <string> roles = new List <string>();

            roles = ((ClaimsIdentity)User.Identity).Claims
                    .Where(c => c.Type == ClaimTypes.Role)
                    .Select(c => c.Value);
            foreach (var x in roles)
            {
                role = x;
            }

            if (role != null)
            {
                ViewData["Role"] = role;
            }
            aspnetuser     u = new aspnetuser();
            ServiceAccount s = new ServiceAccount();

            u = s.getUser(User.Identity.GetUserId());

            return(View(u));
        }
        void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes();
            IBatisNetManager.Init();//数据初始化
            GlobalManager.Init(GlobalManager.SmartLife_WeiXin);
            Assembly     assem             = Assembly.GetExecutingAssembly();
            StreamReader srForErrorMessage = new StreamReader(assem.GetManifestResourceStream("SmartLife.WeiXin.ErrorCode.txt"));

            string[] lines = srForErrorMessage.ReadToEnd().Split('\n');
            srForErrorMessage.Close();
            foreach (var line in lines)
            {
                if (line.Trim() != "")
                {
                    var keyValues = line.Split("=".ToCharArray());
                    if (!GlobalManager.errorCodeMessages.ContainsKey(keyValues[0]))
                    {
                        GlobalManager.errorCodeMessages.Add(keyValues[0], keyValues[1].Replace("\r", ""));
                    }
                }
            }

            TheServiceAccount = BuilderFactory.DefaultBulder().Load <ServiceAccount, ServiceAccountPK>(new ServiceAccountPK {
                AccountCode = "zj-leblue"
            });
        }
        public QuickStartTest()
        {
            // Check for _projectId and throw exception if empty
            _projectId = Environment.GetEnvironmentVariable("GOOGLE_PROJECT_ID");
            if (_projectId == null)
            {
                throw new ArgumentNullException("GOOGLE_PROJECT_ID", "Environment variable not set");
            }

            // Create service account for test
            var credential = GoogleCredential.GetApplicationDefault()
                             .CreateScoped(IamService.Scope.CloudPlatform);

            _iamService = new IamService(
                new IamService.Initializer
            {
                HttpClientInitializer = credential
            });

            var request = new CreateServiceAccountRequest
            {
                AccountId      = "iam-test-account" + DateTime.UtcNow.Millisecond,
                ServiceAccount = new ServiceAccount
                {
                    DisplayName = "iamTestAccount"
                }
            };

            _serviceAccount = _iamService.Projects.ServiceAccounts.Create(
                request, "projects/" + _projectId).Execute();
        }
Beispiel #15
0
        public void NtServiceDescriptorConstructor_WhenEverythinkIsOk_AllPropertiesHavaCorrectValues()
        {
            // Arrange
            string           serviceName           = "serviceName";
            string           serviceExecutablePath = "serviceExecutablePath";
            ServiceAccount   serviceAccount        = ServiceAccount.LocalSystem;
            ServiceStartMode serviceStartMode      = ServiceStartMode.Automatic;
            string           serviceDisplayName    = "serviceDisplayName";
            string           serviceUserName       = "******";
            string           servicePassword       = "******";

            // Act
            var ntServiceDescriptor = new NtServiceDescriptor(serviceName,
                                                              serviceExecutablePath,
                                                              serviceAccount,
                                                              serviceStartMode,
                                                              serviceDisplayName,
                                                              serviceUserName,
                                                              servicePassword);

            // Assert
            Assert.AreEqual(serviceName, ntServiceDescriptor.ServiceName);
            Assert.AreEqual(serviceExecutablePath, ntServiceDescriptor.ServiceExecutablePath);
            Assert.AreEqual(serviceAccount, ntServiceDescriptor.ServiceAccount);
            Assert.AreEqual(serviceStartMode, ntServiceDescriptor.ServiceStartMode);
            Assert.AreEqual(serviceDisplayName, ntServiceDescriptor.ServiceDisplayName);
            Assert.AreEqual(serviceUserName, ntServiceDescriptor.ServiceUserName);
            Assert.AreEqual(servicePassword, ntServiceDescriptor.ServicePassword);
        }
 public ChoServiceInstallerSettings RunAs(string userName, string password)
 {
     Account  = ServiceAccount.User;
     UserName = userName;
     Password = password;
     return(this);
 }
        public override int GetHashCode()
        {
            int hash = 1;

            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            if (EventType != 0)
            {
                hash ^= EventType.GetHashCode();
            }
            if (PubsubTopic.Length != 0)
            {
                hash ^= PubsubTopic.GetHashCode();
            }
            if (ServiceAccount.Length != 0)
            {
                hash ^= ServiceAccount.GetHashCode();
            }
            if (notifyConfigCase_ == NotifyConfigOneofCase.StreamingConfig)
            {
                hash ^= StreamingConfig.GetHashCode();
            }
            hash ^= (int)notifyConfigCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public InvokeResult NullifySelected(string strAccountCodes)
        {
            InvokeResult result = new InvokeResult {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                string[] arrAccountCodes = strAccountCodes.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (arrAccountCodes.Length == 0)
                {
                    result.Success   = false;
                    result.ErrorCode = 59996;
                    return(result);
                }
                string statementName = new ServiceAccount().GetUpdateMethodName();
                foreach (string strAccountCode in arrAccountCodes)
                {
                    ServiceAccount serviceAccount = new ServiceAccount {
                        AccountCode = strAccountCode, Status = 0
                    };
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = statementName, ParameterObject = serviceAccount.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                    });
                }
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        public ActionResult View(int id)
        {
            ServiceAccountGDSAccessRight serviceAccountGDSAccessRight = new ServiceAccountGDSAccessRight();

            serviceAccountGDSAccessRight = serviceAccountGDSAccessRightRepository.GetServiceAccountGDSAccessRight(id);

            //Check Exists
            if (serviceAccountGDSAccessRight == null)
            {
                ViewData["ActionMethod"] = "DeleteGet";
                return(View("RecordDoesNotExistError"));
            }

            ServiceAccountGDSAccessRightVM serviceAccountGDSAccessRightVM = new ServiceAccountGDSAccessRightVM();

            //System User
            ServiceAccount serviceAccount = new ServiceAccount();

            serviceAccount = serviceAccountRepository.GetServiceAccount(serviceAccountGDSAccessRight.ServiceAccountId);
            if (serviceAccount != null)
            {
                serviceAccountGDSAccessRightVM.ServiceAccount = serviceAccount;
            }

            serviceAccountGDSAccessRightVM.ServiceAccountGDSAccessRight = serviceAccountGDSAccessRight;

            return(View(serviceAccountGDSAccessRightVM));
        }
        /// <summary>
        /// 檢查是否已開啟線上交易的服務;
        /// 此功能會自動產生服務帳號密碼,因此僅限用於未來無需變更密碼的服務
        /// </summary>
        /// <param name="GashAccount"></param>
        /// <param name="ServiceCode"></param>
        /// <param name="ServiceRegion"></param>
        /// <param name="GashRegion"></param>
        /// <returns>1成功;0失敗;-1例外錯誤</returns>
        public int CheckOpenEventService(string GashAccount, string ServiceCode, string ServiceRegion, string GashRegion)
        {
            int Result = -1;
            string wsResult = string.Empty;
            string[] aryResult;

            using (ServiceAccount ws = new ServiceAccount())
            {
                ws.Url = GetGashWSUrl("ServiceAccount", GashRegion.ToUpper());
                try
                {
                    //WS
                    //intResult: (1 Success, 0 Failed, -1 Error)
                    //ex:"0;ServiceAccountID_Exists","0;DisplayName_Exists","0;Over_MaxAccount"
                    wsResult = ws.ServiceAccount_CreateSimple(GashAccount, ServiceCode, ServiceRegion, GashAccount);
                    aryResult = wsResult.Split(";".ToCharArray());
                    Result = (aryResult[0] == "0" || aryResult[0] == "1") ? 1 : 0;
                    OutputResult = aryResult[0];
                }
                catch(Exception ex)
                {
                    Result = -1;
                    WSException = ex;
                    aryResult = new string[] { "" };
                }
            }

            OutputMsg = (aryResult!=null && aryResult.Length > 1) ? aryResult[1] : wsResult;

            return Result;
        }
        private void TakeMoney()
        {
            ShowBalanceMenu();
            Console.Write("Выберите счет:");
            int accid = Int32.Parse(Console.ReadLine());

            Console.Write("Вводите сумму:");
            bool   isGood  = false;
            string message = "";

            try
            {
                double         cash = Double.Parse(Console.ReadLine());
                ServiceAccount sa   = new ServiceAccount();
                isGood = sa.MoneyTake(accid, cash, out message);
            }
            catch (Exception exc)
            {
                message = exc.Message;
            }
            if (isGood)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(message);
                Console.ForegroundColor = ConsoleColor.White;
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(message);
                Console.ForegroundColor = ConsoleColor.White;
            }
        }
        public static TransactionResultTypes IsPurchaseValid(CoreAccount payer, ServiceAccount receiver, ChainInfo chainInfo, PurchaseServiceTransaction transaction)
        {
            if (chainInfo == null)
            {
                return(TransactionResultTypes.ChainNotFound);
            }

            if (payer == null || !payer.CanPurchase(transaction.Price))
            {
                return(TransactionResultTypes.InsuficientBalance);
            }

            if (receiver == null)
            {
                return(TransactionResultTypes.InvalidServiceAccount);
            }

            if (!chainInfo.IsPurchaseValid(transaction.PurchaseGroupId, transaction.PurchaseItemId, transaction.Price))
            {
                return(TransactionResultTypes.PurchaseNotFound);
            }

            if (!receiver.CanPurchaseItem(transaction, chainInfo))
            {
                return(TransactionResultTypes.CannotPurchase);
            }

            return(TransactionResultTypes.Ok);
        }
        public ActionResult Create(string id)
        {
            //Set Access Rights
            ViewData["Access"] = "";
            if (rolesRepository.HasWriteAccessToServiceAccounts())
            {
                ViewData["Access"] = "WriteAccess";
            }

            ServiceAccountGDSAccessRightVM serviceAccountGDSAccessRightVM = new ServiceAccountGDSAccessRightVM();

            ServiceAccountGDSAccessRight serviceAccountGDSAccessRight = new ServiceAccountGDSAccessRight();

            serviceAccountGDSAccessRightVM.ServiceAccountGDSAccessRight = serviceAccountGDSAccessRight;

            //GDS
            serviceAccountGDSAccessRightVM.GDSs = new SelectList(gdsRepository.GetAllGDSs().ToList(), "GDSCode", "GDSName");

            //GDSAccessTypes
            serviceAccountGDSAccessRightVM.GDSAccessTypes = new SelectList(gdsAccessTypeRepository.GetAllGDSAccessTypes().ToList(), "GDSAccessTypeId", "GDSAccessTypeName");

            //ServiceAccount
            ServiceAccount serviceAccount = new ServiceAccount();

            serviceAccount = serviceAccountRepository.GetServiceAccount(id);
            if (serviceAccount != null)
            {
                serviceAccountGDSAccessRightVM.ServiceAccount = serviceAccount;
                serviceAccountGDSAccessRightVM.ServiceAccountGDSAccessRight.ServiceAccountId = serviceAccount.ServiceAccountId;
            }

            return(View(serviceAccountGDSAccessRightVM));
        }
        public ModelInvokeResult <ServiceAccountPK> Nullify(string strAccountCode)
        {
            ModelInvokeResult <ServiceAccountPK> result = new ModelInvokeResult <ServiceAccountPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                string         _AccountCode   = strAccountCode;
                ServiceAccount serviceAccount = new ServiceAccount {
                    AccountCode = _AccountCode, Status = 0
                };

                statements.Add(new IBatisNetBatchStatement {
                    StatementName = serviceAccount.GetUpdateMethodName(), ParameterObject = serviceAccount.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                });
                /***********************begin 自定义代码*******************/
                /***********************此处添加自定义代码*****************/
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new ServiceAccountPK {
                    AccountCode = _AccountCode
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        /// <summary>
        /// ProcessingServiceInstaller initialization with custom run as user and service description from specified assembly
        /// </summary>
        /// <param name="serviceDescriptionAssembly">Assembly from which to get service information</param>
        /// <param name="account">Account type under which to run this service</param>
        /// <param name="userName">User name under which to run this service</param>
        /// <param name="password">Password under which to run this service</param>
        public ServiceInstallerBase(ServiceAccount account, string userName = null, string password = null, Assembly serviceDescriptionAssembly = null)
        {
            var assemblyInfo = serviceDescriptionAssembly != null ? new AssemblyInfo(serviceDescriptionAssembly) : AssemblyInfo.Entry;

            Initialize(assemblyInfo.Description, assemblyInfo.Description, assemblyInfo.Title, account, userName,
                       password);
        }
Beispiel #26
0
        public static void LogOnMenu()
        {
            Console.Clear();
            Console.WriteLine("");

            Console.Write("Login: "******"Login: "******"Password: "******"Password: "******"";
            User   user    = service.LogOn(login, password,
                                           out message);

            if (user != null)
            {
                AuthorUser          = user;
                AuthorUser.Accounts = ServiceAccount.GetAccountsByUserId(AuthorUser.Id);
                AuthorizeUserMenu();
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(message);
                Console.ForegroundColor = ConsoleColor.White;

                Thread.Sleep(3000);
                LogOnMenu();
            }
        }
        public async Task <ServiceAccount> AddServiceAccount(ServiceAccount item)
        {
            await _context.ServiceAccount.AddAsync(item);

            await _context.SaveChangesAsync();

            return(await GetServiceAccount(item.id));
        }
        public OutputData Update(IInputData input, object instance)
        {
            ServiceAccount account = instance.Convert <ServiceAccount>();

            account.Update();

            return(OutputData.CreateToolkitObject(KeyData.Empty));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="serviceName"></param>
        /// <param name="serviceAccount"></param>
        public static void SetServiceAccount(String serviceName, ServiceAccount serviceAccount)
        {
            RegistryKey key = Registry.LocalMachine.OpenSubKey(
                "SYSTEM\\CurrentControlSet\\Services\\" + serviceName, true);

            key.SetValue("ObjectName", serviceAccount);
            key.Close();
        }
        /// <summary>
        /// Method to receive the player's account
        /// </summary>
        /// <param name="accountReceived">The account of the player</param>
        public void AccountReceived(ServiceAccount accountReceived)
        {
            account        = accountReceived;
            lEmail.Content = account.Email;
            string password = Security.Decrypt(account.PasswordAccount);

            lPassword.Content = password;
        }
Beispiel #31
0
 public async Task <ApiKey> CreateApiKeyPair(ServiceAccount serviceAccount, string clusterId = null)
 {
     return(await _tikaClient.ApiKeys.CreateAsync(new ApiKeyCreate
     {
         Description = "Automatically created during SA flow",
         ServiceAccountId = serviceAccount.Id
     }, clusterId));
 }
Beispiel #32
0
        protected override void DoExecute(CodeActivityContext context)
        {
            devlog.Debug(string.Format("Entered for '{0}'", ServiceAccount));
            var myServiceAccount = ServiceAccount.Get(context);

            devlog.Debug(string.Format("Got for '{0}'", myServiceAccount));
            ExchangeRepository.Download(myServiceAccount);
        }
        public ServiceIdentity(ServiceAccount serviceAccount)
        {
            if (serviceAccount == ServiceAccount.User)
            {
                throw new ArgumentOutOfRangeException("serviceAccount", "ServiceAccount can't be user without supplying username and password");
            }

            ServiceAccount = serviceAccount;
        }
        protected WindowsServiceInstallerBase(ServiceStartMode startMode, ServiceAccount account, string serviceName, string description)
        {
            _installer.StartType = startMode;
            _processInstaller.Account = account;
            _installer.Description = description;
            _installer.ServiceName = serviceName;

            Installers.Add(_installer);
            Installers.Add(_processInstaller);
        }
        private static ServiceProcessInstaller CreateServiceProcessInstaller(ServiceAccount? account, string username, string password)
        {
            var installer = new ServiceProcessInstaller
            {
                Account = account ?? ServiceAccount.LocalService,
                Username = username ?? string.Empty,
                Password = password ?? string.Empty
            };

            return installer;
        }
		private static ServiceProcessInstaller CreateServiceProcessInstaller(ServiceAccount account, string username, string password)
		{
			var installer = new ServiceProcessInstaller
			{
				Username = username,
				Password = password,
				Account = account
			};

			return installer;
		}
 protected ServiceInstallerExt(ServiceAccount account, ServiceStartMode startMode)
 {
     Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
     var serviceProcessInstaller = new ServiceProcessInstaller
     {
         Account = account
     };
     var serviceInstaller = new ServiceInstaller
     {
         StartType = startMode
     };
     PrepareNames(serviceInstaller);
     Installers.Add(serviceInstaller);
     Installers.Add(serviceProcessInstaller);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ServiceType"></param>
        /// <param name="StartMode"></param>
        /// <param name="ServiceName"></param>
        /// <param name="DisplayName"></param>
        /// <param name="Description"></param>
        /// <param name="Account"></param>
        /// <param name="Username"></param>
        /// <param name="Password"></param>
        public ServiceInstallerAttribute(Type ServiceType, 
            ServiceStartMode StartMode, string ServiceName, string DisplayName, string Description,
            ServiceAccount Account, string Username, string Password)
        {
            this.ServiceType = ServiceType;

            this.StartMode = StartMode;
            this.ServiceName = ServiceName;
            this.DisplayName = DisplayName;
            this.Description = Description;

            this.Account = Account;
            this.Username = Username;
            this.Password = Password;
        }
        public NtServiceDescriptor(string serviceName, string serviceExecutablePath, ServiceAccount serviceAccount, ServiceStartMode serviceStartMode, string serviceDisplayName = null, string serviceUserName = null, string servicePassword = null)
        {
            if (string.IsNullOrEmpty(serviceName))
              {
            throw new ArgumentException("Argument can't be null nor empty.", "serviceName");
              }

              if (string.IsNullOrEmpty(serviceExecutablePath))
              {
            throw new ArgumentException("Argument can't be null nor empty.", "serviceExecutablePath");
              }

              ServiceName = serviceName;
              ServiceExecutablePath = serviceExecutablePath;
              ServiceAccount = serviceAccount;
              ServiceStartMode = serviceStartMode;
              ServiceDisplayName = serviceDisplayName ?? serviceName;
              ServiceUserName = serviceUserName;
              ServicePassword = servicePassword;
        }
 /// <summary>
 /// 转换帐户枚举为有效参数
 /// </summary>
 private static string GetServiceAccountName(ServiceAccount account)
 {
     if (account == ServiceAccount.LocalService)
     {
         return @"NT AUTHORITY\LocalService";
     }
     if (account == ServiceAccount.NetworkService)
     {
         return @"NT AUTHORITY\NetworkService";
     }
     return null;
 }
        /// <summary>
        /// 呼叫Gash Web Service 取得 玩家擁有gash+專用點數  //edit 2009/11/10
        /// </summary>
        /// <param name="tmpGash">Gash帳號</param>
        /// <returns>(成功:玩家的點數 失敗:-1)</returns>
        public static int GetUserGashPoint(string tmpGash, string str_Region)
        {
            string ServiceCode = (string)ConfigurationManager.AppSettings["PayServiceCode"]??"";
            string ServiceRegion = (string) ConfigurationManager.AppSettings["PayServiceRegion"] ?? "";
            string x = string.Empty;
            try
            {
                ServiceAccount Gash_sp = new ServiceAccount();
                MainAccount sp = new MainAccount();
                switch (str_Region.ToUpper())
                {
                    case "TW":
                        Gash_sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_ServiceAccount"] ?? "");
                        sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_MainAccount"] ?? "");
                        break;
                    case "HK":
                        Gash_sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_ServiceAccount_HK"] ?? "");
                        sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_MainAccount_HK"] ?? "");
                        ServiceRegion = (string) ConfigurationManager.AppSettings["PayServiceRegion_HK"] ?? "";
                        break;
                    default:
                        Gash_sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_ServiceAccount"] ?? "");
                        sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_MainAccount"] ?? "");
                        break;
                }

                if (tmpGash.Length <= 0)
                { return -1; }
                else
                {
                    string myresult = Gash_sp.ServiceAccount_GetRemainingPoints(ServiceCode, ServiceRegion, tmpGash);
                    Gash_sp.Dispose();

                    if (myresult.Length > 0)
                    {
                        if (myresult.Substring(0, 2).ToString() == "1;")
                        {
                            x = myresult.Substring(2, myresult.Length - 2);
                            return System.Int32.Parse(x);
                        }
                        else if (myresult == "-1;Check_ServiceAccount_Failed")
                        {

                            myresult = sp.MainAccount_GetRemainingPoints(tmpGash);
                            if (myresult.Length > 0)
                            {
                                if (myresult.Substring(0, 2).ToString() == "1;")
                                {
                                    x = myresult.Substring(2, myresult.Length - 2);
                                    return System.Int32.Parse(x);
                                }
                                else
                                    return -1;
                            }
                            else
                                return -1;

                        }
                        else
                            return -1;
                    }
                    else
                        return -1;
                }
            }
            catch
            {
                return -1;
            }
        }
 public RunAsServiceAccountHostConfigurator(ServiceAccount accountType)
 {
     _accountType = accountType;
 }
Beispiel #43
0
 /// <summary>
 /// ProcessingServiceInstaller initialization
 /// </summary>
 /// <param name="description">Service description</param>
 /// <param name="displayName">Service display name</param>
 /// <param name="serviceName">Service name</param>
 /// <param name="account">Account type under which to run this service</param>
 /// <param name="userName">User name under which to run this service</param>
 /// <param name="password">Password under which to run this service</param>
 public ServiceInstallerBase(string description, string displayName, string serviceName, ServiceAccount account, string userName, string password)
 {
     Initialize(description, displayName, serviceName, account, userName, password);
 }
Beispiel #44
0
 public RunAsHostConfigurator(ServiceAccount accountType)
 {
     _username = "";
     _password = "";
     _accountType = accountType;
 }
Beispiel #45
0
        /// <summary>
        /// ProcessingServiceInstaller initialization with information from service assembly
        /// </summary>
        /// <param name="serviceAssembly">Assembly from which to get assembly information</param>
        /// <param name="account">Account type under which to run this service</param>
        /// <param name="userName">User name under which to run this service</param>
        /// <param name="password">Password under which to run this service</param>
        public ServiceInstallerBase(ServiceAccount account, string userName, string password, Assembly serviceAssembly = null)
        {
            var assemblyInfo = serviceAssembly != null ? new AssemblyInfo(serviceAssembly) : AssemblyInfo.Entry;

            Initialize(assemblyInfo.Description, assemblyInfo.Description, assemblyInfo.Title, account, userName,
                       password);
        }
Beispiel #46
0
        static void SafeMain(string[] args)
        {
            AddERExcludedApplication(Process.GetCurrentProcess().MainModule.ModuleName);
            Console.WriteLine("TraceSpy Service - " + (Environment.Is64BitProcess ? "64" : "32") + "-bit - Build Number " + Assembly.GetExecutingAssembly().GetInformationalVersion());
            Console.WriteLine("Copyright (C) SoftFluent S.A.S 2012-" + DateTime.Now.Year + ". All rights reserved.");

            var token = Extensions.GetTokenElevationType();
            if (token != TokenElevationType.Full)
            {
                Console.WriteLine("");
                Console.WriteLine("Warning: token elevation type (UAC level) is " + token + ". You may experience access denied errors from now on. You may fix these errors if you restart with Administrator rights or without UAC.");
                Console.WriteLine("");
            }

            OptionHelp = CommandLineUtilities.GetArgument(args, "?", false);
            if (!OptionHelp)
            {
                OptionHelp = CommandLineUtilities.GetArgument(args, "h", false);
                if (!OptionHelp)
                {
                    OptionHelp = CommandLineUtilities.GetArgument(args, "help", false);
                }
            }
            OptionService = CommandLineUtilities.GetArgument(args, "s", false);

            if (!OptionService)
            {
                if (OptionHelp)
                {
                    Console.WriteLine("Format is " + Assembly.GetExecutingAssembly().GetName().Name + ".exe [options]");
                    Console.WriteLine("[options] can be a combination of the following:");
                    Console.WriteLine("    /?                     Displays this help");
                    Console.WriteLine("    /i                     Installs the <name> service");
                    Console.WriteLine("    /k                     Kills this process on any exception");
                    Console.WriteLine("    /u                     Uninstalls the <name> service");
                    Console.WriteLine("    /t                     Displays traces on the console");
                    Console.WriteLine("    /l:<name>              Locale used");
                    Console.WriteLine("                           default is " + CultureInfo.CurrentCulture.LCID);
                    Console.WriteLine("    /name:<name>           (Un)Installation uses <name> for the service name");
                    Console.WriteLine("                           default is \"" + DefaultName + "\"");
                    Console.WriteLine("    /displayName:<dname>   (Un)Installation uses <dname> for the display name");
                    Console.WriteLine("                           default is \"" + DefaultDisplayName + "\"");
                    Console.WriteLine("    /description:<desc.>   Installation ses <desc.> for the service description");
                    Console.WriteLine("                           default is \"" + DefaultDisplayName + "\"");
                    Console.WriteLine("    /startType:<type>      Installation uses <type> for the service start mode");
                    Console.WriteLine("                           default is \"" + ServiceStartMode.Manual + "\"");
                    Console.WriteLine("                           Values are " + ServiceStartMode.Automatic + ", " + ServiceStartMode.Disabled + " or " + ServiceStartMode.Manual);
                    Console.WriteLine("    /user:<name>           Name of the account under which the service should run");
                    Console.WriteLine("                           default is Local System");
                    Console.WriteLine("    /password:<text>       Password to the account name");
                    Console.WriteLine("    /config:<path>         Path to the configuration file");
                    Console.WriteLine("    /dependson:<list>      A comma separated list of service to depend on");
                    Console.WriteLine("");
                    Console.WriteLine("Examples:");
                    Console.WriteLine(Assembly.GetExecutingAssembly().GetName().Name + " /i /name:MyService /displayName:\"My Service\" /startType:Automatic");
                    Console.WriteLine(Assembly.GetExecutingAssembly().GetName().Name + " /u /name:MyOtherService");
                    return;
                }
            }

            OptionTrace = CommandLineUtilities.GetArgument(args, "t", false);
            OptionKillOnException = CommandLineUtilities.GetArgument(args, "k", false);
            OptionInstall = CommandLineUtilities.GetArgument(args, "i", false);
            OptionStartType = (ServiceStartMode)CommandLineUtilities.GetArgument(args, "starttype", ServiceStartMode.Manual);
            OptionLcid = CommandLineUtilities.GetArgument<string>(args, "l", null);
            OptionUninstall = CommandLineUtilities.GetArgument(args, "u", false);
            OptionAccount = (ServiceAccount)CommandLineUtilities.GetArgument(args, "user", ServiceAccount.User);
            OptionPassword = CommandLineUtilities.GetArgument<string>(args, "password", null);
            OptionUser = CommandLineUtilities.GetArgument<string>(args, "user", null);
            string dependsOn = CommandLineUtilities.GetArgument<string>(args, "dependson", null);
            if (!string.IsNullOrEmpty(dependsOn))
            {
                OptionDependsOn = dependsOn.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            }
            else
            {
                OptionDependsOn = null;
            }
            OptionConfigPath = CommandLineUtilities.GetArgument<string>(args, "config", null);
            if (!string.IsNullOrEmpty(OptionConfigPath) && !Path.IsPathRooted(OptionConfigPath))
            {
                OptionConfigPath = Path.GetFullPath(OptionConfigPath);
            }
            _configuration = ServiceSection.Get(OptionConfigPath);

            OptionDisplayName = CommandLineUtilities.GetArgument(args, "displayname", DefaultDisplayName);
            OptionDescription = CommandLineUtilities.GetArgument(args, "description", DefaultDescription);

            if (OptionInstall)
            {
                ServiceInstaller si = new ServiceInstaller();
                ServiceProcessInstaller spi = new ServiceProcessInstaller();
                si.ServicesDependedOn = OptionDependsOn;
                Console.WriteLine("OptionAccount=" + OptionAccount);
                Console.WriteLine("OptionUser="******"Password cannot be empty if Account is set to User.");
                            return;
                        }

                        spi.Username = OptionUser;
                        spi.Password = OptionPassword;
                    }
                }
                else
                {
                    spi.Account = OptionAccount;
                }

                si.Parent = spi;
                si.DisplayName = OptionDisplayName;
                si.Description = OptionDescription;
                si.ServiceName = OptionName;
                si.StartType = OptionStartType;
                si.Context = new InstallContext(Assembly.GetExecutingAssembly().GetName().Name + ".install.log", null);

                string asmpath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, AppDomain.CurrentDomain.FriendlyName);

                // TODO: add instance specific parameters here (ports, etc...)
                string binaryPath = "\"" + asmpath + "\""       // exe path
                    + " /s"                                     // we run as a service
                    + " /name:" + OptionName;                    // our name

                if (!string.IsNullOrEmpty(OptionConfigPath))
                {
                    binaryPath += " /c:\"" + OptionConfigPath + "\"";
                }

                si.Context.Parameters["assemblypath"] = binaryPath;

                IDictionary stateSaver = new Hashtable();
                si.Install(stateSaver);

                // see remarks in the function
                FixServicePath(si.ServiceName, binaryPath);
                return;
            }

            if (OptionUninstall)
            {
                ServiceInstaller si = new ServiceInstaller();
                ServiceProcessInstaller spi = new ServiceProcessInstaller();
                si.Parent = spi;
                si.ServiceName = OptionName;

                si.Context = new InstallContext(Assembly.GetExecutingAssembly().GetName().Name + ".uninstall.log", null);
                si.Uninstall(null);
                return;
            }

            if (!OptionService)
            {
                if (OptionTrace)
                {
                    Trace.Listeners.Add(new ConsoleListener());
                }

                if (!string.IsNullOrEmpty(OptionLcid))
                {
                    Extensions.SetCurrentThreadCulture(OptionLcid);
                }

                Console.WriteLine("Console Mode");
                Console.WriteLine("Service Host name: " + OptionName);
                WindowsIdentity identity = WindowsIdentity.GetCurrent();
                Console.WriteLine("Service Host identity: " + (identity != null ? identity.Name : "null"));
                Console.WriteLine("Service Host bitness: " + (IntPtr.Size == 4 ? "32-bit" : "64-bit"));
                Console.WriteLine("Service Host display name: '" + OptionDisplayName + "'");
                Console.WriteLine("Service Host event log source: " + _service.EventLog.Source);
                Console.WriteLine("Service Host trace enabled: " + OptionTrace);
                Console.WriteLine("Service Host administrator mode: " + IsAdministrator());

                string configPath = OptionConfigPath;
                if (configPath == null)
                {
                    configPath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
                }
                Console.WriteLine("Service Host config file path: " + configPath);
                Console.WriteLine("Service Host current locale: " + Thread.CurrentThread.CurrentCulture.LCID + " (" + Thread.CurrentThread.CurrentCulture.Name + ")");

                Console.Title = OptionDisplayName;

                ConsoleControl cc = new ConsoleControl();
                cc.Event += OnConsoleControlEvent;

                _service.InternalStart(args);
                if (!_stopping)
                {
                    _service.InternalStop();
                }
                else
                {
                    int maxWaitTime = Configuration.ConsoleCloseMaxWaitTime;
                    if (maxWaitTime <= 0)
                    {
                        maxWaitTime = Timeout.Infinite;
                    }
                    _closed.WaitOne(maxWaitTime, Configuration.WaitExitContext);
                }
                return;
            }

            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] { _service };
            Run(ServicesToRun);
        }
        //****由遊戲帳號找出gash帳號****   by  joda
        public static string GetMainAccountID(string strGame_ID, string Str_ServiceCode, string Str_Region)
        {
            string strgash = "";
            ServiceAccount ws = new ServiceAccount();

            try
            {
                //strgash = Str_ServiceCode + ";" + Str_Region + ";" + strGame_ID;
                strgash = ws.ServiceAccount_GetMainAccountID(Str_ServiceCode, Str_Region, strGame_ID);
                if (strgash.Split(";".ToCharArray())[0] != "1")
                {
                    strgash = "0";
                }
                else
                {
                    strgash = strgash.Split(";".ToCharArray())[1].ToString();
                }
            }
            catch (Exception ex)
            {
                strgash = "-1";
            }

            ws.Dispose();
            return strgash;
        }
Beispiel #48
0
 public Credentials(string username, string password, ServiceAccount account)
 {
     Username = username;
     Account = account;
     Password = password;
 }
Beispiel #49
0
 public void SettingAccountParsesCorreclty(string accountype, ServiceAccount expected)
 {
     var actual = new Arguments(new[] { "/accounttype=" + accountype });
     Assert.AreEqual(expected, actual.Account);
 }
Beispiel #50
0
 public RunAsHostConfigurator(string username, string password, ServiceAccount accountType)
 {
     _username = username;
     _password = password;
     _accountType = accountType;
 }
Beispiel #51
0
			public ServiceAccountDescriptor(ServiceAccount accountType)
			{
				this.AccountType = accountType;
			}
        private void GetLoginInfo()
        {
            if (((base.Context != null) && !base.DesignMode) && !this.haveLoginInfo)
            {
                this.haveLoginInfo = true;
                if (this.serviceAccount == ServiceAccount.User)
                {
                    if (base.Context.Parameters.ContainsKey("username"))
                    {
                        this.username = base.Context.Parameters["username"];
                    }
                    if (base.Context.Parameters.ContainsKey("password"))
                    {
                        this.password = base.Context.Parameters["password"];
                    }
                    if (((this.username == null) || (this.username.Length == 0)) || (this.password == null))
                    {
                        if (!base.Context.Parameters.ContainsKey("unattended"))
                        {
                            using (ServiceInstallerDialog dialog = new ServiceInstallerDialog())
                            {
                                if (this.username != null)
                                {
                                    dialog.Username = this.username;
                                }
                                dialog.ShowDialog();
                                switch (dialog.Result)
                                {
                                    case ServiceInstallerDialogResult.OK:
                                        this.username = dialog.Username;
                                        this.password = dialog.Password;
                                        break;

                                    case ServiceInstallerDialogResult.UseSystem:
                                        this.username = null;
                                        this.password = null;
                                        this.serviceAccount = ServiceAccount.LocalSystem;
                                        break;

                                    case ServiceInstallerDialogResult.Canceled:
                                        throw new InvalidOperationException(System.ServiceProcess.Res.GetString("UserCanceledInstall", new object[] { base.Context.Parameters["assemblypath"] }));
                                }
                                return;
                            }
                        }
                        throw new InvalidOperationException(System.ServiceProcess.Res.GetString("UnattendedCannotPrompt", new object[] { base.Context.Parameters["assemblypath"] }));
                    }
                }
            }
        }
        /// <summary>
        /// 取得玩家擁有gash點數+遊戲/服務專用點數;
        /// 需帶入專用點數所屬的線上服務代碼;
        /// 適用於已開啟此線上服務的服務帳號
        /// </summary>
        /// <param name="ServiceAccount"></param>
        /// <param name="ServiceCode"></param>
        /// <param name="ServiceRegion"></param>
        /// <param name="GashRegion"></param>
        /// <returns></returns>
        public int GetUserTotalPoint(string ServiceAccount,string ServiceCode,string ServiceRegion, string GashRegion)
        {
            int Result = 0;
            string wsResult = string.Empty;
            string[] aryResult;

            using (ServiceAccount ws = new ServiceAccount())
            {
                ws.Url = GetGashWSUrl("ServiceAccount", GashRegion.ToUpper());
                try
                {
                    //WS return: intResult;Outstring
                    //intResult: (1  Success)
                    //Outstring: will be RemainingPoints when intResult is 1
                    //未開啟此線上服務:"-1;Check_ServiceAccount_Failed"
                    wsResult = ws.ServiceAccount_GetRemainingPoints(ServiceCode, ServiceRegion, ServiceAccount);
                    aryResult = wsResult.Split(";".ToCharArray());
                    if (aryResult[0] == "1") int.TryParse(aryResult[1], out Result);
                    OutputResult = aryResult[0];
                }
                catch (Exception ex)
                {
                    Result = -1;
                    WSException = ex;
                    aryResult = new string[] { "" };
                }
            }

            OutputMsg = (aryResult != null && aryResult.Length > 1) ? aryResult[1] : wsResult;

            return Result;
        }
Beispiel #54
0
        private void Initialize(string description, string displayName, string serviceName, ServiceAccount account,
								string userName, string password)
        {
            _serviceInstaller.Description = description;
            _serviceInstaller.DisplayName = displayName;
            _serviceInstaller.ServiceName = serviceName;

            _serviceProcessInstaller.Account = account;
            _serviceProcessInstaller.Password = userName;
            _serviceProcessInstaller.Username = password;

            Installers.AddRange(new Installer[]
                {
                    _serviceProcessInstaller,
                    _serviceInstaller
                });
        }
 public void AcceptsServiceAccountsThatAreNotUser(ServiceAccount serviceAccount)
 {
     Assert.DoesNotThrow(() => new ServiceIdentity(serviceAccount));
 }
Beispiel #56
0
 public void Account(ServiceAccount value)
 {
     _config.Account = value;
 }
        /// <summary>     
        //        /*'==================================================================================================
        //        '程式說明:檢查是否已開啟線上交易的服務
        //        '傳入參數:	1._strMainAccountID :Gash帳號
        //        '		2.strServiceCode : 線上交易服務代碼
        //        '		3._strServiceRegion:服務區域代碼
        //        '		4._strServiceAccountID:服務帳號
        //        '傳回結果:	0; Output message -- 尚未開啟,則自動替User開啟
        //        '		1; Output message -- 已開啟
        //        '		-1; Output message -- Error
        //        '==================================================================================================*/
        public static int CheckOpenEventService(string tmpGash, string tmpServiceCode, string tmpRegion, string strGashRegion)
        {
            try
            {
                ServiceAccount sp = new ServiceAccount();

                switch (strGashRegion.ToUpper())
                {
                    case "TW":
                        sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_ServiceAccount"] ?? "");
                        break;
                    case "HK":
                        sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_ServiceAccount_HK"] ?? "");
                        break;
                    default:
                        sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_ServiceAccount"] ?? "");
                        break;
                }

                if (tmpGash.Length <= 0)
                { return 0; }
                else
                {
                    string myresult = sp.ServiceAccount_CreateSimple(tmpGash, tmpServiceCode, tmpRegion, tmpGash);
                    string myresult1;
                    string myresult2;

                    if (myresult.IndexOf("0;ServiceAccountID_Exists", 0, myresult.Length) >= 0 || myresult.IndexOf("0;DisplayName_Exists", 0, myresult.Length) >= 0)
                        myresult1 = "1";
                    else
                        myresult1 = "0";

                    if (myresult.IndexOf("0;Over_MaxAccount", 0, myresult.Length) >= 0)
                        myresult2 = "1";
                    else
                        myresult2 = "0";

                    myresult = myresult.Substring(0, 1);

                    if (myresult == "1" || myresult1 == "1" || myresult2 == "1")
                    { return 1; }
                    else
                    { return 0; }
                }
            }
            catch
            {
                return 0;
            }
        }