Example #1
0
        public ActionResult Workplace()
        {
            int    userId   = 0;
            string username = "";

            if (Session["UserID"] != null)
            {
                userId   = Convert.ToInt32(Session["UserID"]);
                username = Session["userName"].ToString();
            }
            List <WatcherWorkplaceDetails> details = new List <WatcherWorkplaceDetails>();
            List <WatherResponse>          ss      = new List <WatherResponse>();

            using (var ibisaRepository = new IBISARepository())
            {
                details = ibisaRepository.GetWorkplaceDetail();
                ss      = ibisaRepository.getTaskCompletDetail(userId);
            }

            foreach (var item in details)
            {
                foreach (var item1 in ss)
                {
                    //var isans = ss.FirstOrDefault(i => i.QuestionId == item.quationsId);
                    if (item1.QuestionId != 0 && item1.QuestionId == item.quationsId)
                    {
                        item.isAnswerd = true;
                        break;
                    }
                }
            }
            ViewBag.userName = username;
            return(View(details));
        }
Example #2
0
        public ActionResult WorkplaceDetails(int qid, int quationid)
        {
            List <options> Options     = new List <options>();
            int            selectedOpt = 0;
            int            wid         = 0;
            string         username    = "";
            string         quation     = "";

            if (Session["UserID"] != null)
            {
                wid      = Convert.ToInt32(Session["UserID"]);
                username = Session["userName"].ToString();
            }
            using (var ibisaRepository = new IBISARepository())
            {
                Options     = ibisaRepository.getOptions(qid);
                selectedOpt = ibisaRepository.GetSelectedOption(wid, quationid);
                quation     = ibisaRepository.getquation(qid);
            }

            WatcherQA wQa = new WatcherQA();

            wQa.QuationId      = quationid;
            wQa.options        = Options;
            wQa.watcherId      = wid;
            wQa.selectedOption = selectedOpt;
            wQa.QName          = quation;
            wQa.iddirId        = qid;
            ViewBag.userName   = username;
            return(View(wQa));
        }
Example #3
0
        public List <BubbleChartData> WatcherAssessmentDashboard()
        {
            List <BubbleChartData> listbubble = new List <BubbleChartData>();

            using (var ibisaRepository = new IBISARepository())
            {
                listbubble = ibisaRepository.GetBubblechartData(int.Parse(ConfigurationManager.AppSettings["BubbleChartRadiusMultiplicationFactor"]));
            }
            return(listbubble);
        }
Example #4
0
        public ActionResult TransactionSummary(int id)
        {
            List <TransactionInfo> transactionDetails;

            using (var ibisaRepository = new IBISARepository())
            {
                transactionDetails = ibisaRepository.GetTransactionDetails(id);
            }

            return(View(transactionDetails));
        }
Example #5
0
        public JsonResult chart()
        {
            List <BubbleChartData> listbubble = new List <BubbleChartData>();

            using (var ibisaRepository = new IBISARepository())
            {
                listbubble = ibisaRepository.GetBubblechartData(int.Parse(ConfigurationManager.AppSettings["BubbleChartRadiusMultiplicationFactor"]));
            }
            var jsonSerialiser = new JavaScriptSerializer();
            var json           = jsonSerialiser.Serialize(listbubble);

            return(Json(listbubble, JsonRequestBehavior.AllowGet));
        }
Example #6
0
        public JsonResult Contribute(int agreementPrimaryId, int id, string address)
        {
            try
            {
                TransactionInfo transactionDetail;
                using (var ibisaRepository = new IBISARepository())
                {
                    transactionDetail = ibisaRepository.GetLatestTransactionDetailsByTrsanactionType(agreementPrimaryId, (int)EnumHelper.TransactionType.Contribution);
                }

                if (transactionDetail == null || transactionDetail.AgreementPrimaryId <= 0)
                {
                    return(Json(new { status = 0 }));
                }

                var     date            = transactionDetail.DateOfAgreement.AddMonths(1);
                var     amount          = transactionDetail.Amount;
                dynamic response        = PostRequest(string.Format("/contribute/{0}/{1}/{2}/{3}", id, address, ((DateTimeOffset)date).ToUnixTimeSeconds(), amount));
                var     jsonResponse    = (JObject.Parse(response)).data;
                var     transactionHash = jsonResponse.tx_hash;

                var transaction = new Transaction
                {
                    AgreementPrimaryId = agreementPrimaryId,
                    TransactionHash    = transactionHash,
                    DateOfAgreement    = date,
                    Amount             = amount,
                    TransactionDate    = DateTime.Now,
                    TransactionTypeId  = (int)EnumHelper.TransactionType.Contribution
                };

                var result = false;
                using (var ibisaRepository = new IBISARepository())
                {
                    result = ibisaRepository.SaveTransaction(transaction);
                }

                if (result)
                {
                    return(Json(response));
                }
            }
            catch (Exception ex)
            {
                ExceptionHelper.Log("Method: Contribute()", ex);
            }
            return(Json(new { status = 0 }));
        }
