/
ivan
/
ModMas
Обзор
Документация
Войти
/
ivan
/
ModMas
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ModuleMaster/app_code/service.vb
108 строк
5 KB
i.krivokon
Initial commit
13 мар 2026, 13:49
13 мар 2026, 13:49
00d9fb6
Код
Авторство
О чём код?
Imports System Imports System.ServiceModel Imports System.ServiceModel.Activation Imports System.ServiceModel.Web Imports sharedClasses.dbFunctions <ServiceContract(Namespace:="DataHandler")> <AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> Public Class Service ' To use HTTP GET, add <WebGet()> attribute. (Default ResponseFormat is WebMessageFormat.Json) ' To create an operation that returns XML, ' add <WebGet(ResponseFormat:=WebMessageFormat.Xml)>, ' and include the following line in the operation body: ' WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml" <OperationContract()> Public Function SaveData(tableName As String, rowId As String, fieldName As String, data As String) As String ' Add your operation implementation here Dim sqlf As New SqlFunctions Dim com As New Data.SqlClient.SqlCommand com.CommandText = "UPDATE UserModules.[user]." & tableName & " SET [" & fieldName & "]=@value WHERE id=@id" With com.Parameters .AddWithValue("value", data) .AddWithValue("id", rowId) End With If sqlf.NonQuery(com) > 0 Then Return "Saved" Else Return "Error" End If 'Return tableName & "|" & rowId & "|" & fieldName & "|" & data End Function <OperationContract()> Public Function GetFormData(tableName As String, fieldName As String, fieldValue As String, fieldText As String) As String Dim sql As New StringBuilder Dim sqlf As New SqlFunctions Dim dt As Data.DataTable Select Case tableName Case "[LOBBY_SALES]" If fieldName = "GEN" Or fieldName = "REQUESTORS_NAME" Then sql.Append("select top 1 * from openquery(ORCHESTRA2,' ") sql.Append("SELECT ") sql.Append("GEN, ") sql.Append("concat(Lastname,'' '', FirstName, '' '',MiddleName) as FullName, ") sql.Append("Dept as Department ") sql.Append("FROM orchestra.`attendance`where gen like ''%" & fieldValue.Replace("--", "") & "%'' OR concat(Lastname,'' '', FirstName, '' '',MiddleName) like ''%" & fieldValue.Replace("--", "") & "%'' ") sql.Append("') ") Try dt = sqlf.GetData(sql.ToString) Return "{""REQUESTORS_NAME"": """ & dt.Rows(0)("FullName") & """,""DEPARTMENT"":""" & dt.Rows(0)("Department").ToString.Split("\")(0) & """,""GEN"":""" & dt.Rows(0)("GEN") & """}" Catch ex As Exception 'Return "{""REQUESTORS_NAME"": """ & dt.Rows(0)("FullName") & _ ' """,""DEPARTMENT"":""" & dt.Rows(0)("Department").ToString.Split("\")(0) & _ ' """,""GEN"":""" & dt.Rows(0)("GEN") & """}" Return Nothing End Try End If If fieldName = "MODEL_NAME" Then Try dt = sqlf.GetData("select top 1 * from UserModules.[user].BRAND_SHOP_PRICE where [MODEL] like '%" & fieldValue & "%'") Return "{""MODEL_NAME"": """ & dt.Rows(0)("MODEL") & """,""ITEM"":""" & dt.Rows(0)("DESCRIPTION").ToString.Split("\")(0) & """,""PRICE_TextBox1"":""" & dt.Rows(0)("PRICE") & """}" Catch ex As Exception End Try End If Return "" Case "[REWORK_LAYOUT]" If fieldName = "MATERIAL" Then Dim dr As Data.DataRow = sqlf.GetRow("SELECT distinct MAKTX as description FROM WMSData.dbo.[tb_sap_z_rfc_mat_master] where MATNR = '" & fieldValue.Replace("--", "") & "'") Return "{""DESCRIPTION"": """ & dr("description") & """}" End If Case "[PERSONAL_CARDS]" If fieldName = "LINE" Then Dim ddt As Data.DataTable = sqlf.GetData("SELECT NAME_RUS, GEN FROM hr.dbo.EMPLOYEE_MASTER WHERE LINE_CODE IN ( SELECT line_code FROM GMESData.dbo.TB_TBM_MD_LINE WHERE line_nm = '" & fieldValue & "' ) ORDER BY NAME_RUS") Dim l As String = "" Dim firstGEn As String = "" Dim firstName As String = "" For Each dr In ddt.Rows If l <> "" Then l &= "," Else firstGEn = dr("GEN") firstName = dr("NAME_RUS") End If l &= """" & dr("NAME_RUS") & """:""" & dr("GEN") & """" Next Return "{""NAME"": {" & l & "}, ""GEN"":""" & firstGEn & """, ""NAME_RUS"":""" & firstName & """ }" ElseIf fieldName = "NAME" Then Return "{""GEN"": """ & fieldValue & """, ""NAME_RUS"":""" & fieldText & """ }" End If Case Else Return "" End Select Return "" End Function ' Add more operations here and mark them with <OperationContract()> End Class