Example #1
0
 public async Task InsertProduct(ProductEntity product, string createdBy)
 {
     try
     {
         await dapperHelper.ExecuteSP_Single <ProductEntity>(Product.INSERT, new
         {
             @ProductCode          = product.ProductCode,
             @ProductName          = product.ProductName,
             @ProductDescription   = product.ProductDescription,
             @ProductType          = product.ProductType,
             @MeasuranceUnit       = product.MeasuranceUnit,
             @StandardPartNumber   = product.StandardPartNumber,
             @PartNumberOther      = product.PartNumberOther,
             @AdditionalPartNumber = product.AdditionalPartNumber,
             @RiskCode             = product.RiskCode,
             @RiskNote             = product.RiskNote,
             @ItemNote             = product.ItemNote,
             @ProductCategoryId    = product.ProductCategoryId,
             @ProductParentId      = product.ProductParentId,
             @CreatedBy            = createdBy
         });
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.StackTrace);
         throw ex;
     }
 }
Example #2
0
 public async Task InsertCompany(CompanyEntity company, string userUniqueName)
 {
     try
     {
         await dapperHelper.ExecuteSP_Single <string>(SpCompany.INSERT, new
         {
             @CompanyCode         = company.CompanyCode,
             @CompanyName         = company.CompanyName,
             @CompanyType         = company.CompanyType,
             @CompanyPhone        = company.CompanyPhone,
             @CompanyEmail        = company.CompanyEmail,
             @CompanyWebsite      = company.CompanyWebsite,
             @CompanyAddress      = company.CompanyAddress,
             @CompanyRegion       = company.CompanyRegion,
             @CompanyLegalId      = company.CompanyLegalId,
             @CompanyContactName  = company.CompanyContactName,
             @CompanyContactPhone = company.CompanyContactPhone,
             @CreatedBy           = userUniqueName
         });
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.StackTrace);
     }
 }
