Dear sirs,
on debug the application is working normally but while we deploy it on server it is not working no error happened but also no records saved in DB knowing that i debug it on server and it is working normally on deployment...it is not working can any one help me
regards
this is the code that must run correctly :
using System;
using System.Collections.Generic;
using System.Data;
using System.Transactions;
using BatchPackage;
using Microsoft.SqlServer.Server;
public partial class CLRGeneratePayroll
{
public CLRGeneratePayroll(string connectionString)
{
_ConnectionString = connectionString;
}
string _ConnectionString;
public string proc_GeneratePayroll(string payProcessId)
{
#region Declare Variables
int processType = 0;
int netShowPage = 0;
int ruleType = 0;
int sequenceNumber = 0;
string payRegulationId = string.Empty;
string payMonth = string.Empty;
string personId = string.Empty;
string netPayElement = string.Empty;
string payelement = string.Empty;
DateTime processStartDate;
DateTime processEndDate;
bool isEducationGenerated = false;
int educationyear = 0;
bool isLoanGenerated = false;
bool isInsuranceGenerated = false;
bool isProvisionGenerated = false;
bool isBonusGenerated = false;
bool isStampGenerated = false;
bool isReverseAccrual = false;
bool isCloseFile = false;
string CurrencySystem = GetSystemCurrency();
#endregion Declare Variables
#region Get Process Detail
DataRow processdetail = GetPayProcessDetail(payProcessId);
payMonth = processdetail["PayMonth"].ToString();
processType = int.Parse(processdetail["PayProcessTypeID"].ToString());
processStartDate = DateTime.Parse(processdetail["PayStartDate"].ToString());
processEndDate = DateTime.Parse(processdetail["PayEndDate"].ToString());
isEducationGenerated = bool.Parse(processdetail["IsGeneratedEducation"].ToString());
if (isEducationGenerated == true)
educationyear = int.Parse(processdetail["EducationYear"].ToString());
isLoanGenerated = bool.Parse(processdetail["IsGeneratedLoan"].ToString());
isInsuranceGenerated = bool.Parse(processdetail["IsGeneratedInsurance"].ToString());
isProvisionGenerated = bool.Parse(processdetail["IsGeneratedProvision"].ToString());
isBonusGenerated = bool.Parse(processdetail["IsGeneratedBonus"].ToString());
isStampGenerated = bool.Parse(processdetail["IsGeneratedStamp"].ToString());
isReverseAccrual = bool.Parse(processdetail["IsReverseAccrual"].ToString());
isCloseFile = bool.Parse(processdetail["IsCloseFile"].ToString());
#endregion Get Process Detail
#region Prepare Data
DataTable employeesInProcess = GetEmployeesforProcess(payProcessId);
List<string> employeeIds = new List<string>();
for (int i = 0; i < employeesInProcess.Rows.Count; i++)
{
if (i == 0)
employeeIds.Add("'" + employeesInProcess.Rows[i]["PersonID"].ToString() + "'");
else
employeeIds.Add(", '" + employeesInProcess.Rows[i]["PersonID"].ToString() + "'");
}
if (employeeIds.Count > 0)
{
DataTable payModification = GetPayModification(payProcessId, false, employeeIds.ToArray());
DataTable fixedTransportation = GetFixedTransport(payProcessId, employeeIds.ToArray());
DataTable transportPayModification = GetPayModification(payProcessId, true, employeeIds.ToArray());
DataTable educationAllowanceInProcess = new DataTable();
DataTable loansInProcess = new DataTable();
DataTable insuranceInProcess = new DataTable();
if (isEducationGenerated && processType != 6)
educationAllowanceInProcess = GetPersonEligibleToEducation(payProcessId, processEndDate, employeeIds.ToArray());
if ((isLoanGenerated || isCloseFile) && processType != 6)
loansInProcess = GetPersonEligibleToLoan(payProcessId, processType, processStartDate, processEndDate, employeeIds.ToArray());
if (isInsuranceGenerated && processType != 6)
insuranceInProcess = GetPersonEligibleToInsurance(payProcessId, processStartDate, processEndDate, employeeIds.ToArray());
DataTable regulationsInProcess = GetRegulationsInProcess(payProcessId, employeeIds.ToArray());
#endregion Prepare Data
LockProcess(payProcessId, true);
#region Generate Payroll
Batch batch = new Batch(_ConnectionString);
batch.batchID = Guid.NewGuid().ToString();
batch.description = processdetail["Description"].ToString();
batch.executionStartTime = DateTime.Now;
batch.transactionID = payProcessId;
List<BatchDetail> lstBatchDetails = new List<BatchDetail>();
foreach (DataRow employeeRow in employeesInProcess.Rows)
{
personId = employeeRow["PersonID"].ToString();
BatchDetail _btchDetail = new BatchDetail(_ConnectionString);
_btchDetail.batchDetailID = Guid.NewGuid().ToString();
_btchDetail.BatchID = batch.batchID;
_btchDetail.batchDetailDate = DateTime.Now;
_btchDetail.personID = personId;
try
{
#region Delete Employee from PayEmployeeRejected
SetEmployeeRejected(null, payProcessId, personId, null, false);
#endregion Delete Employee from PayEmployeeRejected
TransactionOptions tso = new TransactionOptions();
tso.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, tso))
{
#region Update Employee Sequence
sequenceNumber = GetLastSequenceforEmployee(personId, processEndDate);
sequenceNumber += 1;
SetEmployeeSequence(personId, payProcessId, sequenceNumber);
#endregion Update Employee Sequence
#region Update DOM
if (processType == 1)
{
string payparam = employeeRow["PayrollParameterID"].ToString();
SetDOM(payProcessId, personId, payparam, processStartDate, processEndDate);
}
#endregion Update DOM
#region Insert Data from previous process in PayYearTransaction
SetPayYearTransactionFromPrevious(payProcessId, personId);
SetRoundingNetToMonth(payProcessId, personId);
#endregion Get Data from previous
#region Compute Salary and Working Days
ComputeSalary(payProcessId, personId, payMonth, processType, CurrencySystem, processStartDate, processEndDate, isCloseFile);
#endregion
#region Compute PayModification
DataRow[] payModificationRows = payModification.Select("PersonID = '" + personId + "'");
if (payModificationRows.Length > 0)
ComputePayModification(payProcessId, personId, payMonth, processType, processStartDate, processEndDate, CurrencySystem, isCloseFile, payModificationRows);
#endregion (Retrieve PayModification)
#region Compute Fixed Transportation
if (processType == 1)
{
DataRow[] fixedTransportationRows = fixedTransportation.Select("PersonID = '" + personId + "'");
if (fixedTransportationRows.Length > 0)
GenerateFixedTransport(payProcessId, personId, payMonth, processType, processStartDate, processEndDate, CurrencySystem, fixedTransportationRows);
}
#endregion
#region Compute Transportation
DataRow[] transportPayModificationRows = transportPayModification.Select("PersonID = '" + personId + "'");
if (transportPayModificationRows.Length > 0)
GenerateTransportation(payProcessId, personId, payMonth, processType, processStartDate, processEndDate, CurrencySystem, isCloseFile, transportPayModificationRows);
#endregion
#region Compute Educational Allowance
if (isEducationGenerated && processType != 6)
{
DataRow[] employeeeducAllowanceRows = educationAllowanceInProcess.Select("PersonID = '" + personId + "'");
if (employeeeducAllowanceRows.Length > 0)
ComputeEducationalAllowance(payProcessId, personId, processEndDate, payMonth, educationyear, employeeeducAllowanceRows);
}
#endregion Compute Educational Allowance
#region Compute loan
if ((isLoanGenerated || isCloseFile) && processType != 6)
{
DataRow[] employeeLoansRows = loansInProcess.Select("PersonID = '" + personId + "'");
if (employeeLoansRows.Length > 0)
ComputeLoan(payProcessId, personId, processType, payMonth, processStartDate, processEndDate, isCloseFile, employeeLoansRows);
}
#endregion compute loan
#region Compute Insurance
if (isInsuranceGenerated && processType != 6)
{
DataRow[] employeeInsuranceRows = insuranceInProcess.Select("PersonID = '" + personId + "'");
if (employeeInsuranceRows.Length > 0)
ComputeInsurance(payProcessId, personId, processStartDate, processEndDate, employeeInsuranceRows);
}
#endregion compute Insurance
#region To DO Next Release
#endregion To DO Next Release
#region Copy Data from PayMonthTransaction to PayYearTransaction
SetPayYearFromPayMonth(payProcessId, personId);
#endregion Copy Data from PayMonthTransaction to PayYearTransaction
#region Generate Part(II)
payRegulationId = employeeRow["PayRegulationHeaderID"].ToString();
if (processType != 6)
{
#region Compute Accrual
if (isReverseAccrual == false && isCloseFile == false)
ComputeAccrual(payProcessId, processStartDate, processEndDate, personId, processStartDate, processEndDate, true);
#endregion Compute Accrual
#region Compute Rules in Employee Regulation
int ruleSequence = 0, tempSequence = 0;
DataRow[] regulationDetailRows = regulationsInProcess.Select("PayRegulationHeaderID = '" + payRegulationId + "'", "sequence asc, StartingDate asc");
foreach (DataRow regulationDetailRow in regulationDetailRows)
{
ruleType = (int)regulationDetailRow["RuleTypeID"];
ruleSequence = (int)regulationDetailRow["Sequence"];
if (tempSequence == ruleSequence)
continue;
switch (ruleType)
{
case 1:
ComputeFamilyAllowance(payProcessId, personId, processType, processStartDate, processEndDate);
tempSequence = ruleSequence;
break;
case 2:
ComputeTaxProcedure(payProcessId, personId, processType, processStartDate, processEndDate);
tempSequence = ruleSequence;
break;
case 3:
ComputeSocialSecurityProcedure(payProcessId, personId, processType, processStartDate, processEndDate);
tempSequence = ruleSequence;
break;
case 4:
if (isProvisionGenerated == true)
{
ComputeProvisionProcedure(payProcessId, personId, processType, processStartDate, processEndDate);
tempSequence = ruleSequence;
}
break;
default:
break;
}
}
#endregion Compute Rules in Employee Regulation
#region Compute/Reverse Accrual
if (isReverseAccrual == true || isCloseFile == true)
ReverseAccrual(payProcessId, processStartDate, processEndDate, personId, processStartDate, processEndDate);
else
ComputeAccrual(payProcessId, processStartDate, processEndDate, personId, processStartDate, processEndDate, false);
#endregion Compute/Reverse Accrual
}
#region Compute UserRule before-NET
DataTable userRule = new DataTable();
userRule = GetRegulationUserRule(payRegulationId, 5);
foreach (DataRow userRuleRow in userRule.Rows)
{
ComputeUserDefinedRule(payProcessId, processEndDate, personId, userRuleRow["UserRuleHeaderID"].ToString(), processStartDate, processEndDate);
}
#endregion Compute UserRule before-NET
#region Compute NET
DataTable regulationNet = new DataTable();
regulationNet = GetRegulationNet(payRegulationId);
foreach (DataRow netRow in regulationNet.Rows)
{
netPayElement = netRow["PayElementID"].ToString();
netShowPage = int.Parse(netRow["ShowOnPageID"].ToString());
ComputePersonNet(payProcessId, personId, processEndDate, netRow["PayRegulationNetID"].ToString(), int.Parse(netRow["ShowOnPageID"].ToString()));
}
#endregion Compute NET
#region Compute UserRule after-NET
userRule = GetRegulationUserRule(payRegulationId, 6);
foreach (DataRow userRuleRow in userRule.Rows)
{
ComputeUserDefinedRule(payProcessId, processEndDate, personId, userRuleRow["UserRuleHeaderID"].ToString(), processStartDate, processEndDate);
}
#endregion Compute UserRule after-NET
#endregion Generate Part(II)
#region Set RuleDate = TerminationDate in case of CloseFile
if (isCloseFile == true)
{
DateTime terminationDate;
terminationDate = GetTerminationDate(personId);
SetTillDate(personId, terminationDate);
}
#endregion Set RuleDate = TerminationDate in case of CloseFile
#region Set Employee Generated and Update his LastProcessDate
SetProcessDate(personId, processEndDate);
SetEmployeeGenerated(payProcessId, personId);
#endregion Set Employee Generated and Update his LastProcessDate
ts.Complete();
ts.Dispose();
}
_btchDetail.logMessageID = 35;
lstBatchDetails.Add(_btchDetail);
}
catch (Exception ex)
{
_btchDetail.logMessageID = 54;
_btchDetail.remark = ex.Message;
lstBatchDetails.Add(_btchDetail);
SetEmployeeRejected(Guid.NewGuid().ToString(), payProcessId, personId, ((System.Exception)(ex)).Message, true);
}
}
LockProcess(payProcessId, false);
batch.executionEndTime = DateTime.Now;
batch.lstBatchDetail = lstBatchDetails;
batch.insert();
#endregion Generate Payroll
return batch.batchID;
}
return string.Empty;
}
};