Example #7
0
        public ActionResult SubmitAns(WatcherQA wqa)
        {
            var watcherResponceDetail = new WatcherRespons
            {
                WatcherId   = wqa.watcherId,
                QuestionId  = wqa.QuationId,
                OptionId    = wqa.selectedOption,
                CreatedDate = DateTime.Now
            };

            using (var ibisaRepository = new IBISARepository())
            {
                ibisaRepository.saveWatcherresponse(watcherResponceDetail);
            }
            return(RedirectToAction("Workplace"));
        }
Example #8
0
        public ActionResult SystemDashboard()
        {
            try
            {
                dynamic response = JObject.Parse(GetResponse(string.Format("/GetSystemDetails/{0}", "zoneA")));
                if (response.status > 0)
                {
                    DashboardInfo dashboardInfo = JsonConvert.DeserializeObject <DashboardInfo>(response.data.ToString());

                    var dashboardInfoFromDB = new DashboardInfo();
                    using (var ibisaRepository = new IBISARepository())
                    {
                        dashboardInfoFromDB.AgreementDetails = ibisaRepository.GetAgreements();
                    }

                    //if (dashboardInfo.AgreementDetails != null && dashboardInfo.AgreementDetails.Any())
                    //    dashboardInfo.totalUsers = dashboardInfo.AgreementDetails.Count;

                    if (dashboardInfo.AgreementDetails != null && dashboardInfoFromDB.AgreementDetails != null && dashboardInfo.AgreementDetails.Any() && dashboardInfoFromDB.AgreementDetails.Any())
                    {
                        dashboardInfoFromDB.AgreementDetails.ForEach(x =>
                        {
                            var agreement = dashboardInfo.AgreementDetails.FirstOrDefault(i => i.wallet_address == x.wallet_address);
                            if (agreement != null)
                            {
                                agreement.agreementPrimaryId = x.agreementPrimaryId;
                                agreement.agreementNumber    = x.agreementNumber;
                                agreement.zone = x.zone;
                            }
                        });
                    }

                    return(View(dashboardInfo));
                }
            }
            catch (Exception ex)
            {
                ExceptionHelper.Log("Method: SystemDashboard()", ex);
            }

            return(View(new DashboardInfo()));
        }
Example #9
0
        public ActionResult WatcherAssessmentDashboard()
        {
            if (true)
            {
            }
            else
            {
            }
            List <BubbleChartData> listbubble = new List <BubbleChartData>();

            using (var ibisaRepository = new IBISARepository())
            {
                listbubble = ibisaRepository.GetBubblechartData(int.Parse(ConfigurationManager.AppSettings["BubbleChartRadiusMultiplicationFactor"]));
            }
            var jsonSerialiser = new JavaScriptSerializer();
            var json           = jsonSerialiser.Serialize(listbubble);

            ViewBag.datajson = json;
            return(View());
        }
Example #10
0
        public ActionResult Login(LoginModel loginModel)
        {
            LoginModel logindetails = new LoginModel();

            using (var ibisaRepository = new IBISARepository())
            {
                logindetails = ibisaRepository.CheckLogin(loginModel);
            }
            if (logindetails != null)
            {
                FormsAuthentication.SetAuthCookie(logindetails.userName, false);
                Session["userID"]   = logindetails.userId;
                Session["userName"] = logindetails.userName;
                ViewBag.userId      = logindetails.userId;
                return(RedirectToAction("Workplace", "IBISAWatchers"));
            }
            else
            {
                ViewBag.FailedLogin = "******";
                return(View());
            }
        }
