public HttpResponseMessage SaveUploadDocl(UploadDoc obj)
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            OracleCommand    command;

            try
            {
                connection.Open();
                command             = new OracleCommand("HCI_SP_UPLOAD_INSERT");
                command.CommandType = CommandType.StoredProcedure;
                command.Connection  = connection;
                command.Parameters.Add("V_ID", OracleDbType.Double).Value                 = obj.Id;
                command.Parameters.Add("V_AGT_CODE", OracleDbType.NVarchar2).Value        = obj.AgtCode;
                command.Parameters.Add("V_DOC_TYPE_ID", OracleDbType.Double).Value        = obj.DocTypeId;
                command.Parameters.Add("V_DOC_URL", OracleDbType.NVarchar2).Value         = obj.DocUrl;
                command.Parameters.Add("V_CREATED_BY", OracleDbType.NVarchar2).Value      = obj.CreatedBy;
                command.Parameters.Add("V_DOC_DESCRIPTION", OracleDbType.NVarchar2).Value = obj.DocDescription;
                //command.Parameters.Add("V_CREATED_DATE", OracleType.DateTime).Value = "";// obj.CreatedDate;
                //command.Parameters.Add("V_EFFECTIVE_END_DATE", OracleType.DateTime).Value = "";// obj.EffectiveEndDate;
                command.ExecuteNonQuery();
                connection.Close();
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception exception)
            {
                connection.Close();
                return(Request.CreateResponse(HttpStatusCode.ExpectationFailed));
            }
        }
Exemplo n.º 2
0
        public IActionResult GetUploadedLoanDoc(int userId)
        {
            List <UploadDoc> lstUploadedDocVM = new List <UploadDoc>();

            var t = _context.CustomerLoan.Where(q => q.CustomerId == userId).Select(q => q.CustomerLoanId).ToList();
            List <CustomerLoanDocumentDtl> lstUploadedDoc = _context.CustomerLoanDocumentDtl.Where(q => t.Contains(q.CustomerLoanId)).ToList();

            string folderName      = "CustomerDoc";
            string webRootPath     = _hostingEnvironment.WebRootPath;
            string uploadFilesPath = Path.Combine(webRootPath, folderName);
            //var filepath = Path.Combine(uploadFilesPath, filename);
            var result = lstUploadedDoc.GroupBy(q => new { q.FileName, q.DocumentTypeId }).Select(a => a.FirstOrDefault());

            foreach (var item in result)
            {
                var doc = new UploadDoc
                {
                    filedata     = null,
                    Filename     = item.FileName,
                    DocType      = item.DocumentTypeId,
                    DownloadPath = string.Format("{0}/CustomerDoc/{1}", _configuration["DevImageDomain"], item.FileName),
                    isChecked    = true
                };

                lstUploadedDocVM.Add(doc);
            }
            return(Ok(lstUploadedDocVM));
        }
Exemplo n.º 3
0
        public ActionResult UploadDocEdit(TManager.Models.ViewModels.AttachedFileVM uploadhelper, int ProjectID)
        {
            if (ModelState.IsValid)
            {
                if (uploadhelper.AttachedFile != null && uploadhelper.AttachedFile.ContentLength > 0)
                {
                    var    realFileName  = System.IO.Path.GetFileName(uploadhelper.AttachedFile.FileName);
                    var    filePath      = Server.MapPath("~/App_Data/UploadedDoc");
                    var    fileName      = DateTime.Now.Ticks + System.IO.Path.GetExtension(uploadhelper.AttachedFile.FileName);
                    string savedFileName = System.IO.Path.Combine(filePath, fileName);
                    uploadhelper.AttachedFile.SaveAs(savedFileName);
                    // init object here
                    var evd = new UploadDoc();
                    evd.FileName       = realFileName;
                    evd.FileSystemName = fileName;
                    evd.ContentType    = uploadhelper.AttachedFile.ContentType;
                    evd.FileExtension  = Path.GetExtension(fileName);
                    evd.ProjectID      = ProjectID;
                    // for now
                    evd.Description = uploadhelper.FDescription;

                    unitOfWork.Repository <UploadDoc>().Insert(evd);
                    unitOfWork.Save();
                    // we shall send back the id for this file
                    return(Json(new { ID = evd.FileID, R = true, FileName = evd.FileName, FileSystemName = evd.FileSystemName, Description = evd.Description, DLink = Url.Action("Download", "Home", new { id = evd.FileID }) }));
                }
            }

            return(Json(new { R = false }));
        }
