public IHttpActionResult PutBusiness(int id, BusinessDataModel business) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != business.BusinessID) { return(BadRequest()); } try { var objBusiness = db.Update(business); return(CreatedAtRoute("DefaultApi", new { id = business.BusinessID }, objBusiness)); } catch (DbUpdateConcurrencyException) { if (!BusinessExists(id)) { return(NotFound()); } else { throw; } } //return StatusCode(HttpStatusCode.NoContent); }
public BusinessDataModel Get(BusinessDTO modelDTO) { BusinessDataModel BusinessDataModel = null; if (modelDTO != null) { //List<BusinessAddressDTO> BusinessAddressDTO = (modelDTO.BusinessAddresses != null) ? modelDTO.BusinessAddresses.Select(p => p) : null; //AddressDTO oPrimaryAddressDTO = (BusinessAddressDTO != null) ? BusinessAddressDTO.Addres : null; List <AddressDTO> oPrimaryAddressDTO = (modelDTO.BusinessAddresses != null) ? modelDTO.BusinessAddresses.Where(p => p.BusinessID == modelDTO.BusinessID).Select(p => p.Addres).ToList() : null; List <ServiceDTO> servicesList = (modelDTO.Services != null) ? modelDTO.Services.Where(p => p.BusinessID == modelDTO.BusinessID).ToList() : null; List <AchievementDTO> oPrimaryAchievementDTO = (modelDTO.Achievements != null) ? modelDTO.Achievements.Where(p => p.BusinessID == modelDTO.BusinessID).Select(p => p).ToList() : null; BusinessPhoneDTO BusinessPhoneDTO = (modelDTO.BusinessPhones != null) ? modelDTO.BusinessPhones.Where(o => o.IsPrimary).FirstOrDefault() : null; PhoneDTO oPrimaryPhoneDTO = (BusinessPhoneDTO != null) ? BusinessPhoneDTO.Phone : null; //BusinessImageDTO BusinessImageDTO = (modelDTO.BusinessImages != null) ? modelDTO.BusinessImages.Where(o => o.IsPrimary).FirstOrDefault() : null; //ImageDTO oPrimaryImageDTO = (BusinessImageDTO != null) ? BusinessImageDTO.Image : null; ImageDTO oPrimaryImageDTO = (modelDTO.BusinessImages != null) ? modelDTO.BusinessImages.Where(o => o.IsPrimary).Select(p => p.Image).FirstOrDefault() : null; BusinessEmailDTO BusinessEmailDTO = (modelDTO.BusinessEmails != null) ? modelDTO.BusinessEmails.Where(o => o.IsPrimary).FirstOrDefault() : null; EmailDTO oPrimaryEmailDTO = (BusinessEmailDTO != null) ? BusinessEmailDTO.Email : null; BusinessDataModel = BusinessDataModelAssembler.ToDataModel(modelDTO, oPrimaryAddressDTO, oPrimaryPhoneDTO, oPrimaryEmailDTO, oPrimaryImageDTO, oPrimaryAchievementDTO, null, servicesList); BusinessDataModel.PrimaryAddressID = (modelDTO.BusinessAddresses != null) ? modelDTO.BusinessAddresses.FirstOrDefault(p => p.IsPrimary == true).AddressID : 0; //BusinessDataModel.BusinessAddressID = (BusinessAddressDTO != null) ? BusinessAddressDTO.BusinessAddressID : 0; BusinessDataModel.BusinessPhoneID = (BusinessPhoneDTO != null) ? BusinessPhoneDTO.BusinessPhoneID : 0; BusinessDataModel.BusinessEmailID = (BusinessEmailDTO != null) ? BusinessEmailDTO.BusinessEmailID : 0; } return(BusinessDataModel); }
public BusinessDataModel Get(int id) { BusinessDataModel businessDataModel = null; if (id > 0) { BusinessDTO businessDTO = businessBL.Get(id); if (businessDTO != null) { businessDataModel = Get(businessDTO); if (businessDataModel != null) { businessDataModel.BusinessServices = new ServiceBL().Get().Where(p => p.BusinessID == businessDataModel.BusinessID).ToList(); } var businessUsers = new BusinessUserMapBL().Get().Where(p => p.BusinessID == id && p.IsOwner == true).FirstOrDefault(); if (businessUsers != null) { businessDataModel.Owner = new UsersBL().Get(businessUsers.UserID); } } } return(businessDataModel); }
public BusinessDataModel Update(BusinessDataModel dataModel) { if (dataModel != null) { BusinessDTO businessDTO = new BusinessDTO(); List <AddressDTO> addressDTO = new List <AddressDTO>(); PhoneDTO phoneDTO = new PhoneDTO(); EmailDTO emailDTO = new EmailDTO(); BusinessUserMapDTO businessUserMapDTO = new BusinessUserMapDTO(); businessDTO = BusinessDataModelAssembler.ToBusinessDTO(dataModel); phoneDTO = BusinessDataModelAssembler.ToPhoneDTO(dataModel); emailDTO = BusinessDataModelAssembler.ToEmailDTO(dataModel); addressDTO = BusinessDataModelAssembler.ToAddressDTO(dataModel); businessUserMapDTO = BusinessDataModelAssembler.ToBusinessUserMapDTO(dataModel); if (businessDTO != null) { businessDTO = businessBL.Update(businessDTO); } dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); if (phoneDTO != null) { phoneDTO = phonesBL.Update(phoneDTO); } new BusinessPhoneBL().Update(new BusinessPhoneDTO() { BusinessID = dataModel.BusinessID, BusinessPhoneID = dataModel.BusinessPhoneID, IsPrimary = true }); dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); if (emailDTO != null) { emailDTO = emailsBL.Update(emailDTO); } new BusinessEmailBL().Update(new BusinessEmailDTO() { BusinessID = dataModel.BusinessID, BusinessEmailID = dataModel.BusinessEmailID, IsPrimary = true }); dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); if (addressDTO != null) { addressDTO = addressDTO.Select(p => addressBL.Update(p)).ToList(); } dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); new BusinessAddressBL().Update(new BusinessAddressDTO() { BusinessID = dataModel.BusinessID, BusinessAddressID = dataModel.BusinessAddressID, IsPrimary = true }); } return(dataModel); }
public static List <AddressDTO> ToAddressDTO(BusinessDataModel model) { List <AddressDTO> dto = new List <AddressDTO>(); if (model.Addresses != null) { dto = model.Addresses; } //if (model != null) //{ // dto.AddressTypeID = model.BusinessAddressAddressTypeID; // dto.City = model.BusinessAddressCity; // dto.CountryID = model.BusinessAddressCountryID; // dto.AddressID = model.BusinessAddressID; // dto.Line1 = model.BusinessAddressLine1; // dto.Line2 = model.BusinessAddressLine2; // dto.Line3 = model.BusinessAddressLine3; // dto.State = model.BusinessAddressState; // dto.Title = model.BusinessAddressTitle; // dto.ZipCode = model.BusinessAddressZipCode; //} return(dto); }
public IHttpActionResult PutBusiness(int id, BusinessDataModel business) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != business.BusinessID) { return(BadRequest()); } try { db.Update(business); } catch (DbUpdateConcurrencyException) { if (!BusinessExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public BusinessDataModel UpdateBusinessImage(BusinessDataModel dataModel) { if (dataModel != null) { ImageDTO imageDTO = new ImageDTO(); BusinessImageDTO businessImageDTO = new BusinessImageDTO(); imageDTO = BusinessDataModelAssembler.ToImageDTO(dataModel); businessImageDTO = BusinessDataModelAssembler.ToBusinessImageDTO(dataModel); if (CheckBusinessImageExist(dataModel.BusinessID)) { if (imageDTO != null) { imageDTO = imageBL.Update(imageDTO); } } else { if (imageDTO != null) { imageDTO = imageBL.Create(imageDTO); } if (businessImageDTO != null) { businessImageDTO.ImageID = imageDTO.ImageID; businessImageDTO = businessImageBL.Create(businessImageDTO); } } } return(dataModel); }
public IHttpActionResult GetBusiness(int id) { BusinessDataModel BusinessDataModel = db.Get(id); if (BusinessDataModel == null) { return(NotFound()); } return(Ok(BusinessDataModel)); }
public IHttpActionResult PostBusiness(BusinessDataModel business) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Create(business); return(CreatedAtRoute("DefaultApi", new { id = business.BusinessID }, business)); }
public IHttpActionResult GetBusiness(int id) { //BusinessDataModel BusinessDataModel = db.Get().FirstOrDefault(p => p.BusinessID == id); BusinessDataModel BusinessDataModel = db.Get(id); if (BusinessDataModel == null) { return(NotFound()); } return(Ok(BusinessDataModel)); }
public static BusinessUserMapDTO ToBusinessUserMapDTO(BusinessDataModel model) { BusinessUserMapDTO dto = new BusinessUserMapDTO(); if (model != null) { dto.BusinessUserMapID = model.BusinessUserId; dto.BusinessUserTypeID = model.BusinessUserMapTypeCodeId; } return(dto); }
public static EmailDTO ToEmailDTO(BusinessDataModel model) { EmailDTO dto = new EmailDTO(); if (model != null) { dto.Address = model.BusinessEmailAddress; dto.EmailID = model.BusinessEmailID; dto.EmailTypeID = model.BusinessEmailTypeID; } return(dto); }
public static BusinessImageDTO ToBusinessImageDTO(BusinessDataModel datamodel) { BusinessImageDTO dto = new BusinessImageDTO(); if (datamodel != null) { dto.ImageID = datamodel.ImageID; dto.BusinessImageID = datamodel.BusinessImageID; dto.BusinessID = datamodel.BusinessID; dto.IsPrimary = datamodel.BusinessImagePrimary; } return(dto); }
public static ImageDTO ToImageDTO(BusinessDataModel datamodel) { ImageDTO dto = new ImageDTO(); if (datamodel != null) { dto.ImageID = datamodel.ImageID; dto.Name = datamodel.ImageName; dto.ImageTypeID = datamodel.ImageTypeID; dto.ImageExtension = datamodel.ImageExtension; } return(dto); }
public static PhoneDTO ToPhoneDTO(BusinessDataModel model) { PhoneDTO dto = new PhoneDTO(); if (model != null) { dto.CountryID = model.BusinessPhoneCountryID; dto.Ext = model.BusinessPhoneExt; dto.PhoneID = model.BusinessPhoneID; dto.Number = model.BusinessPhoneNumber; dto.PhoneTypeID = model.BusinessPhoneTypeID; dto.AddressbookID = model.BusinessPhoneAddressbookID; } return(dto); }
public HttpResponseMessage PostFileBusiness() { foreach (string fileName in HttpContext.Current.Request.Files) { var file = HttpContext.Current.Request.Files[fileName]; var fname = Path.GetFileNameWithoutExtension(file.FileName); var Ext = Path.GetExtension(file.FileName); string FileName = System.IO.Path.GetFileName(file.FileName); if (file.FileName != "" || fileName != null) { var imgPath = HttpContext.Current.Server.MapPath("~/FileUpload/CompanyImage"); if (!Directory.Exists(imgPath)) { Directory.CreateDirectory(imgPath); } var _strbusinessid = HttpContext.Current.Request["businessID"].ToString(); int businessID = Convert.ToInt32(_strbusinessid); string physicalPath = imgPath + "\\" + businessID + Ext; if (System.IO.File.Exists(physicalPath)) { System.IO.File.Delete(physicalPath); } file.SaveAs(physicalPath); #region Entry in database BusinessDataModel newBusinessModel = new BusinessDataModel(); newBusinessModel.BusinessID = businessID; newBusinessModel.ImageName = file.FileName; newBusinessModel.ImageTypeID = Convert.ToInt32(HttpContext.Current.Request["imageTypeId"].ToString()); newBusinessModel.ImageExtension = Ext; newBusinessModel.BusinessImagePrimary = true; dbBusiness.UpdateBusinessImage(newBusinessModel); #endregion } } return(Request.CreateResponse(HttpStatusCode.OK)); }
public IHttpActionResult PostBusiness(BusinessDataModel business) { //business = new BusinessDataModel(); //business.Name = "AB solutions pVT LTD"; //business.Abbreviation = "Think Big"; //business.BusinessTypeID = 7; //business.IsActive = true; //business.IsDeleted = false; //business.BusinessUserMapTypeCodeId = 7; //business.BusinessUserId = 50; //business.Addresses.Add(new JobsInABA.BL.DTOs.AddressDTO() //{ // Title = "New Line", // Line1 = "New Line 1", // Line2 = "New Line 2 ", // Line3 = "New Line 3", // City = "Ahmedabad", // State = "Gujarat", // ZipCode = "360001", // AddressTypeID = 7 //}); //business.BusinessEmailAddress = "*****@*****.**"; //business.BusinessEmailTypeID = 7; //business.BusinessPhoneNumber = "8866000000"; //business.BusinessPhoneExt = "+91"; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var objBusiness = db.Create(business); return(CreatedAtRoute("DefaultApi", new { id = business.BusinessID }, objBusiness)); }
public static BusinessDTO ToBusinessDTO(BusinessDataModel datamodel) { BusinessDTO dto = new BusinessDTO(); if (datamodel != null) { dto.Abbreviation = datamodel.Abbreviation; dto.BusinessID = datamodel.BusinessID; dto.BusinessTypeID = datamodel.BusinessTypeID; dto.insdt = datamodel.insdt; dto.insuser = datamodel.insuser; dto.IsActive = datamodel.IsActive; dto.IsDeleted = datamodel.IsDeleted; dto.Name = datamodel.Name; dto.StartDate = datamodel.StartDate; dto.upddt = datamodel.upddt; dto.upduser = datamodel.upduser; dto.Description = datamodel.Description; } return(dto); }
private void AddBusinessData(DBreeze.Transactions.Transaction t, BusinessDataModel _model) { t.Insert <string, string>(_model.tableName, _model.key, _model.content); }
public static BusinessDataModel ToDataModel(BusinessDTO BusinessDTO, List <AddressDTO> primaryAddressDTO, PhoneDTO primaryPhoneDTO, EmailDTO primaryEmailDTO, ImageDTO ImageDTO, List <AchievementDTO> primaryAchievementDTO , BusinessUserMapDTO businessUserMapDTO, List <ServiceDTO> primaryServiceDTO) { BusinessDataModel model = new BusinessDataModel(); if (model != null) { model.Abbreviation = BusinessDTO.Abbreviation; model.BusinessID = BusinessDTO.BusinessID; model.BusinessTypeID = BusinessDTO.BusinessTypeID; model.insdt = BusinessDTO.insdt; model.insuser = BusinessDTO.insuser; model.IsActive = BusinessDTO.IsActive; model.IsDeleted = BusinessDTO.IsDeleted; model.Name = BusinessDTO.Name; model.StartDate = BusinessDTO.StartDate; model.upddt = BusinessDTO.upddt; model.upduser = BusinessDTO.upduser; model.Description = BusinessDTO.Description; } if (businessUserMapDTO != null) { model.BusinessUserId = businessUserMapDTO.BusinessUserMapID; model.BusinessUserMapTypeCodeId = businessUserMapDTO.BusinessUserTypeID ?? 0; } model.Addresses = new List <AddressDTO>(); if (primaryAddressDTO != null) { foreach (var item in primaryAddressDTO) { if (item != null) { AddressDTO addressDTO = new AddressDTO(); addressDTO.AddressID = item.AddressID; addressDTO.AddressTypeID = item.AddressTypeID; addressDTO.City = item.City; addressDTO.CountryID = item.CountryID; addressDTO.AddressID = item.AddressID; addressDTO.Line1 = item.Line1; addressDTO.Line2 = item.Line2; addressDTO.Line3 = item.Line3; addressDTO.State = item.State; addressDTO.Title = item.Title; addressDTO.ZipCode = item.ZipCode; model.Addresses.Add(addressDTO); } } } model.Achievement = new List <AchievementDTO>(); if (primaryAchievementDTO != null) { foreach (var item in primaryAchievementDTO) { if (item != null) { AchievementDTO achievementDTO = new AchievementDTO(); achievementDTO.AchievementID = item.AchievementID; achievementDTO.Date = item.Date; achievementDTO.Name = item.Name; model.Achievement.Add(achievementDTO); } } } model.Service = new List <ServiceDTO>(); if (primaryServiceDTO != null) { foreach (var item in primaryServiceDTO) { if (item != null) { ServiceDTO serviceDTO = new ServiceDTO(); serviceDTO.ServiceID = item.ServiceID; serviceDTO.BusinessID = item.BusinessID; serviceDTO.Name = item.Name; model.Service.Add(serviceDTO); } } } if (primaryPhoneDTO != null) { model.BusinessPhoneCountryID = primaryPhoneDTO.CountryID; model.BusinessPhoneExt = primaryPhoneDTO.Ext; model.BusinessPhoneID = primaryPhoneDTO.PhoneID; model.BusinessPhoneNumber = primaryPhoneDTO.Number; model.BusinessPhoneTypeID = primaryPhoneDTO.PhoneTypeID; model.BusinessPhoneAddressbookID = primaryPhoneDTO.AddressbookID; } if (primaryEmailDTO != null) { model.BusinessEmailAddress = primaryEmailDTO.Address; model.BusinessEmailID = primaryEmailDTO.EmailID; model.BusinessEmailTypeID = primaryEmailDTO.EmailTypeID; } if (ImageDTO != null) { model.BusinessImageID = ImageDTO.ImageID; model.ImageExtension = ImageDTO.ImageExtension; model.ImageName = ImageDTO.Name; } return(model); }
/// <summary> /// /// </summary> /// <param name="dataLogModel"></param> /// <param name="businessDataModel"></param> /// <returns></returns> public RatelHttpResponses Del_BusinessData_DataLog(DataLogModel dataLogModel, BusinessDataModel businessDataModel) { var response = new RatelHttpResponses(); dataLogModel.Data = businessDataModel.SerializeProtobuf(); using (var t = Datalog.dbEngine.GetTransaction()) { t.Insert(Datalog._Ratel_log, dataLogModel.Id, dataLogModel); t.RemoveKey <string>(businessDataModel.tableName, businessDataModel.key, out bool removed); t.Commit(); } //var _Node = ClustersNode.node.Where(x => x.Value.ConnectionStatus == true // && x.Value.me == false // && x.Value.master == true // && x.Value.channel != null); //foreach (var item in _Node) //{ // var node_item = item.Value; // try // { // var data = new RatelMessagePack() // { // command = Command.RequestCommand_DataLog, // Data = null, // }; // var _byte = data.SerializeProtobuf(); // var _unpooled = Unpooled.WrappedBuffer(_byte); // node_item.channel.WriteAndFlushAsync(_unpooled); // } // catch (Exception ex) { } //} return(response); }
private void DeleteBusinessData(DBreeze.Transactions.Transaction t, BusinessDataModel businessDataModel) { t.RemoveKey <string>(businessDataModel.tableName, businessDataModel.key, out bool wasremoved); }
public BusinessDataModel Create(BusinessDataModel dataModel) { if (dataModel != null) { BusinessDTO businessDTO = new BusinessDTO(); List <AddressDTO> addressDTO = new List <AddressDTO>(); PhoneDTO phoneDTO = new PhoneDTO(); EmailDTO emailDTO = new EmailDTO(); BusinessUserMapDTO businessUserMapDTO = new BusinessUserMapDTO(); businessDTO = BusinessDataModelAssembler.ToBusinessDTO(dataModel); phoneDTO = BusinessDataModelAssembler.ToPhoneDTO(dataModel); emailDTO = BusinessDataModelAssembler.ToEmailDTO(dataModel); addressDTO = BusinessDataModelAssembler.ToAddressDTO(dataModel); businessUserMapDTO = BusinessDataModelAssembler.ToBusinessUserMapDTO(dataModel); if (businessDTO != null) { businessDTO = businessBL.Create(businessDTO); } dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); if (dataModel.BusinessUserId != 0) { new BusinessUserMapBL().Create(new BusinessUserMapDTO() { BusinessID = dataModel.BusinessID, UserID = dataModel.BusinessUserId, BusinessUserTypeID = dataModel.BusinessUserMapTypeCodeId, IsOwner = true }); } addressDTO = BusinessDataModelAssembler.ToAddressDTO(dataModel); if (addressDTO != null) { List <AddressDTO> addressList = new List <AddressDTO>(); //addressDTO = addressDTO.Select(p => addressBL.Create(p)).ToList(); foreach (var item in addressDTO) { addressList.Add(addressBL.Create(item)); } addressDTO = addressList; } dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); if (dataModel.Addresses.Count() != 0) { new BusinessAddressBL().Create(new BusinessAddressDTO() { BusinessID = dataModel.BusinessID, AddressID = dataModel.Addresses.FirstOrDefault().AddressID, IsPrimary = true }); } if (addressDTO.Count != 0) { phoneDTO = BusinessDataModelAssembler.ToPhoneDTO(dataModel); if (phoneDTO != null) { phoneDTO.AddressbookID = addressDTO.FirstOrDefault().AddressID; phoneDTO = phonesBL.Create(phoneDTO); } dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); new BusinessPhoneBL().Create(new BusinessPhoneDTO() { BusinessID = dataModel.BusinessID, PhoneID = dataModel.BusinessPhoneID, IsPrimary = true }); } dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); emailDTO = BusinessDataModelAssembler.ToEmailDTO(dataModel); if (emailDTO != null) { emailDTO = emailsBL.Create(emailDTO); } dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); new BusinessEmailBL().Create(new BusinessEmailDTO() { BusinessID = dataModel.BusinessID, EmailID = dataModel.BusinessEmailID, IsPrimary = true }); dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); } return(dataModel); }
public async Task Invoke(HttpContext context) { var _httpRequest = context.Request; var _js = _httpRequest.Path.Value; if (_httpRequest.Path.HasValue) { var _js1 = _js.Replace("/", ""); var _find_js = _File_JS.Where(x => x.ToString() == _js1).FirstOrDefault(); if (_find_js != null) { var stream = OpenFile(_find_js); var content = ""; if (stream == null) { await context.Response.WriteAsync(content); return; } using (stream) { content = new StreamReader(stream).ReadToEnd(); } //context.Response.ContentType = "text/html"; await context.Response.WriteAsync(content); return; } } if (_httpRequest.Path == "/") { var stream = OpenFile("index.html"); var content = ""; using (stream) { content = new StreamReader(stream).ReadToEnd(); } context.Response.ContentType = "text/html"; await context.Response.WriteAsync(content); return; } var _web = Ratel.YamlConfig.ServerConfSetting.serverSettingModel.Web; string _token = MD5Hash(_web.loginUser + "," + _web.passWord + Ratel.YamlConfig.ServerConfSetting.serverSettingModel.Key); if (_httpRequest.Path == "/login" && _httpRequest.Method.ToUpper() == "POST") { try { var _login = Json_Convert <InputLoginModel>(_httpRequest.Body); if (_login.userName == _web.loginUser && _login.password == _web.passWord) { var _long_res = new { token = _token, username = _web.loginUser, email = "", avatar = "" }; await WriteJson(context, new Output(_long_res)); } } catch (Exception ex) { } return; } //get if (_httpRequest.Path == "/getConf" && _httpRequest.Method.ToUpper() == "GET") { try { var _web_key = _httpRequest.Headers["confkey"].ToString(); if (_web_key.ToUpper() != YamlConfig.ServerConfSetting.serverSettingModel.Key.ToUpper()) { await WriteJson(context, new Output("webkey error", "error")); return; } string _table = _httpRequest.Query["businesstype"].ToString(); string _key = _httpRequest.Query["key"].ToString(); if (string.IsNullOrEmpty(_table)) { await WriteJson(context, new Output("businesstype null", "error")); return; } if (string.IsNullOrEmpty(_key)) { await WriteJson(context, new Output("key null", "error")); return; } var _proxy = ProxyFactory.CreateProxy <ICommand>(); var _value = await _proxy.GetConf(_table, _key); if (string.IsNullOrEmpty(_value)) { await WriteJson(context, new Output("value null", "error")); return; } await WriteJson(context, new Output(_value)); return; } catch (Exception ex) { await WriteJson(context, new Output("", "error")); return; } } //get heartbeat if (_httpRequest.Path == "/heartbeat" && _httpRequest.Method.ToUpper() == "GET") { var _web_key = _httpRequest.Headers["confkey"].ToString(); if (_web_key.ToUpper() != YamlConfig.ServerConfSetting.serverSettingModel.Key.ToUpper()) { await WriteJson(context, new Output("webkey error", "error")); return; } await WriteJson(context, "ok"); return; } //Headers token var _headers_token = _httpRequest.Headers["token"].ToString().ToUpper(); if (string.IsNullOrEmpty(_headers_token)) { await WriteJson(context, new Output("token null!", "error")); return; } if (_headers_token != _token) { await WriteJson(context, new Output("token error!", "error")); return; } if (_httpRequest.Path == "/iplist") { int pi = 0; int ps = 3; if (_httpRequest.QueryString.HasValue) { int.TryParse(_httpRequest.Query["pi"].ToString(), out pi); int.TryParse(_httpRequest.Query["ps"].ToString(), out ps); } var _node = Ratel.Node.ClustersNode.node.Select(x => x.Value) .OrderByDescending(x => x.host).Skip((pi - 1) * ps).Take(ps).ToList(); var _outResponse = new OutResponse <List <Ratel.Node.ClustersNodeSetting> >(); _outResponse.total = Ratel.Node.ClustersNode.node.Count; foreach (var item in _node) { _outResponse.list.Add(new Ratel.Node.ClustersNodeSetting() { channel = null, ConnectionStatus = item.ConnectionStatus, host = item.host, master = item.master, me = item.me }); } await WriteJson(context, _outResponse); return; } if (_httpRequest.Path == "/addip") { IPClustersModel _IPClustersModel = new IPClustersModel();; try { _IPClustersModel = Json_Convert <IPClustersModel>(_httpRequest.Body); var ipaddress = _IPClustersModel.key.Split(':'); var ip = new IPEndPoint(IPAddress.Parse(ipaddress[0]), int.Parse(ipaddress[1])); } catch (Exception ex) { await WriteJson(context, new Output("错误信息:" + ex.Message, "error")); return; } var model = new Ratel.RatelDBreeze.IPClustersModel() { Content = _IPClustersModel.key, key = "", TableName = "", Master = _IPClustersModel.Master }; var add_data = new Ratel.RatelDBreeze.DataLogModel() { Data = new byte[0], OperationType = OperationCommandType.IPAddress, TableName = "", }; var _proxy = ProxyFactory.CreateProxy <ICommand>(); var res = _proxy.Add_IP_DataLog(add_data, model); await WriteJson(context, new Output(res.message)); return; } if (_httpRequest.Path == "/delip") { var _IPClustersModel = Json_Convert <IPClustersModel>(_httpRequest.Body); Ratel.Node.ClustersNode.RemoveNodeDic(_IPClustersModel.key); var model = new Ratel.RatelDBreeze.IPClustersModel() { Content = _IPClustersModel.key, key = "", TableName = "", }; var add_data = new Ratel.RatelDBreeze.DataLogModel() { Data = new byte[0], OperationType = OperationCommandType.DelIPAddress, TableName = "", }; var _proxy = ProxyFactory.CreateProxy <ICommand>(); _proxy.Del_IP_DataLog(add_data, model); await WriteJson(context, new Output("删除成功!")); return; } if (_httpRequest.Path == "/getBusiness") { int.TryParse(_httpRequest.Query["pageIndex"].ToString(), out int pageIndex); var _proxy = ProxyFactory.CreateProxy <ICommand>(); var _list = _proxy.GetList(pageIndex); await WriteJson(context, new Output(_list)); return; } if (_httpRequest.Path == "/addBusiness") { var _model = new Ratel.RatelDBreeze.BusinessTypeModel(); try { _model = Json_Convert <BusinessTypeModel>(_httpRequest.Body); if (string.IsNullOrEmpty(_model.key)) { await WriteJson(context, new Output("业务类型不能为空!", "error")); return; } } catch (Exception ex) { await WriteJson(context, new Output("错误信息:" + ex.Message, "error")); return; } var add_data = new Ratel.RatelDBreeze.DataLogModel() { Data = new byte[0], OperationType = OperationCommandType.BusinessType, TableName = "", }; var _proxy = ProxyFactory.CreateProxy <ICommand>(); var response = _proxy.Add_BusinessType_DataLog(add_data, _model); await WriteJson(context, new Output("操作成功!")); return; } if (_httpRequest.Path == "/delBusiness") { BusinessTypeModel _model = new BusinessTypeModel(); try { _model = Json_Convert <BusinessTypeModel>(_httpRequest.Body); } catch (Exception ex) { await WriteJson(context, new Output("错误信息:" + ex.Message, "error")); return; } var add_data = new Ratel.RatelDBreeze.DataLogModel() { Data = new byte[0], OperationType = OperationCommandType.DelBusinessType, TableName = "", }; var _proxy = ProxyFactory.CreateProxy <ICommand>(); var response = _proxy.Del_BusinessType_DataLog(add_data, _model); await WriteJson(context, new Output("操作成功!")); return; } if (_httpRequest.Path == "/getBusinessData") { var _proxy = ProxyFactory.CreateProxy <ICommand>(); string _key = _httpRequest.Query["key"].ToString(); int.TryParse(_httpRequest.Query["pageIndex"].ToString(), out int pageIndex); var _list = _proxy.GetListData(_key, pageIndex); await WriteJson(context, new Output(_list)); return; } if (_httpRequest.Path == "/addBusinessData") { BusinessDataModel _model = new BusinessDataModel(); try { _model = Json_Convert <BusinessDataModel>(_httpRequest.Body); if (string.IsNullOrEmpty(_model.tableName)) { await WriteJson(context, new Output("业务类型不能为空!", "error")); return; } if (string.IsNullOrEmpty(_model.key)) { await WriteJson(context, new Output("key 不能为空!", "error")); return; } if (string.IsNullOrEmpty(_model.content)) { await WriteJson(context, new Output("value 不能为空!", "error")); return; } } catch (Exception ex) { await WriteJson(context, new Output("错误信息:" + ex.Message, "error")); return; } var add_data = new Ratel.RatelDBreeze.DataLogModel() { Data = new byte[0], OperationType = OperationCommandType.BusinessData, TableName = "", }; var _proxy = ProxyFactory.CreateProxy <ICommand>(); var response = _proxy.Add_BusinessData_DataLog(add_data, _model); await WriteJson(context, new Output("操作成功!")); return; } if (_httpRequest.Path == "/delBusinessData") { BusinessDataModel _model = new BusinessDataModel(); try { _model = Json_Convert <BusinessDataModel>(_httpRequest.Body); } catch (Exception ex) { await WriteJson(context, new Output("错误信息:" + ex.Message, "error")); return; } var add_data = new Ratel.RatelDBreeze.DataLogModel() { Data = new byte[0], OperationType = OperationCommandType.DelBusinessData, TableName = "", }; var _proxy = ProxyFactory.CreateProxy <ICommand>(); var response = _proxy.Del_BusinessData_DataLog(add_data, _model); await WriteJson(context, new Output("操作成功!")); return; } if (_httpRequest.Path == "/App") { var _out_put = new Output(new App { project = new Project() { name = "ng-alain" }, menu = new List <Menu>() { new Menu() { text = "Dashboard", group = true, children = new List <Menu>() { new Menu() { text = "业务列表", link = "/dashboard", icon = "anticon anticon-appstore-o" }, } }, new Menu() { text = "集群", group = true, children = new List <Menu>() { new Menu() { text = "列表", icon = "anticon anticon-skin", link = "/clusters/list" } } } }, user = new User() { id = 1, name = _web.loginUser } }); await WriteJson(context, _out_put); return; } await this._next(context); }