/// <summary> /// This method is used to add branch to the system - JJ /// </summary> /// <param name="branchDetail">object of BranchDetailAC</param> /// <param name="userName"></param> /// <returns>return BranchDetailAC object</returns> public BranchDetailAC AddBranchDetail(BranchDetailAC branchDetail, string userName) { try { var currentUser = _userDataRepository.First(x => x.UserName == userName && x.IsDelete == false); int companyId = 0; if (_companyDetailContext.Fetch(x => x.UserId == currentUser.UserId).ToList().Any()) { companyId = _companyDetailContext.First(x => x.UserId == currentUser.UserId).Id; } if (CheckBranchNameIdExist(branchDetail.Name, branchDetail.Id, companyId)) { branchDetail.Name = "invalid"; return(branchDetail); } else if (CheckCodeIdExist(branchDetail.Code, branchDetail.Id, branchDetail.CompanyId)) { branchDetail.Code = "invalid"; return(branchDetail); } else if (CheckEmailIdExist(branchDetail.Email, branchDetail.Id)) { branchDetail.Email = "invalid"; return(branchDetail); } else if (CheckPhoneIdExist(branchDetail.Phone, branchDetail.Id)) { branchDetail.Phone = "invalid"; return(branchDetail); } BranchDetail branch = new BranchDetail() { Name = branchDetail.Name, NameSl = branchDetail.NameSl, Code = branchDetail.Code, Storename = branchDetail.Storename, Email = branchDetail.Email, Fax = branchDetail.Fax, Address = branchDetail.Address, IsAutomaticIssueSPO = branchDetail.IsAutomaticIssueSPO, Phone = branchDetail.Phone, CompanyId = companyId, Zipcode = branchDetail.Zipcode, CreatedDateTime = DateTime.UtcNow }; _branchContext.Add(branch); _branchContext.SaveChanges(); branchDetail.CompanyId = companyId; branchDetail.Id = branch.Id; return(branchDetail); } catch (Exception ex) { _errorLog.LogException(ex); throw; } }
public ActionResult AllBranches(Branches br) { BranchDetail bd = new BranchDetail(); HttpPostedFileBase file = Request.Files["imgfile"]; HttpPostedFileBase files = Request.Files["files"]; // string[] files = Request.Files["fileUpload"]; try { if (file != null && file.ContentLength > 0) { file.SaveAs(Server.MapPath("~/imgs/" + file.FileName)); br.mainImg = "~/imgs/" + file.FileName; con.Open(); com = new SqlCommand("insert into Branches Values ('" + br.phone + "',N'" + br.Title + "',N'" + br.mainImg + "',N'" + br.AddBranche + "',N'" + br.enTitle + "',N'" + br.enAddrBranch + "')", con); com.ExecuteNonQuery(); } else { con.Open(); com = new SqlCommand("insert into Branches(phone,Title,AddBranche,enTitle,enAddrBranch) Values ('" + br.phone + "',N'" + br.Title + "',N'" + br.AddBranche + "',N'" + br.enTitle + "',N'" + br.enAddrBranch + "')", con); com.ExecuteNonQuery(); } int id = getMaxId(); SqlCommand com2; for (int i = 0; i < Request.Files.Count; i++) { if (i == 0) { continue; } else { if (Request.Files[i].ContentLength > 0) { Request.Files[i].SaveAs(Server.MapPath("~/imgs/" + Request.Files[i].FileName)); bd.imgSrc = "~/imgs/" + Request.Files[i].FileName; com2 = new SqlCommand("insert into BranchDetail values(N'" + bd.imgSrc + "'," + id + ")", con); com2.ExecuteNonQuery(); } } } con.Close(); ViewBag.msg = "your data inserted successfully"; return(Redirect("AllBranches")); } catch (Exception ex) { ViewBag.Emsg = "your data didn't insert correctly"; return(View()); } }
private async Task <BranchDetail> GetBranchDetail(Repository repository, Branch branch) { var infos = await client.Git.Tree.GetRecursive(repository.Id, branch.Commit.Sha); var obj = new BranchDetail { Name = branch.Name, BakeFiles = infos.Tree.Where(node => node.Path.ToLower().Contains("docker-bake")).Select(node => node.Path).ToList(), Dockerfiles = infos.Tree.Where(node => node.Path.ToLower().Contains("dockerfile")).Select(node => node.Path).ToList(), DockerComposeFiles = infos.Tree.Where(node => node.Path.ToLower().Contains("docker-compose")).Select(node => node.Path).ToList(), Files = infos.Tree.Where(node => node.Type.Value == TreeType.Blob).Select(node => node.Path).ToList(), Folders = infos.Tree.Where(node => node.Type.Value == TreeType.Tree).Select(node => node.Path).ToList() }; return(obj); }
public JsonResult Upload() { BranchDetail bd = new BranchDetail(); con.Open(); foreach (HttpPostedFileBase file in Request.Files) { if (file.ContentLength > 0) { file.SaveAs(Server.MapPath("~/imgs/" + file.FileName)); com = new SqlCommand("insert into BranchDetail values('" + bd.imgSrc + "'," + getMaxId() + ")", con); } } con.Close(); return(Json(new { result = true })); }
public bool _U_ValidateLogin(string LoginId, string Password, string InstanceName, byte[] EncryptedPassword, string IpAddesss, string BrowserInfo, string server, string webSessionID, string OperatingSystem, string BrowserVersion, string BrowserName, string SSOAuthToken, out Struct_LoginUser Ulogin, out List <BranchDetail> userBranchList) { bool ret = false; Ulogin = new Struct_LoginUser(); userBranchList = new List <BranchDetail>(); try { this.Connect(this.GetConnString()); string spName = "_U_ValidateLogin"; this.ClearSPParams(); this.AddSPStringParam("@LoginId", LoginId); this.AddSPStringParam("@Password", Password); this.AddSPVarBinaryParam("@EncryptedPassword", EncryptedPassword); this.AddSPStringParam("@IpAddesss", IpAddesss); this.AddSPStringParam("@BrowserInfo", BrowserInfo); this.AddSPStringParam("@server", server); this.AddSPStringParam("@webSessionID", webSessionID); this.AddSPStringParam("@instanceName", InstanceName); this.AddSPStringParam("@OperatingSystem", OperatingSystem); this.AddSPStringParam("@BrowserVersion", BrowserVersion); this.AddSPStringParam("@Browser", BrowserName); this.AddSPStringParam("@SSOAuthToken", SSOAuthToken); this.AddSPReturnIntParam("@return"); using (SqlDataReader reader = this.ExecuteSelectSP(spName)) { while (reader.Read()) { //get the LoginID (Login User Name) if (reader["LoginID"] != DBNull.Value) { Ulogin.loginId = reader["LoginID"].ToString(); } else { Ulogin.loginId = ""; } //get the Role ID if (reader["RoleID"] != DBNull.Value) { Ulogin.RoleID = Convert.ToInt32(reader["RoleID"]); } else { Ulogin.RoleID = 0; } if (reader["CompanyID"] != DBNull.Value) { Ulogin.CompanyID = Convert.ToInt32(reader["CompanyID"]); } else { Ulogin.CompanyID = 0; } //get the LOGIN_STATUS if (reader["LOGIN_STATUS"] != DBNull.Value) { Ulogin.loginstatus = reader["LOGIN_STATUS"].ToString(); } else { Ulogin.loginstatus = ""; } //get the SCOPE if (reader["Scope"] != DBNull.Value) { Ulogin.rolescope = reader["Scope"].ToString(); } else { Ulogin.rolescope = ""; } //get the LAST_LOGIN //if (reader["LastLoginTime"] != DBNull.Value) // Ulogin.lastlogindate = Convert.ToDateTime(reader["LastLoginTime"]); //get the [USER_ID] if (reader["UserID"] != DBNull.Value) { Ulogin.UserId = Convert.ToInt32(reader["UserID"]); } else { Ulogin.UserId = 0; } ////get the USER_PK //if (reader["USER_PK"] != DBNull.Value) // Ulogin.UserPrimaryKey = Convert.ToInt32(reader["USER_PK"]); //else // Ulogin.UserPrimaryKey = 0; //get the LANDING_PAGE if (reader["LANDING_PAGE"] != DBNull.Value) { Ulogin.Landingpage = reader["LANDING_PAGE"].ToString(); } else { Ulogin.Landingpage = ""; } //get the ROLE_NAME if (reader["RoleName"] != DBNull.Value) { Ulogin.RoleName = reader["RoleName"].ToString(); } else { Ulogin.RoleName = ""; } //get the IS_PASSWORD_REGENERATED if (reader["isPasswordRegenerated"] != DBNull.Value) { Ulogin.Is_Password_Regenerated = Convert.ToBoolean(reader["isPasswordRegenerated"]); } else { Ulogin.Is_Password_Regenerated = false; } if (reader["PassowordExpireOn"] != DBNull.Value) { Ulogin.PASSWD_EXPIRY = Convert.ToDateTime(reader["PassowordExpireOn"]); } ////get the User_type //if (reader["User_Type"] != DBNull.Value) // Ulogin.UserType = Convert.ToByte(reader["User_Type"]); //else // Ulogin.UserType = 0; //SessionTimeOut if (reader["SessionTimeOut"] != DBNull.Value) { Ulogin.SessionOutTime = Convert.ToInt32(reader["SessionTimeOut"]); } else { Ulogin.SessionOutTime = 0; } // Role Type if (reader["ROLE_TYPE"] != DBNull.Value) { Ulogin.roleType = Convert.ToInt32(reader["ROLE_TYPE"]); } else { Ulogin.roleType = 0; } //userName if (reader["userName"] != DBNull.Value) { Ulogin.userName = Convert.ToString(reader["userName"]); } else { Ulogin.userName = ""; } if (reader["IsSSOLogin"] != DBNull.Value) { Ulogin.IsSSOLogin = Convert.ToBoolean(reader["IsSSOLogin"]); } else { Ulogin.IsSSOLogin = false; } if (reader["UserSessionID"] != DBNull.Value) { Ulogin.UserSessionID = reader["UserSessionID"].ToString(); } else { Ulogin.UserSessionID = ""; } if (reader["enableAutoSessionOut"] != DBNull.Value) { Ulogin.enableAutoSessionOut = Convert.ToBoolean(reader["enableAutoSessionOut"]); } else { Ulogin.enableAutoSessionOut = false; } } reader.NextResult(); while (reader.Read()) { BranchDetail item = new BranchDetail(); if (reader["BranchID"] != DBNull.Value) { item.BranchID = Convert.ToInt32(reader["BranchID"]); } else { item.BranchID = 0; } if (reader["BranchName"] != DBNull.Value) { item.BranchName = reader["BranchName"].ToString(); } else { item.BranchName = ""; } userBranchList.Add(item); } reader.Close(); int retcode = this.GetOutValueInt("@return"); switch (retcode) { case 1: ret = true; break; case -1: SetError(102, "The username or password you entered is incorrect"); break; case -2: SetError(109, "The user does not have access to any branches"); break; case -3: SetError(-3, "Your account is locked due to too many failed attempts. Please contact your administrator to unlock."); break; case -4: SetError(-4, "Blocked Your IP Address. Please contact Admin."); break; default: SetError(-100, "Failed to Login. Please try again later"); break; } } } catch (Exception e) { SetError(-100, "Failed to Login. Please try again later"); Utils.Write(0, 0, "SecurityManager", "_U_ValidateLogin", "", "", e); } finally { this.ClearSPParams(); this.Disconnect(); } return(ret); }