public int Create(int companyId, Format_Create parseData) { try { JObject.Parse(parseData.MessageTemplate); } catch { throw new CDSException(10103); } using (CDStudioEntities dbEntity = new CDStudioEntities()) { Application newApplication = new Application() { Name = parseData.Name, Description = parseData.Description ?? "", CompanyId = companyId, MessageTemplate = parseData.MessageTemplate ?? "{}", TargetType = parseData.TargetType, Method = parseData.Method, ServiceURL = parseData.ServiceURL, AuthType = parseData.AuthType, AuthID = parseData.AuthID ?? "", AuthPW = parseData.AuthPW ?? "", TokenURL = parseData.TokenURL ?? "", HeaderValues = parseData.HeaderValues ?? "" }; dbEntity.Application.Add(newApplication); dbEntity.SaveChanges(); return(newApplication.Id); } }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { IoTHub newData = new IoTHub() { IoTHubName = parseData.IoTHubName, Description = parseData.Description ?? "", CompanyID = companyId, IoTHubEndPoint = parseData.IoTHubEndPoint ?? "", IoTHubConnectionString = parseData.IoTHubConnectionString ?? "", EventConsumerGroup = parseData.EventConsumerGroup ?? "", EventHubStorageConnectionString = parseData.EventHubStorageConnectionString ?? "", UploadContainer = parseData.UploadContainer ?? "", EnableMultipleReceiver = parseData.EnableMultipleReceiver }; dbEntity.IoTHub.Add(newData); try { dbEntity.SaveChanges(); } catch (DbUpdateException ex) { if (ex.InnerException.InnerException.Message.Contains("Cannot insert duplicate key")) { throw new CDSException(10905); } else { throw ex; } } return(newData.Id); } }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { UserRole newData = new UserRole(); newData.CompanyId = companyId; newData.Name = parseData.Name; try { dbEntity.UserRole.Add(newData); dbEntity.SaveChanges(); } catch { throw new CDSException(12104); } int userRoleId = newData.Id; if (parseData.PermissionCatalogCode != null) { UserRolePermissionModel model = new UserRolePermissionModel(); model.CreateManyByUserRoleId(userRoleId, parseData.PermissionCatalogCode); } return(newData.Id); } }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { MetaDataDefination newData = new MetaDataDefination() { CompanyId = companyId, EntityType = parseData.EntityType, ObjectName = parseData.ObjectName }; dbEntity.MetaDataDefination.Add(newData); try { dbEntity.SaveChanges(); } catch (DbUpdateException ex) { if (ex.InnerException.InnerException.Message.Contains("Cannot insert duplicate key")) { throw new CDSException(11902); } else { throw ex; } } return(newData.Id); } }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { SystemConfiguration newData = new SystemConfiguration() { Group = parseData.Group ?? "", Key = parseData.Key, Value = parseData.Value }; dbEntity.SystemConfiguration.Add(newData); try { dbEntity.SaveChanges(); } catch (DbUpdateException ex) { if (ex.InnerException.InnerException.Message.Contains("Cannot insert duplicate key")) { throw new CDSException(11902); } else { throw ex; } } return(newData.Id); } }
public int Create(Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { SubscriptionPlan newData = new SubscriptionPlan(); newData.Name = parseData.Name; newData.Description = parseData.Description ?? ""; newData.DefaultRatePer1KMessageIngestion = parseData.DefaultRatePer1KMessageIngestion ?? 0; newData.DefaultRatePer1KMessageHotStore = parseData.DefaultRatePer1KMessageHotStore ?? 0; newData.DefaultRatePer1KMessageColdStore = parseData.DefaultRatePer1KMessageColdStore ?? 0; newData.DefaultPlanDays = parseData.DefaultPlanDays; newData.DefaultMaxMessageQuotaPerDay = parseData.DefaultMaxMessageQuotaPerDay; newData.DefaultStoreHotMessage = parseData.DefaultStoreHotMessage ?? false; newData.DefaultStoreColdMessage = parseData.DefaultStoreColdMessage ?? false; newData.DefaultCosmosDBConnectionString = parseData.DefaultCosmosDBConnectionString ?? ""; newData.DefaultCollectionTTL = parseData.DefaultCollectionTTL ?? 86400; newData.DefaultCollectionReservedUnits = parseData.DefaultCollectionReservedUnits ?? 400; newData.DefaultIoTHubConnectionString = parseData.DefaultIoTHubConnectionString ?? ""; newData.DefaultStorageConnectionString = parseData.DefaultStorageConnectionString ?? ""; dbEntity.SubscriptionPlan.Add(newData); dbEntity.SaveChanges(); return(newData.Id); } }
public int Create(Format_Create dataModel) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { Company newCompany = new Company(); newCompany.Name = dataModel.Name; newCompany.ShortName = dataModel.ShortName ?? ""; newCompany.Address = dataModel.Address ?? ""; newCompany.CompanyWebSite = dataModel.CompanyWebSite ?? ""; newCompany.ContactName = dataModel.ContactName ?? ""; newCompany.ContactPhone = dataModel.ContactPhone ?? ""; newCompany.ContactEmail = dataModel.ContactEmail ?? ""; newCompany.Latitude = (float)dataModel.Latitude; newCompany.Longitude = (float)dataModel.Longitude; newCompany.CultureInfo = dataModel.CultureInfoId; newCompany.AllowDomain = dataModel.AllowDomain ?? ""; newCompany.ExtAppAuthenticationKey = dataModel.ExtAppAuthenticationKey ?? ""; newCompany.LogoURL = ""; newCompany.CreatedAt = DateTime.UtcNow; newCompany.DeletedFlag = false; dbEntity.Company.Add(newCompany); dbEntity.SaveChanges(); return(newCompany.Id); } }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { DeviceCommandCatalog newData = new DeviceCommandCatalog(); newData.CompanyId = companyId; newData.Name = parseData.Name; newData.Method = parseData.Method; newData.Content = parseData.Content ?? ""; dbEntity.DeviceCommandCatalog.Add(newData); try { dbEntity.SaveChanges(); } catch (DbUpdateException ex) { if (ex.InnerException.InnerException.Message.Contains("Cannot insert duplicate key")) { throw new CDSException(10404); } else { throw ex; } } return(newData.Id); } }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { CompanyInSubscriptionPlan newData = new CompanyInSubscriptionPlan(); newData.CompanyID = companyId; newData.SubscriptionPlanID = parseData.SubscriptionPlanId; newData.SubscriptionName = parseData.SubscriptionName ?? ""; newData.RatePer1KMessageIngestion = parseData.RatePer1KMessageIngestion; newData.RatePer1KMessageHotStore = parseData.RatePer1KMessageHotStore; newData.RatePer1KMessageColdStore = parseData.RatePer1KMessageColdStore; newData.StartDate = parseData.StartDate; newData.ExpiredDate = parseData.ExpiredDate; newData.MaxMessageQuotaPerDay = parseData.MaxMessageQuotaPerDay; newData.StoreHotMessage = parseData.StoreHotMessage; newData.StoreColdMessage = parseData.StoreColdMessage; newData.CosmosDBConnectionString = parseData.CosmosDBConnectionString ?? ""; newData.CosmosDBName = parseData.CosmosDBName; newData.CosmosDBCollectionID = parseData.CosmosDBColletionId; newData.CosmosDBCollectionTTL = parseData.CosmosDBCollectionTTL; newData.CosmosDBCollectionReservedUnits = parseData.CosmosDBCollectionReservedUnits; newData.IoTHubConnectionString = parseData.IoTHubConnectionString ?? ""; newData.IoTHubConsumerGroup = parseData.IoTHubConsumerGroup ?? ""; newData.StorageConnectionString = parseData.StorageConnectionString ?? ""; dbEntity.CompanyInSubscriptionPlan.Add(newData); dbEntity.SaveChanges(); return(newData.Id); } }
public int Create(int companyId, Format_Create parseData) { try { JObject.Parse(parseData.TaskContent); } catch { throw new CDSException(11501); } using (CDStudioEntities dbEntity = new CDStudioEntities()) { OperationTask newData = new OperationTask(); newData.CompanyId = companyId; newData.Name = parseData.Name; newData.TaskStatus = "Submit"; newData.Entity = parseData.Entity; newData.EntityId = parseData.EntityId; newData.TaskContent = parseData.TaskContent ?? "{}"; newData.RetryCounter = 0; newData.CreatedAt = DateTime.UtcNow; newData.DeletedFlag = false; dbEntity.OperationTask.Add(newData); dbEntity.SaveChanges(); return(newData.Id); } }
public int Create(int companyId, Format_Create parseData) { try { JObject.Parse(parseData.Content); } catch { throw new CDSException(12303); } using (CDStudioEntities dbEntity = new CDStudioEntities()) { WidgetCatalog newData = new WidgetCatalog(); newData.CompanyID = companyId; newData.MessageCatalogID = parseData.MessageCatalogId; newData.Name = parseData.Name; newData.Level = parseData.Level; newData.WidgetClassKey = parseData.WidgetClassKey; newData.Title = parseData.Title; newData.TitleBgColor = parseData.TitleBgColor ?? ""; newData.Content = parseData.Content; newData.ContentBgColor = parseData.ContentBgColor ?? ""; dbEntity.WidgetCatalog.Add(newData); dbEntity.SaveChanges(); return(newData.Id); } }
public int Create(int companyId, Format_Create parseData) { try { using (CDStudioEntities dbEntity = new CDStudioEntities()) { using (var dbEntityTransaction = dbEntity.Database.BeginTransaction()) { Equipment newData = new Equipment(); newData.EquipmentId = parseData.EquipmentId; newData.Name = parseData.Name; newData.EquipmentClassId = parseData.EquipmentClassId; newData.CompanyID = companyId; newData.FactoryId = parseData.FactoryId; newData.IoTDeviceID = parseData.IoTDeviceId; newData.Latitude = parseData.Latitude; newData.Longitude = parseData.Latitude; newData.MaxIdleInSec = parseData.MaxIdleInSec; newData.PhotoURL = ""; dbEntity.Equipment.Add(newData); dbEntity.SaveChanges(); /***** MetaData *****/ if (parseData.MetaData != null && parseData.MetaData.Count > 0) { List <MetaDataValue> metaDataValueList = new List <MetaDataValue>(); foreach (var data in parseData.MetaData) { metaDataValueList.Add(new MetaDataValue() { MetaDataDefinationId = data.DefinationId, ObjectValue = data.ObjectValue ?? "", ReferenceId = newData.Id }); } dbEntity.MetaDataValue.AddRange(metaDataValueList); } dbEntity.SaveChanges(); dbEntityTransaction.Commit(); return(newData.Id); } } } catch (DbUpdateException ex) { if (ex.InnerException.InnerException.Message.Contains("Cannot insert duplicate key")) { throw new CDSException(10503); } else { throw ex; } } }
public int Create(Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { DeviceType newDeviceType = new DeviceType(); newDeviceType.Name = parseData.Name; newDeviceType.Description = parseData.Description ?? ""; dbEntity.DeviceType.Add(newDeviceType); dbEntity.SaveChanges(); return(newDeviceType.Id); } }
public void Create(Format_Create parseModel) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { PermissionCatalog newData = new PermissionCatalog(); newData.Name = parseModel.Name; newData.Description = parseModel.Description ?? ""; newData.Code = parseModel.Code; dbEntity.PermissionCatalog.Add(newData); dbEntity.SaveChanges(); } }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { EquipmentClass newData = new EquipmentClass(); newData.CompanyId = companyId; newData.Name = parseData.Name; newData.Description = parseData.Description ?? ""; dbEntity.EquipmentClass.Add(newData); dbEntity.SaveChanges(); return(newData.Id); } }
public int Create(Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { IoTDeviceSystemConfiguration newData = new IoTDeviceSystemConfiguration(); newData.Name = parseData.Name; newData.DataType = parseData.DataType; newData.Description = parseData.Description ?? ""; newData.DefaultValue = parseData.DefaultValue ?? ""; dbEntity.IoTDeviceSystemConfiguration.Add(newData); dbEntity.SaveChanges(); return(newData.Id); } }
public int Create(Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { MessageMandatoryElementDef newData = new MessageMandatoryElementDef(); newData.ElementName = parseData.ElementName; newData.ElementDataType = parseData.ElementDataType; newData.Description = parseData.Description ?? ""; newData.MandatoryFlag = parseData.MandatoryFlag; dbEntity.MessageMandatoryElementDef.Add(newData); dbEntity.SaveChanges(); return(newData.Id); } }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { MessageCatalog newData = new MessageCatalog(); newData.CompanyID = companyId; newData.Name = parseData.Name; newData.Description = parseData.Description ?? ""; newData.MonitorFrequenceInMinSec = parseData.MonitorFrequenceInMinSec; newData.ChildMessageFlag = parseData.ChildMessageFlag; dbEntity.MessageCatalog.Add(newData); dbEntity.SaveChanges(); return(newData.Id); } }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { ExternalDashboard newData = new ExternalDashboard() { CompanyId = companyId, Name = parseData.Name, Ordering = parseData.Ordering, URL = parseData.URL }; dbEntity.ExternalDashboard.Add(newData); dbEntity.SaveChanges(); return(newData.Id); } }
public int Create(Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { WidgetClass newWidgetClass = new WidgetClass(); newWidgetClass.Name = parseData.Name; newWidgetClass.Key = parseData.Key; newWidgetClass.Level = parseData.Level; newWidgetClass.PhotoURL = parseData.PhotoURL ?? ""; newWidgetClass.AllowMultipleAppearOnBoard = parseData.AllowMultipleAppearOnBoard; dbEntity.WidgetClass.Add(newWidgetClass); dbEntity.SaveChanges(); return(newWidgetClass.Id); } }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { Dashboard newData = new Dashboard() { CompanyID = companyId, DashboardType = parseData.DashboardType, FactoryID = parseData.FactoryId, EquipmentClassID = parseData.EquipmentClassId, EquipmentID = parseData.EquipmentId }; dbEntity.Dashboard.Add(newData); dbEntity.SaveChanges(); return(newData.Id); } }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { EventRuleCatalog newData = new EventRuleCatalog(); newData.CompanyId = companyId; newData.MessageCatalogId = parseData.MessageCatalogId; newData.Name = parseData.Name; newData.Description = parseData.Description ?? ""; newData.AggregateInSec = parseData.AggregateInSec; newData.ActiveFlag = parseData.ActiveFlag; dbEntity.EventRuleCatalog.Add(newData); dbEntity.SaveChanges(); return(newData.Id); } }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { //Format_CDSDeviceTwinsProperty twinsProperty = new Format_CDSDeviceTwinsProperty(); //twinsProperty.CDS_CustomizedConfig = new JObject(); //twinsProperty.CDS_SystemConfig = new JObject(); IoTDevice newData = new IoTDevice() { CompanyID = companyId, IoTHubDeviceID = parseData.IoTHubDeviceId, IoTHubDevicePW = Crypto.HashPassword(parseData.IoTHubDevicePW), IoTHubDeviceKey = "", IoTHubID = parseData.IoTHubID, IoTHubProtocol = parseData.IoTHubProtocol ?? "", FactoryID = parseData.FactoryId, AuthenticationType = parseData.AuthenticationType ?? "", DeviceCertificateID = parseData.DeviceCertificateID, DeviceTypeId = parseData.DeviceTypeId, DeviceVendor = parseData.DeviceVendor ?? "", DeviceModel = parseData.DeviceModel ?? "", MessageConvertScript = parseData.MessageConvertScript ?? "", EnableMessageConvert = parseData.EnableMessageConvert, OriginMessage = parseData.OriginMessage ?? "" }; dbEntity.IoTDevice.Add(newData); try { dbEntity.SaveChanges(); } catch (DbUpdateException ex) { if (ex.InnerException.InnerException.Message.Contains("Cannot insert duplicate key")) { throw new CDSException(10904); } else { throw ex; } } return(newData.Id); } }
public int Create(Format_Create SuperAdmin) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { SuperAdmin newSuperAdmin = new SuperAdmin(); newSuperAdmin.FirstName = SuperAdmin.FirstName ?? ""; newSuperAdmin.LastName = SuperAdmin.LastName ?? ""; newSuperAdmin.Email = SuperAdmin.Email; newSuperAdmin.Password = Crypto.HashPassword(SuperAdmin.Password); newSuperAdmin.DeletedFlag = false; newSuperAdmin.CreatedAt = DateTime.UtcNow; dbEntity.SuperAdmin.Add(newSuperAdmin); dbEntity.SaveChanges(); return(newSuperAdmin.Id); } }
public int Create(Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { MessageElement newData = new MessageElement(); newData.MessageCatalogID = parseData.MessageCatalogId; newData.ElementName = parseData.ElementName; newData.ElementDataType = parseData.ElementDataType; newData.ChildMessageCatalogID = parseData.ChildMessageCatalogID; newData.MandatoryFlag = parseData.MandatoryFlag; newData.CDSMandatoryFlag = false; dbEntity.MessageElement.Add(newData); dbEntity.SaveChanges(); return(newData.Id); } }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { DeviceCertificate newData = new DeviceCertificate() { CompanyID = companyId, Name = parseData.Name, CertFile = parseData.CertFile ?? "", KeyFile = parseData.KeyFile ?? "", Thumbprint = parseData.Thumbprint, Password = parseData.Password, ExpiredAt = parseData.ExpiredAt }; dbEntity.DeviceCertificate.Add(newData); dbEntity.SaveChanges(); return(newData.Id); } }
public int Create(Format_Create dataModel) { APIServiceRefreshToken newAPIServiceRefreshToken = new APIServiceRefreshToken(); newAPIServiceRefreshToken.UserId = dataModel.UserId; newAPIServiceRefreshToken.ClientId = dataModel.ClientId; newAPIServiceRefreshToken.RefreshToken = dataModel.RefreshToken; newAPIServiceRefreshToken.IssuedAt = dataModel.IssusedAt; newAPIServiceRefreshToken.ExpiredAt = dataModel.ExpiredAt; newAPIServiceRefreshToken.ProtectedTicket = dataModel.ProtectedTicket; newAPIServiceRefreshToken.CreatedAt = DateTime.UtcNow; CDStudioEntities dbEntity = new CDStudioEntities(); dbEntity.APIServiceRefreshToken.Add(newAPIServiceRefreshToken); dbEntity.SaveChanges(); return(newAPIServiceRefreshToken.Id); }
public int Create(int companyId, Format_Create factory) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { Factory newFactory = new Factory() { Name = factory.Name, Description = factory.Description ?? "", CompanyId = companyId, Latitude = factory.Latitude, Longitude = factory.Longitude, PhotoURL = "", TimeZone = factory.TimeZone, CultureInfo = factory.CultureInfoId }; dbEntity.Factory.Add(newFactory); dbEntity.SaveChanges(); return(newFactory.Id); } }
public int Create(int companyId, Format_Create employee) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { Employee newEmployee = new Employee(); newEmployee.CompanyId = companyId; newEmployee.EmployeeNumber = employee.EmployeeNumber ?? ""; newEmployee.FirstName = employee.FirstName ?? ""; newEmployee.LastName = employee.LastName ?? ""; newEmployee.Email = employee.Email; newEmployee.PhotoURL = ""; newEmployee.Password = Crypto.HashPassword(employee.Password); newEmployee.AdminFlag = employee.AdminFlag; newEmployee.Lang = employee.Lang; dbEntity.Employee.Add(newEmployee); dbEntity.SaveChanges(); return(newEmployee.Id); } }