Example #11
0
        public ActionResult WatcherDashboard()
        {
            int    userId   = 0;
            string username = "";

            if (Session["UserID"] != null)
            {
                userId   = Convert.ToInt32(Session["UserID"]);
                username = Session["userName"].ToString();
            }
            List <WatcherWorkplaceDetails> details = new List <WatcherWorkplaceDetails>();
            List <WatherResponse>          ss      = new List <WatherResponse>();

            using (var ibisaRepository = new IBISARepository())
            {
                details = ibisaRepository.GetWorkplaceDetail();
                ss      = ibisaRepository.getTaskCompletDetail(userId);
            }
            ViewBag.taskNumber   = details.Count();
            ViewBag.countpercent = (ss.Count()) * 100 / details.Count();
            return(View());
        }
Example #12
0
        public JsonResult Indemnify(int agreementPrimaryId, int id, string address, string zone)
        {
            try
            {
                dynamic response        = PostRequest(string.Format("/Indemnify/{0}/{1}/{2}", id, address, zone));
                var     jsonResponse    = (JObject.Parse(response)).data;
                var     transactionHash = jsonResponse.tx_hash;
                var     amount          = Convert.ToDecimal(jsonResponse.indemnity_amount);

                var transaction = new Transaction
                {
                    AgreementPrimaryId = agreementPrimaryId,
                    TransactionHash    = transactionHash,
                    DateOfAgreement    = null,
                    Amount             = amount,
                    TransactionDate    = DateTime.Now,
                    TransactionTypeId  = (int)EnumHelper.TransactionType.Indemnification
                };

                var result = false;
                using (var ibisaRepository = new IBISARepository())
                {
                    result = ibisaRepository.SaveTransaction(transaction);
                }

                if (result)
                {
                    return(Json(response));
                }
            }
            catch (Exception ex)
            {
                ExceptionHelper.Log("Method: Indemnify()", ex);
            }

            return(Json(new { status = 0 }));
        }