Exemplo n.º 4
0
 public ActionResult DeleteDoc(string id)
 {
     if (!(string.IsNullOrEmpty(id)))
     {
         int       delID    = int.Parse(id);
         UploadDoc doc      = unitOfWork.Repository <UploadDoc>().GetByID(delID);
         string    fullPath = Request.MapPath("~/App_Data/UploadedDoc/" + doc.FileName);
         if (System.IO.File.Exists(fullPath))
         {
             System.IO.File.Delete(fullPath);
         }
         unitOfWork.Repository <UploadDoc>().Delete(doc);
         unitOfWork.Save();
         return(Json(new { msg = "Document Remove successfully", D = true }));
     }
     return(Json(new { msg = "error in removing doc", D = false }));
 }
Exemplo n.º 5
0
        //protected void DdlReceivedFrom_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    GetAccReceiptInVoicesByReceiptID(1);
        //}

        protected void UploadFile()
        {
            string folderPath = Server.MapPath("~/Files/Receipts/");

            //Check whether Directory (Folder) exists.
            if (!Directory.Exists(folderPath))
            {
                //If Directory (Folder) does not exists. Create it.
                Directory.CreateDirectory(folderPath);
            }

            //Save the File to the Directory (Folder).
            UploadDoc.SaveAs(folderPath + Path.GetFileName(UploadDoc.FileName));

            ////Display the success message.
            //lblMessage.Text = Path.GetFileName(FileUpload1.FileName) + " has been uploaded.";
        }
