Exemplo n.º 1
0
        public Service SetDataFromDatabase(ServiceTypeEnum type, string username, string password)
        {
            this.Type = type;
            this.Username = username;
            this.Password = password;

            return this;
        }
Exemplo n.º 2
0
        public Service SetDataToCreate(ServiceTypeEnum type, string username, string password)
        {
            ValidateDataToCreate(type, username, password);

            this.Type = type;
            this.Username = username;
            this.Password = password;

            return this;
        }
Exemplo n.º 3
0
        private static void ValidateDataToCreate(ServiceTypeEnum type, string username, string password)
        {
            if(type == ServiceTypeEnum.Undefined)
                throw new ArgumentException("Invalid service type");

            if(string.IsNullOrEmpty(username))
                throw new ArgumentException("Invalid username");

            if (string.IsNullOrEmpty(password))
                throw new ArgumentException("Invalid password");
        }
Exemplo n.º 4
0
        public DescriptionActionAttribute(string description, ServiceTypeEnum service, TriggerCompatibilityEnum must, params TriggerCompatibilityEnum[] comp)
        {
            Description = description;
            Service     = service;
            var tmp = new List <TriggerCompatibilityEnum>();

            tmp.Add(must);
            foreach (var compatibility in comp)
            {
                tmp.Add(compatibility);
            }
            Compatibilitys = tmp.ToArray();
        }
Exemplo n.º 5
0
        public IViewModel DeleteToken(Account owner, ServiceTypeEnum type)
        {
            var token = owner.Tokens.Where(t => t.Type == type).FirstOrDefault();

            if (token == null)
            {
                return(new ErrorViewModel());
            }
            owner.Tokens.Remove(token);
            _context.Remove(token);
            _context.SaveChanges();
            return(new SuccessViewModel());
        }
Exemplo n.º 6
0
        /// <summary>
        /// 获取语义理解的请求json数据
        /// </summary>
        /// <param name="query">输入文本(待理解的文本)</param>
        /// <param name="serviceType">服务类别</param>
        /// <param name="latitude">纬度坐标</param>
        /// <param name="longitude">经度坐标</param>
        /// <param name="appid">应用id</param>
        /// <param name="uid">用户id</param>
        /// <returns>返回请求json数据</returns>
        private static string GetQueryJson(string query, ServiceTypeEnum serviceType, float latitude, float longitude,
                                           string appid = defaultAppid, string uid = null)
        {
            dynamic data = new ExpandoObject();

            data.query     = query;
            data.category  = serviceType.ToString("g");
            data.latitude  = latitude;
            data.longitude = longitude;
            data.appid     = string.IsNullOrWhiteSpace(appid) ? defaultAppid : appid;
            data.uid       = string.IsNullOrWhiteSpace(uid) ? "" : uid;
            return(JsonConvert.SerializeObject(data));
        }
Exemplo n.º 7
0
        private ProcessTypeEnum?GetProcessTypeForServiceType(ServiceTypeEnum serviceType)
        {
            switch (serviceType)
            {
            case ServiceTypeEnum.Classifier:
                return(ProcessTypeEnum.ClassifierActivate);

            case ServiceTypeEnum.Prc:
                return(ProcessTypeEnum.PrcActivate);

            default:
                return(null);
            }
        }
Exemplo n.º 8
0
 public Service(string name, string description, string displayName, ServiceStartMode startMode,
                ServiceTypeEnum serviceType, DateTimeOffset nameKeyLastWrite, DateTimeOffset?parametersKeyLastWrite,
                string group, string imagePath, string serviceDll, string reqPrivs)
 {
     Name                   = name;
     Description            = description;
     DisplayName            = displayName;
     StartMode              = startMode;
     ServiceType            = serviceType;
     NameKeyLastWrite       = nameKeyLastWrite.UtcDateTime;
     ParametersKeyLastWrite = parametersKeyLastWrite?.UtcDateTime;
     Group                  = group;
     ImagePath              = imagePath;
     ServiceDLL             = serviceDll;
     RequiredPrivileges     = reqPrivs;
 }
