public ActionResult DARDisclaimerDownload(string Id)
        {
            DARManager objDARManager = new DARManager();

            try
            {
                if (!string.IsNullOrEmpty(Id))
                {
                    Id = Cryptography.GetDecryptedData(Id, true);
                    var darDetail = objDARManager.GetDARDetailsById(Convert.ToInt64(Id));
                    if (!string.IsNullOrEmpty(darDetail.DisclaimerFormFile))
                    {
                        string RootDirectory = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
                        string IsFileExist   = RootDirectory + DARDisclaimerFormPath;
                        RootDirectory = RootDirectory + DARDisclaimerFormPath + darDetail.DisclaimerFormFile;
                        if (Directory.GetFiles(IsFileExist, darDetail.DisclaimerFormFile).Length > 0)
                        {
                            byte[] fileBytes = System.IO.File.ReadAllBytes(RootDirectory);
                            return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, darDetail.DisclaimerFormFile));
                        }
                        else
                        {
                            RootDirectory = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + DisclaimerFormPath + "FileNotFound.png";
                            byte[] fileBytes = System.IO.File.ReadAllBytes(RootDirectory);
                            return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, "FileNotFound.png"));
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(Json("Id is Empty!"));
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message           = ex.Message;
                ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
                return(Json(ex.Message));
            }
        }
