public void AddUnPaidPurchaseScaleExpenses(int scaleId) { // Search for all expenses that matches scaleId. ExpensesRequestLibrary lib = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); string refTableName = new Model.Scale().GetType().Name; IEnumerable <ExpensesRequest> expenses = lib.GetAllPurchasingExepneseByRefTableAndRefId(scaleId, refTableName, new[] { "Payment", "Paid_Party_To" }); ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); foreach (var item in expenses) { // If scale expense already exists. if (TempEntityList.FirstOrDefault(m => m.ID == item.ID) == null) { // Get scale entity Scale scale = scaleLib.GetByID(item.Reference_ID.ToString(), new string[] { "Dispatch_Request_No" }); if (item.Paid_Party_To == null) { item.Paid_Party_To = new Party(); } // Add eexpense to TempList. TempEntityList.Add(item); // Add dispatcher expense. if (scale.Dispatch_Request_No != null && scale.Dispatch_Request_No.ID > 0) { AddUnPaidPurchaseDispatcherExpenses(scale.Dispatch_Request_No.ID); } } } }
public void RemoveUnPaidPurchaseExpenses(string scaleId) { // If TEmpEntityList has no Items. if (TempEntityList != null) { int intScaleId = Convert.ToInt32(scaleId); if (intScaleId > 0) { // Get all scale exepenses. IEnumerable <ExpensesRequest> scaleExps = from exp in TempEntityList where exp.Reference_Table == "Scale" && exp.Reference_ID == intScaleId select exp; if (scaleExps != null) { IList <ExpensesRequest> removeExpenses = new List <ExpensesRequest>(); ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); foreach (var item in scaleExps) { // Get scale entity. Scale scale = scaleLib.GetByID(item.Reference_ID.ToString(), new string[] { "Dispatch_Request_No" }); if (scale != null && scale.Dispatch_Request_No != null && scale.Dispatch_Request_No.ID > 0) { // Get dispatcher id. int dispatcherId = scale.Dispatch_Request_No.ID; // Get all dispatcher expenses. IEnumerable <ExpensesRequest> dispatcherExps = from exp in TempEntityList where exp.Reference_Table == "DispatcherRequest" && exp.Reference_ID == dispatcherId select exp; if (dispatcherExps != null) { foreach (var dispExp in dispatcherExps) { // Add dispatcher expense in removeExpense list. removeExpenses.Add(dispExp); } } } // Add scale expense in removeExpense list. removeExpenses.Add(item); } // Delete scale and dispatcher expense. foreach (var removeExp in removeExpenses) { TempEntityList.Remove(removeExp); } } } } }
// If your activity returns a value, derive from CodeActivity<TResult> // and return the value from the Execute method. protected override void Execute(CodeActivityContext context) { try { int entityType = (int)NotificationType.Get(context); if (entityType == (int)EnumNotificationEntity.Scale) { string conString = System.Configuration.ConfigurationManager.ConnectionStrings["smARTDBContext"].ConnectionString; ScaleLibrary scaleLib = new ScaleLibrary(conString); Scale scale = scaleLib.GetByID(EntityID.Get(context), new string[] { "Dispatch_Request_No", "Party_ID", "Purchase_Order", "Container_No", "Party_Address", "Sales_Order", "Invoice" }); scale.Send_Mail = true; scaleLib.Modify(scale, new string[] { "Dispatch_Request_No", "Party_ID", "Purchase_Order", "Container_No", "Party_Address", "Sales_Order", "Invoice" }); } } catch (Exception ex) { ExceptionFormatter formater = new ExceptionFormatter(); string formatedException = formater.Format("Send mail update log error", ex); Common.MessageLogger.Instance.LogMessage(ex, formatedException, Common.Priority.High, 0, System.Diagnostics.TraceEventType.Critical, "WF Email Error", "Email"); throw ex; } }
public Scale GetTicketById(int id) { return(_scaleLib.GetByID(id.ToString())); }