Exemple #1
0
        public void DownloadUploadedfile(string PartnerCode, string FileName)
        {
            tblProspectDocument objtblDocuments    = new tblProspectDocument();
            HierarchyData       objHierarchyData   = new HierarchyData();
            DocumentDetails     objDocumentDetails = new DocumentDetails();
            tblOrganization     objtblOrganization = null;

            if (PartnerCode != null)
            {
                objtblOrganization = Context.tblOrganizations.Where(a => a.PartnerCode == PartnerCode).FirstOrDefault();
            }
            var    directorypath   = System.Web.HttpContext.Current.Server.MapPath("Upload");
            var    PolicyFileName  = Path.Combine(directorypath, Path.GetFileName(FileName));
            string result          = PolicyFileName;
            string Filecontenttype = Context.tblProspectDocuments.Where(a => a.OrganizationID == objtblOrganization.OrganizationID).FirstOrDefault().DocType;

            objDocumentDetails.FileContent = Encoding.ASCII.GetBytes(Context.tblProspectDocuments.Where(a => a.OrganizationID == objtblOrganization.OrganizationID).FirstOrDefault().DocPath);
            System.Web.HttpContext.Current.Response.ContentType = Filecontenttype;
            System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(PolicyFileName));
            System.Web.HttpContext.Current.Response.Charset = "";
            System.Web.HttpContext.Current.Response.OutputStream.Write(objDocumentDetails.FileContent, 0, objDocumentDetails.FileContent.Length);
            System.Web.HttpContext.Current.Response.Flush();
            System.Web.HttpContext.Current.Response.Close();

            if (System.IO.File.Exists(result))
            {
                System.Web.HttpContext.Current.Response.OutputStream.Dispose();
                System.IO.File.Delete(result);
            }
        }