Exemplo n.º 9
0
        /// <summary>
        /// 获取语义理解的请求json数据
        /// </summary>
        /// <param name="query">输入文本(待理解的文本)</param>
        /// <param name="serviceType">服务类别</param>
        /// <param name="city">城市</param>
        /// <param name="region">区域</param>
        /// <param name="appid">应用id</param>
        /// <param name="uid">用户id</param>
        /// <returns>返回请求json数据</returns>
        private static string GetQueryJson(string query, ServiceTypeEnum serviceType, string city,
                                           string region = null, string appid = defaultAppid, string uid = null)
        {
            dynamic data = new ExpandoObject();

            data.query    = query;
            data.category = serviceType.ToString("g");
            data.city     = city;
            if (!string.IsNullOrWhiteSpace(region))
            {
                data.region = region;
            }
            data.appid = string.IsNullOrWhiteSpace(appid) ? defaultAppid : appid;
            data.uid   = string.IsNullOrWhiteSpace(uid) ? "" : uid;
            return(JsonConvert.SerializeObject(data));
        }
Exemplo n.º 10
0
        private void WarmUpService <TServiceSettings, THandler>(ServiceTypeEnum serviceType)
            where TServiceSettings : BaseServiceSettingsElastic
            where THandler : IServiceHandler <TServiceSettings>
        {
            var services = serviceQuery.GetByType((int)serviceType).ToList();

            var handler = serviceProvider.GetService <THandler>();

            foreach (var service in services)
            {
                ProcessTypeEnum processType;
                switch (serviceType)
                {
                case ServiceTypeEnum.Classifier:
                    processType = ProcessTypeEnum.ClassifierActivate;
                    break;

                case ServiceTypeEnum.Prc:
                    processType = ProcessTypeEnum.PrcActivate;
                    break;

                case ServiceTypeEnum.Search:
                    processType = ProcessTypeEnum.SearchActivate;
                    break;

                default:
                    throw new Exception("Try to warm up service with undefined process activation type!");
                }

                if (service.Status != (int)ServiceStatusEnum.Active)
                {
                    continue;
                }

                var settings = serviceQuery.GetSettings <TServiceSettings>(service.Id);
                var process  = processHandler.Create(
                    processType,
                    service.Id,
                    service,
                    string.Format(Resources.ServiceResources.Activating_0_Service_1, serviceType, service.Name));

                service.ProcessIdList.Add(process.Id);
                serviceQuery.Update(service.Id, service);

                processHandler.Start(process, (tokenSource) => handler.Activate(process.Id, settings, tokenSource.Token));
            }
        }
Exemplo n.º 11
0
        private static void ValidateDataToCreate(ServiceTypeEnum type, string username, string password)
        {
            if (type == ServiceTypeEnum.Undefined)
            {
                throw new ArgumentException("Invalid service type");
            }

            if (string.IsNullOrEmpty(username))
            {
                throw new ArgumentException("Invalid username");
            }

            if (string.IsNullOrEmpty(password))
            {
                throw new ArgumentException("Invalid password");
            }
        }
Exemplo n.º 12
0
        private List <AboutActionReactionViewModel> GetReactionForService(ServiceTypeEnum id)
        {
            var result = new List <AboutActionReactionViewModel>();

            foreach (ReactionTypeEnum type in Enum.GetValues(typeof(ReactionTypeEnum)))
            {
                var description = type.GetAttributeOfType <DescriptionReactionAttribute>();
                if (id != description.Service)
                {
                    continue;
                }
                var action = new AboutActionReactionViewModel()
                {
                    Name        = type.ToString(),
                    Description = description.Description
                };
                result.Add(action);
            }
            return(result);
        }