Example #13
0
        public JsonResult ProcessFileUpload()
        {
            if (Request != null && Request.ContentLength > 0 && Request.Files.Count > 0)
            {
                try
                {
                    var httpPostedFileBase = Request.Files[0];
                    var path = Path.Combine(Server.MapPath("~/Uploads"), Guid.NewGuid() + Path.GetExtension(httpPostedFileBase.FileName));
                    httpPostedFileBase.SaveAs(path);

                    DataTable dataTable = new DataTable();
                    object[,] obj = null;
                    int noOfCol = 0;
                    int noOfRow = 0;

                    using (var package = new ExcelPackage(Request.InputStream))
                    {
                        var currentSheet = package.Workbook.Worksheets;
                        var workSheet    = currentSheet.First();
                        noOfCol = workSheet.Dimension.End.Column;
                        noOfRow = workSheet.Dimension.End.Row;
                        obj     = (object[, ])workSheet.Cells.Value;

                        #region Convert Worksheet to DataTable

                        foreach (var firstRowCell in workSheet.Cells[1, 1, 1, workSheet.Dimension.End.Column])
                        {
                            dataTable.Columns.Add(firstRowCell.Text);
                        }
                        const int startRow = 2;
                        for (int rowNum = startRow; rowNum <= workSheet.Dimension.End.Row; rowNum++)
                        {
                            var     workSheetRow = workSheet.Cells[rowNum, 1, rowNum, workSheet.Dimension.End.Column];
                            DataRow row          = dataTable.Rows.Add();
                            foreach (var cell in workSheetRow)
                            {
                                row[cell.Start.Column - 1] = cell.Text;
                            }
                        }

                        #endregion
                    }

                    if (dataTable.Rows.Count > 0)
                    {
                        var validateHeaders = ValidateHeaders(dataTable);
                        if (validateHeaders)
                        {
                            #region Transfer Ether To Smart Contract
                            var initialResponse = PostRequest("/TransferEtherToSmartContract");
                            #endregion

                            #region Create Users
                            var userResponse = PostRequest("/createUsers");
                            #endregion

                            #region Get Wallet Addresses
                            dynamic walletResponse  = JObject.Parse(GetResponse("/GetAllWallets"));
                            var     walletAddresses = JsonConvert.DeserializeObject <List <string> >(walletResponse.data.ToString());
                            //var walletAddresses = new List<string> { "", "", "", "", "", "", "", "", "" } ;
                            #endregion

                            var counter = 0;
                            foreach (DataRow dr in dataTable.Rows)
                            {
                                #region Process Date To Produce UNIX TimeStamp
                                var dateOfAgreement = Convert.ToDateTime(dr[EnumHelper.ImportParameters.DateOfAgreement.ToString()]);
                                #endregion

                                var transactionDetail = new Transaction
                                {
                                    Agreement = new Agreement
                                    {
                                        AgreementId        = 1,
                                        AgreementNumber    = Convert.ToString(dr[EnumHelper.ImportParameters.AgreementNumber.ToString()]),
                                        WalletAddress      = walletAddresses[counter],
                                        Zone               = Convert.ToString(dr[EnumHelper.ImportParameters.Zone.ToString()]),
                                        Location           = Convert.ToString(dr[EnumHelper.ImportParameters.Location.ToString()]),
                                        PlotId             = Convert.ToString(dr[EnumHelper.ImportParameters.PlotID.ToString()]),
                                        Crop               = Convert.ToString(dr[EnumHelper.ImportParameters.Crop.ToString()]),
                                        MaxPayout          = Convert.ToInt32(dr[EnumHelper.ImportParameters.MaxPayout.ToString()]),
                                        TargetContribution = Convert.ToInt32(dr[EnumHelper.ImportParameters.TargetContribution.ToString()]),
                                        UserDisplayName    = Convert.ToString(dr[EnumHelper.ImportParameters.UserDisplayName.ToString()])
                                    },

                                    DateOfAgreement   = dateOfAgreement,
                                    Amount            = Convert.ToInt32(dr[EnumHelper.ImportParameters.CurrentContribution.ToString()]),
                                    TransactionDate   = DateTime.Now,
                                    TransactionTypeId = (int)EnumHelper.TransactionType.Contribution
                                };

                                var createAgreementParams = new { wallet = transactionDetail.Agreement.WalletAddress, zone = transactionDetail.Agreement.Zone, crop = transactionDetail.Agreement.Crop, maxPayout = transactionDetail.Agreement.MaxPayout, targetContrib = transactionDetail.Agreement.TargetContribution, date = ((DateTimeOffset)dateOfAgreement).ToUnixTimeSeconds(), amt = transactionDetail.Amount };
                                var jsonParam             = JsonConvert.SerializeObject(createAgreementParams);
                                var buffer      = System.Text.Encoding.UTF8.GetBytes(jsonParam);
                                var byteContent = new ByteArrayContent(buffer);
                                byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                                dynamic agreementResponse = JObject.Parse(PostRequest("/CreateAgreement", byteContent));
                                transactionDetail.TransactionHash = agreementResponse.data.tx_hash;

                                #region Save Agreements To DB

                                using (var ibisaRepository = new IBISARepository())
                                {
                                    ibisaRepository.SaveTransaction(transactionDetail);
                                }

                                #endregion

                                counter++;
                            }
                        }
                        else
                        {
                            return(Json(new
                            {
                                IsValid = false,
                                Message = "File headers do not match the format required for Agreement.",
                            }, JsonRequestBehavior.AllowGet));
                        }
                    }
                    else
                    {
                        return(Json(new
                        {
                            IsValid = false,
                            Message = "Data is not available in the uploaded file. Please verify it and upload once again.",
                        }, JsonRequestBehavior.AllowGet));
                    }

                    return(Json(new
                    {
                        IsValid = true,
                        Message = "File uploaded and processed successfully.",
                        data = obj,
                        row = noOfRow,
                        col = noOfCol
                    }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    ExceptionHelper.Log("Method: ProcessFileUpload()", ex);
                    return(Json(new
                    {
                        IsValid = false,
                        Message = "There is an error occurred while processing your file. Please verify it and upload once again.",
                    }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new
            {
                IsValid = false,
                Message = "There is an error occurred while processing your file. Please verify it and upload once again.",
            }, JsonRequestBehavior.AllowGet));
        }