Exemple #2
0
 public void SaveCompanyDetails(CompanyModel CompanyModel)
 {
     if (CompanyModel.Id == 0)
     {
         var company = new tblOrganization()
         {
             ADDRESS1    = CompanyModel.Address1,
             ADDRESS2    = CompanyModel.Address2,
             CONTACTNAME = CompanyModel.ContactName,
             EMAIL       = CompanyModel.Email,
             LAT         = CompanyModel.Lat,
             LNG         = CompanyModel.Lng,
             PHONE_1     = CompanyModel.Phone1,
             PHONE_2     = CompanyModel.Phone2,
             TITLE       = CompanyModel.Title,
             WEBSITE     = CompanyModel.Website,
             ZIPCODE     = CompanyModel.ZipCode
         };
         entity.tblOrganizations.Add(company);
     }
     else
     {
         var y = entity.tblOrganizations.FirstOrDefault(t => t.ID == CompanyModel.Id);
         y.ADDRESS1    = CompanyModel.Address1;
         y.ADDRESS2    = CompanyModel.Address2;
         y.CONTACTNAME = CompanyModel.ContactName;
         y.EMAIL       = CompanyModel.Email;
         y.LAT         = CompanyModel.Lat;
         y.LNG         = CompanyModel.Lng;
         y.PHONE_1     = CompanyModel.Phone1;
         y.PHONE_2     = CompanyModel.Phone2;
         y.TITLE       = CompanyModel.Title;
         y.WEBSITE     = CompanyModel.Website;
         y.ZIPCODE     = CompanyModel.ZipCode;
     }
     entity.SaveChanges();
 }
        public List <JObject> getEvaDataByEvaID(int EvaID)
        {
            var header = ServiceContainer.GetService <PesWeb.Service.Modules.EvaManage>();
            List <SP_GetEvaDataByEvaID_Result> evadata = header.getEvaDataByEvaID(EvaID).ToList();
            List <JObject>     Eva = new List <JObject>();
            List <tblEmployee> emp = header.getEmployees();

            evadata.ForEach(a =>
            {
                JObject tmp                 = new JObject();
                tmp["Part2ID"]              = a.Part2ID;
                tblEvaluation evat          = header.GetAllEvaluation().Where(x => x.Eva_ID == a.Eva_ID).FirstOrDefault();
                tblEmployeeOrganization emo = header.getEmployeeOrganization().Where(x => x.EmployeeNo.Trim() == evat.EmployeeNO.Trim()).OrderByDescending(x => x.StartEffectiveDate).FirstOrDefault();
                tblOrganization org         = header.getOrganization().Where(x => x.OrganizationNo == ((emo != null)?emo.OrganizationNo:0)).FirstOrDefault();
                tmp["GroupOfStaff"]         = (org != null)? org.OrganizationName : "";
                tblProject proj             = header.getProject().Where(x => x.ProjectID == evat.ProjectNO).FirstOrDefault();
                tmp["CustomerCompanyAlias"] = (proj != null)?proj.CustomerCompanyAlias: a.CustomerCompanyAlias;
                tmp["ProjectCode"]          = a.ProjectCode;
                tmp["ProjectType"]          = a.ProjectType;
                tmp["EvaTerm"]              = a.EvaTerm;

                a.StartDatePlan = a.StartDatePlan.Replace(" ", "/");
                if (a.StartDatePlan.ElementAt(4) == '/')
                {
                    a.StartDatePlan = a.StartDatePlan.Substring(0, 4) + "0" + a.StartDatePlan.Substring(5);
                }
                a.StartDatePlan      = a.StartDatePlan.Substring(4, 2) + "/" + a.StartDatePlan.Substring(0, 3) + "/" + a.StartDatePlan.Substring(9, 2);
                tmp["StartDatePlan"] = a.StartDatePlan;

                a.FinishDatePlan = a.FinishDatePlan.Replace(" ", "/");
                if (a.FinishDatePlan.ElementAt(4) == '/')
                {
                    a.FinishDatePlan = a.FinishDatePlan.Substring(0, 4) + "0" + a.FinishDatePlan.Substring(5);
                }
                a.FinishDatePlan          = a.FinishDatePlan.Substring(4, 2) + "/" + a.FinishDatePlan.Substring(0, 3) + "/" + a.FinishDatePlan.Substring(9, 2);
                tmp["FinishDatePlan"]     = a.FinishDatePlan;
                tmp["Function"]           = a.Function;
                tmp["StartTime"]          = a.StartTime;
                tmp["FinishTime"]         = a.FinishTime;
                tmp["EvaluatorFirstName"] = a.EvaluatorFirstName;
                tmp["EvaluatorLastName"]  = a.EvaluatorLastName;
                tmp["Eva_ID"]             = a.Eva_ID;

                string text          = "{\"EN\":\"" + a.EmployeeFirstName + "\",\"TH\":\"" + a.EmployeeFirstNameThai + "\"}";
                tmp["name_language"] = JsonConvert.DeserializeObject <JObject>(text);
                text = "{\"EN\":\"" + a.EmployeeLastName + "\",\"TH\":\"" + a.EmployeeLastNameThai + "\"}";
                tmp["lastname_language"] = JsonConvert.DeserializeObject <JObject>(text);
                //tblEmployee em = emp.Where(b=>b.EmployeeNo.Replace(" ","") == a.)
                text             = "{\"EN\":\"" + a.EvaluatorFirstName + " " + a.EvaluatorLastName + "\",\"TH\":\"" + a.EvaluatorFirstNameThai + " " + a.EvaluatorLastNameThai + "\"}";
                tmp["Evaluator"] = JsonConvert.DeserializeObject <JObject>(text);
                Eva.Add(tmp);

                //  evadata[i].EmployeeFirstNameThai =
            });
            List <JObject> n = new List <JObject>();

            if (Eva.FirstOrDefault() != null)
            {
                n.Add(Eva.FirstOrDefault());
            }
            return(n);
        }
