Example #1
0
        //public async Task<ActionResult> AsyncDownload(int FileId)
        //{
        //    await Task.Run(() => PrepareFile(FileId));

        //    return Json(new { success = 1 }, JsonRequestBehavior.AllowGet);
        //}


        //public async void PrepareFile(int FileId)
        //{


        //    Task<bool> task = new Task<bool>(SyncService);
        //    task.Start();
        //    bool FileDownloaded = await task;

        //}

        public bool SyncService()
        {
            try
            {
                if (Convert.ToBoolean(Session["OTPsent"]) == false)
                {
                    int FileId        = Convert.ToInt32(TempData["FileId"]);
                    int CurrentUserId = USerConfig.GetUserID();
                    if (objFileDataLayer.FileUserAccess(FileId, CurrentUserId))
                    {
                        int        RequestId  = objFileDataLayer.GenerateRequest(FileId, CurrentUserId);
                        List <int> PartnerIds = objFileDataLayer.GetPartnerIds(FileId);
                        objFileDataLayer.GenerateOTP(PartnerIds, RequestId);
                        string          AccessStatus = objFileDataLayer.AuthorizeOTP(RequestId);//Until and unless we get NouserPending status the file will not download
                        User_Controller userData     = new User_Controller();


                        foreach (var partnerid in PartnerIds)
                        {
                            int GetOtp = userData.GetOtp(RequestId, partnerid);
                            SMTPProtocol.NotifyPartners("Notification", string.Format("You partners is waiting for the file ,Please find the OTP : {0} \n Use this link to enter the OTP : /File/EnterOtp?RequestId={1}&UserId={2}", GetOtp, RequestId, partnerid), userData.GetEmailbyPartnerId(partnerid.ToString()));
                        }
                    }

                    Session["OTPsent"] = "true";
                }
            }
            catch (Exception)
            {
                Session["OTPsent"] = "false";
                throw;
            }

            return(true);
        }