/// <summary>
        /// This method is used to load model to display Webgrid data.
        /// </summary>
        /// <param name="model"></param>
        private void getDisplayData(ref Translation model)
        {
            model.ListLang = LoadLanguageDropDown();
            model.ListStatus = LoadStatusDropDown();

            //MembershipUser MemberUser = Membership.GetUser(User.Identity.Name);
            //string UserId = MemberUser.ProviderUserKey.ToString();
            string UserId = Convert.ToString(Common.GetUserId(HttpContext.User.Identity.Name));

            DataTable dtData = new DataTable();

            dtData = BLObj.getRowsCount(Convert.ToString(model.UserName), UserId, model.StartDate, model.EndDate);
            model.Pages = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(dtData.Rows[0][0].ToString()) / Convert.ToDouble((model.RecordsPerPage == 0) ? 5.00 : model.RecordsPerPage)));
            dtData.Clear();

            if (!string.IsNullOrEmpty(model.StartDate) && !string.IsNullOrEmpty(model.UserName))
            {
                dtData = BLObj.GetFilteredTranslationDataByBoth(model.UserName, model.StartIndex, model.EndIndex, model.sort, model.sortdir, model.StartDate, model.EndDate);
            }
            else if (!string.IsNullOrEmpty(model.StartDate))
            {
                dtData = BLObj.GetFilteredTranslationDataByDates(UserId, model.StartIndex, model.EndIndex, model.sort, model.sortdir, model.StartDate, model.EndDate);
            }
            else if (!string.IsNullOrEmpty(model.UserName))
            {
                dtData = BLObj.GetFilteredTranslationData(model.UserName, model.StartIndex, model.EndIndex, model.sort, model.sortdir);
            }
            else
            {
                dtData = BLObj.GetTranslationUserData(UserId, model.StartIndex, model.EndIndex, model.sort, model.sortdir);
            }

            List<Translation> listData = new List<Translation>();
            foreach (DataRow dr in dtData.Rows)
            {
                listData.Add(new Translation
                {
                    SrNo = Convert.ToInt32(dr["row"]),
                    Trn_ID = dr["Trn_ID"].ToString(),
                    OrderID = dr["OrderID"].ToString(),
                    UserName = dr["UserName"].ToString(),
                    FromLanguage = dr["fromlang"].ToString(),
                    ToLanguage = dr["tolang"].ToString(),
                    WordsCount = dr["WordsCount"].ToString(),
                    RequestFilePath = dr["RequestFilePath"].ToString(),
                    ResponseFilePath = dr["ResponseFilePath"].ToString(),
                    Status = dr["status_Name"].ToString(),
                    EstimatedAmt = dr["EstimatedAmt"].ToString(),
                    isPaymentRelesed = dr["IsPaymentReleased"].ToString(),
                    RequestDate = dr["RequestDate"].ToString(),
                    ResponseDate = dr["ResponseDate"].ToString()
                });
            }
            model.ModelList = listData;
        }
        public ActionResult Translation(Translation tr, FormCollection form, string Command, string PageIndex)
        {
            if (Command == "Submit")
            {
                tr.ListLang = LoadLanguageDropDown();
                tr.ListStatus = LoadStatusDropDown();

                //MembershipUser MemberUser = Membership.GetUser(User.Identity.Name);
                //string UserId = MemberUser.ProviderUserKey.ToString();
                string UserId = Convert.ToString(Common.GetUserId(HttpContext.User.Identity.Name));

                var uploadedFile = Request.Files[0];
                string strFileExtension = Path.GetExtension(uploadedFile.FileName);

                if (strFileExtension == ".docx" || strFileExtension == ".pdf")
                {
                    string FilePathToUpload = "";
                    FilePathToUpload = User.Identity.Name + "_" + Constants.strRequest + "_" + DateTime.Today.ToString("dd-MM-yyyy") + "_" + (Path.GetFileName(uploadedFile.FileName));

                    if (!Directory.Exists(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest))
                    {
                        Directory.CreateDirectory(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest);
                    }
                    uploadedFile.SaveAs(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest + "//" + FilePathToUpload);

                    if (strFileExtension == ".docx")
                    {

                        //wordtext=TextFromWord(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest + "//" + FilePathToUpload);

                        wordtext = ReadAllTextFromDocx(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest + "//" + FilePathToUpload);

                        ////Retrieves text from doc file using docx.dll
                        //DocX newDoc = DocX.Load(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest + "//" + FilePathToUpload);
                        //wordtext = newDoc.Text.ToString();

                        /*Reading Text from Word doc into string wordtext.*/
                        //Word.Application wordApplication = new Word.Application();
                        //Word.Document newDocument = wordApplication.Documents.Open(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest + "//" + FilePathToUpload);
                        //wordtext = newDocument.Content.Text;
                        //wordApplication.Quit();
                        //wordApplication.Dispose();

                        /*Counting words from string */

                        ////Method 0
                        //string[] Words = wordtext.Split(' ');
                        //string TotalNumberOfWords = Words.Length.ToString();

                        ////Method 1
                        MatchCollection collection = Regex.Matches(wordtext, @"[\S]+");
                        WordCount = collection.Count;

                        ////word.interop.dll
                        //WordCount = getWordCount(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest + "//" + FilePathToUpload);

                        ////Method 2
                        //int c = 0;
                        //for (int i = 1; i < wordtext.Length; i++)
                        //{
                        //    if (char.IsWhiteSpace(wordtext[i - 1]) == true)
                        //    {
                        //        if (char.IsLetterOrDigit(wordtext[i]) == true ||
                        //            char.IsPunctuation(wordtext[i]))
                        //        {
                        //            c++;
                        //        }
                        //    }
                        //}
                        //if (wordtext.Length > 2)
                        //{
                        //    c++;
                        //}
                        //WordCount = c;

                        ////Method 3
                        //Regex regex = new Regex("\\w+", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant);
                        //MatchCollection match = regex.Matches(wordtext);
                        //string wordC = match.Count.ToString();

                    }
                    else if (strFileExtension == ".pdf")
                    {
                        /*Reading Text from PDF into string PdfText.*/
                        PdfText = ExtractTextFromPdf(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest + "//" + FilePathToUpload);
                        MatchCollection PDFcollection = Regex.Matches(PdfText, @"[\S]+");
                        WordCount = PDFcollection.Count;
                    }

                    tr.OrderID = VishwaPress.BusinessLayer.Utilities.Common.GetUniqueKey(User.Identity.Name, tr.serviceChar);
                    tr.RequestFilePath = FilePathToUpload;
                    tr.UserID = UserId;
                    tr.FromLanguage = form["ddlFLang"];
                    tr.ToLanguage = form["ddlTLang"];
                    tr.WordsCount = WordCount.ToString();
                    tr.EstimatedAmt = "100";

                    tr.RequestDate = DateTime.Now.ToShortDateString();
                    tr.Status = "1";
                    BLObj.InsertTranslationData(tr);
                    //ViewBag.StatusMessage = "Request submited successfuly";
                    //ViewBag.StatusMessageClass = "text-success bg-success";
                    dt = BLObj.GetUserMailID(UserId);
                    htmlFilePath = Server.MapPath(Constants.TREmailHTMLTemplate);
                    SendMail(User.Identity.Name, dt.Rows[0][0].ToString(), int.Parse(tr.WordsCount), int.Parse(tr.EstimatedAmt), tr.OrderID, htmlFilePath);
                }
                else
                {
                    //ViewBag.StatusMessage = "Only document and PDF file allowed!";
                    //ViewBag.StatusMessageClass = "text-danger bg-danger";
                    TempData["StatusMessage"] = "Only .docx and .pdf file allowed!";
                    TempData["StatusMessageClass"] = "text-danger bg-danger";
                    return RedirectToAction("Translation");
                }
            }
            else if (Command == "Save")
            {
                ////////////////Edit button Functionality code Admin
                var uploadedFile = Request.Files[0];
                var fileName1 = Path.GetFileName(uploadedFile.FileName);

                tr.Status = form["ddlStatus"];
                tr.Trn_ID = form["lblTrnID"];
                string UserName = BLObj.GetUserName(tr);
                //MembershipUser MemberUser = Membership.GetUser(User.Identity.Name);
                //string UserId = MemberUser.ProviderUserKey.ToString();
                string UserId = Convert.ToString(Common.GetUserId(HttpContext.User.Identity.Name));
                if (fileName1 != String.Empty)
                {
                    fileName1 = UserName + "_" + Constants.strResponse + "_" + DateTime.Today.ToString("dd-MM-yyyy") + "_" + fileName1;
                    if (!Directory.Exists(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + UserName + "//" + Constants.strResponse))
                    {
                        Directory.CreateDirectory(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + UserName + "//" + Constants.strResponse);
                    }
                    var fileSavePath = Server.MapPath(Constants.strUploadFileIntialPath + "//" + UserName + "//" + Constants.strResponse + "//" + fileName1);
                    uploadedFile.SaveAs(fileSavePath);
                    tr.ResponseFilePath = fileName1;
                }
                tr.ResponseDate = DateTime.Now.ToShortDateString();
                BLObj.UpdateTranslationData(tr);

                TempData["StatusMessage"] = "Saved successfuly";
                TempData["StatusMessageClass"] = "text-success bg-success";
                dt.Clear();
                dt = BLObj.getUserIDFromTrnID(form["lblTrnID"]);
                uid = Convert.ToString(dt.Rows[0]["UserId"]);
                OId = Convert.ToString(dt.Rows[0]["OrderID"]);
                dt.Clear();
                dt = BLObj.GetUserMailID(uid);
                statusHtmlFilePath = Server.MapPath(Constants.StatusChangeHTMLTemplate);
                SendMailOnStatusChange(UserName, dt.Rows[0][0].ToString(), form["ddlStatus"], OId, statusHtmlFilePath);
                return RedirectToAction("Translation");
            }
            else if (Command == "SearchUser")
            {
                //TempData["searchUser"] = pr.txtFilterUserName;
                return RedirectToAction("Translation", new { UserName = tr.txtFilterUserName });
            }
            else if (Command == "Search")
            {
                return RedirectToAction("Translation", new { StartDate = tr.StartDate, EndDate = tr.EndDate, UserName = tr.txtFilterUserName });
            }

            return RedirectToAction("RequestSuccess");
        }
        /// <summary>
        /// This Action executes for loading Translation view.
        /// </summary>
        /// <returns></returns>
        public ActionResult Translation(int? page, string sort, string sortdir, string UserName, string StartDate, string EndDate, int? RecordsPerPage)
        {
            var model = new Translation();
            model.PagingRange = Constants.PagingRange;
            if (!string.IsNullOrEmpty(UserName))
            {
                model.txtFilterUserName = UserName;
            }

            if (!string.IsNullOrEmpty(StartDate))
            {
                model.StartDate = StartDate;
                model.EndDate = EndDate;
            }
            if (page != null)
            {
                model.CurrentPage = Convert.ToInt32(page);
                if (RecordsPerPage == null)
                {
                    model.StartIndex = (Convert.ToInt32(page) * 5) - 4;
                    model.EndIndex = Convert.ToInt32(page) * 5;
                }
                else
                {
                    model.RecordsPerPage = Convert.ToInt32(RecordsPerPage);
                    model.StartIndex = (Convert.ToInt32(page) * model.RecordsPerPage) - (model.RecordsPerPage - 1);
                    model.EndIndex = Convert.ToInt32(page) * model.RecordsPerPage;
                }
                if (!string.IsNullOrEmpty(sort))
                {
                    model.sort = sort;
                    model.sortdir = sortdir;
                }
                else
                {
                    model.sort = "Trn_ID";
                    model.sortdir = "Desc";
                }
            }
            else
            {
                model.CurrentPage = 1;
                if (RecordsPerPage == null)
                {
                    model.StartIndex = 1;
                    model.EndIndex = 5;
                }
                else
                {
                    model.RecordsPerPage = Convert.ToInt32(RecordsPerPage);
                    model.StartIndex = 1;
                    model.EndIndex = model.RecordsPerPage;
                }
                if (!string.IsNullOrEmpty(sort))
                {
                    model.sort = sort;
                    model.sortdir = sortdir;
                }
                else
                {
                    model.sort = "Trn_ID";
                    model.sortdir = "Desc";
                }
            }
            model.UserName = UserName;
            getDisplayData(ref model);
            model.LastPageIndex = model.Pages;
            if (string.IsNullOrEmpty(sort))
            {
                if (Request.IsAjaxRequest()) { return PartialView("_WebgridTranslation", model); }
            }
            if (!string.IsNullOrEmpty(sort) && page != null)
            {
                return PartialView("_WebgridTranslation", model);
            }

            return View(model);
        }
