コード例 #1
0
        /// <summary>
        /// Get master list of dropdowns for create problem page.
        /// </summary>
        /// <param name="sessionkey">string</param>
        /// <returns>string</returns>
        public ResponseObjectForAnything GetDropDownItems(string sessionkey)
        {
            List<Company> lstcompany = new List<Company>();
            List<Category> lstcategory = new List<Category>();
            List<Country> lstcountry = new List<Country>();
            List<ProductStatus> lstproductstatus = new List<ProductStatus>();
            List<ResolutionMethod> lstresolutionmethod = new List<ResolutionMethod>();
            CreateProblemObject createproblemobj = new CreateProblemObject();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            bool isValid = authEngine.IsValidSession(sessionkey);
            int count = 0;
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();

            try
            {
                if (isValid)
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetDropDownItems");
                    db.AddInParameter(dbCommand, "SessionKey", DbType.String, sessionkey);

                    DataSet dsDropdowns = db.ExecuteDataSet(dbCommand);
                    if(dsDropdowns.Tables.Count > 0)
                    {
                        DataTable tDropDowns = dsDropdowns.Tables[0];
                        foreach(DataRow dr in tDropDowns.Rows)
                        {
                            Company company = new Company();
                            if (dr["CompanyID"] != DBNull.Value) { company.CompanyID = Convert.ToInt32(dr["CompanyID"]); }
                            if (dr["CompanyName"] != DBNull.Value) { company.CompanyName = dr["CompanyName"].ToString(); }
                            lstcompany.Add(company);
                            count++;
                        }
                        createproblemobj.companies = lstcompany;
                    }
                    if (dsDropdowns.Tables.Count > 1)
                    {
                        DataTable tDropDowns = dsDropdowns.Tables[1];
                        foreach (DataRow dr in tDropDowns.Rows)
                        {
                            Category category = new Category();
                            if (dr["ID"] != DBNull.Value) { category.ID = Convert.ToInt32(dr["ID"]); }
                            if (dr["Name"] != DBNull.Value) { category.Name = dr["Name"].ToString(); }
                            lstcategory.Add(category);
                            count++;
                        }
                        createproblemobj.categories = lstcategory;
                    }
                    if (dsDropdowns.Tables.Count > 2)
                    {
                        DataTable tDropDowns = dsDropdowns.Tables[2];
                        foreach (DataRow dr in tDropDowns.Rows)
                        {
                            ProductStatus productstatus = new ProductStatus();
                            if (dr["ProductStatusID"] != DBNull.Value) { productstatus.ProductStatusID = Convert.ToInt32(dr["ProductStatusID"]); }
                            if (dr["ProductStatusName"] != DBNull.Value) { productstatus.ProductStatusName = dr["ProductStatusName"].ToString(); }
                            lstproductstatus.Add(productstatus);
                            count++;
                        }
                        createproblemobj.productstatuses = lstproductstatus;
                    }
                    if (dsDropdowns.Tables.Count > 3)
                    {
                        DataTable tDropDowns = dsDropdowns.Tables[3];
                        foreach (DataRow dr in tDropDowns.Rows)
                        {
                            Country country = new Country();
                            if (dr["CountryID"] != DBNull.Value) { country.CountryID = Convert.ToInt32(dr["CountryID"]); }
                            if (dr["CountryName"] != DBNull.Value) { country.CountryName = dr["CountryName"].ToString(); }
                            if (dr["IsDefaulted"] != DBNull.Value) { country.IsDefaulted = Convert.ToBoolean(dr["IsDefaulted"].ToString()); }
                            lstcountry.Add(country);
                            count++;
                        }
                        createproblemobj.countries = lstcountry;
                    }
                    if (dsDropdowns.Tables.Count > 4)
                    {
                        DataTable tDropDowns = dsDropdowns.Tables[4];
                        foreach (DataRow dr in tDropDowns.Rows)
                        {
                            if (dr["PinCode"] != DBNull.Value) { createproblemobj.PinCode = dr["PinCode"].ToString(); }
                        }
                    }
                }
                responseObject.ResultCode = "SUCCESS";
                responseObject.ResultObjectJSON = Serializer.ObjectToJSON(createproblemobj);
                responseObject.ResultObjectRecordCount = count;
                if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No master items configured."; }
            }
            catch (Exception ex)
            {
                responseObject.ResultCode = "ERROR";
                responseObject.ResultMessage = ex.Message;
                CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetDropDownItems", System.DateTime.Now);
                ExceptionManager.PublishException(exc);
            }
            return (responseObject);
        }