Exemplo n.º 6
0
 public void UpdateUploadDoc(UploadDoc upload)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
 public void AddUploadDoc(UploadDoc upload)
 {
     _db.UploadDocs.Add(upload);
 }
        public UploadDoc getLeader_HProfilePicByAgentID(string vAGT_CODE)
        {
            UploadDoc        UploadDocObj1 = new UploadDoc();
            OracleDataReader dataReader1   = null;
            OracleConnection connection1   = new OracleConnection(ConnectionString);
            OracleCommand    command1;

            string sql = "";


            sql = "SELECT " +
                  "CASE WHEN t.ID IS NULL THEN 0  ELSE t.ID END, " +
                  "t.AGT_CODE || ' - ' || A.AGT_FULL_NAME, " +
                  "CASE WHEN t.DOC_TYPE_ID IS NULL THEN 0  ELSE t.DOC_TYPE_ID END, " +
                  "CASE WHEN t.DOC_URL IS NULL THEN ''  ELSE t.DOC_URL END, " +
                  "CASE WHEN t.CREATED_BY IS NULL THEN ''  ELSE t.CREATED_BY END, " +
                  "CASE WHEN t.CREATED_DATE IS NULL THEN to_date('01/01/1900', 'DD/MM/RRRR')  ELSE t.CREATED_DATE END, " +
                  "CASE WHEN t.EFFECTIVE_END_DATE IS NULL THEN to_date('01/01/1900', 'DD/MM/RRRR')  ELSE to_date(t.EFFECTIVE_END_DATE, 'DD/MM/RRRR') END, DT.DOC_TYPE_NAME, t.doc_description   " +
                  "FROM HCI_TBL_UPLOADED_DOC t, Hci_Tbl_Uploaded_Doc_Type DT, HCI_TBL_AGENT A " +
                  "WHERE A.AGT_CODE=:vAGT_CODE AND DT.doc_type_id = T.doc_type_id AND t.EFFECTIVE_END_DATE is null AND t.DOC_TYPE_ID = 1 AND A.AGT_CODE = T.AGT_CODE AND A.AGT_EFFECTIVE_END_DATE IS NULL";



            command1 = new OracleCommand(sql, connection1);
            command1.Parameters.Add(new OracleParameter("vAGT_CODE", vAGT_CODE));
            connection1.Open();
            try
            {
                dataReader1 = command1.ExecuteReader();
                if (dataReader1.HasRows)
                {
                    dataReader1.Read();

                    UploadDocObj1.Id               = Convert.ToInt32(dataReader1[0]);
                    UploadDocObj1.AgtCode          = dataReader1[1].ToString();
                    UploadDocObj1.DocTypeId        = Convert.ToInt32(dataReader1[2].ToString());
                    UploadDocObj1.DocUrl           = dataReader1[3].ToString();
                    UploadDocObj1.CreatedBy        = dataReader1[4].ToString();
                    UploadDocObj1.CreatedDate      = dataReader1[5].ToString();
                    UploadDocObj1.EffectiveEndDate = dataReader1[6].ToString();
                    UploadDocObj1.DocTypeDesc      = dataReader1[7].ToString();
                    UploadDocObj1.DocDescription   = dataReader1[8].ToString();

                    dataReader1.Close();
                    connection1.Close();
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception exception)
            {
                if (dataReader1 != null || connection1.State == ConnectionState.Open)
                {
                    dataReader1.Close();
                    connection1.Close();
                }
            }
            finally
            {
                connection1.Close();
            }
            return(UploadDocObj1);
        }
        public async Task <FileUploadResult> UploadExcel(string vAGT_CODE)
        {
            try
            {
                var uploadPath = CommissionSystemREST.Properties.Settings.Default.Commission_Docs;


                string year = DateTime.Now.Year.ToString();

                var dbSavePath = "/" + year + "/" + vAGT_CODE;

                uploadPath = uploadPath + "/" + year + "/" + vAGT_CODE;
                if (!Directory.Exists(uploadPath))
                {
                    System.IO.Directory.CreateDirectory(uploadPath);
                }

                var multipartFormDataStreamProvider = new UploadMultipartFormProvider(uploadPath);



                // Read the MIME multipart asynchronously
                await Request.Content.ReadAsMultipartAsync(multipartFormDataStreamProvider);

                string AgentCode = multipartFormDataStreamProvider.FormData["AgentCode"];

                string DocTypeID = multipartFormDataStreamProvider.FormData["DocTypeID"];

                string UserID = multipartFormDataStreamProvider.FormData["UserID"];

                string DocDescription = multipartFormDataStreamProvider.FormData["DocDescription"];

                string _localFileName = multipartFormDataStreamProvider
                                        .FileData.Select(multiPartData => multiPartData.LocalFileName).FirstOrDefault();

                dbSavePath = dbSavePath + "/" + multipartFormDataStreamProvider
                             .FileData.Select(multiPartData => multiPartData.Headers.ContentDisposition.FileName).FirstOrDefault().Replace("\"", "");



                DataTable Dt = ConvertExceltoDatatable(_localFileName, vAGT_CODE, UserID);   // DPTSManualUpload   /   ReceiptManualUpload

                if (vAGT_CODE == "DPTSManualUpload")
                {
                    BulkCopyDPTS(Dt, UserID);
                }
                else if (vAGT_CODE == "ReceiptManualUpload")
                {
                    BulkCopyRECEIPT(Dt);
                }



                UploadDoc uploadedDoc = new UploadDoc();
                uploadedDoc.Id               = 0;
                uploadedDoc.AgtCode          = AgentCode;
                uploadedDoc.DocTypeId        = Convert.ToInt32(DocTypeID);
                uploadedDoc.DocUrl           = dbSavePath;
                uploadedDoc.CreatedBy        = UserID;
                uploadedDoc.CreatedDate      = null;
                uploadedDoc.EffectiveEndDate = null;
                uploadedDoc.DocDescription   = vAGT_CODE;  // DPTSManualUpload   /   ReceiptManualUpload


                SaveUploadDocl(uploadedDoc);


                // Create response
                return(new FileUploadResult
                {
                    LocalFilePath = _localFileName,

                    FileName = Path.GetFileName(_localFileName),

                    FileLength = new FileInfo(_localFileName).Length
                });
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 10
0
        public string GenerateInvoiceAndTask(int POId)
        {
            try
            {
                string strDefCulZone = Global.DefCulZone();

                DataAccess dba = new DataAccess();
                using (SqlConnection conn = dba.dxConnection)
                {
                    conn.Open();
                    SqlTransaction trans   = conn.BeginTransaction();
                    SqlCommand     command = conn.CreateCommand();
                    command.Transaction = trans;

                    string message = string.Empty;
                    int    claimId = 0;

                    claimId      = dba.dxGetIntData("select projid from schedule where schid=" + schId);
                    SubProcessId = dba.dxGetIntData("select subprocessid from schedule where schid=" + schId);

                    ////string claimNo = this.ddlProject.SelectedItem.Text.Trim();

                    SmartFlowLite.APInvoice inv = null;

                    // Task variables
                    int nextActionID      = 22854; //task no this goes to
                    int assignedAccountId = 0;     //branch id
                    int assignedUserId    = 0;     //user id

                    if ((this.SubProcessId == 1) || (this.SubProcessId == 2))
                    {
                        assignedUserId    = WorkFlow.BLL.Invoice.APInvoice.GetPMforClaims(this.WfId, this.SubProcessId);
                        assignedAccountId = Claim.GetBranchID(this.WfId, SubProcessId);
                    }



                    Doxess.Web.WorkFlow.Process.Process dxProcess = new Doxess.Web.WorkFlow.Process.Process();

                    dba.dxAddParameter("@POId", POId);
                    int VendorId   = dba.dxGetIntData("Select VendorId from PurchaseOrders where POId = @POId");
                    int CostCodeId = dba.dxGetIntData("Select defcostcode from vendors where vendorid =" + VendorId);

                    // Add new invoice record
                    inv             = new SmartFlowLite.APInvoice();
                    inv.InvoiceDate = DateTime.Parse(this.txtInvoiceDate.Text);
                    inv.Amount      = Math.Round(Convert.ToDecimal(this.txtAmount.Text), 2);
                    inv.GSTAmount   = Math.Round(Convert.ToDecimal(this.txtHST.Text), 2);

                    //inv.setProvincialTaxField(ref inv, SelectedVendor, SelectedBranch, Math.Round(Convert.ToDecimal(this.txtPSTAmt.Text), 2));

                    inv.TotalAmount   = Math.Round((inv.Amount + inv.GSTAmount + inv.PSTAmount + inv.QSTAmount), 2);
                    inv.ClaimId       = claimId;
                    inv.InvoiceNo     = this.txtInvoiceNumber.Text.Trim();
                    inv.PONo          = POId;
                    inv.VendorId      = VendorId;
                    inv.VendorName    = WorkFlow.Objects.BLL.Vendors.GetVendorName(VendorId);
                    inv.SubProcess    = this.SubProcessId;
                    inv.FileId        = this.FileId;
                    inv.CostCodeId    = CostCodeId;
                    inv.History       = false;
                    inv.BatchId       = WorkFlow.BLL.Invoice.APInvoice.GetBatchId();
                    inv.AdminOrClaims = 1;
                    inv.ProcessId     = 22;

                    int invoiceId = inv.AddNewWithProcessId(ref message, command, userID);

                    InvoiceId = invoiceId;

                    if (!message.Equals(string.Empty))
                    {
                        //delete the uplaoded file
                        WorkFlow.BLL.Claim.UploadDoc doc = new UploadDoc(this.FileId);
                        doc.DeleteFile(ref message);

                        //delete attached PO
                        WorkFlow.BLL.JobCost.PoData.DeletePO(POId);

                        //this.lblMessage.Text = message;
                        trans.Rollback();
                        return(message);
                    }


                    string TaskDesc = "Approve Vendor Cost - " + inv.VendorName + " No. " + inv.InvoiceNo;
                    int    DetId    = dxProcess.wfTaskCreate(ref message, command, this.WfId, nextActionID, -1, assignedAccountId, assignedUserId, TaskDesc, "", "", InvoiceId, this.FileId, this.SubProcessId);


                    if (!message.Equals(string.Empty) || DetId < 0)
                    {
                        WorkFlow.BLL.JobCost.PoData.DeletePO(POId);
                        WorkFlow.BLL.Invoice.APInvoice.DeleteIncomingInvoice(command, InvoiceId, this.WfId, this.SubProcessId);
                        WorkFlow.BLL.Claim.UploadDoc doc = new UploadDoc(this.FileId);
                        doc.DeleteFile(ref message);
                        //this.lblMessage.Text = message;
                        trans.Rollback();
                        return(message);
                    }
                    else
                    {
                        if (cat == "20")
                        {
                            this.userName = dba.dxGetTextData("select resname from schresources where resindexid=(select accountid from wfusers where userid=" + this.userID.ToString() + ") and rescatid=20");
                        }
                        else
                        {
                            this.userName = TimebookCom.WeeklyTimebook.GetUserNameById(userID);
                        }
                        Notes.AddNewNote(this.WfId, "A", 0, DateTime.Now.ToString(), userID, "Invoice " + InvoiceId + " created by " + userName, this.SubProcessId);
                    }

                    dba.dxAddParameter("@UserId", assignedUserId);
                    int       assignedToRoleId = 0;// = 211;
                    DataTable dtRoles          = dba.dxGetTable("Select RoleId from wfUsersRoles where UserId = @UserId order by RoleId");
                    if (dtRoles.Rows.Count > 0)
                    {
                        for (int count = 0; count < dtRoles.Rows.Count; count++)
                        {
                            if (Convert.ToInt32(dtRoles.Rows[count]["RoleId"].ToString()) == 210)
                            {
                                assignedToRoleId = 210;
                                break;
                            }
                            else if (Convert.ToInt32(dtRoles.Rows[count]["RoleId"].ToString()) == 211)
                            {
                                assignedToRoleId = 211;
                                break;
                            }
                        }
                    }


                    if (!message.Equals(string.Empty) || DetId < 0)
                    {
                        WorkFlow.BLL.JobCost.PoData.DeletePO(POId);
                        WorkFlow.BLL.Invoice.APInvoice.DeleteIncomingInvoice(command, InvoiceId, this.WfId, this.SubProcessId);
                        WorkFlow.BLL.Claim.UploadDoc doc = new UploadDoc(this.FileId);
                        doc.DeleteFile(ref message);
                        //this.lblMessage.Text = message;
                        trans.Rollback();
                        return(message);
                    }
                    else
                    {
                        message = dba.dxUpdate(command, "wfDet", "AssignedToRoleId", "DetId", assignedToRoleId, DetId);
                        message = dba.dxUpdate(command, "wfDetR2G", "AssignedToRoleId", "DetId", assignedToRoleId, DetId);
                        dba.dxUpdate(command, "PurchaseOrders", "POStatusId", "POId", 2, inv.PONo); //update purchase order status
                    }


                    trans.Commit();
                    SetExpiryDate(DetId);
                    return("");
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;

                WorkFlow.BLL.Claim.UploadDoc doc = new UploadDoc(this.FileId);
                doc.DeleteFile(ref message);
                return(message);
            }
        }
Exemplo n.º 11
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            lbl_Massage.Visible = true;

            //System.Threading.Thread.Sleep(15000);

            if (drpDownType.Text == "--Select--" || drpDownType.SelectedValue.ToString() == "--Select--" || drpDownType.Text == "" || drpDownType.Text == "--Seleccionar--" || drpDownType.SelectedValue.ToString() == "--Seleccionar--")
            {
                btnSave.Enabled = true;
                string alertmsg;
                if (CultureInfo.CurrentCulture.Name == "es-ES")
                {
                    alertmsg = "alert('Por favor seleccione tipo');";
                }
                else
                {
                    alertmsg = "alert('Please Select Type');";
                }
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertscript", alertmsg, true);
                return;
            }

            if (drpDownApplication.Text == "Select" || drpDownApplication.SelectedValue.ToString() == "Select" || drpDownApplication.Text == "" || drpDownApplication.Text == "--Seleccionar--" || drpDownApplication.SelectedValue.ToString() == "--Seleccionar--")
            {
                btnSave.Enabled = true;
                string alertmsg;
                if (CultureInfo.CurrentCulture.Name == "es-ES")
                {
                    alertmsg = "alert('Por favor seleccione la aplicación');";
                }
                else
                {
                    alertmsg = "alert('Please Select Application');";
                }
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertscript", alertmsg, true);
                return;
            }

            if (DrpPriority.Text == "--Select Priority--" || DrpPriority.Text == "Select" || DrpPriority.Text == "" || DrpPriority.Text == "Seleccionar" || DrpPriority.Text == "--Seleccionar prioridad--")
            {
                btnSave.Enabled = true;
                string alertmsg;
                if (CultureInfo.CurrentCulture.Name == "es-ES")
                {
                    alertmsg = "alert('Seleccione Prioridad');";
                }
                else
                {
                    alertmsg = "alert('Please Select Priority');";
                }
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertscript", alertmsg, true);
                return;
            }
            if (fnCheckEmail(drpDownType.SelectedValue) == false)
            {
                string alertmsg;
                if (CultureInfo.CurrentCulture.Name == "es-ES")
                {
                    alertmsg = "alert('Por favor contacte al administrador');";
                }
                else
                {
                    alertmsg = "alert('Please contact Administrator');";
                }
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertscript", alertmsg, true);
                return;
            }



            string Ticket_Id = Fn_Get_Ticket_NO();


            string query         = "insert into tbl_Ticket_Master(Ticket_Id,Type_Id,Application_Id,Issue_Id,Issue_Details,Priority,Created_By,Created_Time,Status) values('" + Ticket_Id + "', " + drpDownType.SelectedValue + "," + drpDownApplication.SelectedValue + "," + DrpIssueType.SelectedValue + ",'" + IssueDetail.Text.Replace("'", "''").ToString() + "','" + DrpPriority.SelectedItem + "','" + UserId + "','" + DateTime.Now.ToString() + "','0')";
            int    executeStatus = DBUtils.ExecuteSQLCommand(new SqlCommand(query));

            if (executeStatus != -1)
            {
                typeName        = DBNulls.StringValue(drpDownType.SelectedItem.Text);
                applicationName = DBNulls.StringValue(drpDownApplication.SelectedItem.Text);
                issueName       = DBNulls.StringValue(DrpIssueType.Text);
                issueDetails    = DBNulls.StringValue(IssueDetail.Text);
                priority        = DBNulls.StringValue(DrpPriority.Text);
                createdBy       = UserId;
                createdAt       = PublicMethods.fnGetDateTimeNow();
                typeId          = DBNulls.StringValue(drpDownType.SelectedValue);
                applictionsId   = DBNulls.StringValue(drpDownApplication.SelectedValue);

                if (UploadDoc.HasFile)
                {
                    try
                    {
                        string filename   = Path.GetFileName(UploadDoc.FileName);
                        string folderPath = Server.MapPath("Files/" + Ticket_Id.ToString() + "/");

                        if (!Directory.Exists(folderPath))
                        {
                            Directory.CreateDirectory(folderPath);
                        }
                        UploadDoc.SaveAs(Server.MapPath("Files/" + Ticket_Id.ToString() + "/") + filename);
                        string queryFile = "Insert into tbl_Attachment_Master(Ticket_Id,File_Path,File_Name) values(" + Ticket_Id + ",'" + folderPath + "','" + filename + "')";
                        DBUtils.ExecuteSQLCommand(new SqlCommand(queryFile));
                        fileName = "files/" + Ticket_Id + "/" + filename;

                        //ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Ticket creation is successfull')", true);
                        string alertmsg;
                        if (CultureInfo.CurrentCulture.Name == "es-ES")
                        {
                            alertmsg = "alert(''La creación de entradas es exitosa');";
                        }
                        else
                        {
                            alertmsg = "alert(''Ticket creation is successful');";
                        }

                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alertscript", alertmsg, true);
                    }
                    catch (Exception ex)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(" + ex.Message + ")", true);
                    }
                }
                //Send Email

                fnSendMailXML(Ticket_Id);
                btnSave.Enabled = false;
                string alertmsg1;
                if (CultureInfo.CurrentCulture.Name == "es-ES")
                {
                    alertmsg1 = "alert('Ticket creado con éxito');";
                }
                else
                {
                    alertmsg1 = "alert('Ticket created successfully');";
                }
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertscript", alertmsg1, true);


                Response.Redirect("UserDash.aspx", true);
            }
            else
            {
                string alertmsg;
                if (CultureInfo.CurrentCulture.Name == "es-ES")
                {
                    alertmsg = "alert(''Error de inserción');";
                }
                else
                {
                    alertmsg = "alert(''Insertion Error');";
                }
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertscript", alertmsg, true);
                btnSave.Enabled = true;

                return;
            }
        }
        catch (Exception ex)
        {
            Response.Redirect("UserDash.aspx", true);
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(" + ex.Message + ")", true);
        }
    }
Exemplo n.º 12
0
        public ActionResult AddProject(ProjectReg preg)
        {
            var           insertProject  = new ProjectReg();
            List <string> arr            = new List <string>();
            string        tid            = null;
            int           CompID         = 0;
            var           additionalFile = false;

            try
            {
                insertProject.ProjectName     = preg.ProjectName;
                insertProject.Priority        = preg.Priority;
                insertProject.ProjectManager  = preg.ProjectManager;
                insertProject.DeptResponsible = preg.DeptResponsible;
                insertProject.LeadDeveloper   = preg.LeadDeveloper;

                var otherDev = preg.multiSelectLob.Split(','); //string.Join(",", preg.multiSelectLob.ToArray()).Split(',');
                foreach (var o in otherDev.ToList())
                {
                    var od = unitOfWork.Repository <Team>().Get(f => f.Fullname == o);
                    if (od.Count() > 0) //.FirstOrDefault().TeamID;
                    {
                        tid = od.FirstOrDefault().TeamID.ToString();

                        arr.Add(tid);
                        od = null;
                    }
                }
                CompID = int.Parse(preg.CompanyID);
                var com = unitOfWork.Repository <Company>().GetByID(CompID);
                insertProject.OtherDeveloper  = string.Join(",", arr.ToArray());
                insertProject.NumberOfUsers   = preg.NumberOfUsers;
                insertProject.oDeveloper      = preg.oDeveloper;
                insertProject.oProjectManager = preg.oProjectManager;
                insertProject.CompanyID       = preg.CompanyID;
                insertProject.CompanyName     = com.CompanyName;
                insertProject.BusinessNeed    = preg.BusinessNeed;
                insertProject.BizContact      = com.ContactPerson;
                insertProject.DateRecieved    = DateTime.Now;

                // insertProject.RegisteredBy
                insertProject.ProjectRemark    = preg.ProjectRemark;
                insertProject.ProjectStatus    = preg.ProjectStatus;
                insertProject.ProjectTaskType  = preg.ProjectTaskType;
                insertProject.ProjectObjective = preg.ProjectObjective;
                insertProject.ProjectStatus    = TManager.Models.Consts.ApprovalConsts.PENDING;
                bool hasv = unitOfWork.Repository <ProjectReg>().Get().Any(a => a.ProjectName == insertProject.ProjectName);
                if (hasv == false)
                {
                    unitOfWork.Repository <ProjectReg>().Insert(insertProject);
                    unitOfWork.Save();
                    var       docs = unitOfWork.Repository <TempDoc>().Get().Where(d => d.Description == insertProject.ProjectName && d.FileStatus == 1);
                    UploadDoc doc  = new UploadDoc();
                    if (docs != null && docs.ToList().Count != 0)
                    {
                        foreach (var f in docs)
                        {
                            doc.FileName       = f.FileName;
                            doc.FileSystemName = f.FileSystemName;
                            doc.Description    = f.Description;
                            doc.ProjectID      = insertProject.ProjectRegisterID;
                            doc.ContentType    = f.ContentType;
                            unitOfWork.Repository <UploadDoc>().Insert(doc);
                            unitOfWork.Save();
                        }

                        // we have to set the file status to 2 to differentiate the ones taken from tempDoc to vendorDoc tables
                        foreach (var t in docs)
                        {
                            TempDoc td = unitOfWork.Repository <TempDoc>().GetByID(t.TempID);
                            td.FileStatus = 2;
                            td.ProjectID  = insertProject.ProjectRegisterID;
                            unitOfWork.Repository <TempDoc>().Update(td);
                        }
                        unitOfWork.Save();
                    }
                }
                return(RedirectToAction("Projects"));
            }

            catch (DbEntityValidationException e)
            {
                ViewBag.Error = e.StackTrace;
                foreach (var eve in e.EntityValidationErrors)
                {
                    ViewBag.Error += eve.Entry.Entity.GetType().Name + ", " + eve.Entry.State;
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        ViewBag.Error += ve.PropertyName + " :: " + ve.ErrorMessage;
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
            }
            // set notification for approval
            //    string TargetMsg = PCMS_v1.Models.Consts.Message.RequesterLp1VendorMsg(insertVendor.VendorName, newaction.ActionID, BasePath());
            //    string subject = "#" + insertVendor.VendorID + " / " + insertVendor.VendorType + "/" + insertVendor.VendorName + " Registration Approval";
            //    var lp1Data = unitOfWork.Repository<ConsolStaffData>().Get(e => e.POSITION_NBR == RequesterData.ReportsTo).FirstOrDefault();
            //    // initiator's message
            //    string initiatorMsg = PCMS_v1.Models.Consts.Message.initiatorMsg(insertVendor);
            //    //insertVendor.RequesterLp1Data.FullName = lp1Data.FULL_NAME;
            //    insertVendor.RequesterData = DataHelper.GetRequesterInfo(unitOfWork, insertVendor.VendorRequester);
            //    insertVendor.RequesterData.FullName = RequesterData.LastName + " " + RequesterData.OtherNames;
            //    insertVendor.RequesterData.EmailAddress = RequesterData.EmailAddress;
            //    string TargetMail = lp1Data.EMAIL_ADDR;
            //    // we can fire mail to both requester and initiator
            //      SendEmail(TargetMsg, TargetMail, subject, newaction.ActionID, newaction, PCMS_v1.Models.Consts.ProcessAndFlowName.VENDOR_PROCESS);
            //    SendEmail(initiatorMsg, RequesterData.EmailAddress, subject, newaction.ActionID, newaction, PCMS_v1.Models.Consts.ProcessAndFlowName.VENDOR_PROCESS);
            //    // NotifyNextActor(insertVendor, insertVendor.RequesterLp1, insertVendor.RequesterLp1, PCMS_v1.Models.Consts.ActorRole.REQUESTER_LP1, "ReviewVendor", PCMS_v1.Models.Consts.ActorRole.VENDOR_PROCESS, sequenceNumber, insertVendor.VendorID, targetMsg, initiatorMsg, insertVendor.RequesterLp1Data.EmailAddress, insertVendor.RequesterData.EmailAddress);

            //TempData["CssClass"] = "success";
            //TempData["Notify"] = "Vendor" + insertVendor.VendorName + " created successfully !";

            var company = unitOfWork.Repository <Company>().Get().OrderBy(o => o.CompanyName);

            var LeadDev    = unitOfWork.Repository <Team>().Get();
            var projectMgr = unitOfWork.Repository <Team>().Get(e => e.Role == TManager.Models.Consts.ActorRole.PROJECT_MANAGER);

            ViewBag.LeadDeveloper  = new SelectList(LeadDev, "TeamID", "Fullname");
            ViewBag.ProjectManager = new SelectList(projectMgr, "TeamID", "Fullname");
            ViewBag.CompanyID      = new SelectList(company, "CompanyID", "CompanyName");
            return(View());
        }
        public async Task <IActionResult> AddUpload(UploadViewModel model)
        {
            if (ModelState.IsValid)
            {
                string unique = Guid.NewGuid().ToString();

                string UniqueTransId = "Upload-" + unique;

                var upload = new UploadDoc
                {
                    Name        = model.Name,
                    Email       = model.Email,
                    TransNumber = UniqueTransId
                };

                _upload.AddUploadDoc(upload);

                string webrootPath = _hostEnvironment.WebRootPath;
                var    files       = model.FormFiles;

                var uploads = Path.Combine(webrootPath, "images");



                for (int i = 0; i < files.Count; i++)
                {
                    string fileName = files[i].FileName;
                    //var extension = Path.GetExtension(files[i].FileName);
                    using (var fileStreams = new FileStream(Path.Combine(uploads, fileName), FileMode.Create))
                    {
                        files[i].CopyTo(fileStreams);
                    }
                    var uploadFile = new UploadImage
                    {
                        UploadId  = upload.Id,
                        ImagePath = @"\images\" + fileName
                    };

                    _upload.AddUploadFile(uploadFile);
                }

                #region Mail

                MailMessage msg = new MailMessage                                        // instance Mail sender service
                {
                    From = new MailAddress("#########################################"), // Server Email Address
                };
                msg.To.Add(model.Email);                                                 // receiver Email

                msg.Subject = "SDSD Developer Test";
                msg.Body    = "Hello " + model.Name + ", these are your attachments"; // Message Body


                foreach (var filepath in files)
                {
                    string fileName = Path.GetFileName(filepath.FileName);

                    msg.Attachments.Add(new Attachment(filepath.OpenReadStream(), fileName));
                }

                SmtpClient client = new SmtpClient
                {
                    Host = "smtp.gmail.com"
                };
                NetworkCredential credential = new NetworkCredential
                {  // Server Email credentisal
                    UserName = "******",
                    Password = "******"
                };
                client.Credentials = credential;
                client.EnableSsl   = true;
                client.Port        = 587;
                client.Send(msg);


                ViewBag.Success = $"Email has been sent successfully to {model.Email}";
                _logger.LogInformation("User created ");

                #endregion


                if (await _upload.SaveChangesAsync())
                {
                    return(RedirectToAction(nameof(Index)));
                }

                return(View(model));
            }
            return(View(model));
        }