示例#4
0
        /// <summary>
        /// This method is used to Update Status and Upload Response File .
        /// </summary>
        /// <param name="tr"></param>
        public void UpdateTranslationData(Translation tr)
        {
            try
            {
                clsParameterCollection clsParaCollection = new clsParameterCollection();

                clsParaCollection.Add(new clsParameter("@TrnID", tr.Trn_ID));
                clsParaCollection.Add(new clsParameter("@Status", tr.Status));
                clsParaCollection.Add(new clsParameter("@ResponseDate", tr.ResponseDate));

                if (tr.ResponseFilePath != null)
                {
                    clsParaCollection.Add(new clsParameter("@ResponseFilePath", tr.ResponseFilePath));
                    clsParaCollection.ProcedureName = Constants.sp_Translation_upadateResponse;
                }
                else
                {
                    clsParaCollection.ProcedureName = Constants.sp_Translation_updateStatus;
                }

                DataAccess.ExecuteNonQuerySp(clsParaCollection);

            }
            catch (Exception ex)
            {
                BL_Exception.WriteLog(ex);
                throw ex;
            }
        }
示例#5
0
        /// <summary>
        /// This method is used to insert Record of Translation Serive request against respective User(userid).
        /// </summary>
        /// <param name="TranslationRef"></param>
        public void InsertTranslationData(Translation TranslationRef)
        {
            try
            {
                clsParameterCollection clsParaCollection = new clsParameterCollection();
                clsParaCollection.ProcedureName = Constants.sp_Translation_insertTranslation;
                clsParaCollection.Add(new clsParameter("@UserID", TranslationRef.UserID));
                clsParaCollection.Add(new clsParameter("@FLangID", TranslationRef.FromLanguage));
                clsParaCollection.Add(new clsParameter("@TLangID", TranslationRef.ToLanguage));
                clsParaCollection.Add(new clsParameter("@RequestFilePath", TranslationRef.RequestFilePath));
                clsParaCollection.Add(new clsParameter("@StatusID", TranslationRef.Status));
                clsParaCollection.Add(new clsParameter("@RequestDate", TranslationRef.RequestDate));
                clsParaCollection.Add(new clsParameter("@EstimatedAmt", TranslationRef.EstimatedAmt));
                clsParaCollection.Add(new clsParameter("@WordsCount", TranslationRef.WordsCount));
                clsParaCollection.Add(new clsParameter("@OrderID", TranslationRef.OrderID));

                DataAccess.ExecuteNonQuerySp(clsParaCollection);
            }
            catch (Exception ex)
            {
                BL_Exception.WriteLog(ex);
                throw ex;
            }
        }
示例#6
0
        /// <summary>
        /// This method is used to fetch UserName based on TrnID.
        /// </summary>
        /// <param name="tr"></param>
        /// <returns></returns>
        public string GetUserName(Translation tr)
        {
            try
            {
                clsParameterCollection clsParaCollection = new clsParameterCollection();
                clsParaCollection.ProcedureName = Constants.sp_Translation_GetUserNameFromtranID;
                clsParaCollection.Add(new clsParameter("@TrnId", tr.Trn_ID));
                dt.Reset();
                dt = DataAccess.ExecuteSpAndGetDataTable(clsParaCollection);
                return dt.Rows[0][0].ToString();

            }
            catch (Exception ex)
            {
                BL_Exception.WriteLog(ex);
                throw ex;
            }
        }