protected virtual dynamic JsonResponse <TDTO, TEntity>(DataTransferObject <TEntity> entityObject) where TDTO : new() { if (entityObject.HasErrors) { return(new ValidationFailedResult(entityObject.Error)); } else { ObjectHelper.CopyObject <Paging>(entityObject.Paging); DataTransferObject <TDTO> dtoObject = new DataTransferObject <TDTO>(); TDTO instance = new TDTO(); List <Expression <Func <TDTO, object> > > includes = new List <Expression <Func <TDTO, object> > >(); ObjectHelper.CopyObject(entityObject.Result, ref instance); dtoObject.Paging = entityObject.Paging; dtoObject.Result = instance; ObjectHelper.CopyObject(entityObject.Includes, ref includes); dtoObject.Includes = includes; return(this.Ok(dtoObject)); } }
public IHttpActionResult Process(DataTransferObject RequestDTO) { if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } if (RequestDTO.DirectionId == (int)SyncDirection.ClientToServer) { var tuple = new DataAccess() .GetTableColumns(RequestDTO.TableName) .AddTempBinaryColumnAsString(); RequestDTO.TableData = new DataAccess() .UpdateServerData(RequestDTO.StoredProcedure, RequestDTO.TableData .ConvertToDataTable(tuple.Item2) .ConvertStringToByteArray(tuple.Item1) .RemoveExtraSlashes()) .ConvertToJson(); } else if (RequestDTO.DirectionId == (int)SyncDirection.ServerToClient) { RequestDTO.TableData = new DataAccess() .GetServerData(RequestDTO.TableName, RequestDTO.SyncDateTime, RequestDTO.RowsToSyncPerTime) .HandleByteArrayColumns() .RemoveExtraSlashes() .ConvertToJson(); } return(Ok(RequestDTO)); }
public async Task <DataTransferObject <object> > RegisterDevice([FromBody] UserDeviceInfo input) { DataTransferObject <object> response = new DataTransferObject <object>(); if (input == null) { throw new ApplicationException("Invalid object"); } var IsSave = await _userDeviceInfoService.RegisterDevice(input); if (IsSave) { string serverAPIKey = _configuration.GetSection(appSettings)["NMSAPPServerKey"]; string BroadCastRoute = _configuration.GetSection(appSettings)["NMSAPPBroadCastRoute"]; if (!string.IsNullOrEmpty(input.CategoryName)) { BroadCastRoute = input.CategoryName; } response.Data = await Helper.FireBaseNotificationHelper.Subscribe(input.DeviceToken, BroadCastRoute, serverAPIKey); } response.IsSuccess = true; return(response); }
private List <DataTransferObject> GetSyncableTables() { List <DataTransferObject> l = new List <DataTransferObject>(); DataTable dt = new DataTable(); dt = DataAccess.GetSyncableTables(); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { DataTransferObject dto = new DataTransferObject(); dto.DirectionId = (dt.Rows[i]["DirectionId"] != System.DBNull.Value ? Convert.ToInt32(dt.Rows[i]["DirectionId"]) : 0); dto.TableName = (dt.Rows[i]["TableName"] != System.DBNull.Value ? dt.Rows[i]["TableName"].ToString() : ""); dto.RowsToSyncPerTime = (dt.Rows[i]["RowsToSyncPerTime"] != System.DBNull.Value ? Convert.ToInt32(dt.Rows[i]["RowsToSyncPerTime"]) : 0); dto.StoredProcedure = (dt.Rows[i]["StoredProcedure"] != System.DBNull.Value ? dt.Rows[i]["StoredProcedure"].ToString() : ""); if (dto.DirectionId == 0 || dto.TableName == "" || dto.RowsToSyncPerTime == 0 || dto.StoredProcedure == "") { continue; } l.Add(dto); } } return(l); }
public override DbCommandWrapper InitializeCommand(Database db, DataTransferObject criteria) { //Cast the DataTransferObject to the Subscription object Subscription subscriptionDto = criteria as Subscription; //Create a database command object within which T-SQL commands can //be executed. DbCommandWrapper cw = DbCommandFactory.GetStoredProcCommandWrapper(db, "spAdminUpdateSubscription"); //Parameters are added here, update each line to reflect the parameter from //the subscription object cw.AddInParameter("SubscriptionId", DbType.Int32, subscriptionDto.SubscriptionId); cw.AddInParameter("UserId", DbType.Int32, subscriptionDto.UserId); cw.AddInParameter("VolumeIssueId", DbType.Int32, subscriptionDto.VolumeIssueId); cw.AddInParameter("ArticleId", DbType.Int32, subscriptionDto.ArticleId); cw.AddInParameter("EffectiveDate", DbType.DateTime, subscriptionDto.EffectiveDate); cw.AddInParameter("ExpirationDate", DbType.DateTime, subscriptionDto.ExpirationDate); cw.AddInParameter("Active", DbType.Boolean, subscriptionDto.IsActive); cw.AddInParameter("UpdateUserId", DbType.Int32, subscriptionDto.UpdateUserId); //Return the commandwrapper object to DALCHelper where the stored proc //will be executed return(cw); }
public JsonResult Subscribe(SubscriberEntity user) { DataTransferObject transferObj = new DataTransferObject(); try { if (!subscribersService.CheckIfEmailExists(user.Email)) { user.IsActive = true; user.CreationDate = DateTime.UtcNow; subscribersService.CreateSubscriber(user); subscribersService.SaveSubscriber(); transferObj.StatusCode = ServiceConstants.Success; return(Json(transferObj)); } else { transferObj.StatusCode = ServiceConstants.DuplicateEmail; transferObj.StatusMessage = AppResources.Email_Exist; return(Json(transferObj)); } } catch (Exception ex) { Logging.LogException(ex); } transferObj.StatusCode = ServiceConstants.Error; transferObj.StatusMessage = AppResources.Server_Error; return(Json(transferObj)); }
public void Run() { Guid id; Guid.TryParse(DataTransferObject.ParentInstanceID, out id); ID = DataTransferObject.ResourceID; ParentID = DataTransferObject.ParentID; WorkspaceID = DataTransferObject.WorkspaceID; // handle queuing WaitForSlot(); // abort the execution - no space at the inn if (!ExecutableServiceRepository.Instance.DoesQueueHaveSpace()) { _instance.Abort(); } else { ExecutableServiceRepository.Instance.Add(this); // here is space at the inn ;) var wfappUtils = new WfApplicationUtils(); if (DataTransferObject.IsDebugMode()) { ErrorResultTO invokeErrors; wfappUtils.DispatchDebugState(DataTransferObject, StateType.Start, AllErrors.HasErrors(), AllErrors.MakeDisplayReady(), out invokeErrors, null, true); AllErrors.MergeErrors(invokeErrors); } _previousNumberOfSteps = DataTransferObject.NumberOfSteps; DataTransferObject.NumberOfSteps = 0; _instance.Run(); } }
public void SendData(DataTransferObject exampleDTO) { using (var ms = new MemoryStream()) { // İlgili object'imizi binary'e serialize ediyoruz. new BinaryFormatter().Serialize(ms, exampleDTO); IList <ArraySegment <byte> > data = new List <ArraySegment <byte> >(); data.Add(new ArraySegment <byte>(ms.ToArray())); // Gönderme işlemine başlıyoruz. _Socket.BeginSend(data, SocketFlags.None, out socketError, (asyncResult) => { // Gönderme işlemini bitiriyoruz. int length = _Socket.EndSend(asyncResult, out socketError); if (length <= 0 || socketError != SocketError.Success) { Console.WriteLine("Server bağlantısı koptu!"); return; } }, null); if (socketError != SocketError.Success) { Console.WriteLine("Server bağlantısı koptu!"); } } }
public override DbCommandWrapper InitializeCommand(Database db, DataTransferObject criteria) { UserIPAddress userIPAddressDto = criteria as UserIPAddress; //Create a database command object within which T-SQL commands can //be executed. DbCommandWrapper cw = DbCommandFactory.GetStoredProcCommandWrapper(db, "spInsertUserIPAddress"); //Parameters are added here, update each line to reflect the parameter from //the subscription object cw.AddInParameter("UserId", DbType.Int32, userIPAddressDto.UserId); cw.AddInParameter("IPOctet1Begin", DbType.Int32, userIPAddressDto.BeginAddress.Octet1); cw.AddInParameter("IPOctet2Begin", DbType.Int32, userIPAddressDto.BeginAddress.Octet2); cw.AddInParameter("IPOctet3Begin", DbType.Int32, userIPAddressDto.BeginAddress.Octet3); cw.AddInParameter("IPOctet3End", DbType.Int32, userIPAddressDto.EndAddress.Octet3); cw.AddInParameter("IPOctet4Begin", DbType.Int32, userIPAddressDto.BeginAddress.Octet4); cw.AddInParameter("IPOctet4End", DbType.Int32, userIPAddressDto.EndAddress.Octet4); //Return the commandwrapper object to DALCHelper where the stored proc //will be executed return(cw); }
public static IChangedFieldsMappingPolicy CreatePolicy(DataTransferObject objectDTO) { lock (LockObject) { if (_factory == null) { _factory = new ChangedFieldsPolicyFactory(); } } if (objectDTO is UserStoryDTO) { return(new UserStoryChangedFieldsPolicy()); } if (objectDTO is BugDTO) { return(new UserStoryChangedFieldsPolicy()); } if (objectDTO is FeatureDTO) { return(new UserStoryChangedFieldsPolicy()); } if (objectDTO is RequestDTO) { return(new UserStoryChangedFieldsPolicy()); } throw new ArgumentException("Wrong DTO type", objectDTO.GetType().FullName); }
static void Main(string[] args) { int port = 5555; Console.WriteLine(string.Format("Client Başlatıldı. Port: {0}", port)); Console.WriteLine("-----------------------------"); TcpSocket tcpSocket = new TcpSocket(new IPEndPoint(IPAddress.Parse("127.0.0.1"), port)); tcpSocket.Start(); Console.WriteLine("Göndermek için \"S\", basınız..."); int count = 1; while (Console.ReadLine().ToUpper() == "S") { DataTransferObject dataTransferObject = new DataTransferObject() { Status = string.Format("{0}. Alındı", count), Message = string.Format("{0} ip numaralı client üzerinden geliyorum!", GetLocalIPAddress()) }; tcpSocket.SendData(dataTransferObject); count++; } Console.ReadLine(); }
public static DataTransferObject <T> CreateErrorResponse <T>(string error, T value) { var errorResponse = new DataTransferObject <T>(value); errorResponse.HasErrors = true; errorResponse.Error = new Exception(error); return(errorResponse); }
public override DataTransferObject CreateResultsDto(DbCommandWrapper cw, DataTransferObject insertObj) { Volume volumeDto = insertObj as Volume; volumeDto.VolumeId = Convert.ToInt32(cw.GetParameterValue("VolumeId")); return(volumeDto); }
public async Task <DataTransferObject <List <string> > > SearchKeyword(string searchtext, int count = 30) { DataTransferObject <List <string> > response = new DataTransferObject <List <string> >(); response.IsSuccess = true; response.Data = await _newsFileService.SearchKeyword(searchtext, count); return(response); }
public async Task <DataTransferObject <List <NewsFile> > > GetNewsFileByFilter([FromBody] NewsFileFilterDTO newsFileFilter) { DataTransferObject <List <NewsFile> > response = new DataTransferObject <List <NewsFile> >(); response.IsSuccess = true; response.Data = await _newsFileService.GetNewsFileByFilter(newsFileFilter.CategoryId, newsFileFilter.Filters, newsFileFilter.PageOffset, newsFileFilter.PageSize, newsFileFilter.SearchText) ?? new List <NewsFile>(); return(response); }
public async Task <DataTransferObject <List <Category> > > GetAllCategories() { DataTransferObject <List <Category> > response = new DataTransferObject <List <Category> >(); response.IsSuccess = true; response.Data = await _categoryService.GetAllCategories(); return(response); }
public async Task <DataTransferObject <List <Filter> > > GetAllFilters() { DataTransferObject <List <Filter> > response = new DataTransferObject <List <Filter> >(); response.IsSuccess = true; response.Data = await _filterService.GetAllFilters(); return(response); }
public override DbCommandWrapper InitializeCommand(Database db, DataTransferObject criteria) { Volume volDeleteDto = criteria as Volume; DbCommandWrapper cw = DbCommandFactory.GetStoredProcCommandWrapper(db, "spDeleteVolume"); cw.AddInParameter("VolumeId", DbType.Int32, volDeleteDto.VolumeId); return(cw); }
public override DbCommandWrapper InitializeCommand(Database db, DataTransferObject criteria) { Issue issueDto = criteria as Issue; DbCommandWrapper cw = DbCommandFactory.GetStoredProcCommandWrapper(db, "spGetActiveArticles"); cw.AddInParameter("VolumeIssueId", DbType.Int32, issueDto.VolumeIssueId); return(cw); }
public override DbCommandWrapper InitializeCommand(Database db, DataTransferObject criteria) { User userDto = criteria as User; DbCommandWrapper cw = DbCommandFactory.GetStoredProcCommandWrapper(db, "spGetUserByEmail"); cw.AddInParameter("Email", DbType.String, userDto.EmailAddress); return(cw); }
public override DbCommandWrapper InitializeCommand(Database db, DataTransferObject criteria) { User userDto = criteria as User; DbCommandWrapper cw = DbCommandFactory.GetStoredProcCommandWrapper(db, "spGetUserRolesByUserId"); cw.AddInParameter("UserId", DbType.Int32, userDto.UserId); return(cw); }
private void SyncServerToClient(DataTransferObject request_dto) { using (var client = new HttpClient()) { var WebApi = AppConfig.WebApiUrl; client.BaseAddress = new Uri(WebApi); DataTable request_dataTable = new DataTable(); request_dataTable = DataAccess.GetTableColumns(request_dto.TableName); DateTime?LastSyncDateTime = DataAccess.GetClientDataLastUpdatedDateTime(request_dto.TableName) ?? DateTime.Now.AddYears(-50); request_dto.SyncDateTime = Convert.ToDateTime(LastSyncDateTime); if (request_dataTable == null) { return; } request_dto.TableData = request_dataTable.ConvertToJson(); var postTask = client.PostAsJsonAsync(WebApi, request_dto); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <DataTransferObject>(); readTask.Wait(); var response_dto = readTask.Result; if (response_dto == null) { return; } DataTable response_dataTable = new DataTable(); response_dataTable = DataAccess.GetTableColumns(response_dto.TableName); Tuple <List <string>, DataTable> tuple = response_dataTable.AddTempBinaryColumnAsString(); response_dataTable = response_dto.TableData .ConvertToDataTable(tuple.Item2) .ConvertStringToByteArray(tuple.Item1) .RemoveExtraSlashes(); if (response_dataTable != null && response_dataTable.Rows.Count > 0) { DataAccess.UpdateData(response_dto.StoredProcedure, response_dataTable); } } } }
private bool CheckForOperationSuccess(DataTransferObject dataTransferObject) { if (dataTransferObject.Bytes.Length < dataTransferObject.BytesAmountPerTransfer) { dataTransferObject.Status = TransferStatus.Success; return(true); } return(false); }
public void Initialise(DataTransferObject dto) { if (dto.ContainsKey($"{Name}ID") || dto.ContainsKey("ID")) { var key = dto.ContainsKey($"{Name}ID") ? (int)dto[$"{Name}ID"] : (int)dto["ID"]; var value = dto.ContainsKey($"{Name}Name") ? dto[$"{Name}Name"].ToString() : dto["Name"].ToString(); Add(key, value); } }
internal List <Car> GetCarsByConditions(Car car) { DataTransferObject transferObject = new DataTransferObject { Operation = Operation.FindCar, Object = car }; binaryFormater.Serialize(clientStream, transferObject); transferObject = (DataTransferObject)binaryFormater.Deserialize(clientStream); return((List <Car>)transferObject.Result); }
internal List <Reservation> GetReservationsByConditions(Reservation reservation) { DataTransferObject transferObject = new DataTransferObject { Operation = Operation.FindReservation, Object = reservation }; binaryFormater.Serialize(clientStream, transferObject); transferObject = (DataTransferObject)binaryFormater.Deserialize(clientStream); return((List <Reservation>)transferObject.Result); }
private HttpResponseMessage CreateExceptionResponse(Exception ex) { var tempDto = new DataTransferObject { Status = 0, Message = ex.Message + "\r\n" + ex.StackTrace }; var messageContent = Newtonsoft.Json.JsonConvert.SerializeObject(tempDto); return(new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent(messageContent) }); }
internal List <Car> LoadCars() { DataTransferObject transferObject = new DataTransferObject { Operation = Operation.GetAllCars, Object = new Car() }; binaryFormater.Serialize(clientStream, transferObject); transferObject = (DataTransferObject)binaryFormater.Deserialize(clientStream); return((List <Car>)transferObject.Result); }
internal List <Reservation> LoadReservation() { DataTransferObject transferObject = new DataTransferObject { Operation = Operation.GetAllReservations, Object = new Reservation() }; binaryFormater.Serialize(clientStream, transferObject); transferObject = (DataTransferObject)binaryFormater.Deserialize(clientStream); return((List <Reservation>)transferObject.Result); }
public void Update(object ob) { DataTransferObject dto = (DataTransferObject)ob; if (dto.valueB > 40) { Console.WriteLine("{0} accept valueB -> {1}", this.Name, dto.valueB); } else { Console.WriteLine("{0} accept valueB -> {1}", this.Name, dto.valueB); } }
/// <inheritdoc /> public int AddSubscriber(string authKey, DataTransferObject.SubscriberDto s) { if (!IsAuthenticatedKey(authKey)) { return 0; } using (var context = new NewsletterEntities()) { var subscriber = new Subscriber(); var sessions = new SessionManager(context); subscriber.name = s.Name; subscriber.contact = s.Contact; subscriber.newsletter = sessions.GetSession(authKey).NewsletterId; context.Subscribers.AddObject(subscriber); context.SaveChanges(); return subscriber.id; } }
/// <inheritdoc /> public void UpdateSubscriber(string authKey, DataTransferObject.SubscriberDto sub) { if (!IsAuthenticatedKey(authKey)) { return; } using (var context = new NewsletterEntities()) { var sessions = new SessionManager(context); var newsletterId = sessions.GetSession(authKey).NewsletterId; var subscriberQuery = from s in context.Subscribers where s.newsletter == newsletterId && s.id == sub.Id select s; foreach (var row in subscriberQuery) { row.name = sub.Name; row.contact = sub.Contact; } context.SaveChanges(); } }