Exemplo n.º 13
0
    /// <summary>
    /// 请求语义理解结果
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnQuery_Click(object sender, EventArgs e)
    {
        string userName = lbPublicAccount.SelectedValue;

        if (rbJson.Checked)
        {
            string json = GetQueryJson();
            string url  = "https://api.weixin.qq.com/semantic/semproxy/search?access_token={0}";
            ltrMessage.Text = string.Format("请求json字符串:{0}", json);
            txtResult.Text  = HttpHelper.RequestResponseContent(url, userName, null, "Post", json);
        }
        else
        {
            string query = txtQuery.Text;
            long   type  = 0;
            foreach (ListItem item in cblType.Items)
            {
                if (item.Selected)
                {
                    type += long.Parse(item.Value);
                }
            }
            ServiceTypeEnum st     = (ServiceTypeEnum)type;
            string          city   = txtCity.Text;
            string          region = txtRegion.Text;
            string          appid  = txtAppid.Text;
            string          uid    = txtUid.Text;
            BaseReply       reply  = Semantic.Query(userName, query, st, city, region, appid, uid);
            if (reply != null)
            {
                ltrMessage.Text = "语义请求成功。";
                txtResult.Text  = reply.ToString();
            }
            else
            {
                ltrMessage.Text = "语义请求失败。";
                txtResult.Text  = "";
            }
        }
    }
        /// <summary>
        /// Получение типа сервиса по коду (уже зарегистрированному в базе)
        /// </summary>
        /// <param name="secret"></param>
        public AcceptingWorkflowBindingModule(string secret)
        {
            string FileSharesCode = System.Configuration.ConfigurationManager.AppSettings["FileSharesCode"].ToString();

            using (Models.PhonesDataContext model = new Models.PhonesDataContext())
            {
                if (model.RequestTickets.Count(x => x.secret == secret) > 0)
                {
                    string serviceId = model.RequestTickets.First(x => x.secret == secret).serviceId;
                    this.serviceType = ServiceTypeEnum.UserService;

                    ///----Если сервис ФайловыеШары
                    if (serviceId.StartsWith(FileSharesCode + "."))
                    {
                        this.serviceType = ServiceTypeEnum.FileShare;
                    }
                }
                else
                {
                    throw new Exception("Cannot find RequestTickets with secret = " + secret);
                }
            }
        }
Exemplo n.º 15
0
        public ServiceType(string serviceType)
        {
            switch (serviceType)
            {
            case "Kernel Driver":
                _serviceType = ServiceTypeEnum.KernelDriver;
                break;

            case "File System Driver":
                _serviceType = ServiceTypeEnum.FileSystemDriver;
                break;

            case "Adapter":
                _serviceType = ServiceTypeEnum.Adapter;
                break;

            case "Recognizer Driver":
                _serviceType = ServiceTypeEnum.RecognizerDriver;
                break;

            case "Own Process":
                _serviceType = ServiceTypeEnum.OwnProcess;
                break;

            case "Share Process":
                _serviceType = ServiceTypeEnum.ShareProcess;
                break;

            case "Interactive Process":
                _serviceType = ServiceTypeEnum.InteractiveProcess;
                break;

            default:
                throw new ArgumentException($"invalid value: {Enum.GetName(typeof(ServiceTypeEnum), serviceType)}", "serviceType");
            }
        }
Exemplo n.º 16
0
 public static string GetServiceTypeEnumStringValue(this ServiceTypeEnum enumValue)
 {
     return(enumValue.GetCustomEnumAttributeValue <StringValueAttribute, string>());
 }
 public ServiceThreadInfo(string SystemUserID, int IDNumber, ServiceTypeEnum ServiceType)
 {
     systemUserID = SystemUserID;
     idNumber     = IDNumber;
     serviceType  = ServiceType;
 }
