//[HttpPost] //public void RemoveUnPaidSellingExpenses(string bookingId) { // // If TEmpEntityList has no Items. // if (TempEntityList != null) { // int intBookingId = Convert.ToInt32(bookingId); // if (intBookingId > 0) { // // Get all scale exepenses. // IEnumerable<ExpensesRequest> scaleExps = from exp in TempEntityList // where exp.Reference_Table == "Scale" && exp.Reference_ID == intBookingId // 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); // } // } // } // } //} public void AddNonInvoiceSellingScaleExpenses(int bookingId) { TempEntityList.Clear(); ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <Scale> scales = scaleLib.GetScalesByBookingId(bookingId); // Search for all expenses that matches scaleId. ExpensesRequestLibrary lib = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); string refTableName = new Model.Scale().GetType().Name; foreach (var scale in scales) { IEnumerable <ExpensesRequest> expenses = lib.GetAllSellingExepneseByRefTableAndRefId(scale.ID, refTableName, new[] { "Payment", "Paid_Party_To", "Invoice" }); foreach (var expense in expenses) { // If scale expense already exists. if (TempEntityList.FirstOrDefault(m => m.ID == expense.ID) == null) { if (expense.Paid_Party_To == null) { expense.Paid_Party_To = new Party(); } // Add eexpense to TempList. TempEntityList.Add(expense); // Add dispatcher expense. } } AddNonInvoiceSellingDispatcherExpenses(bookingId, scale.ContainerNo); } }
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 static IEnumerable <Scale> OpenTicketsList() { ScaleLibrary lib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <Scale> result = lib.GetOpenTickets(smART.MVC.Present.Controllers.QScaleController.ReceivingTicketType); return(result); }
public RSmartTicketService() { _scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); _scaleDetailLib = new ScaleDetailsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); _scaleAttachmentLib = new ScaleAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); _leadLogLib = new LeadLogLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); }
public void MajorScaleStepTest() { Assert.AreEqual(MidiPitch.E0, ScaleLibrary.Step(Pitch.C, ScaleType.Major, MidiPitch.A0, -3)); Assert.AreEqual(MidiPitch.GNeg1, ScaleLibrary.Step(Pitch.C, ScaleType.Major, MidiPitch.C0, -3)); Assert.AreEqual(MidiPitch.D1, ScaleLibrary.Step(Pitch.C, ScaleType.Major, MidiPitch.A0, 3)); Assert.AreEqual(MidiPitch.A1, ScaleLibrary.Step(Pitch.C, ScaleType.Major, MidiPitch.A0, 7)); Assert.AreEqual(MidiPitch.D1, ScaleLibrary.Step(Pitch.C, ScaleType.Major, MidiPitch.B0, 2)); }
public override ActionResult _Delete(string id) { Scale scale = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()).GetByID(id); if (scale.Ticket_Settled == true) { throw new Exception("Can not delete paid ticket."); } return(base._Delete(id)); }
public override ActionResult _Index() { int totalRows = 0; ViewBag.PageSize = ConfigurationHelper.GetsmARTLookupGridPageSize(); ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <Scale> resultList = scaleLib.GetAllByPaging(out totalRows, 1, ViewBag.PageSize, "", "Asc", _includeEntities, null, ReceivingTicketType); return(View("~/Views/Transaction/QScale/_List.cshtml", resultList)); }
public void MinorScaleStepTest() { Assert.AreEqual(MidiPitch.GSharpNeg1, ScaleLibrary.Step(Pitch.C, ScaleType.Minor, MidiPitch.D0, -3)); Assert.AreEqual(MidiPitch.D4, ScaleLibrary.Step(Pitch.C, ScaleType.Minor, MidiPitch.G4, -3)); Assert.AreEqual(MidiPitch.F2, ScaleLibrary.Step(Pitch.C, ScaleType.Minor, MidiPitch.DSharp2, 1)); Assert.AreEqual(MidiPitch.D1, ScaleLibrary.Step(Pitch.E, ScaleType.Minor, MidiPitch.G1, -3)); Assert.AreEqual(MidiPitch.C3, ScaleLibrary.Step(Pitch.E, ScaleType.Minor, MidiPitch.B3, -6)); Assert.AreEqual(MidiPitch.FSharp5, ScaleLibrary.Step(Pitch.E, ScaleType.Minor, MidiPitch.D5, 2)); }
public void MinorPentatonicScaleTest() { var scale = ScaleLibrary.GetScale(Pitch.C, ScaleType.MinorPentatonic).ToList(); Assert.AreEqual(5, scale.Count); Assert.AreEqual(Pitch.C, scale[0]); Assert.AreEqual(Pitch.DSharp, scale[1]); Assert.AreEqual(Pitch.F, scale[2]); Assert.AreEqual(Pitch.G, scale[3]); Assert.AreEqual(Pitch.ASharp, scale[4]); }
public void MinorScaleTest() { var scale = ScaleLibrary.GetScale(Pitch.C, ScaleType.Minor).ToList(); Assert.AreEqual(7, scale.Count); Assert.AreEqual(Pitch.C, scale[0]); Assert.AreEqual(Pitch.D, scale[1]); Assert.AreEqual(Pitch.DSharp, scale[2]); Assert.AreEqual(Pitch.F, scale[3]); Assert.AreEqual(Pitch.G, scale[4]); Assert.AreEqual(Pitch.GSharp, scale[5]); Assert.AreEqual(Pitch.ASharp, scale[6]); }
public void MajorScaleTest() { var scale = ScaleLibrary.GetScale(Pitch.D, ScaleType.Major).ToList(); Assert.AreEqual(7, scale.Count); Assert.AreEqual(Pitch.D, scale[0]); Assert.AreEqual(Pitch.E, scale[1]); Assert.AreEqual(Pitch.FSharp, scale[2]); Assert.AreEqual(Pitch.G, scale[3]); Assert.AreEqual(Pitch.A, scale[4]); Assert.AreEqual(Pitch.B, scale[5]); Assert.AreEqual(Pitch.CSharp, scale[6]); }
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); } } } } }
protected override void ValidateEntity(Scale entity) { ModelState.Clear(); entity.Ticket_Type = ReceivingTicketType; entity.QScale = true; // Add new scale id if (entity.ID == 0) { ScaleLibrary lib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); entity.Scale_Ticket_No = lib.GenerateUniqueId(Session["Unique_ID"].ToString()); } if (string.IsNullOrEmpty(entity.Ticket_Status)) { entity.Ticket_Status = TicketStatus.Open.ToString(); } if (entity.Party_ID != null && !string.IsNullOrEmpty(entity.Party_ID.License_No)) { if (string.IsNullOrEmpty(entity.Party_ID.Party_Name)) { throw new Exception("Party name is required."); } PartyController partyCont = new PartyController(); entity.Party_ID.Created_By = HttpContext.User.Identity.Name; string thumbImage1RefId, thumbImage2RefId, photoRefId, signatureImageRefId, drivingLicImageRefId, vechicleImageRefId, cashCardImageRefId; GetCustomerImageRefIds(entity.ID, out thumbImage1RefId, out thumbImage2RefId, out photoRefId, out signatureImageRefId, out drivingLicImageRefId, out vechicleImageRefId, out cashCardImageRefId); entity.Party_ID.ThumbImage1RefId = thumbImage1RefId; entity.Party_ID.ThumbImage2RefId = thumbImage2RefId; entity.Party_ID.PhotoRefId = photoRefId; entity.Party_ID.SignatureImageRefId = signatureImageRefId; entity.Party_ID.LicenseImageRefId = drivingLicImageRefId; entity.Party_ID.VehicleImageRegId = vechicleImageRefId; entity.Party_ID.CashCardImageRefId = cashCardImageRefId; entity.Party_ID.State = entity.State; Party newParty = partyCont.SaveParty(entity.Party_ID, entity.PrimaryAddress); entity.Party_ID.ID = newParty.ID; if (entity.Party_ID.ID <= 0) { throw new Exception("Issue to add new party."); } } Validate(entity); }
private static List <MidiPitch> GetPitches(Chord chord, ScaleType scaleType, int count, int octave) { var interval = 0; var pitchesInChord = chord.Pitches(octave).Select(p => p.FromMidiPitch()).ToList(); var pitches = new List <MidiPitch>(); var stdDev = 0.5; for (var i = 0; i < count; i++) { interval = Randomizer.Clamp(interval + Randomizer.Clamp(Randomizer.NextNormalized(0, stdDev), -4, 4), -7, 7); var pitch = ScaleLibrary.Step(chord.BasePitch, scaleType, chord.BasePitch.ToMidiPitch(octave), interval); pitches.Add(pitch); stdDev = pitchesInChord.Contains(pitch.FromMidiPitch()) ? 0.75 : 2; } return(pitches); }
public override ActionResult _OpenTickets() { int totalRows = 0; ViewBag.PageSize = ConfigurationHelper.GetsmARTLookupGridPageSize(); IEnumerable <Scale> resultList = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()).GetByStatus(TicketStatus.Open.ToString(), out totalRows, 1, ViewBag.PageSize, "", "Asc", _predicates, null, ReceivingTicketType ); return(View("~/Views/Transaction/QScale/_OpenTickets.cshtml", resultList)); }
public override ActionResult _OpenTickets(GridCommand command) { int totalRows = 0; IEnumerable <Scale> resultList = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()).GetByStatus( TicketStatus.Open.ToString(), out totalRows, command.Page, command.PageSize, command.SortDescriptors.Count == 0 ? "" : command.SortDescriptors[0].Member, command.SortDescriptors.Count == 0 ? "" : command.SortDescriptors[0].SortDirection == System.ComponentModel.ListSortDirection.Descending ? "Desc" : "Asc", _predicates, (command.FilterDescriptors.Count == 0 ? null : command.FilterDescriptors), ReceivingTicketType); return(View(new GridModel { Data = resultList, Total = totalRows })); }
protected override ActionResult Display(GridCommand command, string id, bool isNew) { int totalRows = 0; IEnumerable <PaymentReceiptDetails> resultList; PaymentReceiptDetailsLibrary lib = new PaymentReceiptDetailsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); ScaleLibrary libScale = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); if (isNew || id == "0") { resultList = lib.GetAllByPaging(TempEntityList, out totalRows, command.Page, command.PageSize, command.SortDescriptors.Count == 0 ? "" : command.SortDescriptors[0].Member, command.SortDescriptors.Count == 0 ? "" : command.SortDescriptors[0].SortDirection == System.ComponentModel.ListSortDirection.Descending ? "Desc" : "Asc", IncludePredicates, (command.FilterDescriptors.Count == 0 ? null : command.FilterDescriptors) ); } else { resultList = new PaymentReceiptDetailsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()) .GetAllByPagingByParentID(out totalRows, int.Parse(id.ToString()), command.Page, command.PageSize == 0 ? 20 : command.PageSize, command.SortDescriptors.Count == 0 ? "" : command.SortDescriptors[0].Member, command.SortDescriptors.Count == 0 ? "" : command.SortDescriptors[0].SortDirection == System.ComponentModel.ListSortDirection.Descending ? "Desc" : "Asc", new string[] { "PaymentReceipt", "Settlement.Scale.Party_ID", "Settlement.Scale.Purchase_Order", "ExpenseRequest.Paid_Party_To", "ExpenseRequest.Scale_Ref", "ExpenseRequest.Dispatcher_Request_Ref.Booking_Ref_No", "ExpenseRequest.Dispatcher_Request_Ref.Container" }, (command.FilterDescriptors.Count == 0 ? null : command.FilterDescriptors) ); foreach (var item in resultList) { if (item.ExpenseRequest != null && item.ExpenseRequest.Dispatcher_Request_Ref != null && item.ExpenseRequest.Dispatcher_Request_Ref.Container != null) { item.ExpenseRequest.Scale_Ref = libScale.GetScalesByContainerId(item.ExpenseRequest.Dispatcher_Request_Ref.Container.ID); } } } return(View(new GridModel { Data = resultList, Total = totalRows })); }
// 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 void ValidItem(ScaleDetails entity) { if (entity != null && entity.Scale != null && entity.Scale.ID > 0) { Scale scale = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()).GetByID(entity.Scale.ID.ToString(), new string[] { "Purchase_Order", "Sales_Order", "Container_No.Booking.Sales_Order_No", "Booking.Sales_Order_No" }); // Receiving ticket. if (scale.Ticket_Type != null && new string[] { "receiving ticket", "trading" }.Any(s => s == scale.Ticket_Type.ToLower())) { ValidatePOItem(scale, entity); } // Shipping ticket. else if (scale.Ticket_Type != null && new string[] { "shipping ticket", "trading" }.Any(s => s == scale.Ticket_Type.ToLower()) && scale.Container_No != null && scale.Container_No.Booking != null && scale.Container_No.Booking.Sales_Order_No != null) { ValidateSOItem(scale.Container_No.Booking.Sales_Order_No.ID, entity); } // Local Sales. else if (scale.Ticket_Type != null && scale.Ticket_Type.ToLower().Contains("local sale") && scale.Sales_Order != null) { ValidateSOItem(scale.Sales_Order.ID, entity); } // Brokerage. else if (scale.Ticket_Type != null && scale.Ticket_Type.ToLower().Contains("brokerage")) { // Validate SO if (scale.Booking != null && scale.Booking.Sales_Order_No != null) { ValidateSOItem(scale.Booking.Sales_Order_No.ID, entity); } // Validate PO ValidatePOItem(scale, entity); } } }
protected override void ValidateEntity(Invoice entity) { ModelState.Clear(); if (entity.ID == 0 && new string[] { "exports", "brokerage" }.Any(s => s == entity.Invoice_Type.ToLower()) && entity.Booking.ID == 0) { ModelState.AddModelError("Booking", "Booking is required"); } if (entity.ID == 0 && new string[] { "local sales", "trading" }.Any(s => s == entity.Invoice_Type.ToLower()) && entity.Sales_Order_No.ID == 0) { ModelState.AddModelError("SalesOrder", "Sales Order is required"); } if (entity.Net_Amt <= 0) { ModelState.AddModelError("Net_Amt", "Net invoice amount is required."); } if (new string[] { "brokerage" }.Any(s => s == entity.Invoice_Type.ToLower()) && entity.Booking != null && entity.Booking.ID > 0) { ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); Scale scale = scaleLib.GetScaleByBookingId(entity.Booking.ID); if (scale == null) { ModelState.AddModelError("Brokerage1", "To generate a Invoice, valid scale ticket has to be created and closed."); } else if (scale != null) { ContainerLibrary contLib = new ContainerLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <Container> containers = contLib.GetAllByParentID(entity.Booking.ID, new string[] { "Booking" }); decimal totalContNetWeight = containers.Sum(s => s.Net_Weight); if (totalContNetWeight != scale.Net_Weight || scale.Ticket_Status != "Close") { ModelState.AddModelError("Booking2", "Net weight on scale ticket should match with total net weight of all containers for this invoice."); } } } }
public override ActionResult _Index(GridCommand command) { int totalRows = 0; FilterDescriptor filterDesc = new FilterDescriptor("Active_Ind", FilterOperator.IsNotEqualTo, "false"); command.FilterDescriptors.Add(filterDesc); ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <Scale> resultList = scaleLib.GetAllByPaging( out totalRows, command.Page, command.PageSize, command.SortDescriptors.Count == 0 ? "" : command.SortDescriptors[0].Member, command.SortDescriptors.Count == 0 ? "" : command.SortDescriptors[0].SortDirection == System.ComponentModel.ListSortDirection.Descending ? "Desc" : "Asc", _includeEntities, (command.FilterDescriptors.Count == 0 ? null : command.FilterDescriptors), ReceivingTicketType ); return(View(new GridModel { Data = resultList, Total = totalRows })); }
public ActionResult SendEmail(string id) { string destinationFilePath = string.Empty; FilelHelper fileHelper = new FilelHelper(); try { if (string.IsNullOrEmpty(id)) { throw new Exception("Email send failed due to Container# not found."); } ContainerLibrary containerLib = new ContainerLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); Container container = containerLib.GetByID(id, new string[] { "Booking.Sales_Order_No.Party" }); if (container == null || container.Booking == null || container.Booking.Sales_Order_No == null || container.Booking.Sales_Order_No.Party == null) { throw new Exception("Email send failed."); } IEnumerable <Contact> contacts = Helpers.ContactHelper.GetEmailContactsByPartyId(container.Booking.Sales_Order_No.Party.ID); if (contacts.Count() <= 0) { throw new Exception("There is no email contact exists."); } NotificationDefinition notDef = new NotificationDefinition(); notDef.ToRecipients = new System.Net.Mail.MailAddressCollection(); foreach (var item in contacts) { notDef.ToRecipients.Add(new System.Net.Mail.MailAddress(item.Email, item.ListText)); } EmployeeHelper employeeHelper = new EmployeeHelper(); Employee employee = employeeHelper.GetEmployeeByUsername(System.Web.HttpContext.Current.User.Identity.Name); if (employee == null || string.IsNullOrEmpty(employee.Email) || string.IsNullOrEmpty(employee.Email_Password)) { throw new Exception("Sender email and password is required."); } ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); Scale scale = scaleLib.GetScalesByContainerId(container.ID); ScaleAttachmentsLibrary scaleAttachLib = new ScaleAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <ScaleAttachments> scaleAttachments = scaleAttachLib.GetAllByParentID(scale.ID); if (scaleAttachments == null || scaleAttachments.Count() <= 0) { throw new Exception("There is no attachment found."); } destinationFilePath = Path.Combine(Path.GetTempPath(), container.ID.ToString()); fileHelper.CreateDirectory(destinationFilePath); fileHelper.DeleteFiles(destinationFilePath); string imageFilePath = Path.Combine(destinationFilePath, "Images"); fileHelper.CreateDirectory(imageFilePath); string zipFilePath = Path.Combine(destinationFilePath, container.ID.ToString() + ".zip"); foreach (var item in scaleAttachments) { string sourceFilePath = fileHelper.GetFilePathByFileRefId(item.Document_RefId.ToString()); string imageFileFullPath = Path.Combine(imageFilePath, item.Document_Name); System.IO.File.Copy(sourceFilePath, imageFileFullPath); } new smART.Common.FilelHelper().CreateZip(imageFilePath, zipFilePath); if (!fileHelper.FileExits(zipFilePath)) { throw new Exception("There is no attachment found."); } string xslPath = Path.Combine(ConfigurationHelper.GetsmARTXslPath(), "ContainerEmailBody.xslt"); string smtpAddress = ConfigurationHelper.GetsmARTSMTPServer(); notDef.Attachments = new List <System.Net.Mail.Attachment>(); notDef.Attachments.Add(new System.Net.Mail.Attachment(zipFilePath)); notDef.DeliveryType = EnumNotificationDeliveryType.Email; notDef.FormatType = EnumFormatType.HTML; notDef.Sender = new System.Net.Mail.MailAddress(employee.Email, employee.Emp_Name); notDef.SMTPServer = smtpAddress; notDef.SMTPServerCredentialID = employee.Email; notDef.SMTPServerCredentialPwd = employee.Email_Password; notDef.Subject = "Booking#/Container#: " + container.Booking.Booking_Ref_No + "/" + container.Container_No; NotificationHelper.StartNotificationWF(id, container.Booking.Sales_Order_No.Party.Party_Name, PartyHelper.GetOrganizationName(), employee.Emp_Name, notDef, xslPath, NotificationWFCompleted, container.Booking.Booking_Ref_No, container.Booking.Sales_Order_No.ID.ToString()); //return Display(command, container); if (_sendMail == true) { return(Json(new { Sucess = "Email send sucessfully." }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Sucess = "Email send failed." }, JsonRequestBehavior.AllowGet)); } //return Json(new { Sucess = "Email send sucessfully." }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { //var script = @"ShowAlertMessage(""Send mail failed"");"; //return JavaScript(script); return(Json(new { Sucess = ex.Message }, JsonRequestBehavior.AllowGet)); } finally { //fileHelper.DeleteDirectory(destinationFilePath); } }
private void SaveThumbScannerAttachment(int Id, byte[] data, string fileName, EnumAttachmentRefType refType, FileFormat fileFormat, bool updateParty = true) { Guid guid = SaveFile(data, string.Format("{0}.{1}", fileName, fileFormat.ToString())); ScaleAttachments attachments = new ScaleAttachments(); attachments.Document_Name = string.Format("{0}.{1}", fileName, fileFormat.ToString());// "Thumb-Image.jpeg"; attachments.Document_RefId = guid; attachments.Document_Size = data.LongLength; attachments.Document_Title = "Thumb-Image"; attachments.Document_Type = "jpeg"; attachments.Ref_Type = (int)refType; attachments.Updated_By = User.Identity.Name; attachments.Created_By = User.Identity.Name; attachments.Created_Date = DateTime.Now; attachments.Last_Updated_Date = DateTime.Now; attachments.Parent = new Scale { ID = Id }; string destinationPath; string sourcePath; FilelHelper fileHelper = new FilelHelper(); destinationPath = fileHelper.GetSourceDirByFileRefId(attachments.Document_RefId.ToString()); // Path.Combine(Configuration.GetsmARTDocPath(), Scale.Document_RefId.ToString()); sourcePath = fileHelper.GetTempSourceDirByFileRefId(attachments.Document_RefId.ToString()); // Path.Combine(Configuration.GetsmARTTempDocPath(), Scale.Document_RefId.ToString()); attachments.Document_Path = fileHelper.GetFilePath(sourcePath); if (Id > 0) { fileHelper.MoveFile(attachments.Document_Name, sourcePath, destinationPath); ScaleAttachmentsLibrary ScaleLibrary = new ScaleAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); attachments.Document_Name = string.Format("{0}.{1}", fileName, "jpg"); ScaleAttachments scaleAttachment = ScaleLibrary.Add(attachments); if (updateParty) { Scale scale = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()).GetByID(Id.ToString(), new string[] { "Party_ID" }); PartyLibrary partyLib = new PartyLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); Party party = partyLib.GetByID(scale.Party_ID.ID.ToString()); if (party != null) { party.PhotoRefId = scaleAttachment.Document_RefId.ToString(); partyLib.Modify(party); } } } else { if (Session["ScaleAttachments"] == null) { Session["ScaleAttachments"] = new List <ScaleAttachments>(); } IList <ScaleAttachments> iList = (IList <ScaleAttachments>)Session["ScaleAttachments"]; iList.Add(attachments); } }
public JsonResult _PartyById(string id) { int intID; bool isParse = int.TryParse(id, out intID); Party party = null; AddressBook address = null; if (isParse) { party = new PartyLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()).GetByID(id); address = new AddressBookLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()).GetPrimaryAddressesByPartyId(intID); } int partyId = 0; string partyName, photoRefId, thumb1RefId, thumb2RefId, signatureRefId, licenseRefId, cashCardRefId; partyName = photoRefId = thumb1RefId = thumb2RefId = signatureRefId = licenseRefId = cashCardRefId = ""; string state = " "; string make = ""; string model = ""; string vehiclePlateNo = ""; string vehicleYear = ""; string vehicleSate = ""; string color = ""; string address1, city, country, zip, addressType, dob, acLicenseId, licenseNo; address1 = city = country = zip = addressType = dob = acLicenseId = licenseNo = ""; if (party != null) { partyName = party.Party_Name; partyId = party.ID; state = party.State == null ? " " : party.State; dob = Convert.ToString(party.Party_DOB); acLicenseId = Convert.ToString(party.ACLicense_ID); licenseNo = Convert.ToString(party.License_No); photoRefId = Convert.ToString(party.PhotoRefId); thumb1RefId = Convert.ToString(party.ThumbImage1RefId); thumb2RefId = Convert.ToString(party.ThumbImage2RefId); signatureRefId = Convert.ToString(party.LicenseImageRefId); licenseRefId = Convert.ToString(party.SignatureImageRefId); cashCardRefId = Convert.ToString(party.CashCardImageRefId); Scale scale = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()).GetLastTicketByPartyId(party.ID, new string[] { "Party_ID" }); if (scale != null) { make = scale.Make; model = scale.Model; vehiclePlateNo = scale.Vehicle_Plate_No; vehicleYear = scale.Vehicle_Year; vehicleSate = scale.Plate_State; color = scale.Color; } } if (address != null) { address1 = address.Address1; city = address.City; country = address.Country; zip = address.Zip_Code; addressType = address.Address_Type; // state = address.State == null ? " " : address.State; } var data = new { ID = partyId, Name = partyName, State = state, LicenseNo = licenseNo, Address1 = address1, City = city, Country = country, Zip = zip, AddressType = addressType, DOB = dob, ACLicenseId = acLicenseId, PhotoRefId = photoRefId, Thumb1RefId = thumb1RefId, Thumb2RefId = thumb2RefId, SignatureRefId = signatureRefId, LicenseRefId = licenseRefId, CashCardRefId = cashCardRefId, Make = make, Model = model, VehiclePlateNo = vehiclePlateNo, VehicleYear = vehicleYear, Color = color, VehicleLicenseState = vehicleSate }; return(Json(data, JsonRequestBehavior.AllowGet)); }