public static ResponseDTO GetAllCategory(string name, string title, string code) { ErrorDTO ErrorResponse = new ErrorDTO(); ResponseDTO Response = new ResponseDTO(); List <CategoryDTO> ListCategoryData = new List <CategoryDTO>(); SqlConnection con = connection.loadDB(); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "SearchCategoryData"; SqlParameter param1 = new SqlParameter(); param1.ParameterName = "Name"; param1.SqlDbType = SqlDbType.NVarChar; param1.Value = name; cmd.Parameters.Add(param1); SqlParameter param2 = new SqlParameter(); param2.ParameterName = "Title"; param2.SqlDbType = SqlDbType.NVarChar; param2.Value = title; cmd.Parameters.Add(param2); SqlParameter param3 = new SqlParameter(); param3.ParameterName = "Code"; param3.SqlDbType = SqlDbType.VarChar; param3.Value = code; cmd.Parameters.Add(param3); try { SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { CategoryDTO CategoryData = new CategoryDTO(); CategoryData.ID = Convert.ToInt16(reader["ID"].ToString()); CategoryData.Name = reader["name"].ToString(); CategoryData.Title = reader["title"].ToString(); CategoryData.Code = reader["code"].ToString(); ListCategoryData.Add(CategoryData); } } Response.Data = ListCategoryData; } catch (Exception ex) { ErrorResponse.Code = 400; ErrorResponse.Message = ex.ToString(); Response.Error = ErrorResponse; } finally { con.Close(); } return(Response); }
public static ResponseDTO AddOrUpdateCategory(CategoryRequestDTO categoryData) { ErrorDTO ErrorResponse = new ErrorDTO(); ResponseDTO Response = new ResponseDTO(); SqlConnection con = connection.loadDB(); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = categoryData.id == null ? "AddCategoryData" : "UpdateCategoryData"; if (categoryData.id != null) { SqlParameter param1 = new SqlParameter(); param1.ParameterName = "ID"; param1.SqlDbType = SqlDbType.Int; param1.Value = categoryData.id; cmd.Parameters.Add(param1); } SqlParameter param6 = new SqlParameter(); param6.ParameterName = "Name"; param6.SqlDbType = SqlDbType.NVarChar; param6.Value = categoryData.name != "" ? categoryData.name : ""; cmd.Parameters.Add(param6); SqlParameter param2 = new SqlParameter(); param2.ParameterName = "Title"; param2.SqlDbType = SqlDbType.NVarChar; param2.Value = categoryData.title != "" ? categoryData.title : ""; cmd.Parameters.Add(param2); SqlParameter param3 = new SqlParameter(); param3.ParameterName = "Code"; param3.SqlDbType = SqlDbType.NVarChar; param3.Value = categoryData.code != "" ? categoryData.code : ""; cmd.Parameters.Add(param3); try { cmd.ExecuteNonQuery(); Response.Data = categoryData.id == null ? "CREATED" : "UPDATED"; } catch (Exception ex) { ErrorResponse.Code = 400; ErrorResponse.Message = ex.ToString(); Response.Error = ErrorResponse; } finally { con.Close(); } return(Response); }
public static ActivityResponseDTO AddErrorDTO(this ActivityResponseDTO activityResponse, ErrorDTO errorDTO) { return(AddBaseDTO <ErrorDTO>(activityResponse, ErrorPropertyName, errorDTO)); }
public static bool TryParseErrorDTO(this ActivityResponseDTO activityResponse, out ErrorDTO errorDTO) { return(TryParseBaseDTO <ErrorDTO>(activityResponse, ErrorPropertyName, out errorDTO)); }
/**********************************************************************************/ /// <summary> /// returns error to hub /// </summary> /// <param name="errorCode"></param> /// <param name="currentActivity">Activity where the error occured</param> /// <param name="currentTerminal">Terminal where the error occured</param> /// <param name="errorMessage"></param> /// <param name="errorType"></param> /// <returns></returns> protected void RaiseError(string errorMessage, ErrorType errorType, ActivityErrorCode?errorCode = null, string currentActivity = null, string currentTerminal = null) { OperationalState.CurrentActivityErrorCode = errorCode; OperationalState.CurrentActivityResponse = ActivityResponseDTO.Create(ActivityResponse.Error); OperationalState.CurrentActivityResponse.AddErrorDTO(ErrorDTO.Create(errorMessage, errorType, errorCode.ToString(), null, currentActivity, currentTerminal)); }
public BaseException(ErrorCode errorCode, string message = null) : base(message) { ErrorCode = errorCode; _error = new ErrorDTO(ErrorCode, message ?? ErrorCode.GetDescription()); }
/**********************************************************************************/ /// <summary> /// returns error to hub /// </summary> /// <param name="errorCode"></param> /// <param name="currentActivity">Activity where the error occured</param> /// <param name="currentTerminal">Terminal where the error occured</param> /// <param name="errorMessage"></param> /// <param name="errorType"></param> /// <returns></returns> protected void RaiseError(string errorMessage, ActivityErrorCode?errorCode = null, ErrorType errorType = ErrorType.Generic) { SetResponse(ActivityResponse.Error); OperationalState.CurrentActivityResponse.AddErrorDTO(ErrorDTO.Create(errorMessage, errorType, errorCode.ToString(), null, MyTemplate.Name, MyTemplate.Terminal?.Name)); }
public static ResponseDTO CountStore(string category_code, string city_code, string district_code, string ward_code, int page, int size) { ErrorDTO ErrorResponse = new ErrorDTO(); ResponseDTO Response = new ResponseDTO(); List <CountStoreDTO> ListStoreData = new List <CountStoreDTO>(); SqlConnection con = connection.loadDB(); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "CountStoreData"; SqlParameter param2 = new SqlParameter(); param2.ParameterName = "CategoryCode"; param2.SqlDbType = SqlDbType.NVarChar; param2.Value = category_code; cmd.Parameters.Add(param2); SqlParameter param6 = new SqlParameter(); param6.ParameterName = "WardCode"; param6.SqlDbType = SqlDbType.VarChar; param6.Value = ward_code; cmd.Parameters.Add(param6); SqlParameter param3 = new SqlParameter(); param3.ParameterName = "CityCode"; param3.SqlDbType = SqlDbType.VarChar; param3.Value = city_code; cmd.Parameters.Add(param3); SqlParameter param7 = new SqlParameter(); param7.ParameterName = "DistrictCode"; param7.SqlDbType = SqlDbType.VarChar; param7.Value = district_code; cmd.Parameters.Add(param7); SqlParameter param4 = new SqlParameter(); param4.ParameterName = "Page"; param4.SqlDbType = SqlDbType.Int; param4.Value = page; cmd.Parameters.Add(param4); SqlParameter param5 = new SqlParameter(); param5.ParameterName = "Size"; param5.SqlDbType = SqlDbType.Int; param5.Value = size; cmd.Parameters.Add(param5); try { SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { CountStoreDTO counta = new CountStoreDTO(); counta.CT = reader["CT"].ToString(); counta.Total = reader["Total"].ToString(); counta.City = reader["City"].ToString(); counta.District = reader["District"].ToString(); counta.Ward = reader["Ward"].ToString(); ListStoreData.Add(counta); } } Response.Data = ListStoreData; } catch (Exception ex) { ErrorResponse.Code = 400; ErrorResponse.Message = ex.ToString(); Response.Error = ErrorResponse; } finally { con.Close(); } return(Response); }
public void RemoveError(ErrorDTO error) { Clients.All.removeError(error); }
public void UpdateError(ErrorDTO error) { Clients.All.updateError(error); }
public void CreateError(ErrorDTO error) { Clients.All.createError(error); }
public static ResponseDTO AddOrUpdateStore(StoreRequestDTO StoreData) { ErrorDTO ErrorResponse = new ErrorDTO(); ResponseDTO Response = new ResponseDTO(); SqlConnection con = connection.loadDB(); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = StoreData.id == null ? "AddStoreData" : "UpdateStoreData"; if (StoreData.id != null) { SqlParameter param1 = new SqlParameter(); param1.ParameterName = "ID"; param1.SqlDbType = SqlDbType.Int; param1.Value = StoreData.id; cmd.Parameters.Add(param1); } SqlParameter param6 = new SqlParameter(); param6.ParameterName = "WardCode"; param6.SqlDbType = SqlDbType.NVarChar; param6.Value = StoreData.ward_code != "" ? StoreData.ward_code : ""; cmd.Parameters.Add(param6); SqlParameter param2 = new SqlParameter(); param2.ParameterName = "Code"; param2.SqlDbType = SqlDbType.NVarChar; param2.Value = StoreData.code != "" ? StoreData.code : ""; cmd.Parameters.Add(param2); SqlParameter param10 = new SqlParameter(); param10.ParameterName = "Adress"; param10.SqlDbType = SqlDbType.NVarChar; param10.Value = StoreData.adress != "" ? StoreData.adress : ""; cmd.Parameters.Add(param10); SqlParameter param3 = new SqlParameter(); param3.ParameterName = "Name"; param3.SqlDbType = SqlDbType.NVarChar; param3.Value = StoreData.name != "" ? StoreData.name : ""; cmd.Parameters.Add(param3); SqlParameter param4 = new SqlParameter(); param4.ParameterName = "Information"; param4.SqlDbType = SqlDbType.NVarChar; param4.Value = StoreData.information != "" ? StoreData.information : ""; cmd.Parameters.Add(param4); SqlParameter param5 = new SqlParameter(); param5.ParameterName = "Latitude"; param5.SqlDbType = SqlDbType.NVarChar; param5.Value = StoreData.latitude != "" ? StoreData.latitude : ""; cmd.Parameters.Add(param5); SqlParameter param7 = new SqlParameter(); param7.ParameterName = "Longitude"; param7.SqlDbType = SqlDbType.NVarChar; param7.Value = StoreData.longitude != "" ? StoreData.longitude : ""; cmd.Parameters.Add(param7); SqlParameter param8 = new SqlParameter(); param8.ParameterName = "Note"; param8.SqlDbType = SqlDbType.NChar; param8.Value = StoreData.note != "" ? StoreData.note : ""; cmd.Parameters.Add(param8); SqlParameter param9 = new SqlParameter(); param9.ParameterName = "Type"; param9.SqlDbType = SqlDbType.NChar; param9.Value = StoreData.type != "" ? StoreData.type : ""; cmd.Parameters.Add(param9); SqlParameter param11 = new SqlParameter(); param11.ParameterName = "CategoryCode"; param11.SqlDbType = SqlDbType.NChar; param11.Value = StoreData.category_code != "" ? StoreData.category_code : ""; cmd.Parameters.Add(param11); try { cmd.ExecuteNonQuery(); Response.Data = StoreData.id == null ? "CREATED" : "UPDATED"; } catch (Exception ex) { ErrorResponse.Code = 400; ErrorResponse.Message = ex.ToString(); Response.Error = ErrorResponse; } finally { con.Close(); } return(Response); }
public static ResponseDTO GetStoreByID(int id) { ErrorDTO ErrorResponse = new ErrorDTO(); ResponseDTO Response = new ResponseDTO(); List <StoreDTO> ListStoreData = new List <StoreDTO>(); SqlConnection con = connection.loadDB(); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "SearchStoreDataByID"; SqlParameter param1 = new SqlParameter(); param1.ParameterName = "ID"; param1.SqlDbType = SqlDbType.Int; param1.Value = id; cmd.Parameters.Add(param1); try { SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { StoreDTO StoreData = new StoreDTO(); StoreData.ID = reader["ID"].ToString(); StoreData.WardCode = reader["ward_code"].ToString(); StoreData.Code = reader["code"].ToString(); StoreData.Type = reader["type"].ToString(); StoreData.Adress = reader["adress"].ToString(); StoreData.CategoryCode = reader["category_code"].ToString(); StoreData.Latitude = reader["latitude"].ToString(); StoreData.Longitude = reader["longitude"].ToString(); StoreData.Information = reader["information"].ToString(); StoreData.Name = reader["name"].ToString(); StoreData.Note = reader["note"].ToString(); ListStoreData.Add(StoreData); } } Response.Data = ListStoreData; } catch (Exception ex) { ErrorResponse.Code = 400; ErrorResponse.Message = ex.ToString(); Response.Error = ErrorResponse; } finally { con.Close(); } return(Response); }
public static ResponseDTO GetWardByID(int id) { ErrorDTO ErrorResponse = new ErrorDTO(); ResponseDTO Response = new ResponseDTO(); List <WardDTO> ListWardData = new List <WardDTO>(); SqlConnection con = connection.loadDB(); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "SearchWardDataByID"; SqlParameter param1 = new SqlParameter(); param1.ParameterName = "ID"; param1.SqlDbType = SqlDbType.NVarChar; param1.Value = id; cmd.Parameters.Add(param1); try { SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { WardDTO WardData = new WardDTO(); WardData.ID = Convert.ToInt16(reader["ID"].ToString()); WardData.WardCode = reader["ward_code"].ToString(); WardData.WardName = reader["ward_name"].ToString(); WardData.Type = reader["type"].ToString(); WardData.DistrictCode = reader["district_code"].ToString(); WardData.DistrictName = reader["district_name"].ToString(); WardData.CityCode = reader["city_code"].ToString(); WardData.CityName = reader["city_name"].ToString(); WardData.Population = Convert.ToInt64(reader["population"].ToString()); WardData.Area = Convert.ToInt64(reader["area"].ToString()); WardData.CreateAt = reader["create_at"].ToString(); WardData.UpdateAt = reader["update_at"].ToString(); ListWardData.Add(WardData); } } Response.Data = ListWardData; } catch (Exception ex) { ErrorResponse.Code = 400; ErrorResponse.Message = ex.ToString(); Response.Error = ErrorResponse; } finally { con.Close(); } return(Response); }
/**********************************************************************************/ /// <summary> /// returns error to hub /// </summary> protected void Error(string errorMessage = null, ActivityErrorCode?errorCode = null) { SetResponse(ActivityResponse.Error); OperationalState.CurrentActivityErrorCode = errorCode; OperationalState.CurrentActivityResponse.AddErrorDTO(ErrorDTO.Create(errorMessage, ErrorType.Generic, errorCode.ToString(), null, null, null)); }
/// <summary> /// This constructor is ONLY used for creating new contracts, not for getting information about existing contracts. /// </summary> /// <param action="ContractName">The action for the new contract being created</param> /// <param action="ContractTypeID">The type for the new contract being created</param> /// <param action="ContractStatusID">The status for the new contract being created</param> /// <param action="UserIdCreator">The ID of the user creating the contract</param> /// <param action="CultureIdentifier">Culture Identifier used for the selection of Fields and Field-Groups /// names in the appropriate language, in the process of creating those for the contract. The language /// is not needed for the creation, so much as it is needed for the population of data in the newly created contract</param> public Contract(Guid OrganizationIdentifier, string ContractName, long ContractTypeID, long? ContractStatusID, long UserIdCreator, string CultureIdentifier, long RoleID = 0) { //int RoleIdCreator = (int)SpecialRoles.OwnerRoleID; //Always the "owner" is the one creating the contracts... long RoleIdCreator = RoleID; //RoleID is a default userid used for contractuser table try { Deleted = false; Properties = new ContractProperties(); initLists(); New = true; Properties.Name = ContractName; Properties.ContractTypeID = ContractTypeID; Properties.StatusID = (int?)ContractStatusID; Properties.OrganizationIdentifier = OrganizationIdentifier; ContractUsers.Add(new ContractUser() { New = true, EntryId = UserIdCreator, RoleID = RoleIdCreator }); TopContractsV01Entities context = new TopContractsV01Entities(Utilities.getTestEnvName()); //long ContractTypeContractsID = ConfigurationProvider.Default.ContractTypeContracts.ContractTypeContractsID; long ContractTypeContractsID = Utilities.contractTypeContractsID; // Code implemented by Viplav on 17 june 2013 for remove webconfig concept TopContractsDAL10.SystemTables.FieldGroups fieldGroups = new SystemTables.FieldGroups(); if (context.ContractTypes.Any(ct => ct.ParentContractTypeID == ContractTypeContractsID && ct.ContractTypeID == ContractTypeID)) fieldGroups = SystemTables.FieldGroups.Get(false, false, true, CultureIdentifier); else fieldGroups = SystemTables.FieldGroups.GetWithoutParentContractTypeID(false, false, true, CultureIdentifier); string logData1 = "FieldGroups created: " + Environment.NewLine; foreach (TopContractsDAL10.SystemTables.FieldGroup fGrp in fieldGroups.Entries) { logData1 = logData1 + string.Format("FieldGroup info: groupID-{0}", fGrp.ID) + Environment.NewLine; } Logger.WriteGeneralVerbose("Contract class - CTOR", logData1); Logger.WriteGeneralVerbose("Contract class - CTOR", "Creating FieldGroups collection"); foreach (TopContractsDAL10.SystemTables.FieldGroup fieldGroup in fieldGroups.Entries) { //if (fieldGroup.ContractTypeIDsVisible.Any(ct => ct == ContractTypeID)) //Boaz - 7-Aug-2012 if (context.ContractTypes.Any(ct => ct.ParentContractTypeID == ContractTypeContractsID && ct.ContractTypeID == ContractTypeID)) { if (fieldGroup.ContractTypeIDsVisible.Any(ct => ct == ContractTypeID) || fieldGroup.VisibleToAllContractTypes) ContractFieldGroups.Add(new ContractFieldGroup(fieldGroup, CultureIdentifier)); } else { if (fieldGroup.ContractTypeIDsVisible.Any(ct => ct == ContractTypeID)) ContractFieldGroups.Add(new ContractFieldGroup(fieldGroup, CultureIdentifier)); } } string logData2 = "ContractFieldGroups created: " + Environment.NewLine; foreach (ContractFieldGroup cFldGrp in ContractFieldGroups) { logData2 = logData2 + string.Format("FieldGroup info: groupID-{0}", cFldGrp.EntryId) + Environment.NewLine; } Logger.WriteGeneralVerbose("Contract class - CTOR", logData2); } catch (Exception ex) { Logger.WriteExceptionError("Contract class - Contract", ex); ErrorDTO Error = new ErrorDTO(new ExceptionUnknownContractInit(ex)); } }
public static ResponseDTO GetAllStore(string name, string category_code, string address, string ward_code, int page, int size) { ErrorDTO ErrorResponse = new ErrorDTO(); ResponseDTO Response = new ResponseDTO(); List <StoreDTO> ListStoreData = new List <StoreDTO>(); SqlConnection con = connection.loadDB(); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "SearchStoreData"; SqlParameter param1 = new SqlParameter(); param1.ParameterName = "Name"; param1.SqlDbType = SqlDbType.NVarChar; param1.Value = name; cmd.Parameters.Add(param1); SqlParameter param2 = new SqlParameter(); param2.ParameterName = "CategoryCode"; param2.SqlDbType = SqlDbType.NVarChar; param2.Value = category_code; cmd.Parameters.Add(param2); SqlParameter param3 = new SqlParameter(); param3.ParameterName = "Adress"; param3.SqlDbType = SqlDbType.VarChar; param3.Value = address; cmd.Parameters.Add(param3); SqlParameter param6 = new SqlParameter(); param6.ParameterName = "WardCode"; param6.SqlDbType = SqlDbType.VarChar; param6.Value = ward_code; cmd.Parameters.Add(param6); SqlParameter param4 = new SqlParameter(); param4.ParameterName = "Page"; param4.SqlDbType = SqlDbType.Int; param4.Value = page; cmd.Parameters.Add(param4); SqlParameter param5 = new SqlParameter(); param5.ParameterName = "Size"; param5.SqlDbType = SqlDbType.Int; param5.Value = size; cmd.Parameters.Add(param5); try { SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { StoreDTO StoreData = new StoreDTO(); StoreData.ID = reader["ID"].ToString(); StoreData.WardCode = reader["ward_code"].ToString(); StoreData.Code = reader["code"].ToString(); StoreData.Type = reader["type"].ToString(); StoreData.Adress = reader["adress"].ToString(); StoreData.CategoryCode = reader["category_code"].ToString(); StoreData.Latitude = reader["latitude"].ToString(); StoreData.Longitude = reader["longitude"].ToString(); StoreData.Information = reader["information"].ToString(); StoreData.Name = reader["name"].ToString(); StoreData.Note = reader["note"].ToString(); ListStoreData.Add(StoreData); ErrorResponse.Code = Convert.ToInt64(reader["Total"].ToString()); } } if (ListStoreData.Count != 0) { Response.Data = ListStoreData; } else { Response.Data = null; } Response.Error = ErrorResponse; } catch (Exception ex) { ErrorResponse.Code = 400; ErrorResponse.Message = ex.ToString(); Response.Error = ErrorResponse; } finally { con.Close(); } return(Response); }