static Guid() { // Note: this type is marked as 'beforefieldinit'. Guid guid = new Guid(new byte[16]); Guid.zeroString = guid.ToString(); Guid.random = new Random(); }
public static void LogHttpResponse(this DiagnosticListener @this, Task<HttpResponseMessage> responseTask, Guid loggingRequestId) { if (@this.IsEnabled(HttpHandlerLoggingStrings.ResponseWriteName)) { ScheduleLogResponse(@this, responseTask, loggingRequestId); } }
protected Activity(Guid activityId, Guid parentId) { _currentId = activityId; this.parentId = parentId; _mustDispose = true; DiagnosticTraceBase.ActivityId = _currentId; }
/// <summary> /// Constructor for ServerRemoteHost. /// </summary> internal ServerRemoteHost( Guid clientRunspacePoolId, Guid clientPowerShellId, HostInfo hostInfo, AbstractServerTransportManager transportManager, Runspace runspace, ServerDriverRemoteHost serverDriverRemoteHost) { _clientRunspacePoolId = clientRunspacePoolId; _clientPowerShellId = clientPowerShellId; Dbg.Assert(hostInfo != null, "Expected hostInfo != null"); Dbg.Assert(transportManager != null, "Expected transportManager != null"); // Set host-info and the transport-manager. HostInfo = hostInfo; _transportManager = transportManager; _serverDriverRemoteHost = serverDriverRemoteHost; // Create the executor for the host methods. _serverMethodExecutor = new ServerMethodExecutor( clientRunspacePoolId, clientPowerShellId, _transportManager); // Use HostInfo to create host-UI as null or non-null based on the client's host-UI. _remoteHostUserInterface = hostInfo.IsHostUINull ? null : new ServerRemoteHostUserInterface(this); Runspace = runspace; }
public static void LogHttpResponse(this DiagnosticListener @this, HttpResponseMessage response, Guid loggingRequestId) { if (@this.IsEnabled(HttpHandlerLoggingStrings.ResponseWriteName)) { LogHttpResponseCore(@this, response, loggingRequestId); } }
public RegisterInfo (Guid client, string meshId, PeerNodeAddress address) : this () { body.ClientId = client; body.MeshId = meshId; body.NodeAddress = address; }
public UpdateInfoDC(Guid registrationId, Guid client, string meshId, PeerNodeAddress address) { this.ClientId = client; this.MeshId = meshId; this.NodeAddress = address; this.RegistrationId = registrationId; }
public TimerEventSubscription (Guid timerId, Guid workflowInstanceId, DateTime expiresAt) : this () { this.timerId = timerId; this.workflowInstanceId = workflowInstanceId; this.expiresAt = expiresAt; this.name = timerId; }
/// <summary> /// Constructor /// </summary> /// <param name="ownerId"> /// Instance Id of the object creating this instance /// </param> /// <param name="callback"> /// A AsyncCallback to call once the async operation completes. /// </param> /// <param name="state"> /// A user supplied state object /// </param> internal AsyncResult(Guid ownerId, AsyncCallback callback, object state) { Dbg.Assert(Guid.Empty != ownerId, "ownerId cannot be empty"); OwnerId = ownerId; Callback = callback; AsyncState = state; }
internal SymbolDocumentWithGuids(string fileName, ref Guid language, ref Guid vendor, ref Guid documentType) : base(fileName) { Language = language; LanguageVendor = vendor; DocumentType = documentType; }
protected internal override void Schedule (WaitCallback callback, Guid workflowInstanceId, DateTime whenUtc, Guid timerId) { //WorkflowInstance wi = WorkflowRuntime.GetInstanceFromGuid (workflowInstanceId); //wi.TimerEventSubscriptionCollection.Add // (new TimerEventSubscription (workflowInstanceId, timerId)); }
public virtual ISymbolDocumentWriter DefineDocument (String url, Guid language, Guid languageVendor, Guid documentType) { // Nothing to do here. return new SymDocumentWriter(); }
protected void GenerateLoadSqlCommand ( SqlCommand command, LoadType loadType, Guid keyToLoadBy, Guid instanceId, List<CorrelationKey> keysToAssociate ) { long surrogateLockOwnerId = base.StoreLock.SurrogateLockOwnerId; byte[] concatenatedKeyProperties = null; bool singleKeyToAssociate = (keysToAssociate != null && keysToAssociate.Count == 1); if (keysToAssociate != null) { concatenatedKeyProperties = SerializationUtilities.CreateKeyBinaryBlob(keysToAssociate); } double operationTimeout = this.TimeoutHelper.RemainingTime().TotalMilliseconds; SqlParameterCollection parameters = command.Parameters; parameters.Add(new SqlParameter { ParameterName = "@surrogateLockOwnerId", SqlDbType = SqlDbType.BigInt, Value = surrogateLockOwnerId }); parameters.Add(new SqlParameter { ParameterName = "@operationType", SqlDbType = SqlDbType.TinyInt, Value = loadType }); parameters.Add(new SqlParameter { ParameterName = "@keyToLoadBy", SqlDbType = SqlDbType.UniqueIdentifier, Value = keyToLoadBy }); parameters.Add(new SqlParameter { ParameterName = "@instanceId", SqlDbType = SqlDbType.UniqueIdentifier, Value = instanceId }); parameters.Add(new SqlParameter { ParameterName = "@handleInstanceVersion", SqlDbType = SqlDbType.BigInt, Value = base.InstancePersistenceContext.InstanceVersion }); parameters.Add(new SqlParameter { ParameterName = "@handleIsBoundToLock", SqlDbType = SqlDbType.Bit, Value = base.InstancePersistenceContext.InstanceView.IsBoundToLock }); parameters.Add(new SqlParameter { ParameterName = "@keysToAssociate", SqlDbType = SqlDbType.Xml, Value = singleKeyToAssociate ? DBNull.Value : SerializationUtilities.CreateCorrelationKeyXmlBlob(keysToAssociate) }); parameters.Add(new SqlParameter { ParameterName = "@encodingOption", SqlDbType = SqlDbType.TinyInt, Value = base.Store.InstanceEncodingOption }); parameters.Add(new SqlParameter { ParameterName = "@concatenatedKeyProperties", SqlDbType = SqlDbType.VarBinary, Value = (object) concatenatedKeyProperties ?? DBNull.Value }); parameters.Add(new SqlParameter { ParameterName = "@operationTimeout", SqlDbType = SqlDbType.Int, Value = (operationTimeout < Int32.MaxValue) ? Convert.ToInt32(operationTimeout) : Int32.MaxValue }); parameters.Add(new SqlParameter { ParameterName = "@singleKeyId", SqlDbType = SqlDbType.UniqueIdentifier, Value = singleKeyToAssociate ? keysToAssociate[0].KeyId : (object) DBNull.Value }); }
public bool Vote(string serviceID, string clientID, string pollStr, string choiceStr) { BowmarPollsDataContext context = new BowmarPollsDataContext(); Guid choice = new Guid(choiceStr); Guid poll = new Guid(pollStr); if (this.hasClientParticipated(context, poll, clientID)) return false; var query = from element in context.PollElements where element.id == choice select element; foreach (PollElement element in query) { if (element.count == null) element.count = 0; element.count++; } ClientParticipation cp = new ClientParticipation(); cp.client_id = clientID; cp.poll_id = poll; context.ClientParticipations.InsertOnSubmit(cp); context.SubmitChanges(); return true; }
public void Create() { // SqlGuid (Byte[]) byte[] b = new byte[16]; b[0] = 100; b[1] = 200; try { SqlGuid Test = new SqlGuid(b); // SqlGuid (Guid) Guid TestGuid = new Guid(b); Test = new SqlGuid(TestGuid); // SqlGuid (string) Test = new SqlGuid("12345678-1234-1234-1234-123456789012"); // SqlGuid (int, short, short, byte, byte, byte, byte, byte, byte, byte, byte) Test = new SqlGuid(10, 1, 2, 13, 14, 15, 16, 17, 19, 20, 21); } catch (Exception e) { Assert.False(true); } }
private static unsafe bool CheckRegistered(Guid id, Assembly assembly, [MarshalAs(UnmanagedType.U1)] bool checkCache, [MarshalAs(UnmanagedType.U1)] bool cacheOnly) { if (checkCache && (_regCache[assembly] != null)) { return true; } if (cacheOnly) { return false; } bool flag = false; string name = @"CLSID\{" + id.ToString() + @"}\InprocServer32"; RegistryKey key = Registry.ClassesRoot.OpenSubKey(name, false); if (key != null) { _regCache[assembly] = bool.TrueString; } else if (IsWin64(&flag)) { HKEY__* hkey__Ptr; IntPtr hglobal = Marshal.StringToHGlobalUni(name); char* chPtr = (char*) hglobal.ToPointer(); int num = flag ? 0x100 : 0x200; Marshal.FreeHGlobal(hglobal); if (RegOpenKeyExW(-2147483648, (char modopt(IsConst)*) chPtr, 0, (uint modopt(IsLong)) (num | 0x20019), &hkey__Ptr) != 0) { return false; } RegCloseKey(hkey__Ptr); return true; } return ((key != null) ? ((bool) ((byte) 1)) : ((bool) ((byte) 0))); }
public virtual AuditRule AuditRuleFactory (IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags, Guid objectType, Guid inheritedObjectType) { throw GetNotImplementedException (); }
private TransactionInformation(TransactionInformation other) { this.local_id = other.local_id; this.dtcId = other.dtcId; this.creation_time = other.creation_time; this.status = other.status; }
private static void VerifySymbolDocumentInfo(SymbolDocumentInfo document, string fileName, Guid language, Guid languageVendor, Guid documentType) { Assert.Equal(fileName, document.FileName); Assert.Equal(language, document.Language); Assert.Equal(languageVendor, document.LanguageVendor); Assert.Equal(documentType, document.DocumentType); }
public static async Task<IList<HttpRequestMessage>> ReadChangeSetRequestAsync(this ODataBatchReader reader, Guid batchId, CancellationToken cancellationToken) { if (reader == null) { throw Error.ArgumentNull("reader"); } if (reader.State != ODataBatchReaderState.ChangesetStart) { throw Error.InvalidOperation( SRResources.InvalidBatchReaderState, reader.State.ToString(), ODataBatchReaderState.ChangesetStart.ToString()); } Guid changeSetId = Guid.NewGuid(); List<HttpRequestMessage> requests = new List<HttpRequestMessage>(); while (reader.Read() && reader.State != ODataBatchReaderState.ChangesetEnd) { if (reader.State == ODataBatchReaderState.Operation) { requests.Add(await ReadOperationInternalAsync(reader, batchId, changeSetId, cancellationToken)); } } return requests; }
// ActivityID support (see also WriteEventWithRelatedActivityIdCore) /// <summary> /// When a thread starts work that is on behalf of 'something else' (typically another /// thread or network request) it should mark the thread as working on that other work. /// This API marks the current thread as working on activity 'activityID'. This API /// should be used when the caller knows the thread's current activity (the one being /// overwritten) has completed. Otherwise, callers should prefer the overload that /// return the oldActivityThatWillContinue (below). /// /// All events created with the EventSource on this thread are also tagged with the /// activity ID of the thread. /// /// It is common, and good practice after setting the thread to an activity to log an event /// with a 'start' opcode to indicate that precise time/thread where the new activity /// started. /// </summary> /// <param name="activityId">A Guid that represents the new activity with which to mark /// the current thread</param> public static void SetCurrentThreadActivityId(Guid activityId) { if (TplEtwProvider.Log != null) TplEtwProvider.Log.SetActivityId(activityId); #if FEATURE_MANAGED_ETW #if FEATURE_ACTIVITYSAMPLING Guid newId = activityId; #endif // FEATURE_ACTIVITYSAMPLING // We ignore errors to keep with the convention that EventSources do not throw errors. // Note we can't access m_throwOnWrites because this is a static method. if (UnsafeNativeMethods.ManifestEtw.EventActivityIdControl( UnsafeNativeMethods.ManifestEtw.ActivityControl.EVENT_ACTIVITY_CTRL_GET_SET_ID, ref activityId) == 0) { #if FEATURE_ACTIVITYSAMPLING var activityDying = s_activityDying; if (activityDying != null && newId != activityId) { if (activityId == Guid.Empty) { activityId = FallbackActivityId; } // OutputDebugString(string.Format("Activity dying: {0} -> {1}", activityId, newId)); activityDying(activityId); // This is actually the OLD activity ID. } #endif // FEATURE_ACTIVITYSAMPLING } #endif // FEATURE_MANAGED_ETW }
public InstanceKey(Guid value, IDictionary<XName, InstanceValue> metadata) { if (value == Guid.Empty) { throw Fx.Exception.Argument("value", SRCore.InstanceKeyRequiresValidGuid); } this.Value = value; if (metadata != null) { if (metadata.IsReadOnly) { this.Metadata = metadata; } else { Dictionary<XName, InstanceValue> copy = new Dictionary<XName, InstanceValue>(metadata); this.Metadata = new ReadOnlyDictionaryInternal<XName, InstanceValue>(copy); } } else { this.Metadata = emptyMetadata; } }
public MembershipUnitTests() { _userGuid = Guid.NewGuid(); _userName = _userGuid.ToString(); _userEmail = string.Format("{0}@gmail.com", _userName.Replace("-", string.Empty)); _userPwd = "1*dk**_=lsdk/()078909"; }
public static void Register_ActivateAccount(Guid UserNameValidActivationToken) { ControllerFake<UserAccountController, object> controller = new ControllerFake<UserAccountController, object>(); ActionResult resultValid = controller.Controller.Activate(UserNameValidActivationToken.ToString()); Assert.AreEqual(true, resultValid.GetType() == typeof(RedirectResult)); Assert.AreEqual(true, (((RedirectResult)resultValid).Url == controller.Controller.RedirectResultOnLogIn().Url)); }
protected internal override void Schedule(WaitCallback callback, Guid workflowInstanceId) { if (callback == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("callback"); } WorkflowDispatchContext currentDispatchContext = WorkflowDispatchContext.Current; if (currentDispatchContext != null && currentDispatchContext.IsSynchronous) { callback(workflowInstanceId); } else { if (this.syncContext != null) { SynchronizationContextPostHelper.Post(this.syncContext, Fx.ThunkCallback(new SendOrPostCallback(callback)), workflowInstanceId); } else { base.Schedule(callback, workflowInstanceId); } } }
private TransactionInformation (TransactionInformation other) { local_id = other.local_id; dtcId = other.dtcId; creation_time = other.creation_time; status = other.status; }
/// <summary> /// Private constructor that does most of the work constructing a remote pipeline object. /// </summary> /// <param name="runspace">RemoteRunspace object</param> /// <param name="addToHistory">AddToHistory</param> /// <param name="isNested">IsNested</param> private RemotePipeline(RemoteRunspace runspace, bool addToHistory, bool isNested) : base(runspace) { _addToHistory = addToHistory; _isNested = isNested; _isSteppable = false; _runspace = runspace; _computerName = ((RemoteRunspace)_runspace).ConnectionInfo.ComputerName; _runspaceId = _runspace.InstanceId; //Initialize streams _inputCollection = new PSDataCollection<object>(); _inputCollection.ReleaseOnEnumeration = true; _inputStream = new PSDataCollectionStream<object>(Guid.Empty, _inputCollection); _outputCollection = new PSDataCollection<PSObject>(); _outputStream = new PSDataCollectionStream<PSObject>(Guid.Empty, _outputCollection); _errorCollection = new PSDataCollection<ErrorRecord>(); _errorStream = new PSDataCollectionStream<ErrorRecord>(Guid.Empty, _errorCollection); // Create object stream for method executor objects. MethodExecutorStream = new ObjectStream(); IsMethodExecutorStreamEnabled = false; SetCommandCollection(_commands); //Create event which will be signalled when pipeline execution //is completed/failed/stoped. //Note:Runspace.Close waits for all the running pipeline //to finish. This Event must be created before pipeline is //added to list of running pipelines. This avoids the race condition //where Close is called after pipeline is added to list of //running pipeline but before event is created. PipelineFinishedEvent = new ManualResetEvent(false); }
public EncoderParameter(Encoder encoder, byte[] value) { this.encoder = encoder.Guid; this.numberOfValues = value.Length; this.type = EncoderParameterValueType.ValueTypeByte; this.value = value; }
/// <summary> /// Executes the operation. /// </summary> /// <param name="batchReader">The batch reader.</param> /// <param name="batchId">The batch id.</param> /// <param name="originalRequest">The original request containing all the batch requests.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>The response for the operation.</returns> public virtual async Task<ODataBatchResponseItem> ExecuteOperationAsync(ODataBatchReader batchReader, Guid batchId, HttpRequestMessage originalRequest, CancellationToken cancellationToken) { if (batchReader == null) { throw Error.ArgumentNull("batchReader"); } if (originalRequest == null) { throw Error.ArgumentNull("originalRequest"); } cancellationToken.ThrowIfCancellationRequested(); OperationRequestItem operation = new OperationRequestItem(await batchReader.ReadOperationRequestAsync(batchId, bufferContentStream: false)); try { ODataBatchResponseItem response = await operation.SendRequestAsync(Invoker, cancellationToken); return response; } finally { originalRequest.RegisterForDispose(operation.GetResourcesForDisposal()); originalRequest.RegisterForDispose(operation); } }
internal void PrepareData() { lock (_syncObject) { if (_dataReady == true) return; IEnumerable<EventTask> result = _pmReference.Tasks; _name = null; _displayName = null; _guid = Guid.Empty; _dataReady = true; foreach (EventTask task in result) { if (task.Value == _value) { _name = task.Name; _displayName = task.DisplayName; _guid = task.EventGuid; _dataReady = true; break; } } } }
public async Task<ResultDto<List<StopMapDto>>> GetAllByMonitor([FromQuery]Guid monitorId, [FromQuery]int typeStop) { var result = await _stopService.GetAllByMonitor(monitorId,typeStop); return result; }
public void Seed(ApplicationDbContext context) { var reason = new Company() { Id = Guid.Parse("9854e4fd-6e1f-4c31-9f0d-65422dbd0bd9"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "Reason", Sector = "Yazılım", Description = "Reason firması açıklaması", HeadCount = 200 }; var microsoft = new Company() { Id = Guid.Parse("a53a3120-f00a-4f3f-9a6b-5ebf3a1ede32"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "Microsoft", Sector = "Yazılım", Description = "Microsoft firması açıklaması", HeadCount = 1000 }; var turkey = new Country() { Id = Guid.Parse("73756f28-9de2-4592-a7cc-4675d3bfedef"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "Türkiye" }; var usa = new Country() { Id = Guid.Parse("b780f09d-c2d1-4be0-8916-1ca1a6b5ecc6"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "USA" }; var turkeyCity = new City() { Id = Guid.Parse("6dbe0db1-763d-4ed1-8709-e7d7ce8a77a0"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "İstanbul", CountryId = Guid.Parse("73756f28-9de2-4592-a7cc-4675d3bfedef") }; var usaCity = new City() { Id = Guid.Parse("8540d2c6-b95f-4129-8fe0-869db732045e"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "New York", CountryId = Guid.Parse("b780f09d-c2d1-4be0-8916-1ca1a6b5ecc6") }; var istCounty = new County() { Id = Guid.Parse("48800942-4888-409e-89a0-e51a60a2e7ba"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "Beşiktaş", CityId = Guid.Parse("6dbe0db1-763d-4ed1-8709-e7d7ce8a77a0") }; var newYorkCounty = new County() { Id = Guid.Parse("6b04b845-0552-44ae-81b2-bbce7e3da273"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "Brooklyn", CityId = Guid.Parse("8540d2c6-b95f-4129-8fe0-869db732045e") }; var reasonBranch = new Branch() { Id = Guid.Parse("b98c6a08-40ed-4a0f-a13a-9b7b772b2828"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "İstanbul Şubesi", CompanyId = Guid.Parse("9854e4fd-6e1f-4c31-9f0d-65422dbd0bd9"), CountryId = Guid.Parse("73756f28-9de2-4592-a7cc-4675d3bfedef"), CityId = Guid.Parse("6dbe0db1-763d-4ed1-8709-e7d7ce8a77a0"), CountyId = Guid.Parse("48800942-4888-409e-89a0-e51a60a2e7ba"), Address = "Reason Software Beşiktaş/İstanbul" }; var reasonBranch2 = new Branch() { Id = Guid.Parse("9fcf4898-20c2-4e21-9948-62d954421955"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "New York Şubesi", CompanyId = Guid.Parse("9854e4fd-6e1f-4c31-9f0d-65422dbd0bd9"), CountryId = Guid.Parse("b780f09d-c2d1-4be0-8916-1ca1a6b5ecc6"), CityId = Guid.Parse("8540d2c6-b95f-4129-8fe0-869db732045e"), CountyId = Guid.Parse("6b04b845-0552-44ae-81b2-bbce7e3da273"), Address = "Reason Software Brooklyn/New York" }; var microsoftBranch = new Branch() { Id = Guid.Parse("0e36930a-8756-4411-af32-5f087e0ecf27"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "Turkey Office", CompanyId = Guid.Parse("a53a3120-f00a-4f3f-9a6b-5ebf3a1ede32"), CountryId = Guid.Parse("73756f28-9de2-4592-a7cc-4675d3bfedef"), CityId = Guid.Parse("6dbe0db1-763d-4ed1-8709-e7d7ce8a77a0"), CountyId = Guid.Parse("48800942-4888-409e-89a0-e51a60a2e7ba"), Address = "Microsoft Beşiktaş/İstanbul", }; var employee = new Employee() { Id = Guid.Parse("9f7ba10d-7e07-4f84-afb5-1071d05ba657"), CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, FirstName = "FirstName", LastName = "LastName", UserName = "******", Photo = null, Email = "*****@*****.**", Position = "CEO", CompanyId = Guid.Parse("9854e4fd-6e1f-4c31-9f0d-65422dbd0bd9"), BranchId = Guid.Parse("b98c6a08-40ed-4a0f-a13a-9b7b772b2828"), }; var reasonDepartment = new Department() { Id = Guid.Parse("623a567d-e087-4040-befe-b1533aaa9794"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "Software", BranchId = Guid.Parse("b98c6a08-40ed-4a0f-a13a-9b7b772b2828"), }; var reasonDepartment2 = new Department() { Id = Guid.Parse("7f3026e7-1e18-43af-ade0-ae3c64086697"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "İnsan Kaynakları", BranchId = Guid.Parse("9fcf4898-20c2-4e21-9948-62d954421955"), }; var microsoftDepartment = new Department() { Id = Guid.Parse("5f31a2ae-76c2-445a-859d-912f1b813ab6"), CreatedAt = DateTime.Now, CreatedBy = "*****@*****.**", UpdatedAt = DateTime.Now, UpdatedBy = "*****@*****.**", Name = "Software", BranchId = Guid.Parse("0e36930a-8756-4411-af32-5f087e0ecf27"), }; var user = new ApplicationUser() { Id = "0a5152bb-9563-4eec-bde0-501127bacfb9", FirstName = "FirstName", LastName = "LastName", Email = "*****@*****.**", EmailConfirmed = false, PasswordHash = "AILqh33d5oU3noI48vS/RMHp8DlNiYRTn78wTQyW0nmtVvtTxy0j36yqR8hDO5P4og==", // Parola: 123456Can! SecurityStamp = "69b2fb73-64be-4619-8125-a2b22dafff2a", PhoneNumber = null, PhoneNumberConfirmed = false, TwoFactorEnabled = false, LockoutEnabled = false, LockoutEndDateUtc = null, AccessFailedCount = 0, UserName = "******", Role = "Developer", IsAgreeTheTerms = true }; context.Companies.AddOrUpdate(reason); context.Companies.AddOrUpdate(microsoft); context.Countries.AddOrUpdate(turkey); context.Countries.AddOrUpdate(usa); context.Cities.AddOrUpdate(turkeyCity); context.Cities.AddOrUpdate(usaCity); context.Counties.AddOrUpdate(istCounty); context.Counties.AddOrUpdate(newYorkCounty); context.Branches.AddOrUpdate(reasonBranch); context.Branches.AddOrUpdate(reasonBranch2); context.Branches.AddOrUpdate(microsoftBranch); context.Employees.AddOrUpdate(employee); context.Departments.AddOrUpdate(reasonDepartment); context.Departments.AddOrUpdate(reasonDepartment2); context.Departments.AddOrUpdate(microsoftDepartment); context.Users.AddOrUpdate(user); }
public async Task <Artist> Get(Guid id) { return(await repository.GetById(id)); }
public RemoveChequeCommand(Guid id) { Id = id; }
internal IOrganizationService CreateOrganizationService(Guid userId) { return ServiceFactory.CreateOrganizationService(userId); }
protected override void When() { _id = Guid.NewGuid(); _conn.AppendToStreamAsync(_stream, ExpectedVersion.Any, DefaultData.AdminCredentials, new EventData(_id, "test", true, Encoding.UTF8.GetBytes("{'foo' : 'bar'}"), new byte[0])).Wait(); }
private async Task <AuthenticationResult> GenerateAuthenticationResultForUserAsync(ApplicationUser user) { var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(_jwtSettings.Secret); var userProfile = await GetUserProfileByUserId(user.Id); var employee = await _context.Employees.FirstOrDefaultAsync(x => x.UserProfileId == userProfile.Id); var claims = new List <Claim> { new Claim(JwtRegisteredClaimNames.Sub, user.Email), new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), new Claim(JwtRegisteredClaimNames.Email, user.Email), new Claim("firstName", userProfile.FirstName), new Claim("lastName", userProfile.LastName), new Claim("id", userProfile.Id.ToString()) }; if (employee != null) { claims.Add(new Claim("clinicId", employee.ClinicId.ToString())); } var userClaims = await _userManager.GetClaimsAsync(user); claims.AddRange(userClaims); var userRoles = await _userManager.GetRolesAsync(user); foreach (var userRole in userRoles) { claims.Add(new Claim(ClaimTypes.Role, userRole)); var role = await _roleManager.FindByNameAsync(userRole); if (role == null) { continue; } var roleClaims = await _roleManager.GetClaimsAsync(role); foreach (var roleClaim in roleClaims) { if (claims.Contains(roleClaim)) { continue; } claims.Add(roleClaim); } } var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(claims), Expires = DateTime.UtcNow.Add(_jwtSettings.TokenLifetime), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor); await _context.SaveChangesAsync(); return(new AuthenticationResult { Success = true, Token = tokenHandler.WriteToken(token) }); }
public void SetUserContext(Guid userId) { _organizationService = CreateOrganizationService(userId); }
public static MachineId NewId() => new MachineId(Guid.NewGuid());
private bool UsuarioViewModelExists(Guid id) { return(_context.UsuarioViewModel.Any(e => e.Id == id)); }
public MachineId(Guid id) { _id = id; }
private static void InsertPost(SqlConnection conn, SqlTransaction transaction, BlogPost blogPost, string userId) { var blogPostNewId = Guid.NewGuid().ToString(); using (var cmd = new SqlCommand(@"INSERT INTO [dbo].[Posts] ([Id] ,[Abstract] ,[Content] ,[CreatedById] ,[CreatedOnUtc] ,[CreationIpAddress] ,[Format] ,[Language] ,[Title]) VALUES (@Id, @Abstract, @Content, @CreatedById, @CreatedOnUtc, @CreationIpAddress, @Format, @Language, @Title)", conn, transaction)) { // TODO: Old Identifier? // TODO: Last updated date? cmd.Parameters.AddWithValue("Id", blogPostNewId); cmd.Parameters.AddWithValue("Abstract", blogPost.BriefInfo ?? string.Empty); cmd.Parameters.AddWithValue("Content", blogPost.Content); cmd.Parameters.AddWithValue("CreatedById", userId); cmd.Parameters.AddWithValue("CreatedOnUtc", blogPost.CreatedOn.UtcDateTime); cmd.Parameters.AddWithValue("CreationIpAddress", blogPost.CreationIp ?? "127.0.0.1"); cmd.Parameters.AddWithValue("Format", 2); cmd.Parameters.AddWithValue("Language", "en-US"); cmd.Parameters.AddWithValue("Title", blogPost.Title); cmd.ExecuteNonQuery(); } foreach (var blogPostTag in blogPost.Tags) { using (var cmd = new SqlCommand(@"INSERT INTO [dbo].[PostTagEntity] ([PostId] ,[TagName]) VALUES (@PostId, @TagName)", conn, transaction)) { cmd.Parameters.AddWithValue("PostId", blogPostNewId); cmd.Parameters.AddWithValue("TagName", blogPostTag.Name); cmd.ExecuteNonQuery(); } } foreach (var blogPostSlug in blogPost.Slugs) { using (var cmd = new SqlCommand(@"INSERT INTO [dbo].[PostSlugEntity] ([Path] ,[CreatedById] ,[CreatedOnUtc] ,[IsDefault] ,[OwnedById]) VALUES (@Path, @CreatedById, @CreatedOnUtc, @IsDefault, @OwnedById)", conn, transaction)) { cmd.Parameters.AddWithValue("Path", blogPostSlug.Path); cmd.Parameters.AddWithValue("CreatedById", userId); cmd.Parameters.AddWithValue("CreatedOnUtc", blogPostSlug.CreatedOn.UtcDateTime); cmd.Parameters.AddWithValue("IsDefault", blogPostSlug.IsDefault); cmd.Parameters.AddWithValue("OwnedById", blogPostNewId); cmd.ExecuteNonQuery(); } } if (blogPost.IsApproved) { using (var cmd = new SqlCommand(@"INSERT INTO [dbo].[PostApprovalStatusActionEntity] ([Id] ,[PostId] ,[RecordedById] ,[RecordedOnUtc] ,[Status]) VALUES (@Id, @PostId, @RecordedById, @RecordedOnUtc, @Status)", conn, transaction)) { cmd.Parameters.AddWithValue("Id", Guid.NewGuid().ToString()); cmd.Parameters.AddWithValue("PostId", blogPostNewId); cmd.Parameters.AddWithValue("RecordedById", userId); cmd.Parameters.AddWithValue("RecordedOnUtc", DateTime.UtcNow); cmd.Parameters.AddWithValue("Status", 1); cmd.ExecuteNonQuery(); } } }