public async Task <IActionResult> UpdateCeltaBS(ModelCustomerProduct customersettings) { try { string message; var _customerSettings = _repository.Get() .Include(c => c.Customer) .Include(p => p.Product) .Where(x => x.CustomersProductsId == customersettings.CustomersProductsId).First(); if (_customerSettings != null) { message = await Update(_customerSettings); return(Ok(message)); //if (await Update(_customerSettings)) //{ // return Ok(); //} //else //{ // return NotFound("Erro ao atualizar"); //} } else { return(NotFound("Cliente não encontrado")); } } catch (Exception err) { return(NotFound(err.Message)); } }
public async Task <IActionResult> AddUpdate(ModelCustomerProduct _customerProduct) { try { ModelCustomerProduct newCustomerProduct = await _repository.FindAsynch(_customerProduct.CustomersProductsId); if (newCustomerProduct == null) { await _repository.AddAsynch(_customerProduct); return(Ok(_customerProduct.CustomersProductsId)); } else { newCustomerProduct.AddressName = _customerProduct.AddressName; newCustomerProduct.ProductId = _customerProduct.ProductId; newCustomerProduct.ServersId = _customerProduct.ServersId; await _repository.UpdateAsynch(newCustomerProduct); return(Ok(_customerProduct.CustomersProductsId)); } } catch (Exception err) { if (err.InnerException == null) { return(BadRequest(err.Message + "\n" + err.InnerException.Message)); } return(BadRequest(err.Message)); } }
public async Task <string> Update(ModelCustomerProduct customerProduct) { string message = " "; try { if (ValidateFile(customerProduct.Customer.RootDirectory)) { switch (customerProduct.Product.ProductId) { case 1: Copy(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\temp\CIP\Release\BSF\", @"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory, true); SystemUpdateHelpers.MarkVersionFile(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory + @"\version.txt"); message += await SystemUpdateHelpers.UpdateBsfFull(customerProduct); break; case 2: Copy(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\temp\CCS\Release\WebService\", @"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory, true); SystemUpdateHelpers.MarkVersionFile(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory + @"\version.txt"); break; case 3: Copy(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\temp\CSS\Release\webservice\", @"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory, true); SystemUpdateHelpers.MarkVersionFile(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory + @"\version.txt"); break; case 4: Copy(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\temp\ReleaseConcentrador\Release\", @"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory, true); SystemUpdateHelpers.MarkVersionFile(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory + @"\version.txt"); break; case 5: if (StopSynchronizerService(customerProduct.SynchronizerServiceName)) { System.Threading.Thread.Sleep(9 * 1000); Copy(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\temp\CSS\Release\WindowsService\", @"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory, true); SystemUpdateHelpers.MarkVersionFile(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory + @"\version.txt"); StartSynchronizerService(customerProduct.SynchronizerServiceName); } break; } return(message); } else { return("Erro ao validar Arquivo Deployment."); } } catch (Exception err) { return(err.Message); } }
public async static void GenerateConnectionString(ModelCustomerProduct customerProduct, string celtaBSUserPassword) { string path = $"C:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\BSF\\Bin\\"; string command = "CeltaWare.CBS.CAT.GenerateConnectionString.exe "; string args = $" server={customerProduct.IpAddress},{customerProduct.Port};database={customerProduct.SynchronizerServiceName};uid=CeltaBSUser;pwd={celtaBSUserPassword} server=192.168.1.6,9980;database=CeltaBSCep;uid=sa;pwd=Celta@123 server={customerProduct.IpAddress},{customerProduct.Port};database={customerProduct.SynchronizerServiceName};uid={customerProduct.LoginUser}pwd={customerProduct.LoginPassword}"; await ServicesCeltaWare.Tools.CommandWin32.Execute(path, command, args); // 2 - Copiar CeltaWare.CBS.Common.dll.config para diretórios ccs e windowsService*/ string file = $"C:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\BSF\\Bin\\CeltaWare.CBS.Common.dll.config"; string destination = $"C:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\CCS\\bin\\CeltaWare.CBS.Common.dll.config"; ServicesCeltaWare.Tools.CommandWin32.Copy(file, destination, true); destination = $"C:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\CSS\\WindowsService\\CeltaWare.CBS.Common.dll.config"; ServicesCeltaWare.Tools.CommandWin32.Copy(file, destination, true); }
public async Task <IActionResult> Add(ModelCustomerProduct _customerProduct) { try { _repository.Add(_customerProduct); var customerProductId = _customerProduct.CustomersProductsId; return(Ok(customerProductId)); } catch (Exception err) { if (err.InnerException != null) { return(BadRequest(err.Message + "\n" + err.InnerException.Message)); } return(BadRequest(err.Message)); } }
private DateTime VersionFile(ModelCustomerProduct customerProduct) { try { int value = customerProduct.ProductId; FileInfo file = null; switch (value) { case (1): file = new FileInfo(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory + @"\bin\CeltaWare.CBS.CIP.BSF.Model.dll"); break; case (2): file = new FileInfo(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory + @"\bin\CeltaWare.CBS.CIP.BSF.Model.dll"); break; case (3): file = new FileInfo(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory + @"\bin\CeltaWare.CBS.CIP.BSF.Model.dll"); break; case (4): file = new FileInfo(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory + @"\bin\CeltaWare.CBS.PDV.Concentrator.BLL.dll"); break; case (5): file = new FileInfo(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory + @"\CeltaWare.CBS.CIP.BSF.Model.dll"); break; } // FileInfo file = new FileInfo(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory + @"\version.txt"); if (file.Exists) { return(file.LastWriteTime); } else { return(DateTime.MinValue); } } catch (Exception) { return(DateTime.MinValue); } }
public async static Task <bool> Create(ModelCustomerProduct customerProduct) { try { // 1- Executar GenerateKeys.exe string path = $"C:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\BSF\\Bin\\"; string command = "CeltaWare.CBS.CAT.GenerateKeys.exe"; string args = " "; await ServicesCeltaWare.Tools.CommandWin32.Execute(path, command, args); // 2- Copiar as chaves para diretórios ccs e windowsService e updateVersion string file = $"C:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\BSF\\Bin\\CeltaPublic.csk"; string destination = $"C:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\CCS\\bin\\CeltaPublic.csk"; ServicesCeltaWare.Tools.CommandWin32.Copy(file, destination, true); //CeltaPrivate.csk file = $"C:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\BSF\\Bin\\CeltaPrivate.csk"; destination = $"C:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\CCS\\bin\\CeltaPrivate.csk"; ServicesCeltaWare.Tools.CommandWin32.Copy(file, destination, true); //CeltaPublic.csk file = $"C:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\BSF\\Bin\\CeltaPublic.csk"; destination = $"C:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\CSS\\WindowsService\\CeltaPublic.csk"; ServicesCeltaWare.Tools.CommandWin32.Copy(file, destination, true); //CeltaPublic.csk // 3 - Executar ResetPassword.exe <DBSERVERNAME> <DATABASENAME> <DBUSERNAME> <DBUSERPASSWORD> <PRIVATEKEY> <PUBLICKEY> command = "CeltaWare.CBS.CAT.ResetPasswords.exe "; args = $" {customerProduct.IpAddress},{customerProduct.Port} {customerProduct.SynchronizerServiceName} {customerProduct.LoginUser} {customerProduct.LoginPassword} CeltaPrivate.csk CeltaPublic.csk"; await ServicesCeltaWare.Tools.CommandWin32.Execute(path, command, args); // 4 - Executar ChangeAdminpassword.exe - <DBSERVERNAME> <DATABASENAME> <DBUSERNAME> <DBUSERPASSWORD> <ADMINNEWPASSWORD> <PUBLICKEY> command = "CeltaWare.CBS.CAT.ChangeAdminPassword.exe "; args = $" {customerProduct.IpAddress},{customerProduct.Port} {customerProduct.SynchronizerServiceName} {customerProduct.LoginUser} {customerProduct.LoginPassword} CeltaBusinessSolutions+=123 CeltaPublic.csk "; await ServicesCeltaWare.Tools.CommandWin32.Execute(path, command, args); // 5 - Executar GenerateEventLogCategorys.exe command = "CeltaWare.CBS.CAT.GenerateEventLogCategorys.exe"; args = " "; await ServicesCeltaWare.Tools.CommandWin32.Execute(path, command, args); return(true); } catch (Exception err) { throw err; } }
private DateTime LastExecution(ModelCustomerProduct customerProduct) { try { FileInfo file = new FileInfo(@"c:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory + @"\version.txt"); if (file.Exists) { return(file.LastWriteTime); } else { return(DateTime.MinValue); } } catch (Exception) { return(DateTime.MinValue); } }
public async Task <IActionResult> CreateCustomerProduct(ModelCustomerProduct _customerProduct) { try { var customerProduct = _repository.Get() .Include(c => c.Customer) .Include(s => s.Server) .Where(cp => cp.CustomersProductsId == _customerProduct.CustomersProductsId) .First(); ProductName product = ProductName.BSF; switch (_customerProduct.ProductId) { case 1: product = ProductName.BSF; break; case 2: product = ProductName.CCS; break; case 3: product = ProductName.CSS; break; case 4: product = ProductName.Concentrador; break; case 5: product = ProductName.SynchronizerService; break; case 6: product = ProductName.Database; break; case 7: product = ProductName.CertificadoA1; break; } string message = await CustomerProductHelpers.CreateProducts(product, customerProduct); if (message.Contains("ERROR")) { return(NotFound(message)); } return(Ok()); } catch (Exception err) { //return BadRequest(err.Message); throw err; } }
public async static Task <string> UpdateBsfFull(ModelCustomerProduct customerProduct) { try { string message = await GenerateConfig(customerProduct.Customer.RootDirectory); message += await DeleteConfigSection(customerProduct.Customer.RootDirectory); message += await InsertConfigInSection(customerProduct.Customer.RootDirectory); message += await ExecuteCatUpdateVersionPackage(customerProduct.Customer.RootDirectory); message += await GenerateClient(customerProduct); return(message); } catch (Exception err) { return(err.Message); } }
private async static Task <bool> GenerateClient(ModelCustomerProduct customerProduct) { //copy celtapublic to UpdatedVersion string source = $"c:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\BSF\\Bin\\CeltaPublic.csk"; string destination = $"c:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\BSF\\Bin\\UpdatedVersion\\CeltaPublic.csk"; await ServicesCeltaWare.Tools.CommandWin32.Copy(source, destination, true); //copy updatedVersion to Client source = $"c:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\BSF\\Bin\\UpdatedVersion"; destination = $"c:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\Client"; await ServicesCeltaWare.Tools.CommandWin32.Copy(source, destination, true, false); //CompactFile source = $"c:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\Client"; destination = $"c:\\Celta Business Solutions\\{customerProduct.Customer.RootDirectory}\\BSF\\ClientFiles\\celtabsclient.zip"; await ServicesCeltaWare.Tools.CommandWin32.Compress(source, destination); ////Copy celtabsclient.zip to clientfiles return(true); }
public async static Task <string> CreateProducts(ProductName productName, ModelCustomerProduct customerProduct) { try //ServicesCeltaWare.Tools.CommandWin32.WriteLog(err.Message); { string msgCreateSite = null; string directory = @"C:\Celta Business Solutions\" + customerProduct.Customer.RootDirectory + @"\" + customerProduct.InstallDirectory; DirectoryInfo dir = new DirectoryInfo(directory); switch (productName) { case ProductName.BSF: { if (!dir.Exists) { await ServicesCeltaWare.Tools.CommandWin32.Copy(@"c:\Celta Business Solutions\Empty\BSF", dir.ToString(), true, true); } msgCreateSite = await ServicesCeltaWare.Tools.CommandWin32.Execute(@"C:\Windows\System32\inetsrv\", "appcmd.exe", // /physicalPath:" + "\"" + DefaultDir + " \"" + $" add app /site.name:{customerProduct.Customer.RootDirectory}-CeltaBS /path:/{customerProduct.InstallDirectory} /physicalPath:" + "\"" + dir + "\""); ChangeDefaultHtm(customerProduct.Customer.RootDirectory, customerProduct.Port, ServicesCeltaWare.Model.Enum.ProductName.BSF); break; } case ProductName.CCS: { if (!dir.Exists) { await ServicesCeltaWare.Tools.CommandWin32.Copy(@"c:\Celta Business Solutions\Empty\CCS", dir.ToString(), true, true); } msgCreateSite = await ServicesCeltaWare.Tools.CommandWin32.Execute(@"C:\Windows\System32\inetsrv\", "appcmd.exe", $" add app /site.name:{customerProduct.Customer.RootDirectory}-CeltaBS /path:/{customerProduct.InstallDirectory} /physicalPath:" + "\"" + dir + "\""); ChangeDefaultHtm(customerProduct.Customer.RootDirectory, customerProduct.Port, ProductName.CCS); break; } case ProductName.CSS: { if (!dir.Exists) { await ServicesCeltaWare.Tools.CommandWin32.Copy(@"c:\Celta Business Solutions\Empty\CSS\WebService", dir.ToString(), true, true); } msgCreateSite = await ServicesCeltaWare.Tools.CommandWin32.Execute(@"C:\Windows\System32\inetsrv\", "appcmd.exe", $" add app /site.name:{customerProduct.Customer.RootDirectory}-CeltaBS /path:/{ValidateNameForPathSite(customerProduct.InstallDirectory)} /physicalPath:" + "\"" + dir + " \""); break; } case ProductName.Concentrador: { break; } case ProductName.SynchronizerService: { break; } case ProductName.Database: { break; } case ProductName.CertificadoA1: { if (!dir.Exists) { dir.Create(); } await ServicesCeltaWare.Tools.CommandWin32.Copy(@"c:\Celta Business Solutions\Empty\bsf\certificados", dir.ToString(), true, true); break; } default: break; } return(msgCreateSite); } catch (Exception err) { // error = err.Message; return(err.Message); } }