Exemplo n.º 18
0
        private void HandleConflict(string[] args)
        {
            Utils.ParseCloudServerAddress();
            ILog conflictLogger = CreateConflictLogger();

            conflictLogger.Info("Another instance of the app is running.");
            ParseStartupArgs(args, conflictLogger);
            // save join conf args
            if (!string.IsNullOrEmpty(_anonymousJoinConfServerAddress))
            {
                conflictLogger.InfoFormat("join conf server address: {0}", _anonymousJoinConfServerAddress);
                bool        saveConfArgs = true;
                LoginStatus loginStatus  = Utils.GetLoginStatus();
                conflictLogger.InfoFormat("login status: {0}", loginStatus);
                if (LoginStatus.LoggingIn == loginStatus || LoginStatus.AnonymousLoggingIn == loginStatus)
                {
                    conflictLogger.Info("Another process of the application is logging in.");
                    //MessageBox.Show("Another process of the application is logging in. Please close it and rejoin the conference.");
                    MessageBox.Show(LanguageUtil.Instance.GetValueByKey("ANOTHER_APP_LOGGIN"));
                    saveConfArgs = false;
                }
                else if (LoginStatus.LoggedIn == loginStatus || LoginStatus.AnonymousLoggedIn == loginStatus)
                {
                    ServiceTypeEnum serviceType   = Utils.GetServiceType();
                    string          serverAddress = Utils.GetServerAddress(serviceType);
                    if (_anonymousJoinConfServerAddress.Equals(serverAddress))
                    {
                        bool isConfRunning = Utils.GetIsConfRunning();
                        if (isConfRunning)
                        {
                            string confId = Utils.GetRunningConfId();
                            if (!confId.Equals(_anonymousJoinConfId))
                            {
                                conflictLogger.InfoFormat("Another conference is running on the application. Running conf id:{0}, current conf id:{1}", confId, _anonymousJoinConfId);
                                //MessageBox.Show("Another conference is running on the application. Please terminate the conference and rejoin the conference.");
                                MessageBox.Show(LanguageUtil.Instance.GetValueByKey("ANOTHER_CONF_RUNNING"));
                            }
                            saveConfArgs = false;
                        }
                    }
                    else
                    {
                        conflictLogger.InfoFormat("The application has been logged in with another address. Logged server address: {0}, current address: {1}", serverAddress, _anonymousJoinConfServerAddress);
                        bool isConfRunning = Utils.GetIsConfRunning();
                        if (isConfRunning)
                        {
                            conflictLogger.InfoFormat("There is a conference running on the other server.");
                            MessageBox.Show(LanguageUtil.Instance.GetValueByKey("ANOTHER_CONF_RUNNING"));
                            saveConfArgs = false;
                        }
                        else
                        {
                            log.Info("Set SetAnonymousLogoutAndAnonymousJoinConf to true.");
                            //MessageBox.Show("The application has been logged in with another address. Please log out and rejoin the conference.");
                            //MessageBox.Show(LanguageUtil.Instance.GetValueByKey("APP_LOGGED_WITH_ANOTHER_ADDRESS"));
                            //saveConfArgs = false;
                            Utils.SetAnonymousLogoutAndAnonymousJoinConf(true);
                        }
                    }
                }
                if (saveConfArgs)
                {
                    conflictLogger.Info("Save join conf data");
                    SaveJoinConfData();
                }
            }

            conflictLogger.Info("notify another instance and exit.");
            // Notify other instance so it could bring itself to foreground.
            this.eventWaitHandle.Set();

            // Terminate this instance.
            //this.Shutdown();
            System.Environment.Exit(1);
        }
 /// <summary>
 /// Получение типа сервиса напрямую
 /// </summary>
 /// <param name="serviceType"></param>
 public AcceptingWorkflowBindingModule(ServiceTypeEnum serviceType)
 {
     this.serviceType = serviceType;
 }