Exemple #4
0
        public List <JObject> Report1(string Group, string SubGroup, int PeriodID)
        {
            var           header = ServiceContainer.GetService <PesWeb.Service.Modules.EvaManage>();
            List <Period> per    = header.GetPeriod();
            int           groupn = 0;
            string        evatmp = "";
            int           period = 0;

            if (Group == "0")
            {
                //tblOrganization g = header.getOrganization().Where(a => a.OrganizationAlias == Group).FirstOrDefault();
                //if(g!=null)
                //groupn = g.OrganizationNo;
            }
            if (SubGroup != "0" && Group != "0")
            {
                tblOrganization g = header.getOrganization().Where(a => a.OrganizationAlias == Group + "-" + SubGroup).FirstOrDefault();
                if (g != null)
                {
                    groupn = g.OrganizationNo;
                }
                else
                {
                    groupn = -1;
                }
            }
            List <tblEmployee> listem = header.getEmployees();

            //tblReport a = new tblReport();
            var em1 = header.GetAllEvaluation().OrderBy(a => a.EvaluatorNO).ToList();

            List <tblEmployeeOrganization> emo = header.getEmployeeOrganization();
            List <tblEvaluation>           eva = new List <tblEvaluation>();
            List <tblOrganization>         or  = header.getOrganization();

            var e = em1.OrderBy(a => a.EvaluatorNO).ToList();

            if (PeriodID == 0)
            {
                if (SubGroup == "0" && Group == "0")
                {
                    List <JObject>       jResult = new List <JObject>();
                    List <tblEvaluation> result  = new List <tblEvaluation>();
                    per.ForEach(g =>
                    {
                        if (period != g.Period_Id)
                        {
                            JObject tmp     = new JObject();
                            period          = g.Period_Id;
                            tmp["type"]     = 1;
                            tmp["PeriodID"] = g.Period_Id;
                        }
                        e = em1.Where(a => a.PeriodID == g.Period_Id).OrderBy(a => a.EvaluatorNO).ToList();
                        e.ForEach(a =>
                        {
                            if (evatmp != a.EvaluatorNO)
                            {
                                tblEvaluation tmp2 = new tblEvaluation();
                                tmp2.EvaluatorNO   = a.EvaluatorNO;
                                evatmp             = a.EvaluatorNO;
                                tmp2.PeriodID      = a.PeriodID;
                                tmp2.period        = a.period;
                                result.Add(tmp2);
                            }
                            tblEvaluation tmp = new tblEvaluation();
                            tmp.EvaluatorNO   = a.EvaluatorNO;
                            tmp.EmployeeNO    = a.EmployeeNO;
                            tmp.Eva_ID        = a.Eva_ID;
                            tmp.PeriodID      = a.PeriodID;
                            tmp.Job_ID        = a.Job_ID;
                            tmp.period        = a.period;
                            result.Add(tmp);
                        });
                    });


                    return(toJson(result));
                }
                else
                {
                    if (SubGroup != "0")
                    {
                        List <tblEvaluation> result = new List <tblEvaluation>();
                        per.ForEach(g =>
                        {
                            e = em1.Where(a => a.PeriodID == g.Period_Id).OrderBy(a => a.EvaluatorNO).ToList();
                            e.ForEach(a =>
                            {
                                if (emo.Where(x => x.EmployeeNo.Trim() == a.EmployeeNO.Trim() && x.OrganizationNo == groupn).ToList().Count > 0)
                                {
                                    if (evatmp != a.EvaluatorNO)
                                    {
                                        tblEvaluation tmp2 = new tblEvaluation();
                                        tmp2.EvaluatorNO   = a.EvaluatorNO;
                                        evatmp             = a.EvaluatorNO;
                                        tmp2.PeriodID      = a.PeriodID;
                                        tmp2.period        = a.period;
                                        result.Add(tmp2);
                                    }
                                    tblEvaluation tmp = new tblEvaluation();
                                    tmp.EvaluatorNO   = a.EvaluatorNO;
                                    tmp.EmployeeNO    = a.EmployeeNO;
                                    tmp.Eva_ID        = a.Eva_ID;
                                    tmp.PeriodID      = a.PeriodID;
                                    tmp.Job_ID        = a.Job_ID;
                                    tmp.period        = a.period;
                                    result.Add(tmp);
                                }
                            });
                        });
                        return(toJson(result));
                    }
                    else
                    {
                        List <tblEvaluation> result = new List <tblEvaluation>();
                        per.ForEach(g =>
                        {
                            e = em1.Where(a => a.PeriodID == g.Period_Id).OrderBy(a => a.EvaluatorNO).ToList();

                            e.ForEach(a =>
                            {
                                List <tblOrganization> ortmp = or.Where(x => x.OrganizationAlias.Contains(Group) == true).ToList();

                                ortmp.ForEach(y =>
                                {
                                    if (emo.Where(x => x.EmployeeNo.Trim() == a.EmployeeNO.Trim() && x.OrganizationNo == y.OrganizationNo).ToList().Count > 0 && result.Where(x => x.Eva_ID == a.Eva_ID).ToList().Count == 0)
                                    {
                                        if (evatmp != a.EvaluatorNO)
                                        {
                                            tblEvaluation tmp2 = new tblEvaluation();
                                            tmp2.EvaluatorNO   = a.EvaluatorNO;
                                            evatmp             = a.EvaluatorNO;
                                            tmp2.PeriodID      = a.PeriodID;
                                            tmp2.period        = a.period;
                                            result.Add(tmp2);
                                        }
                                        tblEvaluation tmp = new tblEvaluation();
                                        tmp.EvaluatorNO   = a.EvaluatorNO;
                                        tmp.EmployeeNO    = a.EmployeeNO;
                                        tmp.Eva_ID        = a.Eva_ID;
                                        tmp.PeriodID      = a.PeriodID;
                                        tmp.Job_ID        = a.Job_ID;
                                        tmp.period        = a.period;
                                        result.Add(tmp);
                                    }
                                });
                            });
                        });
                        return(toJson(result));
                    }
                }
            }
            else
            {
                if (SubGroup == "0" && Group == "0")
                {
                    List <tblEvaluation> result = new List <tblEvaluation>();
                    per.ForEach(g =>
                    {
                        e = em1.Where(a => a.PeriodID == g.Period_Id).OrderBy(a => a.EvaluatorNO).ToList();

                        e.ForEach(a =>
                        {
                            if (a.PeriodID == PeriodID)
                            {
                                if (evatmp != a.EvaluatorNO)
                                {
                                    tblEvaluation tmp2 = new tblEvaluation();
                                    tmp2.EvaluatorNO   = a.EvaluatorNO;
                                    evatmp             = a.EvaluatorNO;
                                    tmp2.PeriodID      = a.PeriodID;
                                    tmp2.period        = a.period;
                                    result.Add(tmp2);
                                }
                                tblEvaluation tmp = new tblEvaluation();
                                tmp.EvaluatorNO   = a.EvaluatorNO;
                                tmp.EmployeeNO    = a.EmployeeNO;
                                tmp.Eva_ID        = a.Eva_ID;
                                tmp.PeriodID      = a.PeriodID;
                                tmp.Job_ID        = a.Job_ID;
                                tmp.period        = a.period;
                                result.Add(tmp);
                            }
                        });
                    });
                    return(toJson(result));
                }
                else
                {
                    if (SubGroup != "0")
                    {
                        List <tblEvaluation> result = new List <tblEvaluation>();
                        per.ForEach(g =>
                        {
                            e = em1.Where(a => a.PeriodID == g.Period_Id).OrderBy(a => a.EvaluatorNO).ToList();

                            e.ForEach(a =>
                            {
                                if (emo.Where(x => x.EmployeeNo.Trim() == a.EmployeeNO.Trim() && x.OrganizationNo == groupn).ToList().Count > 0)
                                {
                                    if (a.PeriodID == PeriodID)
                                    {
                                        if (evatmp != a.EvaluatorNO)
                                        {
                                            tblEvaluation tmp2 = new tblEvaluation();
                                            tmp2.EvaluatorNO   = a.EvaluatorNO;
                                            evatmp             = a.EvaluatorNO;
                                            tmp2.PeriodID      = a.PeriodID;
                                            tmp2.period        = a.period;
                                            result.Add(tmp2);
                                        }
                                        tblEvaluation tmp = new tblEvaluation();
                                        tmp.EvaluatorNO   = a.EvaluatorNO;
                                        tmp.EmployeeNO    = a.EmployeeNO;
                                        tmp.Eva_ID        = a.Eva_ID;
                                        tmp.PeriodID      = a.PeriodID;
                                        tmp.Job_ID        = a.Job_ID;
                                        tmp.period        = a.period;
                                        result.Add(tmp);
                                    }
                                }
                            });
                        });
                        return(toJson(result));
                    }
                    else
                    {
                        List <tblEvaluation> result = new List <tblEvaluation>();
                        per.ForEach(g =>
                        {
                            e = em1.Where(a => a.PeriodID == g.Period_Id).OrderBy(a => a.EvaluatorNO).ToList();

                            e.ForEach(a =>
                            {
                                List <tblOrganization> ortmp = or.Where(x => x.OrganizationAlias.Contains(Group) == true).ToList();
                                ortmp.ForEach(y =>
                                {
                                    if (emo.Where(x => x.EmployeeNo.Trim() == a.EmployeeNO.Trim() && x.OrganizationNo == y.OrganizationNo).ToList().Count > 0)
                                    {
                                        if (a.PeriodID == PeriodID)
                                        {
                                            if (evatmp != a.EvaluatorNO)
                                            {
                                                tblEvaluation tmp2 = new tblEvaluation();
                                                tmp2.EvaluatorNO   = a.EvaluatorNO;
                                                evatmp             = a.EvaluatorNO;
                                                tmp2.PeriodID      = a.PeriodID;
                                                tmp2.period        = a.period;
                                                result.Add(tmp2);
                                            }
                                            tblEvaluation tmp = new tblEvaluation();
                                            tmp.EvaluatorNO   = a.EvaluatorNO;
                                            tmp.EmployeeNO    = a.EmployeeNO;
                                            tmp.Eva_ID        = a.Eva_ID;
                                            tmp.PeriodID      = a.PeriodID;
                                            tmp.period        = a.period;
                                            tmp.Job_ID        = a.Job_ID;

                                            result.Add(tmp);
                                        }
                                    }
                                });
                            });
                        });
                        return(toJson(result));
                    }
                }
            }


            return(null);
        }