コード例 #2
0
        /// <summary>
        /// This method gets the complete list of all companies
        /// in the system.
        /// </summary>
        /// <returns>ResponseObjectForAnything</returns>
        public ResponseObjectForAnything GetCompanyList(string sessionKey)
        {
            List<Company> companylist = new List<Company>();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            bool isValid = authEngine.IsValidSession(sessionKey);
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            int count = 0;

            try
            {
                if (isValid)
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetCompanies");

                    using (IDataReader dr = db.ExecuteReader(dbCommand))
                    {
                        while (dr.Read())
                        {
                            Company company = new Company();
                            if (dr["CompanyID"] != DBNull.Value) { company.CompanyID = Convert.ToInt32(dr["CompanyID"]); }
                            if (dr["CompanyName"] != DBNull.Value) { company.CompanyName = dr["CompanyName"].ToString(); }
                            if (dr["Address1"] != DBNull.Value) { company.Address1 = dr["Address1"].ToString(); }
                            if (dr["Address2"] != DBNull.Value) { company.Address2 = dr["Address2"].ToString(); }
                            if (dr["Address3"] != DBNull.Value) { company.Address3 = dr["Address3"].ToString(); }
                            if (dr["City"] != DBNull.Value) { company.City = dr["City"].ToString(); }
                            if (dr["StateID"] != DBNull.Value) { company.StateID = Convert.ToInt32(dr["StateID"]); }
                            if (dr["StateName"] != DBNull.Value) { company.StateName = dr["StateName"].ToString(); }
                            if (dr["CountryID"] != DBNull.Value) { company.CountryID = Convert.ToInt32(dr["CountryID"]); }
                            if (dr["CountryName"] != DBNull.Value) { company.CountryName = dr["CountryName"].ToString(); }
                            if (dr["Phone"] != DBNull.Value) { company.Phone = dr["Phone"].ToString(); }
                            if (dr["EmailID"] != DBNull.Value) { company.EmailID = dr["EmailID"].ToString(); }
                            if (dr["LogoPath"] != DBNull.Value) { company.EmailID = dr["LogoPath"].ToString(); }
                            if (dr["WeekdaysStartTime"] != DBNull.Value) { company.WeekdaysStartTime = dr["WeekdaysStartTime"].ToString(); }
                            if (dr["WeekdaysEndTime"] != DBNull.Value) { company.WeekdaysEndTime = dr["WeekdaysEndTime"].ToString(); }
                            if (dr["WeekendsStartTime"] != DBNull.Value) { company.WeekendsStartTime = dr["WeekendsStartTime"].ToString(); }
                            if (dr["WeekendsEndTime"] != DBNull.Value) { company.WeekendsEndTime = dr["WeekendsEndTime"].ToString(); }
                            companylist.Add(company);
                            count++;
                        }
                    }
                    responseObject.ResultCode = "SUCCESS";
                    responseObject.ResultObjectJSON = Serializer.ObjectToJSON(companylist);
                    responseObject.ResultObjectRecordCount = count;
                    if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No companies configured."; }
                }
            }
            catch (Exception ex)
            {
                responseObject.ResultCode = "ERROR";
                responseObject.ResultMessage = ex.Message;
                CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetCompanies", System.DateTime.Now);
                ExceptionManager.PublishException(exc);
            }
            return (responseObject);
        }
