#region using System; using System.Collections.Generic; using System.Data; using System.ServiceModel; using CSFrameworkV5.Common; using CSFrameworkV5.Core; using CSFrameworkV5.DataAccess; using CSFrameworkV5.Interfaces; using CSFrameworkV5.Interfaces.InterfaceModels; using CSFrameworkV5.Models; #endregion namespace CSFrameworkV5.WCFContract.WCF_Class { [ServiceBehavior(IncludeExceptionDetailInFaults = true)] [WCF_ExceptionBehaviour(typeof(WCF_ExceptionHandler))] public class CommonService : ICommonService { public bool AdvancedFilter_Delete(byte[] loginTicket, string account, string configName) { try { var user = WebSecurity.ValidateLoginer(loginTicket); return new dalAdvancedFilter(user).Delete(account, configName); } catch (Exception ex) { throw new FaultException(ex.Message); } } public bool AdvancedFilter_Exists(byte[] loginTicket, string account, string configName) { try { var user = WebSecurity.ValidateLoginer(loginTicket); return new dalAdvancedFilter(user).Exists(account, configName); } catch (Exception ex) { throw new FaultException(ex.Message); } } public List AdvancedFilter_GetConfig(byte[] loginTicket, string account) { try { var user = WebSecurity.ValidateLoginer(loginTicket); return new dalAdvancedFilter(user).GetConfig(account); } catch (Exception ex) { throw new FaultException(ex.Message); } } public bool AdvancedFilter_Post(byte[] loginTicket, MyConfigData data) { try { var user = WebSecurity.ValidateLoginer(loginTicket); return new dalAdvancedFilter(user).Post(data); } catch (Exception ex) { throw new FaultException(ex.Message); } } public string AdvancedFormConfig_ExistsConfig(byte[] loginTicket, string systemID, string programID, string configName, string applyType, string IDs) { try { var user = WebSecurity.ValidateLoginer(loginTicket); return new dalAdvancedFormConfig(user).ExistsConfig(systemID, programID, configName, applyType, IDs); } catch (Exception ex) { throw new FaultException(ex.Message); } } public DataTable AdvancedFormConfig_GetFormConfig(byte[] loginTicket, string systemID, string programID, string userID) { try { var user = WebSecurity.ValidateLoginer(loginTicket); return new dalAdvancedFormConfig(user).GetFormConfig(systemID, programID, userID); } catch (Exception ex) { throw new FaultException(ex.Message); } } public DataTable AdvancedFormConfig_Search(byte[] loginTicket, string SystemID, string ProgramID, string StyleID) { try { var user = WebSecurity.ValidateLoginer(loginTicket); return new dalAdvancedFormConfig(user).Search(SystemID, ProgramID, StyleID); } catch (Exception ex) { throw new FaultException(ex.Message); } } public bool ApprovalBusiness(byte[] loginTicket, QueryApproval P) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalCommon(loginer).ApprovalBusiness(P); } catch (Exception ex) { throw new FaultException(ex.Message); } } public bool CustomModule_Delete(byte[] loginTicket, string Account, string FormFullName, string MenuName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalUserCustomAction(loginer).Delete(Account, FormFullName, MenuName); } catch (Exception ex) { throw new FaultException(ex.Message); } } public bool CustomModule_Exist(byte[] loginTicket, string Account, string FormFullName, string MenuName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalUserCustomAction(loginer).Exist(Account, FormFullName, MenuName); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] CustomModule_GetCustomAction(byte[] loginTicket, string Account) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalUserCustomAction(loginer).GetCustomAction(Account); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] CustomModule_GetRowIndexAOrderID(byte[] loginTicket, string Account, int maxRows, int maxCols) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalUserCustomAction(loginer).GetRowIndexAOrderID( Account, maxRows, maxCols); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public bool CustomModule_ResetCustomActions(byte[] loginTicket, string account) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalUserCustomAction(loginer).ResetCustomActions( account); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] DFC_GetConfigByAccount(byte[] loginTicket, string account, string configName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalDataFieldConfig(loginer).GetConfig(account, configName); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] DFC_GetConfigByName(byte[] loginTicket, string configName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalDataFieldConfig(loginer).GetConfig(configName); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public bool DocNoRule_CheckNoExistsEx(byte[] loginTicket, string DBID, string docCode) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dal_DocNoRule(loginer) .CheckNoExistsEx(DBID, docCode); } catch (Exception ex) { throw new FaultException(ex.Message); } } public bool DocNoRule_Delete(byte[] loginTicket, string DBID, string keyValue) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dal_DocNoRule(loginer).Delete(DBID, keyValue); } catch (Exception ex) { throw new FaultException(ex.Message); } } public DataTable DocNoRule_GetData(byte[] loginTicket, string DBID) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dal_DocNoRule(loginer).GetDataByKey(DBID); } catch (Exception ex) { throw new FaultException(ex.Message); } } public DataTable DocNoRule_GetDataByKey(byte[] loginTicket, string DBID, string keyValue) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dal_DocNoRule(loginer).GetDataByKey(DBID, keyValue); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] DocNoRule_Search(byte[] loginTicket, string DBID, string DocCode) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dal_DocNoRule(loginer).Search(DBID, DocCode); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public bool DocNoRule_UpdateToDB(byte[] loginTicket, string DBID, DataTable data) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dal_DocNoRule(loginer).UpdateToDB(DBID, data); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] FN_GetDataBaseList(byte[] loginTicket) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalFieldNameDefs(loginer).GetDataBaseList(); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] FN_GetTableNames(byte[] loginTicket, string DB) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalFieldNameDefs(loginer).GetTableNames(DB); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] FN_Search(byte[] loginTicket, string TableName, string FieldName, string DisplayName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalFieldNameDefs(loginer).Search(TableName, FieldName, DisplayName); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] FN_SyncTable(byte[] loginTicket, string DB, string tableName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalFieldNameDefs(loginer).SyncTable(DB, tableName); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] GetAttachedFiles(byte[] loginTicket, string docID) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalAttachFile(loginer).GetData(docID); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] GetBusinessTables(byte[] loginTicket) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalCommon(loginer).GetBusinessTables(); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public string GetDataSN(byte[] loginTicket, string dataCode, bool asHeader) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalCommon(loginer).GetDataSN(dataCode, asHeader); } catch (Exception ex) { throw new FaultException(ex.Message); } } public List GetDbTableFields(byte[] loginTicket, string DBName, string tableName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalCommon(loginer).GetDbTableFields(DBName, tableName); } catch (Exception ex) { throw new FaultException(ex.Message); } } public List GetDbTables(byte[] loginTicket) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalCommon(loginer).GetDbTables(); } catch (Exception ex) { throw new FaultException(ex.Message); } } public string GetDocNo(byte[] loginTicket, string docNoName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalCommon(loginer).GetDocNo(docNoName); } catch (Exception ex) { throw new FaultException(ex.Message); } } public DataTable GetEmptyTable(byte[] loginTicket, string DBID, string tableName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalCommon(loginer).GetEmptyTable(DBID, tableName); } catch (Exception ex) { throw new FaultException(ex.Message); } } public DataTable GetFields(byte[] loginTicket, string databaseName, string tableName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalFieldNameDefs(loginer).GetFields(databaseName, tableName); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] GetLogFieldDef(byte[] loginTicket, string tableName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalEditLogHistory(loginer).GetLogFieldDef(tableName); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] GetModules(byte[] loginTicket) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalCommon(loginer).GetModules(); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public DateTime GetServerTime(byte[] loginTicket) { try { WebSecurity.ValidateLoginIdentity(loginTicket); return DateTime.Now; } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] GetSystemDataSet(byte[] validationTicket) { try { var pass = WebSecurity.ValidateLoginIdentity(validationTicket); //检查校验码成功,有效的登录请求. if (pass) { var data = new dalCommon(null).GetSystemDataSet(); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } return null; } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] GetSystemDataSetEx(byte[] loginTicket, string user, string password) { try { WebSecurity.ValidateLoginIdentity(loginTicket); var data = new dalCommon(null).GetSystemDataSet(user, password); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] GetSystemSettings4Program(byte[] validationTicket, string DataSetID, string UserID) { try { var pass = WebSecurity.ValidateLoginIdentity(validationTicket); var data = new dalCommon(null).GetSystemSettings4Program(DataSetID, UserID); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] GetSystemSettingsByUser(byte[] loginTicket, string DataSetID, string UserID) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalCommon(loginer).GetSystemSettingsByUser(DataSetID, UserID); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] GetSystemSettingsEx(byte[] loginTicket, string ParamName, string ParamType) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalCommon(loginer).GetSystemSettingsEx(ParamName, ParamType); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] GetTableFields(byte[] loginTicket, string tableName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalCommon(loginer).GetTableFields(tableName); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public DataTable GetTableFieldsByDB(byte[] loginTicket, string DatasetDB, string DBName, string tableName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalFieldNameDefs(loginer).GetTableFields(DatasetDB, DBName, tableName); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] GetTableFieldsDef(byte[] loginTicket, string tableName, bool onlyDisplayField) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalCommon(loginer).GetTableFieldsDef(tableName, onlyDisplayField); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public string[] GetTracedFields(byte[] loginTicket, string tableName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalEditLogHistory(loginer) .GetTracedFields(tableName); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] GetUpgrader(byte[] loginTicket, string upgraderName, string serverVer) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalFileUpload().GetUpgrader(upgraderName, serverVer); } catch (Exception ex) { throw new FaultException(ex.Message); } } public int GetUpgraderPackages(byte[] loginTicket, string currentVersionID) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalCommon(loginer).GetUpgraderPackages( currentVersionID); } catch (Exception ex) { throw new FaultException(ex.Message); } } public string GetUpgraderVersion(byte[] loginTicket, string upgraderName) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalFileUpload().GetUpgraderVersion(upgraderName); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] Language_GetData(byte[] validationTicket) { try { WebSecurity.ValidateLoginIdentity(validationTicket); var data = new dalLanguage(null).GetLanguageData(); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] Language_GetTypeData(byte[] validationTicket) { try { WebSecurity.ValidateLoginIdentity(validationTicket); var data = new dalLanguage(null).GetLanguageTypeData(); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public bool Language_Post(byte[] validationTicket, string lan, string objectID, string defaultValue, string itemType) { try { WebSecurity.ValidateLoginIdentity(validationTicket); return new dalLanguage(null).PostLanguage(lan, objectID, defaultValue, itemType); } catch (Exception ex) { throw new FaultException(ex.Message); } } public DataTable Language_Query(byte[] loginTicket, string ObjectID, string CHS, string CHT, string ENG, string DataType) { try { var user = WebSecurity.ValidateLoginer(loginTicket); var data = new dalLanguage(user).Query(ObjectID, CHS, CHT, ENG, DataType); return data; } catch (Exception ex) { throw new FaultException(ex.Message); } } public void PostUserSettings(byte[] loginTicket, string paramKey, string paramValue) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); new dalCommon(loginer).PostUserSettings(loginer, paramKey, paramValue); } catch (Exception ex) { throw new FaultException(ex.Message); } } public bool SaveFieldDef(byte[] loginTicket, byte[] data) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var ds = ZipTools.DecompressionDataSet(data); return new dalEditLogHistory(loginer) .SaveFieldDef(ds.Tables[0]); } catch (Exception ex) { throw new FaultException(ex.Message); } } public bool SaveLog(byte[] loginTicket, byte[] data) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var ds = ZipTools.DecompressionDataSet(data); return new dalEditLogHistory(loginer).Update(ds); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] SearchLog(byte[] loginTicket, string logUser, string tableName, string keyValue, DateTime dateFrom, DateTime dateTo) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalEditLogHistory(loginer).SearchLog(logUser, tableName, keyValue, dateFrom, dateTo); return ZipTools.CompressionDataSet(data); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] SearchOutstanding(byte[] loginTicket, string invoiceNo, string customer, DateTime dateFrom, DateTime dateTo, DateTime dateEnd, string outstandingType) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var data = new dalCommon(loginer).SearchOutstanding(invoiceNo, customer, dateFrom, dateTo, dateEnd, outstandingType); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(data)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] SearchOutstanding_ByPage(byte[] loginTicket, string invoiceNo, string customer, DateTime dateFrom, DateTime dateTo, DateTime dateEnd, string outstandingType, int pageNo, int pageSize) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var ds = new dalCommon(loginer).SearchOutstandingByPage( invoiceNo, customer, dateFrom, dateTo, dateEnd, outstandingType, pageNo, pageSize); return ZipTools.CompressionDataSet(ds); } catch (Exception ex) { throw new FaultException(ex.Message); } } public string TestConnection(byte[] validationTicket) { try { WebSecurity.ValidateLoginIdentity(validationTicket); //检查校验码成功,有效的登录请求. //bool ok= new dalCommon(null).TestConnection(); var ok = true; if (DatabaseProvider.SystemDatabase == null) return ok.ToStringEx() + "DatabaseProvider.SystemDatabase=null"; return ok.ToStringEx() + "DatabaseProvider.SystemDatabase"; } catch (Exception ex) { throw new FaultException(ex.Message); } } public bool UploadUpgrader(byte[] loginTicket, string upgraderName, byte[] body, string version, DateTime uploadTime, string user) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); new dalFileUpload().UploadUpgrader(upgraderName, body, version, uploadTime, user); return true; } catch (Exception ex) { throw new FaultException(ex.Message); } } #region Log日志相关 public void Log_WriteLogObject(byte[] validationTicket, sys_LogOperation data) { try { WebSecurity.ValidateLoginIdentity(validationTicket); new dalLog(null).WriteLog(data); } catch (Exception ex) { throw new FaultException(ex.Message); } } public void Log_WriteLogString(byte[] validationTicket, string content) { try { WebSecurity.ValidateLoginIdentity(validationTicket); new dalLog(null).WriteLog(content); } catch (Exception ex) { throw new FaultException(ex.Message); } } public void Log_ClearLog(byte[] loginTicket, DateTime beginDate, DateTime endDate) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); new dalLog(loginer).ClearLog(beginDate, endDate); } catch (Exception ex) { throw new FaultException(ex.Message); } } public void Log_ClearAll(byte[] loginTicket) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); new dalLog(loginer).ClearAll(); } catch (Exception ex) { throw new FaultException(ex.Message); } } public void Log_ClearLogByUser(byte[] loginTicket, string user, DateTime beginDate, DateTime endDate) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); new dalLog(loginer).ClearLog(user, beginDate, endDate); } catch (Exception ex) { throw new FaultException(ex.Message); } } public DataSet Log_GetDynamicReport(byte[] loginTicket, string[] years) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalLog(loginer).GetDynamicReport(years); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] Log_QueryOperateLog(byte[] loginTicket, string Content, DateTime Date1, DateTime Date2, string OperateType, string User) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var dt = new dalLog(loginer).QueryOperateLog(Content, Date1, Date2, OperateType, User); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(dt)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public byte[] Log_QueryLoginLog(byte[] loginTicket, string loginType, string loginUser, string loginIP, string loginMAC, DateTime LoginD1, DateTime LoginD2) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); var dt = new dalLog(loginer).QueryLoginLog(loginType, loginUser, loginIP, loginMAC, LoginD1, LoginD2); return ZipTools.CompressionDataSet( ServerLibrary.TableToDataSet(dt)); } catch (Exception ex) { throw new FaultException(ex.Message); } } public int Log_DeleteLoginLog(byte[] loginTicket, string isids) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalLog(loginer).DeleteLoginLog(isids); } catch (Exception ex) { throw new FaultException(ex.Message); } } public int Log_DeleteOperateLog(byte[] loginTicket, string isids) { try { var loginer = WebSecurity.ValidateLoginer(loginTicket); return new dalLog(loginer).DeleteOperateLog(isids); } catch (Exception ex) { throw new FaultException(ex.Message); } } #endregion } }