Exemplo n.º 20
0
        /// <summary>
        /// Modifies a service
        /// </summary>
        /// <param name="displayName">The display name of the service. This string has a maximum length of 256 characters. The name is case-preserved in the service control manager. DisplayName comparisons are always case-insensitive. </param>
        /// <param name="pathName">The fully-qualified path to the executable file that implements the service, for example, "\SystemRoot\System32\drivers\afd.sys".</param>
        /// <param name="serviceType">The type of services provided to processes that call them.</param>
        /// <param name="errorControl">Severity of the error if this service fails to start during startup. The value indicates the action taken by the startup program if failure occurs. All errors are logged by the system.</param>
        /// <param name="startMode">Start mode of the Windows base service.</param>
        /// <param name="desktopInteract">If true, the service can create or communicate with a window on the desktop.</param>
        /// <param name="startName">Account name the service runs under. Depending on the service type, the account name may be in the form of DomainName\Username or .\Username. The service process will be logged using one of these two forms when it runs. If the account belongs to the built-in domain, .\Username can be specified. If NULL is specified, the service will be logged on as the LocalSystem account. For kernel or system-level drivers, StartName contains the driver object name (that is, \FileSystem\Rdr or \Driver\Xns) that the input and output (I/O) system uses to load the device driver. If NULL is specified, the driver runs with a default object name created by the I/O system based on the service name, for example, "DWDOM\Admin".   You also can use the User Principal Name (UPN) format to specify the StartName, for example, Username@DomainName.</param>
        /// <param name="startPassword">Password to the account name specified by the StartName parameter. Specify NULL if you are not changing the password. Specify an empty string if the service has no password.  Note  When changing a service from a local system to a network, or from a network to a local system, StartPassword must be an empty string ("") and not NULL. </param>
        /// <param name="loadOrderGroup">Group name that it is associated with. Load order groups are contained in the system registry, and determine the sequence in which services are loaded into the operating system. If the pointer is NULL, or if it points to an empty string, the service does not belong to a group. Dependencies between groups should be listed in the LoadOrderGroupDependencies parameter. Services in the load-ordering group list are started first, followed by services in groups not in the load-ordering group list, followed by services that do not belong to a group. The system registry has a list of load ordering groups located at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ServiceGroupOrder. </param>
        /// <param name="loadOrderGroupDependencies">List of load-ordering groups that must start before this service starts. The array is doubly null-terminated. If the pointer is NULL, or if it points to an empty string, the service has no dependencies. Group names must be prefixed by the SC_GROUP_IDENTIFIER (defined in the Winsvc.h file) character to differentiate them from service names because services and service groups share the same namespace. Dependency on a group means that this service can run if at least one member of the group is running after an attempt to start all of the members of the group.</param>
        /// <param name="serviceDependencies">List that contains the names of services that must start before this service starts. The array is doubly NULL-terminated. If the pointer is NULL, or if it points to an empty string, the service has no dependencies. Dependency on a service indicates that this service can run only if the service it depends on is running.</param>
        /// <returns></returns>
        public ServiceManager.MethodExecutionResultEnum Change(
                string displayName,
                string pathName,
                ServiceTypeEnum serviceType,
                ErrorControlEnum errorControl,
                StartModeEnum startMode,
                bool desktopInteract,
                string startName,
                string startPassword,
                string loadOrderGroup,
                string loadOrderGroupDependencies,
                string serviceDependencies
            )
        {
            throw new NotImplementedException("Not tested, out of scope");

            ManagementBaseObject inParams = m_mo.GetMethodParameters("Change");
            inParams["DisplayName"] = displayName;
            inParams["PathName"] = pathName;
            inParams["ServiceType"] = (UInt32)serviceType;
            inParams["ErrorControl"] = (UInt32)errorControl;
            inParams["StartMode"] = Convert.ToString(startMode); //TODO: make sure it works...
            inParams["DesktopInteract"] = desktopInteract;
            inParams["StartName"] = startName;
            inParams["StartPassword"] = startPassword;
            inParams["LoadOrderGroup"] = loadOrderGroup;
            inParams["LoadOrderGroupDependencies"] = loadOrderGroupDependencies;
            inParams["ServiceDependencies"] = serviceDependencies;

            return (ServiceManager.MethodExecutionResultEnum)Convert.ToUInt32(m_mo.InvokeMethod("Change", inParams, null)["ReturnValue"]);
        }
Exemplo n.º 21
0
 public ServiceTypeCache(Type type, ServiceTypeEnum typeEnum)
 {
     _type     = type;
     _typeEnum = typeEnum;
 }
Exemplo n.º 22
0
 public ServiceType(ServiceTypeEnum serviceType)
 {
     _serviceType = serviceType;
 }
Exemplo n.º 23
0
 public ServiceTypeCache(Object t, ServiceTypeEnum typeEnum)
 {
     _obj      = t;
     _typeEnum = typeEnum;
 }
Exemplo n.º 24
0
 public DescriptionReactionAttribute(string description, ServiceTypeEnum service, TriggerCompatibilityEnum comp)
 {
     Description   = description;
     Compatibility = comp;
     Service       = service;
 }