コード例 #3
0
        /// <summary>
        /// Get Problems by user ID.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <returns>string</returns>
        public ResponseObjectForAnything GetProblemsByUserID(string sessionKey, string startindex, string pageindex, bool paging, string problemstatusid)
        {
            DashboardObject dashboardobject = new DashboardObject();
            List<RecentProblemObject> recentproblemlist = new List<RecentProblemObject>();
            List<Problem> problemlist = new List<Problem>();
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            bool isValid = true;
            int count = 0;
            if (!string.IsNullOrEmpty(sessionKey))
            {
                isValid = authEngine.IsValidSession(sessionKey);
            }
            List<ProblemStatus> lstproblemstatus = new List<ProblemStatus>();
            List<Category> lstcategory = new List<Category>();
            List<Company> lstcompany = new List<Company>();

            if (isValid)
            {
                try
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetProblemsByUserID");
                    db.AddInParameter(dbCommand, "@SessionKey", DbType.String, sessionKey);
                    db.AddInParameter(dbCommand, "@StartCount", DbType.Int32, Int32.Parse(startindex));
                    db.AddInParameter(dbCommand, "@PageSize", DbType.Int32, Int32.Parse(pageindex));
                    db.AddInParameter(dbCommand, "@IsPaging", DbType.Boolean, Convert.ToBoolean(paging));
                    db.AddInParameter(dbCommand, "@ProblemStatusID", DbType.Boolean, Int32.Parse(problemstatusid));

                    DataSet dsProblem = db.ExecuteDataSet(dbCommand);

                    if (dsProblem.Tables.Count > 0)
                    {
                        DataTable tProblem = dsProblem.Tables[0];

                        foreach (DataRow dRow in tProblem.Rows)
                        {
                            Problem problem = new Problem();
                            User user = new User();
                            if (dRow["ID"] != DBNull.Value) { problem.ID = Int32.Parse(dRow["ID"].ToString()); }
                            if (dRow["UserID"] != DBNull.Value) { problem.UserID = Int32.Parse(dRow["UserID"].ToString()); }
                            if (dRow["FirstName"] != DBNull.Value) { problem.FirstName = dRow["FirstName"].ToString(); }
                            if (dRow["LastName"] != DBNull.Value) { problem.LastName = dRow["LastName"].ToString(); }
                            if (dRow["DisplayName"] != DBNull.Value) { problem.DisplayName = dRow["DisplayName"].ToString(); }
                            if (dRow["EmailID"] != DBNull.Value) { problem.EmailID = dRow["EmailID"].ToString(); }
                            if (dRow["CompanyRelated"] != DBNull.Value) { problem.IsCompanyRelated = Convert.ToBoolean(dRow["CompanyRelated"].ToString()); }
                            if (dRow["CompanyID"] != DBNull.Value) { problem.CompanyID = Int32.Parse(dRow["CompanyID"].ToString()); }
                            if (dRow["CompanyName"] != DBNull.Value) { problem.CompanyName = dRow["CompanyName"].ToString(); }
                            if (dRow["ProblemHeading"] != DBNull.Value) { problem.ProblemHeading = dRow["ProblemHeading"].ToString(); }
                            if (dRow["CategoryID"] != DBNull.Value) { problem.CategoryID = Int32.Parse(dRow["CategoryID"].ToString()); }
                            if (dRow["SubCategoryID"] != DBNull.Value) { problem.SubCategoryID = Int32.Parse(dRow["SubCategoryID"].ToString()); }
                            if (dRow["ProductID"] != DBNull.Value) { problem.ProductID = Int32.Parse(dRow["ProductID"].ToString()); }
                            if (dRow["ModelNo"] != DBNull.Value) { problem.ModelNo = dRow["ModelNo"].ToString(); }
                            if (dRow["Description"] != DBNull.Value) { problem.Description = dRow["Description"].ToString(); }
                            if (dRow["PurchaseMonth"] != DBNull.Value) { problem.PurchaseMonth = Int32.Parse(dRow["PurchaseMonth"].ToString()); }
                            if (dRow["PurchaseYear"] != DBNull.Value) { problem.PurchaseYear = Int32.Parse(dRow["PurchaseYear"].ToString()); }
                            if (dRow["ProductStatusID"] != DBNull.Value) { problem.ProductStatusID = Int32.Parse(dRow["ProductStatusID"].ToString()); }
                            if (dRow["ProductStatusName"] != DBNull.Value) { problem.ProductStatusName = dRow["ProductStatusName"].ToString(); }
                            if (dRow["ProblemStatusID"] != DBNull.Value) { problem.ProblemStatusID = Int32.Parse(dRow["ProblemStatusID"].ToString()); }
                            if (dRow["ProblemStatusName"] != DBNull.Value) { problem.ProblemStatusName = dRow["ProblemStatusName"].ToString(); }
                            if (dRow["ResolutionNeededBy"] != DBNull.Value) { problem.ResolutionNeededBy = Convert.ToDateTime(dRow["ResolutionNeededBy"].ToString()); }
                            if (dRow["IsVirtual"] != DBNull.Value) { problem.IsVirtual = Convert.ToBoolean(dRow["IsVirtual"].ToString()); }
                            if (dRow["IsRegisteredAddress"] != DBNull.Value) { problem.IsRegisteredAddress = Convert.ToBoolean(dRow["IsRegisteredAddress"].ToString()); }
                            if (dRow["Address1"] != DBNull.Value) { problem.Address1 = dRow["Address1"].ToString(); }
                            if (dRow["Address2"] != DBNull.Value) { problem.Address2 = dRow["Address2"].ToString(); }
                            if (dRow["Address3"] != DBNull.Value) { problem.Address3 = dRow["Address3"].ToString(); }
                            if (dRow["City"] != DBNull.Value) { problem.City = dRow["City"].ToString(); }
                            if (dRow["StateID"] != DBNull.Value) { problem.StateID = Int32.Parse(dRow["StateID"].ToString()); }
                            if (dRow["StateName"] != DBNull.Value) { problem.StateName = dRow["StateName"].ToString(); }
                            if (dRow["CountryID"] != DBNull.Value) { problem.CountryID = Int32.Parse(dRow["CountryID"].ToString()); }
                            if (dRow["CountryName"] != DBNull.Value) { problem.CountryName = dRow["CountryName"].ToString(); }
                            if (dRow["PinCode"] != DBNull.Value) { problem.PinCode = dRow["PinCode"].ToString(); }
                            if (dRow["Latitude"] != DBNull.Value) { problem.Latitude = Convert.ToDecimal(dRow["Latitude"].ToString()); }
                            if (dRow["Longitude"] != DBNull.Value) { problem.Longitude = Convert.ToDecimal(dRow["Longitude"].ToString()); }
                            if (dRow["Distance"] != DBNull.Value) { problem.Distance = Convert.ToDecimal(dRow["Distance"].ToString()); }
                            if (dRow["ThumbnailMedia"] != DBNull.Value) { problem.ThumbnailMedia = dRow["ThumbnailMedia"].ToString(); }
                            problemlist.Add(problem);
                            count++;
                        }
                        dashboardobject.ProblemList = problemlist;
                    }
                    if (dsProblem.Tables.Count > 1)
                    {
                        DataTable tProblemStatus = dsProblem.Tables[1];

                        foreach (DataRow dRow in tProblemStatus.Rows)
                        {
                            ProblemStatus probstatus = new ProblemStatus();
                            if (dRow["ProblemStatusID"] != DBNull.Value) { probstatus.ProblemStatusID = Int32.Parse(dRow["ProblemStatusID"].ToString()); }
                            if (dRow["ProblemStatusName"] != DBNull.Value) { probstatus.ProblemStatusName = dRow["ProblemStatusName"].ToString(); }
                            lstproblemstatus.Add(probstatus);
                        }
                        dashboardobject.ProblemStatus = lstproblemstatus;
                    }
                    if (!paging)
                    {
                        if (dsProblem.Tables.Count > 2)
                        {
                            DataTable tCategories = dsProblem.Tables[2];
                            foreach (DataRow dRow in tCategories.Rows)
                            {
                                Category category = new Category();
                                if (dRow["ID"] != DBNull.Value) { category.ID = Int32.Parse(dRow["ID"].ToString()); }
                                if (dRow["Name"] != DBNull.Value) { category.Name = dRow["Name"].ToString(); }
                                lstcategory.Add(category);
                            }
                            dashboardobject.Categories = lstcategory;
                        }
                        if (dsProblem.Tables.Count > 3)
                        {
                            DataTable tCountries = dsProblem.Tables[3];
                            foreach (DataRow dRow in tCountries.Rows)
                            {
                                Company company = new Company();
                                if (dRow["CompanyID"] != DBNull.Value) { company.CompanyID = Int32.Parse(dRow["CompanyID"].ToString()); }
                                if (dRow["CompanyName"] != DBNull.Value) { company.CompanyName = dRow["CompanyName"].ToString(); }
                                lstcompany.Add(company);
                            }
                            dashboardobject.Companies = lstcompany;
                        }
                        if (dsProblem.Tables.Count > 4)
                        {
                            DataTable tProblem = dsProblem.Tables[4];

                            foreach (DataRow dRow in tProblem.Rows)
                            {
                                RecentProblemObject problem = new RecentProblemObject();
                                if (dRow["ProblemID"] != DBNull.Value) { problem.ProblemID = Int32.Parse(dRow["ProblemID"].ToString()); }
                                if (dRow["ProblemTitle"] != DBNull.Value) { problem.ProblemTitle = dRow["ProblemTitle"].ToString(); }
                                if (dRow["Description"] != DBNull.Value) { problem.Description = dRow["Description"].ToString(); }
                                if (dRow["ProblemImagePath"] != DBNull.Value) { problem.ProblemImagePath = dRow["ProblemImagePath"].ToString(); }
                                recentproblemlist.Add(problem);
                            }
                            dashboardobject.RecentProblems = recentproblemlist;
                        }
                    }
                    responseObject.ResultCode = "SUCCESS";
                    responseObject.ResultObjectRecordCount = count;
                    responseObject.ResultObjectJSON = Serializer.ObjectToJSON(dashboardobject);
                    if (responseObject.ResultObjectRecordCount <= 0) { responseObject.ResultMessage = "No records found."; }
                }
                catch (Exception ex)
                {
                    responseObject.ResultCode = "ERROR";
                    responseObject.ResultMessage = ex.Message;
                    CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetProblemsByUserID", System.DateTime.Now);
                    ExceptionManager.PublishException(exc);
                }
            }
            return responseObject;
        }