示例#2
0
        public JsonResult GeDARList(long?LocationId, int?TastType, long?EmployeeId, string FromDate, string ToDate, string FromTime, string ToTime)
        {
            eTracLoginModel    ObjLoginModel = null;
            DARManager         objDARDetailsList = new DARManager();
            var                details = new List <WorkRequestAssignmentModelList>();
            long               UserId = 0;
            string             sord = null; String sidx = null; string txtSearch = "";
            GlobalAdminManager _GlobalAdminManager = new GlobalAdminManager();

            if (Session["eTrac"] != null)
            {
                ObjLoginModel = (eTracLoginModel)(Session["eTrac"]);
                UserId        = ObjLoginModel.UserId;
                if (LocationId == 0)
                {
                    LocationId = Convert.ToInt32(ObjLoginModel.LocationID);
                    UserId     = ObjLoginModel.UserId;
                }
            }
            //Getting client date time.
            var clientdt = DateTime.UtcNow.GetClientDateTimeNow();
            //flag status for if user filter record in time span so to date is till midnight.
            bool isUTCDay = true;
            //Fetching record like 2017-06-11T00:00:00-04:00 to 2017-06-12T00:0000-04:00
            string fromDate = (FromDate == null || FromDate == " " || FromDate == "") ? clientdt.Date.ToString() : FromDate;
            string toDate   = (ToDate == null || ToDate == " " || ToDate == "") ? clientdt.AddDays(1).Date.ToString() : ToDate;

            //maintaining flag  if interval date come then need to fetch record till midnight of todate day
            if (ToDate != null && ToDate != "" && FromDate != "null")
            {
                DateTime tt = Convert.ToDateTime(toDate);
                if (tt.ToLongTimeString() == "12:00:00 AM")
                {
                    isUTCDay = false;
                }
            }

            if (fromDate != null && toDate != null)
            {
                DateTime frmd = Convert.ToDateTime(fromDate);
                DateTime tod  = Convert.ToDateTime(toDate);
                ////if interval date come then need to fetch record till midnight of todate day
                if ((frmd.Date != tod.Date) && (tod.ToLongTimeString() == "12:00:00 AM") && isUTCDay == false)
                {
                    tod    = tod.AddDays(1).Date;
                    toDate = tod.ToString();
                }
                if ((frmd.Date == tod.Date) && (tod.ToLongTimeString() == "12:00:00 AM"))
                {
                    tod    = tod.AddDays(1).Date;
                    toDate = tod.ToString();
                }
            }
            //Converting datetime from userTZ to UTC
            fromDate = Convert.ToDateTime(fromDate).ConvertClientTZtoUTC().ToString();
            toDate   = Convert.ToDateTime(toDate).ConvertClientTZtoUTC().ToString();
            int?rows = 20; int?page = 1;

            sord = string.IsNullOrEmpty(sord) ? "desc" : sord;
            sidx = string.IsNullOrEmpty(sidx) ? "CreatedDate" : sidx;
            var             obj_Common_B      = new Common_B();
            ObjectParameter paramTotalRecords = new ObjectParameter("TotalRecords", typeof(int));
            var             data              = objDARDetailsList.GetDARDetails(UserId, LocationId, EmployeeId, TastType, page, rows, sord, sord, txtSearch, paramTotalRecords, fromDate, toDate);

            if (data.Count() > 0)
            {
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
        }
示例#3
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest  request  = context.Request;
            HttpResponse response = context.Response;

            try
            {
                DARManager      objDARDetailsList = new DARManager();
                eTracLoginModel ObjLoginModel     = null;
                System.Collections.Specialized.NameValueCollection forms = context.Request.Form;


                long?locationId  = null;
                long?userId      = null;
                long loginUserId = 0;

                if (Convert.ToInt64(request["empId"]) != 0)
                {
                    userId = Convert.ToInt64(request["empId"]);
                }
                else
                {
                    userId = null;
                }

                int?taskType = null;
                if (Convert.ToInt32(request["taskType"]) != 0)
                {
                    taskType = Convert.ToInt32(request["taskType"]);
                }
                else
                {
                    taskType = null;
                }

                //(Convert.ToInt64(request["empId"])!=0) ? Convert.ToInt64(request["empId"]) : null;
                string _search        = request["_search"];
                string textSearch     = request["txtSearch"] ?? "";
                int    numberOfRows   = Convert.ToInt32(request["rows"]);
                int    pageIndex      = Convert.ToInt32(request["page"]);
                string sortColumnName = request["sidx"];
                string sortOrderBy    = request["sord"];

                //Getting client date time.
                var clientdt = DateTime.UtcNow.GetClientDateTimeNow();
                //flag status for if user filter record in time span so to date is till midnight.
                bool isUTCDay = true;
                //Fetching record like 2017-06-11T00:00:00-04:00 to 2017-06-12T00:0000-04:00
                string fromDate = (request["fromDate"] == null || request["fromDate"] == " " || request["fromDate"] == "") ? clientdt.Date.ToString(): request["fromDate"];
                string toDate   = (request["toDate"] == null || request["toDate"] == " " || request["toDate"] == "") ? clientdt.AddDays(1).Date.ToString(): request["toDate"];

                //maintaining flag  if interval date come then need to fetch record till midnight of todate day
                if (request["toDate"] != null && request["toDate"] != "" && request["fromDate"] != "null")
                {
                    DateTime tt = Convert.ToDateTime(toDate);
                    if (tt.ToLongTimeString() == "12:00:00 AM")
                    {
                        isUTCDay = false;
                    }
                }

                if (fromDate != null && toDate != null)
                {
                    DateTime frmd = Convert.ToDateTime(fromDate);
                    DateTime tod  = Convert.ToDateTime(toDate);
                    ////if interval date come then need to fetch record till midnight of todate day
                    if ((frmd.Date != tod.Date) && (tod.ToLongTimeString() == "12:00:00 AM") && isUTCDay == false)
                    {
                        tod    = tod.AddDays(1).Date;
                        toDate = tod.ToString();
                    }
                    if ((frmd.Date == tod.Date) && (tod.ToLongTimeString() == "12:00:00 AM"))
                    {
                        tod    = tod.AddDays(1).Date;
                        toDate = tod.ToString();
                    }
                }
                if (context.Session["eTrac"] != null)
                {
                    ObjLoginModel = (eTracLoginModel)(context.Session["eTrac"]);
                    locationId    = ObjLoginModel.LocationID;
                    loginUserId   = ObjLoginModel.UserId; //Added by Bhushan due to useid is null in Sp. It will not return created on due joinon the basis of userid.
                }
                //Converting datetime from userTZ to UTC
                fromDate = Convert.ToDateTime(fromDate).ConvertClientTZtoUTC().ToString();
                toDate   = Convert.ToDateTime(toDate).ConvertClientTZtoUTC().ToString();

                ObjectParameter totalRecords   = new ObjectParameter("TotalRecords", typeof(int));
                var             darDetailsList = objDARDetailsList.GetDARDetails(loginUserId, locationId, userId, taskType, pageIndex, numberOfRows, sortColumnName, sortOrderBy, textSearch, totalRecords, fromDate, toDate);
                if (darDetailsList.Count() > 0)
                {
                    string output = BuildJQGridResults(darDetailsList, numberOfRows, pageIndex, Convert.ToInt32(totalRecords.Value));
                    response.Write(output);
                }
                else
                {
                    JQGridResults    result = new JQGridResults();
                    List <JQGridRow> rows   = new List <JQGridRow>();
                    result.rows    = rows.ToArray();
                    result.page    = 0;
                    result.total   = 0;
                    result.records = 0;
                    response.Write(new JavaScriptSerializer().Serialize(result));
                }
            }
            catch (Exception ex)
            {
                Exception_B.exceptionHandel_Runtime(ex, "public void ProcessRequest(HttpContext context)-DARDetails.ashx", "context", context.ToString());
                JQGridResults    result = new JQGridResults();
                List <JQGridRow> rows   = new List <JQGridRow>();
                result.rows    = rows.ToArray();
                result.page    = 0;
                result.total   = 0;
                result.records = 0;
                response.Write(new JavaScriptSerializer().Serialize(result));
            }
        }