Example #3
0
        public async Task Update_status()
        {
            try
            {
                List <HeaderScheduler> headers = await dapperHelper.ExecuteSP_Multiple <HeaderScheduler>(Header.GET_ALL_BYSTATUS);

                DateTime Now = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                foreach (HeaderScheduler item in headers)//int i = 0; i < headers.Count; i++)
                {
                    //la fecha de cierre es menor a la de apertura
                    if (item.CloseDate < item.OpenDate)
                    {
                        await dapperHelper.ExecuteSP_Single <string>(Header.UPDATE_STATUS, new
                        {
                            @Status   = "ERROR",
                            @HeaderId = item.HeaderId
                        });
                    }
                    else
                    {
                        //fecha de apertura es menor o igual a la fecha actual
                        if (item.OpenDate <= Now)
                        {
                            //Si la fecha de cierre es mayor o igual  a la fecha actual y igual a la fecha de apertura el estado es "PROGRAMADO"
                            if (item.CloseDate >= Now && item.Status == "PROGRAMADO")
                            {
                                await dapperHelper.ExecuteSP_Single <string>(Header.RFX_OPEN, new
                                {
                                    @HeaderId = item.HeaderId
                                });

                                //Add pending RFx invitations to message table
                                await dapperHelper.ExecuteSP_Single <string>(spMessage.SET_DATA_INVITATION_RFX, new
                                {
                                    @HeaderId = item.HeaderId
                                });

                                //Send email to suppliers invited
                                await messageRepository.message_notification();
                            } //si la fecha de cierre es menor a la fecha actual
                            else if (item.CloseDate < Now && item.Status == "PUBLICADO")
                            {
                                await dapperHelper.ExecuteSP_Single <string>(Header.RFX_CLOSE, new
                                {
                                    @HeaderId = item.HeaderId
                                });
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
 public async Task DeleteMeasuranceUnit(MeasuranceUnitEntity unit, string modifiedBy)
 {
     try
     {
         await dapperHelper.ExecuteSP_Single <string>(MeasuranceUnit.DELETE, new
         {
             @Id         = unit.MeasuranceUnitId,
             @ModifiedBy = modifiedBy
         });
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #5
0
 public async Task InsertCharacteristic(CharacteristicEntity characteristic, string userUniqueName)
 {
     try
     {
         await dapperHelper.ExecuteSP_Single <string>(SpCharacteristic.INSERT, new
         {
             @CharacteristicCode        = characteristic.CharacteristicCode,
             @CharacteristicDescription = characteristic.CharacteristicDescription,
             @CreatedBy = userUniqueName
         });
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.StackTrace);
     }
 }
Example #6
0
 public async Task InsertCategory(CategoryEntity category)
 {
     try
     {
         await dapperHelper.ExecuteSP_Single <string>(SpCategory.INSERT, new
         {
             @CategoryName = category.CategoryName,
             @CategoryCode = category.CategoryCode,
             @CompanyId    = category.CompanyId
         });
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.StackTrace);
     }
 }
Example #7
0
 public async Task InsertCarrier(CarrierEntity carrier)
 {
     try
     {
         await dapperHelper.ExecuteSP_Single <string>(SpCarrier.florida_Carrier_insert, new
         {
             @Driver   = carrier.CarrierDriver,
             @Licence  = carrier.CarrierLicense,
             @CarPlane = carrier.CarrierCarPlate,
             @CarModel = carrier.CarrierCarModel,
             @Company  = carrier.CarrierCompany
                         //@CompanyId = carrier.CompanyId
         });
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.StackTrace);
     }
 }
Example #8
0
        public async Task Insert(UserEntity entity)
        {
            int    userExist;
            string uservalidado = await dapperHelper.ExecuteSP_Single <string>(User.VALIDATE, new
            {
                @UserFirstName = entity.UserFirstName,
                @UserLastName  = entity.UserLastName,
                @UserEmail     = entity.UserEmail,
                @UserLogin     = entity.UserLogin,
                @UserPassword  = entity.UserPassword
            });

            userExist = Convert.ToInt32(uservalidado);

            if (userExist != 0)
            {
                var ex = new ArgumentException("Hey, soy una excepción guardada en una variable");
                throw ex;
            }

            else
            {
                try
                {
                    await dapperHelper.ExecuteSP_Single <string>(User.INSERT, new
                    {
                        @UserFirstName = entity.UserFirstName,
                        @UserLastName  = entity.UserLastName,
                        @UserEmail     = entity.UserEmail,
                        @UserLogin     = entity.UserLogin,
                        @UserPassword  = entity.UserPassword,
                        @CompanyId     = entity.CompanyId,
                        @UserRoles     = entity.Roles.AsTableValuedParameter("udtt_RoleUserType", new[] { "RoleId" })
                    });
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }
Example #9
0
 public async Task InsertBid(List <BidEntity> bid, int companyId, string userUniqueName)
 {
     try
     {
         await dapperHelper.ExecuteSP_Single <BidEntity>(SpBid.INSERT, new
         {
             @BuyerId  = companyId,
             @BidArray = bid.AsTableValuedParameter("udtt_BidArrayType", new[] {
                 "BidId",
                 "VendorId",
                 "HeaderId",
                 "Status",
             }),
             @CreatedBy = userUniqueName
         });
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #10
0
 public async Task InsertWarehouse(WarehouseEntity warehouse, string userUniqueName, int companyId)
 {
     try
     {
         await dapperHelper.ExecuteSP_Single <string>(SpWarehouse.INSERT, new
         {
             @WarehouseName    = warehouse.WarehouseName,
             @WarehouseAddress = warehouse.WarehouseAddress,
             @WarehouseCity    = warehouse.WarehouseCity,
             @WarehouseState   = warehouse.WarehouseState,
             @WarehouseCountry = warehouse.WarehouseCountry,
             @WarehousePhone   = warehouse.WarehousePhone,
             @CompanyId        = companyId,
             @CreatedBy        = userUniqueName
         });
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.StackTrace);
     }
 }
Example #11
0
 public async Task InsertAttachment(List <AttachmentEntity> attachments, string createdBy, int headerId)
 {
     try
     {
         await dapperHelper.ExecuteSP_Single <AttachmentEntity>(SpAttachment.INSERT, new
         {
             @AttachmentArray = attachments.AsTableValuedParameter("udtt_AttachmentArrayType", new[] {
                 "AttachmentId",
                 "AttachmentDescription",
                 "AttachmentPath",
                 "Deleted",
                 "HeaderId",
                 "isNew"
             }),
             @CreatedBy  = createdBy,
             @ModifiedBy = createdBy,
             @HeaderId   = headerId
         });
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #12
0
        //Rfx
        public async Task <int> Insert_Rfx(HeaderEntity header, string createdBy, int userId, int companyId)
        {
            try
            {
                string idHeader = await dapperHelper.ExecuteSP_Single <string>(Header.INSERT_RFX, new
                {
                    @BuyerCompanyId            = companyId,
                    @DocumentNumber            = header.DocumentNumber,
                    @Description               = header.Description,
                    @Budget                    = header.Budget,
                    @Status                    = header.Status,
                    @DecisionDate              = header.DecisionDate,
                    @RequestDeliveryDate       = header.RequestDeliveryDate,
                    @LeadDays                  = header.LeadDays,
                    @OpenDate                  = header.OpenDate,
                    @CloseDate                 = header.CloseDate,
                    @ValidityStartDate         = header.ValidityStartDate,
                    @ValidityEndDate           = header.ValidityEndDate,
                    @RealDeliveryDate          = header.RealDeliveryDate,
                    @TotalGrossValue           = header.TotalGrossValue,
                    @TotalTaxValue             = header.TotalTaxValue,
                    @TotalAllowances           = header.TotalAllowances,
                    @TotalCharges              = header.TotalCharges,
                    @PaymentType               = header.PaymentType,
                    @CreditDetail              = header.CreditDetail,
                    @DepartureDate             = header.DepartureDate,
                    @ArrivalDate               = header.ArrivalDate,
                    @DocCancelBy               = header.DocCancelBy,
                    @DocCancelOn               = header.DocCancelOn,
                    @CancelReason              = header.CancelReason,
                    @DocPartLocation           = header.DocPartLocation,
                    @PaymentTypeDocument       = header.PaymentTypeDocument,
                    @PaymentTypeDocumentNumber = header.PaymentTypeDocumentNumber,
                    @LastModifiedOn            = header.LastModifiedOn,
                    @LastModifiedBy            = header.LastModifiedBy,
                    @CargoValue                = header.CargoValue,
                    @HeaderNote                = header.HeaderNote,
                    @AwardingNote              = header.AwardingNote,
                    @SummaryNote               = header.SummaryNote,
                    @CurrencyId                = header.CurrencyId,
                    @UserId                    = userId,
                    @CreatedBy                 = createdBy
                });

                return(Convert.ToInt32(idHeader));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #13
0
        public async Task message_notification()
        {
            try
            {
                string rootPath = Directory.GetCurrentDirectory();
                if (!System.IO.Directory.Exists(Path.Combine(rootPath, "\\HTMLMessages")))
                {
                    Directory.CreateDirectory("HTMLMessages");
                }
                string htmlPath = Directory.GetCurrentDirectory() + "\\HTMLMessages\\";

                string html = "InvitationMessage.html";
                if (!System.IO.File.Exists(Path.Combine(htmlPath + html)))
                {
                    File.WriteAllText(htmlPath + html, "<b>Estimado [SupplierName]</b>" +
                                      "\r\n<br />" +
                                      "\r\n<br />" +
                                      "Usted ha sido invitado a participar en la licitación N°[DocumentNumber], la cual estará disponible desde [OpenDate] hasta [CloseDate]." +
                                      "\r\n<br />" +
                                      "\r\n<br />" +
                                      "Atentamente" +
                                      "\r\n<br />" +
                                      "\r\n<br />" +
                                      "[BuyerName]");
                }

                List <MessageEntity> listPending = await dapperHelper.ExecuteSP_Multiple <MessageEntity>(spMessage.GET_ALL_BYPENDING);

                foreach (MessageEntity item in listPending)
                {
                    string body = System.IO.File.ReadAllText(Path.Combine(htmlPath + html));
                    InvitationRfxEntity data = dapperHelper.ExecuteSP_Single <InvitationRfxEntity>(spMessage.GET_DATA_INVITATION_RFX, new { @messageId = item.MessageId }).Result;
                    body = body.Replace("[BuyerName]", data.BuyerName);
                    body = body.Replace("[SupplierName]", data.SupplierName);
                    body = body.Replace("[DocumentNumber]", data.DocumentNumber);
                    body = body.Replace("[OpenDate]", data.OpenDate.ToShortDateString());
                    body = body.Replace("[CloseDate]", data.CloseDate.ToShortDateString());

                    item.Subject     = "Invitación a licitación " + data.DocumentNumber;
                    item.MessageSent = body;

                    SendMail(item.MessageId, item.MessageTo, item.MessageToBCC, item.MessageSent, item.Subject);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #14
0
        public async Task <JsonResult> UploadFile(IFormCollection collection, int headerId)
        {
            try
            {
                string        companyCode = HttpContext.User.Claims.First(c => c.Type == "CompanyCode").Value;
                HeaderEntity  header      = dapperHelper.ExecuteSP_Single <HeaderEntity>(Header.GET_BY_ID, new { @headerId = headerId, @companyId = 0 }).Result;
                CompanyEntity buyer       = dapperHelper.ExecuteSP_Single <CompanyEntity>(SpCompany.GET_BY_ID, new { @companyId = header.BuyerCompanyId }).Result;
                string        buyerCode   = buyer.CompanyCode;


                //Azure
                // Retrieve storage account from connection string.
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
                // Create the blob client.
                CloudBlobClient serviceClient = storageAccount.CreateCloudBlobClient();

                // Create container. Name must be lower case.
                Console.WriteLine("Creating container...");
                CloudBlobContainer container = serviceClient.GetContainerReference(buyerCode.ToLower());
                container.CreateIfNotExistsAsync().Wait();



                List <AttachmentEntity> attachments = new List <AttachmentEntity>();

                string rootPath = Directory.GetCurrentDirectory();
                rootPath = Path.GetFullPath(Path.Combine(rootPath, @"..\..\"));

                string savePath = rootPath + "Attachments";//Ftp
                if (!System.IO.Directory.Exists(Path.Combine(savePath)))
                {
                    Directory.CreateDirectory(Path.Combine(savePath));
                }

                string savePathAzure = "attachments";//Azure

                var f = collection.Files;
                foreach (var file in f)
                {
                    AttachmentEntity attachment = new AttachmentEntity();

                    string filePath      = savePath + "\\" + companyCode + "_" + headerId;      //Ftp
                    string filePathAzure = savePathAzure + "\\" + companyCode + "_" + headerId; //Azure

                    // Get the name of the file to upload.
                    string fileName      = file.FileName; //Ftp
                    string fileNameAzure = file.FileName; //Azure

                    //// Create the path and file name to check for duplicates.
                    //string pathToCheck = filePath + "_" + fileName;
                    //// Create a temporary file name to use for checking duplicates.
                    //string tempfileName = "";
                    //// Check to see if a file already exists with the
                    //// same name as the file to upload.
                    //if (System.IO.File.Exists(pathToCheck))
                    //{
                    //    int counter = 2;
                    //    while (System.IO.File.Exists(pathToCheck))
                    //    {
                    //        // if a file with this name already exists,
                    //        // prefix the filename with a number.
                    //        tempfileName = Path.GetFileNameWithoutExtension(fileName) + '(' + counter.ToString() + ')' + Path.GetExtension(fileName);
                    //        pathToCheck = filePath + '_' + tempfileName;
                    //        counter++;
                    //    }
                    //    fileName = tempfileName;
                    //}

                    // Append the name of the file to upload to the path.
                    filePath      += "_" + fileName;      //Ftp
                    filePathAzure += "_" + fileNameAzure; //Azure

                    // Retrieve reference to a blob named "myblob".
                    CloudBlockBlob blockBlob = container.GetBlockBlobReference(filePathAzure.ToLower());

                    ////Upload file to API
                    //using (var stream = new FileStream(filePath, FileMode.Create))
                    //{
                    //    await file.CopyToAsync(stream);
                    //}

                    ////Upload file from API to Azure Storage
                    //using (var fileStream = System.IO.File.OpenRead(filePath))
                    //{
                    //    await blockBlob.UploadFromStreamAsync(fileStream);
                    //}

                    ////Delete file from API
                    //System.IO.File.Delete(filePath);

                    Stream temp;
                    temp = file.OpenReadStream();
                    await blockBlob.UploadFromStreamAsync(temp);

                    attachment.AttachmentDescription = fileName;
                    //attachment.AttachmentPath = filePath;
                    attachments.Add(attachment);
                }
                return(Json(attachments));
            }
            catch (Exception ex)
            {
                await errorServices.ErrorNotification(ex, HttpContext.User.Identity.Name, "", "");

                return(Json(ex));
            }
        }
Example #15
0
        public async Task Insert(List <DetailEntity> details, string userUniqueName)
        {
            try
            {
                try
                {
                    string sinCodigoId;
                    sinCodigoId = await dapperHelper.ExecuteSP_Single <string>(Product.SIN_CODIGO);

                    foreach (var item in details)
                    {
                        if (item.ProductId == 0)
                        {
                            item.ProductId = Int32.Parse(sinCodigoId);
                        }
                    }
                }
                catch (Exception)
                {
                }

                foreach (var item in details)
                {
                    if (item.ProductionDate < new DateTime(1900, 1, 1))
                    {
                        item.ProductionDate = new DateTime(1900, 1, 1);
                    }
                    if (item.ExpirationDate < new DateTime(1900, 1, 1))
                    {
                        item.ExpirationDate = new DateTime(1900, 1, 1);
                    }
                }

                await dapperHelper.ExecuteSP_Single <DetailEntity>(SpDetail.INSERT, new
                {
                    @DetailArray = details.AsTableValuedParameter("udtt_DetailArrayType", new[] {
                        "DetailId",
                        "HeaderId",
                        "ProductId",
                        "SellerProductCode",
                        "SellerProductPartNumber",
                        "ProductionDate",
                        "ExpirationDate",
                        "LeadDays",
                        "CharacteristicId",
                        "Description",
                        "MeasuranceUnit",
                        "StandardPartNumber",
                        "PartNumberOther",
                        "AdditionalPartNumber",
                        "ItemQuantity",
                        "EnforceQuantity",
                        "QuantityAwarded",
                        "OrderQuantity",
                        "ShippedQuantity",
                        "ReferalPrice",
                        "UnitPrice",
                        "Subtotal",
                        "Weight",
                        "TradeDiscount",
                        "DetailNote",
                        "CountryProductOrigin",
                        "Status",
                        "isNew"
                    }),
                    @CreatedBy  = userUniqueName,
                    @ModifiedBy = userUniqueName
                });
            }
            catch (Exception e)
            {
                throw e;
            }
        }