public BaseResponse SaveAppSetting(SaveRequest request) { return Execute(_repository, r => { var response = new BaseResponse(); if (request.Entity.IsNew && r.CheckExist(request.Entity.SettingType, request.Entity.Name)) { response.Success = false; response.Messages.Add("NameIsExisted"); //resource key return response; } if (!request.Entity.IsNew && r.CheckExist(request.Entity.SettingType, request.Entity.Name, request.Entity.Id)) { response.Success = false; response.Messages.Add("NameIsExisted"); //resource key return response; } if (request.Entity.IsNew) { request.Entity.InitId(); } r.SaveAppSetting(request); return response; }); }
public BusinessMessageResponse SaveAttributeDefinition(SaveRequest<FernBusinessBase.AttributeDefinition> request) { var ad = request.Item; object[] adProperties = new object[] { ad.ID, ad.CompanyID, ad.UserID, ad.DateCreated, ad.DateModified, ad.Active, ad.Deleted, ad.VarName, ad.FriendlyName, ad.Description, ad.GroupID, ad.VarType, ad.Format, ad.CaptureHistory, ad.Viewable, ad.EntityTypeName }; return GenericSaveEntity<AttributeDefinition>("AttributeDefinition", adProperties); }
public BusinessMessageResponse SaveProfileAdmission(SaveRequest<ProfileAdmission> request) { try { ProfileAdmission entity = request.Item; var properties = new object[] { entity.ID, entity.CompanyID, entity.UserID, entity.DateCreated, entity.DateModified = DateTime.UtcNow, entity.Active, entity.Deleted ,entity.ProfileID ,entity.AllowCustomersToUse #if EntityProperty_NoDate ,entity.`field` #endif #if EntityProperty_Date ,BusinessBase.ReadyDateForStorage(entity.`field`) #endif }; var response = GenericSaveEntity<ProfileAdmission>(entity.CompanyID, entity.Attributes, properties); //Review IM-3747 return response; } catch (Exception ex) { return ErrorHandler.Handle(ex); } }
public BusinessMessageResponse SaveMessageOwner(SaveRequest<MessageOwner> request) { try { MessageOwner entity = request.Item; var properties = new object[] { entity.ID, entity.MessageID, entity.CRMID, entity.DateCreated, entity.DateModified = DateTime.UtcNow, entity.Active, entity.Deleted, entity.Viewed }; var response = GenericSaveEntity<MessageOwner>(entity.CompanyID, entity.Attributes, properties); //Review IM-3747 return response; } catch (Exception ex) { return ErrorHandler.Handle(ex); } }
public BusinessMessageResponse SaveAttributeValue(SaveRequest<FernBusinessBase.AttributeValue> request) { var response = new BusinessMessageResponse(); try { AttributeValue attributeValue = ConvertToBusinessAttributeValue(request.Item); BaseEntity.ValidateThrow(attributeValue); object[] properties = new object[] { attributeValue.ID, attributeValue.AttributeID, attributeValue.EntityID, //& gs-351 attributeValue.Value, attributeValue.DateModified = DateTime.UtcNow, attributeValue.PrevValue, BusinessBase.ReadyDateForStorage(attributeValue.PrevDateModified), attributeValue.Deleted, }; response = GenericSaveEntity<AttributeValue>("AttributeValue", properties); } catch (Exception ex) { return ErrorHandler.Handle(ex); } return response; }
public BusinessMessageResponse SaveRelationShipType(SaveRequest<RelationShipType> request) { try { RelationShipType entity = request.Item; var properties = new object[] { entity.ID, entity.CompanyID, entity.UserID, entity.DateCreated, entity.DateModified = DateTime.UtcNow, entity.Active, entity.Deleted ,entity.Name ,entity.Description #if EntityProperty_NoDate ,entity.`field` #endif #if EntityProperty_Date ,BusinessBase.ReadyDateForStorage(entity.`field`) #endif }; var response = GenericSaveEntity<RelationShipType>(entity.CompanyID, entity.Attributes, properties); //Review IM-3747 return response; } catch (Exception ex) { return ErrorHandler.Handle(ex); } }
public BusinessMessageResponse SaveIncidentConfigurationCompany(SaveRequest<IncidentConfigurationCompany> request) { try { IncidentConfigurationCompany entity = request.Item; var properties = new object[] { entity.ID, entity.CompanyID, entity.UserID, entity.DateCreated, entity.DateModified = DateTime.UtcNow, entity.Active, entity.Deleted ,entity.IncidentConfigurationID #if EntityProperty_NoDate ,entity.`field` #endif #if EntityProperty_Date ,BusinessBase.ReadyDateForStorage(entity.`field`) #endif }; var response = GenericSaveEntity<IncidentConfigurationCompany>(entity.CompanyID, entity.Attributes, properties); return response; } catch (Exception ex) { return ErrorHandler.Handle(ex); } }
public BusinessMessageResponse SaveRouteWayPoint(SaveRequest<RouteWaypoint> request) { try { RouteWaypoint entity = request.Item; BaseEntity.ValidateThrow(entity); var properties = new object[] { entity.ID, entity.CompanyID, entity.UserID, entity.DateCreated, entity.DateModified = DateTime.UtcNow, entity.Active, entity.Deleted, entity.RouteId, entity.WayPointId #if EntityProperty_NoDate ,entity.`field` #endif #if EntityProperty_Date ,BusinessBase.ReadyDateForStorage(entity.`field`) #endif }; var response = GenericSaveEntity<RouteWaypoint>(entity.CompanyID, entity.Attributes, properties); //Review IM-3747 return response; } catch (Exception ex) { return ErrorHandler.Handle(ex); } }
public BusinessMessageResponse SaveCompany(SaveRequest<Company> request) { var response = new BusinessMessageResponse(); try { Company entity = request.Item; BaseEntity.ValidateThrow(entity); object[] properties = new object[]{ entity.ID, entity.CompanyID, entity.Path, entity.Active, entity.Deleted, entity.DateCreated, entity.DateModified = DateTime.UtcNow, entity.UserID, entity.Name, entity.StreetAddress, entity.Suburb, entity.City, entity.State, entity.PostCode, entity.DisplayName, entity.Phone, entity.Fax, entity.Mobile, entity.Email, entity.ServiceEmail, entity.RunPrograms, entity.AccountManagerID, entity.AutoLogoffPeriod, entity.GracePeriod, entity.MinorBreak, entity.MajorBreak, entity.WorkPeriod, entity.MapLocationID, entity.MasterPassword, entity.Country ?? "XX", entity.FatigueRuleDefault ,entity.UnlockCode ,entity.LinkID ,entity.ClientType ,entity.TimeZone #if EntityProperty_NoDate ,entity.`field` #endif #if EntityProperty_Date ,BusinessBase.ReadyDateForStorage(entity.`field`) #endif }; response = GenericSaveEntity<Company>(entity.CompanyID, entity.Attributes, properties); //Review IM-3747 } catch (Exception ex) { return ErrorHandler.Handle(ex); } return response; }
public BaseResponse Insert(SaveRequest request) { return Execute(_repository, r => { if (request.Entity.IsNew) { request.Entity.InitId(); } var res = r.Insert(request); return res; }); }
public BusinessMessageResponse SaveHistory(SaveRequest<History> request) { try { History entity = request.Item; var properties = new object[] { entity.ID, entity.CompanyID, entity.Path, entity.UserID, entity.DateCreated, entity.DateModified = DateTime.UtcNow, entity.Active, entity.Deleted ,BusinessBase.ReadyDateForStorage(entity.Date) ,entity.Subject ,entity.Description ,entity.EventType ,entity.OwnerType ,entity.OwnerID ,entity.ContactID ,entity.EmployeeID ,entity.JobID ,entity.TaskID ,entity.TaskType ,entity.AttachmentID ,entity.Completed ,BusinessBase.ReadyDateForStorage(entity.CompleteDate) #if EntityProperty_NoDate ,entity.`field` #endif #if EntityProperty_Date ,BusinessBase.ReadyDateForStorage(entity.`field`) #endif }; var response = GenericSaveEntity<History>(entity.CompanyID, entity.Attributes, properties); //Review IM-3747 return response; } catch (Exception ex) { return ErrorHandler.Handle(ex); } }
private BusinessMessageResponse ChangeReportTypeOwner(SaveRequest<ReportType> request) { BusinessMessageResponse response = new BusinessMessageResponse(); try { var db = ImardaDatabase.CreateDatabase(Util.GetConnName<ReportType>()); object[] args = new object[] { request.Item.ID, request.Item.OwnerID }; db.ExecuteNonQuery("SPChangeReportTypeOwner", args); } catch (Exception ex) { return ErrorHandler.Handle(ex); } return response; }
public BaseResponse Insert(SaveRequest request) { var response = new BaseResponse(); using (var db = DbContext) { var entityDb = request.Entity.Map<DataLog, Entity.DataLog>(); db.DataLogs.Add(entityDb); response.Success = db.SaveChanges() > 0; } return response; }
public BusinessMessageResponse SaveMessageItem(SaveRequest<MessageItem> request) { try { BusinessMessageResponse busresp = null; MessageItem msgitem = request.Item; var service = ImardaProxyManager.Instance.IImardaCRMProxy; ChannelInvoker.Invoke(delegate(out IClientChannel channel) { channel = service as IClientChannel; busresp = service.SaveMessageItem(request); }); string[] usersId = null; usersId = !string.IsNullOrEmpty(request.Item.Users) ? request.Item.Users.Split(',') : usersId; MessageOwner ow; List<MessageOwner> listMessageOwner = new List<MessageOwner>(); foreach (string userid in usersId) { ow = new MessageOwner(); MessageOwner.Copy(msgitem,ow); ow.CRMID = new Guid(userid); ow.MessageID = request.Item.ID; ow.ID = SequentialGuid.NewDbGuid(); listMessageOwner.Add(ow); } SaveListRequest<MessageOwner> ownerRequest = new SaveListRequest<MessageOwner>(listMessageOwner); service = ImardaProxyManager.Instance.IImardaCRMProxy; ChannelInvoker.Invoke(delegate(out IClientChannel channel) { channel = service as IClientChannel; busresp = service.SaveMessageOwnerList(ownerRequest); }); return busresp; } catch (Exception ex) { return ErrorHandler.Handle<GetItemResponse<MessageItem>>(ex); } }
public BaseResponse SaveRole(SaveRequest request) { return Execute(_repository, r => { var response = new BaseResponse(); var isNew = !r.IsExists(request.Entity.Id); if (isNew && r.NameIsExist(request.Entity.Name.ToStr().Trim())) { response.Success = false; response.Messages.Add("NameIsExisted"); //resource key return response; } if(r.NameIsExist(request.Entity.Name.ToStr().Trim(), request.Entity.Id)) { response.Success = false; response.Messages.Add("NameIsExisted"); //resource key return response; } request.Entity.Permissions.ForEach(m => { if (m.IsNew) m.InitId(); m.RoleId = request.Entity.Id; }); var pages = typeof(BePage).EnumToList(); if (request.Entity.Permissions.Count > pages.Count) { response.Success = false; response.Messages.Add("DataIsInvalid"); //resource key return response; } var res = r.SaveRole(request); _cacheHelper.ClearGetRole(request.Entity.Id); return res; }); }
//public GetItemResponse<FtpSent> GetFtpSent(IDRequest request) //{ // try // { // return GenericGetEntity<FtpSent>(request); // } // catch (Exception ex) // { // return ErrorHandler.Handle<GetItemResponse<FtpSent>>(ex); // } //} //public GetUpdateCountResponse GetFtpSentUpdateCount(GetUpdateCountRequest request) //{ // try // { // var response = GenericGetEntityUpdateCount<FtpSent>("FtpSent", request.TimeStamp, true, request.ID, request.LastRecordID); // return response; // } // catch (Exception ex) // { // return ErrorHandler.Handle<GetUpdateCountResponse>(ex); // } //} //public GetListResponse<FtpSent> GetFtpSentListByTimeStamp(GetListByTimestampRequest request) //{ // try // { // return GenericGetEntityListByTimestamp<FtpSent>("FtpSent", request.TimeStamp, request.Cap, true, request.ID, request.LastRecordID); // } // catch (Exception ex) // { // return ErrorHandler.Handle<GetListResponse<FtpSent>>(ex); // } //} //public GetListResponse<FtpSent> GetFtpSentList(IDRequest request) //{ // try // { // return GenericGetEntityList<FtpSent>(request); // } // catch (Exception ex) // { // return ErrorHandler.Handle<GetListResponse<FtpSent>>(ex); // } //} public BusinessMessageResponse SaveFtpSent(SaveRequest<FtpSent> request) { try { FtpSent entity = request.Item; BaseEntity.ValidateThrow(entity); object[] properties = new object[] { entity.ID, entity.CompanyID, entity.UserID, entity.IPAddress, entity.Port, entity.Username, entity.Password, entity.PSK, entity.AttachmentFiles, entity.DestinationPath, entity.Retry, entity.TimeToSend, entity.Status, entity.DateCreated, entity.DateModified = DateTime.UtcNow, entity.LastRetryAt, entity.Active, entity.Deleted #if EntityProperty_NoDate ,entity.`field` #endif #if EntityProperty_Date ,BusinessBase.ReadyDateForStorage(entity.`field`) #endif }; var response = GenericSaveEntity<FtpSent>(entity.CompanyID, entity.Attributes, properties); //Review IM-3747 return response; } catch (Exception ex) { return ErrorHandler.Handle(ex); } }
public BusinessMessageResponse SaveContactMap(SaveRequest<ContactMap> request) { try { BusinessMessageResponse response = null; var service = ImardaProxyManager.Instance.IImardaCRMProxy; ChannelInvoker.Invoke(delegate(out IClientChannel channel) { channel = service as IClientChannel; response = service.SaveContactMap(request); ErrorHandler.Check(response); }); return response; } catch (Exception ex) { return ErrorHandler.Handle<BusinessMessageResponse>(ex); } }
public BaseResponse SaveArtice(SaveRequest request) { var response = new BaseResponse(); using (var db = DbContext) { var entityDb = request.Entity.Map<Artice, Entity.Artice>(); if (!db.Artices.Any(e => e.Id == entityDb.Id)) { db.Artices.Add(entityDb); } else { db.Entry(entityDb).State = EntityState.Modified; } response.Success = db.SaveChanges() > 0; } return response; }
public Snippet SaveSnippet(SaveRequest request, bool clone) { // get username var currentUser = GetCurrentUserId(HttpContext); Snippet snippet = null; var snippetExists = !String.IsNullOrWhiteSpace(request.SnippetId); if (snippetExists) { snippet = _repository.FindSnippet(request.SnippetId); snippetExists = (snippet != null); } // See if we are cloning or not if (snippetExists) { var userOwnsSnippet = snippet.CreatedBy.Equals(currentUser, StringComparison.OrdinalIgnoreCase); clone = clone || !userOwnsSnippet; } var shouldCreateNewSnippet = !snippetExists || clone; if (shouldCreateNewSnippet) { snippet = new Snippet() { CreatedBy = currentUser, Language = request.Language, Model = request.Model, Notes = request.Notes, Title = request.Title, View = request.Template, CloneOf = clone ? request.SnippetId : null }; } _repository.Save(snippet); return snippet; }
public BaseResponse SaveHtmlContent(SaveRequest request) { using (var db = DbContext) { var entityDb = request.Entity.Map<HtmlContent, Entity.HtmlContent>(); if (!db.HtmlContents.Any(e => e.Id == entityDb.Id)) { db.HtmlContents.Add(entityDb); } else { db.Entry(entityDb).State = EntityState.Modified; } var success = db.SaveChanges() > 0; return new BaseResponse { Success = success }; } }
public BusinessMessageResponse SaveApplicationPlanFeature(SaveRequest<ApplicationPlanFeature> request) { try { ApplicationPlanFeature entity = request.Item; var properties = new object[] { entity.ID, entity.CompanyID, entity.UserID, entity.DateCreated, entity.DateModified = DateTime.UtcNow, entity.Active, entity.Deleted ,entity.ApplicationPlanID ,entity.FeatureID ,entity.FeatureType ,entity.Billable ,entity.Price ,entity.UnitCount #if EntityProperty_NoDate ,entity.`field` #endif #if EntityProperty_Date ,BusinessBase.ReadyDateForStorage(entity.`field`) #endif }; var response = GenericSaveEntity<ApplicationPlanFeature>(entity.CompanyID, entity.Attributes, properties); //Review IM-3747 return response; } catch (Exception ex) { return ErrorHandler.Handle(ex); } }
public BusinessMessageResponse SaveAccessLog(SaveRequest<AccessLog> request) { var response = new BusinessMessageResponse(); try { AccessLog log = request.Item; if (log != null) { response = GenericSaveEntity<AccessLog>(request.CompanyID, log.Attributes, null); //Review IM-3747 if (!response.Status) throw new ApplicationException(response.StatusMessage); } response.Status = true; } catch (Exception ex) { return ErrorHandler.Handle(ex); } return response; }
public BusinessMessageResponse SaveScopeAccessLimit(SaveRequest<ScopeAccessLimit> request) { try { ScopeAccessLimit entity = request.Item; var properties = new object[] { entity.ID, entity.CompanyID, entity.UserID, entity.DateCreated, entity.DateModified = DateTime.UtcNow, entity.Active, entity.Deleted ,entity.ScopeID ,entity.AssignedToID ,entity.AssignedToType ,entity.Limit ,entity.PerTimeSpan #if EntityProperty_NoDate ,entity.`field` #endif #if EntityProperty_Date ,BusinessBase.ReadyDateForStorage(entity.`field`) #endif }; var response = GenericSaveEntity<ScopeAccessLimit>(entity.CompanyID, entity.Attributes, properties); return response; } catch (Exception ex) { return ErrorHandler.Handle(ex); } }
public BaseResponse Save(SaveRequest request) { using (var db = DbContext) { var entityDb = request.Entity.Map<RequestPassword, Entity.RequestPassword>(); entityDb.Email = entityDb.Email.ToStr().Trim().ToLower(); if (!db.RequestPasswords.Any(e => e.Id == entityDb.Id)) { db.RequestPasswords.Add(entityDb); } else { db.Entry(entityDb).State = EntityState.Modified; } var success = db.SaveChanges() > 0; return new BaseResponse { Success = success }; } }
public BusinessMessageResponse ChangeReportTypeListOwner(SaveListRequest<ReportType> request) { Initialize(); BusinessMessageResponse response = new BusinessMessageResponse(); string sNewOwnerID = request["NewOwnerID"].ToLower(); Guid newOwnerID = new Guid(sNewOwnerID); string pathFrom = null; string pathTo = null; bool moved = false; try { foreach (ReportType reportType in request.List) { SaveRequest<ReportType> req = new SaveRequest<ReportType>(); moved = false; string ownerPath = InstancesFolder + '/' + sNewOwnerID.ToLower(); CreateFolder(sNewOwnerID.ToLower(), InstancesFolder); pathFrom = InstancesFolder + '/' + reportType.OwnerID.ToString().ToLower() + '/' + reportType.Name; pathTo = ownerPath + '/' + reportType.Name; _Rs2005.MoveItem(pathFrom, pathTo); moved = true; reportType.OwnerID = newOwnerID; req.Item = reportType; ChangeReportTypeOwner(req); } } catch (Exception ex) { if (moved) _Rs2005.MoveItem(pathTo, pathFrom); // reverse the move return ErrorHandler.Handle(ex); } return response; }
public static jQueryXmlHttpRequest Create(SaveRequest <ShipperRow> request, Action <SaveResponse> onSuccess, ServiceCallOptions options = null) { return(null); }
public static jQueryXmlHttpRequest Update(SaveRequest <CustomerDemographicRow> request, Action <SaveResponse> onSuccess, ServiceCallOptions options = null) { return(null); }
private void SaveNote(IUnitOfWork uow, NoteRow note, string entityType, Int64 entityId, Int64? noteId) { note = note.Clone(); note.NoteId = noteId; note.EntityType = entityType; note.EntityId = entityId; note.InsertDate = null; note.ClearAssignment(NoteRow.Fields.InsertDate); var saveRequest = new SaveRequest<NoteRow> { Entity = note }; if (noteId == null) new NoteRepository().Create(uow, saveRequest); else new NoteRepository().Update(uow, saveRequest); }
public Result <SaveResponse> Update(SaveRequest <MyRow> request) { return(this.InTransaction("Default", (uow) => new MyRepository().Update(uow, request))); }
public static jQueryXmlHttpRequest Update(SaveRequest <TransDetailRow> request, Action <SaveResponse> onSuccess, ServiceCallOptions options = null) { return(null); }
public SaveResponse Update(IUnitOfWork uow, SaveRequest <MyRow> request) { return(new MyRepository().Update(uow, request)); }
public SaveResponse Create(IUnitOfWork uow, SaveRequest <MyRow> request) { return(new MySaveHandler(Context).Process(uow, request, SaveRequestType.Create)); }
public static jQueryXmlHttpRequest Update(SaveRequest<CustomerRow> request, Action<SaveResponse> onSuccess, ServiceCallOptions options = null) { return null; }
public static jQueryXmlHttpRequest Update(SaveRequest <SupplierRow> request, Action <SaveResponse> onSuccess = null, ServiceCallOptions options = null) { return(null); }
public virtual void Process(IUnitOfWork uow) { foreach (var row in oldList.Where(x => !newById.Contains(GetID(x)))) { var request = new DeleteRequest { EntityId = GetID(row) }; Delete(uow, request); } foreach (var row in newList.Where(x => { var id = GetID(x); return(id == null || !oldById.ContainsKey(id.Value)); })) { var insert = row.Clone(); insert.IdField[insert] = null; setOwnerID(insert); var request = new SaveRequest <TRow> { Entity = insert }; Save(uow, request); } foreach (var row in newList) { var id = GetID(row); if (id == null) { continue; } TRow old; if (!oldById.TryGetValue(id.Value, out old)) { continue; } if (CheckChangesOnUpdate) { bool anyChanges = false; foreach (var field in row.GetFields()) { if (row.IsAssigned(field) && (field.Flags & FieldFlags.Updatable) == FieldFlags.Updatable & field.IndexCompare(old, row) != 0) { anyChanges = true; break; } } if (!anyChanges) { continue; } } var update = row.Clone(); setOwnerID(update); var request = new SaveRequest <TRow> { Entity = update }; Save(uow, request); } }
public SaveResponse Create(IUnitOfWork uow, SaveRequest <MyRow> request) { return(new MyRepository(Context).Create(uow, request)); }
public static jQueryXmlHttpRequest Create(SaveRequest<LanguageRow> request, Action<SaveResponse> onSuccess, ServiceCallOptions options = null) { return null; }
protected virtual void Save(IUnitOfWork uow, SaveRequest <TRow> request) { new SaveRequestHandler <TRow>().Process(uow, request); }
public SaveResponse Update(IUnitOfWork uow, SaveRequest<MyRow> request) { return new MyRepository().Update(uow, request); }
public SaveResponse Update(IUnitOfWork uow, SaveRequest <MyRow> request) { return(new MySaveHandler().Process(uow, request, SaveRequestType.Update)); }
public static jQueryXmlHttpRequest Update(SaveRequest<MeetingDecisionRow> request, Action<SaveResponse> onSuccess, ServiceCallOptions options = null) { return Q.ServiceRequest("Meeting/MeetingDecision/Update", request, onSuccess, options); }
// Update row request with fileList public static IRestResponse <SaveResponse> Update <MyRow>(string baseUrl, string resource, SaveRequest <MyRow> saveRequest, List <string> fileList, string cookieName) { #region Update Service Request IRestResponse <SaveResponse> response = new RestResponse <SaveResponse>(); if (InternetConnection.IsConnectedToInternet() == true) { try { var restClient = new RestClient(baseUrl); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/octet-stream"); request.AddHeader("Authorization", "Bearer " + VMMainModel.Instance.AuthToken); request.Resource = resource; request.AddJsonBody(saveRequest); request.RequestFormat = DataFormat.Json; fileList.ForEach(file => { request.AddFile("receipt[receipt_file]", File.ReadAllBytes(file), "Invoice.jpg", "application/octet-stream"); }); response = restClient.Execute <SaveResponse>(request); if (response.StatusCode == HttpStatusCode.OK && response.ResponseStatus == ResponseStatus.Completed) { var jsonResponse = JsonConvert.DeserializeObject <dynamic>(response.Content); response.Data.EntityId = (object)jsonResponse["EntityId"]; } } catch (Exception ex) { response.ErrorMessage = ex.Message; response.ErrorException = ex.InnerException; //MessageBox.Show(ex.Message); } return(response); } else { response.ErrorMessage = "Internet connection not available. Please check connection."; return(response); } #endregion }