private async Task UpdateCatalog_ExecuteAsync() { Reporter.StartBusy(); BulkData oracleBulkData = (await ScryfallService.GetBulkDataInfo(Reporter)).Data.Single(bd => bd.Name.Contains("Oracle")); List <Card> cards = await ScryfallService.GetBulkCards(oracleBulkData.PermalinkUri, Reporter); if (cards == null || cards.Count == 0) { Reporter.Report("Cards not found or empty", true); Reporter.StopBusy(); return; } Reporter.Report("Transcribing secrets of the fish men"); var catalog = new CardCatalog(oracleBulkData, cards, DateTime.Now); try { catalog.SaveToFile(); } catch (Exception e) { DisplayError(e, "Could not save card catalog to local disk."); Reporter.Report(e.Message, true); Reporter.StopBusy(); return; } OracleCatalog = catalog; Reporter.Report("Secrets hidden in a safe place"); Reporter.StopBusy(); }
//public async Task<UpdateLoginUsersResponse> Post([FromBody]LoginUsersAddRequest loginuser) public async Task <dynamic> Post([FromBody] LoginUsersAddRequest loginuser) { UpdateLoginUsersResponse registrationResponse = new UpdateLoginUsersResponse(); var response = await _cloudantService.GetAllAsync(DBNames.loginusers.ToString()); BulkData loginusers = JsonConvert.DeserializeObject <BulkData>(response); var IsUserExist = loginusers.rows.FirstOrDefault(a => a.doc.Username == loginuser.Username); if (IsUserExist == null) { if (_postUserLoginProcessor != null) { //return await _postUserLoginProcessor.PostNewUserRecord(loginuser, _cloudantService); HashSalt hashSalt = Helper.GenerateSaltedHash(64, loginuser.Password); loginuser.Password = hashSalt.Hash; loginuser.Passwordsalt = hashSalt.Salt; _postUserLoginProcessor.PostNewUserRecord(loginuser, _cloudantService); return(new string[] { "SUCCESS" }); } else { //return new UpdateLoginUsersResponse(); return(new string[] { "No database connection" }); } } else { return(new string[] { "USER_ALREADY_EXIST" }); } }
public async Task <dynamic> ChangePassword([FromBody] ValidateLoginUsersAddRequest validateloginuser) { UpdateLoginUsersResponse registrationResponse = new UpdateLoginUsersResponse(); var response = await _cloudantService.GetAllAsync(DBNames.loginusers.ToString()); BulkData loginusers = JsonConvert.DeserializeObject <BulkData>(response); var UpdatedLoginDetails = loginusers.rows.FirstOrDefault(a => a.doc.Username == validateloginuser.Username); HashSalt hashSalt = Helper.GenerateSaltedHash(64, validateloginuser.Password); LoginUsers loginuser = new LoginUsers(); loginuser.Username = UpdatedLoginDetails.doc.Username; loginuser.Password = hashSalt.Hash; loginuser.Passwordsalt = hashSalt.Salt; loginuser._id = UpdatedLoginDetails.doc._id; loginuser.Id = UpdatedLoginDetails.doc.Id; loginuser.EmailID = UpdatedLoginDetails.doc.EmailID; loginuser.Type = UpdatedLoginDetails.doc.Type; loginuser._rev = UpdatedLoginDetails.doc._rev; if (_postUserLoginProcessor != null) { return(await _putUserLoginProcessor.PutExistingUserRecord(loginuser, _cloudantService)); } else { return(new string[] { "No database connection" }); } }
public void ClearData_Test() { BulkData data = new BulkData(); int expectedSize = 0; data.AddData("1"); data.ClearData(); Assert.AreEqual(expectedSize, data.GetSize()); }
public void GetStringData_Test() { BulkData data = new BulkData(); data.AddData("1"); data.AddData("2"); data.AddData("3"); string expectedStr = "[1,2,3]"; Assert.AreEqual(expectedStr, data.GetStringData()); }
public async Task <dynamic> EditDetails([FromBody] EditDetails editDetails) { var response = await _cloudantService.GetAllAsync(DBNames.loginusers.ToString()); BulkData loginusers = JsonConvert.DeserializeObject <BulkData>(response); var UpdatedLoginDetails = loginusers.rows.FirstOrDefault(a => a.doc.Username == editDetails.Username); LoginUsers loginuser = new LoginUsers(); if (editDetails.Password != "") { HashSalt hashSalt = Helper.GenerateSaltedHash(64, editDetails.Password); loginuser.Password = hashSalt.Hash; loginuser.Passwordsalt = hashSalt.Salt; } else { loginuser.Password = UpdatedLoginDetails.doc.Password; loginuser.Passwordsalt = UpdatedLoginDetails.doc.Passwordsalt; } if (editDetails.EmailID != "") { loginuser.EmailID = editDetails.EmailID; } else { loginuser.EmailID = UpdatedLoginDetails.doc.EmailID; } if (editDetails.Type != "") { loginuser.Type = editDetails.Type; } else { loginuser.Type = UpdatedLoginDetails.doc.Type; } loginuser.Username = UpdatedLoginDetails.doc.Username; loginuser._id = UpdatedLoginDetails.doc._id; loginuser.Id = UpdatedLoginDetails.doc.Id; loginuser._rev = UpdatedLoginDetails.doc._rev; if (_postUserLoginProcessor != null) { return(await _putUserLoginProcessor.PutExistingUserRecord(loginuser, _cloudantService)); } else { return(new string[] { "No database connection" }); } }
public IEnumerable <PriceInfo> Parse(WebAccess webAccess, string url, object param, out string errorMessage) { _errorMessages = new List <string>(); BulkData bulkData = (BulkData)param; Card[] cards = GetCardsInfo(webAccess, url); List <PriceInfo> ret = cards.SelectMany(c => ExtractCardPrice(c, bulkData.UpdatedAt)).ToList(); errorMessage = string.Join("\r\n", _errorMessages); return(ret); }
public IReadOnlyList <KeyValuePair <string, object> > GetUrls(WebAccess webAccess) { IList <KeyValuePair <string, object> > urls = new List <KeyValuePair <string, object> >(); string json = webAccess.GetHtml(Scryfall); BulkDataList bulkDataList = JsonConvert.DeserializeObject <BulkDataList>(json); BulkData bulkData = bulkDataList.Data.FirstOrDefault(d => d.Type == WantedBulkType); if (bulkData != null) { urls.Add(new KeyValuePair <string, object>(bulkData.DownloadUri, bulkData)); } return(urls.ToArray()); }
public async Task <UpdateLoginUsersvalidateResponse> PostLogin([FromBody] ValidateLoginUsersAddRequest validateloginuser) { var response = await _cloudantService.GetAllAsync(DBNames.loginusers.ToString()); BulkData loginusers = JsonConvert.DeserializeObject <BulkData>(response); //if (validateloginuser.Username != null) //{ var User = loginusers.rows.FirstOrDefault(a => a.doc.Username == validateloginuser.Username); var validateuser = loginusers.rows.FirstOrDefault(a => a.doc.Username == validateloginuser.Username);// && a.doc.Password == validateloginuser.Password); bool isPasswordMatched = Helper.VerifyPassword(validateloginuser.Password, User.doc.Password, User.doc.Passwordsalt); if (isPasswordMatched) { var responsetype = await _cloudantService.GetAllAsync(DBNames.userrights.ToString()); BulkDataUserRights userrights = JsonConvert.DeserializeObject <BulkDataUserRights>(responsetype); var usertyperesponse = userrights.rows.FirstOrDefault(a => a.doc.logintypes == validateuser.doc.Type); UpdateLoginUsersvalidateResponse validloginuser = new UpdateLoginUsersvalidateResponse(); validloginuser.logintypes = usertyperesponse.doc.logintypes; validloginuser.EmployeeMaster = usertyperesponse.doc.EmployeeMaster; validloginuser.ILCMaster = usertyperesponse.doc.ILCMaster; validloginuser.ForcastMaster = usertyperesponse.doc.ForcastMaster; validloginuser.Financials = usertyperesponse.doc.Financials; validloginuser.Reports = usertyperesponse.doc.Reports; validloginuser.LoginMaster = usertyperesponse.doc.LoginMaster; validloginuser.Id = usertyperesponse.doc._id; validloginuser.Rev = usertyperesponse.doc._rev; usertyperesponse.doc.ok = "Success"; validloginuser.ok = usertyperesponse.doc.ok; //validloginuser.lateston = usertyperesponse.doc.lateston; return(validloginuser); } else { UpdateLoginUsersvalidateResponse validloginuser = new UpdateLoginUsersvalidateResponse(); validloginuser.ok = "Wrong Password"; return(validloginuser); } //UpdateLoginUsersvalidateResponse validloginuser = new UpdateLoginUsersvalidateResponse(); //validloginuser.ok = "Invalid user name"; //return validloginuser; //} }
public void GetSize_Test() { BulkData data = new BulkData(); int expectedSize = 0; Assert.AreEqual(expectedSize, data.GetSize()); data.AddData("1"); data.AddData("2"); data.AddData("3"); expectedSize = 3; Assert.AreEqual(expectedSize, data.GetSize()); }
public void GetData_Test() { BulkData data = new BulkData(); data.AddData("1"); data.AddData("2"); data.AddData("3"); List <string> expectedList = new List <string>(); expectedList.Add("1"); expectedList.Add("2"); expectedList.Add("3"); //List<string> compareList = data.GetData(); for (int i = 0; i < expectedList.Count; ++i) { Assert.AreEqual(expectedList[i], data.GetData()[i]); } }
public void ProcessRequest(HttpContext context) { SqlConnection conn = new SqlConnection(strcon); long PTID = 0; try { if (context.Request.Form["oid"] != null) { orderID = long.Parse(context.Request.Form["oid"]); } if (context.Request.Form["wrid"] != null) { WarehouseID = long.Parse(context.Request.Form["wrid"]); } if (context.Request.Form["objname"] != null) { objname = context.Request.Form["objname"].ToString(); } if (context.Request.Form["uid"] != null) { UserID = long.Parse(context.Request.Form["uid"]); } if (context.Request.Form["page"] != null) { page = context.Request.Form["page"].ToString(); } if (context.Request.Form["isAllSelected"] != null) { AllSelect = context.Request.Form["isAllSelected"].ToString(); } if (context.Request.Form["Batch"] != null) { Batch = context.Request.Form["Batch"].ToString(); } if (context.Request.Form["loc"] != null) { LocID = long.Parse(context.Request.Form["loc"]); } if (context.Request.Form["pid"] != null) { ProdID = long.Parse(context.Request.Form["pid"]); } if (context.Request.Form["bulkdata"] != null) { BulkData = context.Request.Form["bulkdata"].ToString(); } iInboundClient Inbound = new iInboundClient(); string userName = GetUserID(UserID); CustomProfile profile = CustomProfile.GetProfile(userName); DataSet dsUserDetail = new DataSet(); dsUserDetail = GetUserDetails(UserID); CompanyID = long.Parse(dsUserDetail.Tables[0].Rows[0]["CompanyID"].ToString()); CustomerID = long.Parse(dsUserDetail.Tables[0].Rows[0]["CustomerID"].ToString()); int result = 0; context.Response.ContentType = "text/plain"; String jsonString = String.Empty; jsonString = "{\n"; /*json Loop Start*/ jsonString = jsonString + "\"result\":[{\n"; if (AllSelect == "yes") { result = BulkSavePutIn(orderID, objname, page, CompanyID, CustomerID, UserID, LocID, Batch, ProdID); if (result > 0) { jsonString = jsonString + "\"status\": \"success\",\n"; jsonString = jsonString + "\"reason\": \"\"\n"; } else { jsonString = jsonString + "\"status\": \"failed\",\n"; jsonString = jsonString + "\"reason\": \"Server error occured\"\n"; } } else { tPutInHead ph = new tPutInHead(); ph.ObjectName = objname; ph.OID = orderID; ph.PutInDate = DateTime.Now; ph.PutInBy = UserID; ph.Remark = ""; ph.CreatedBy = UserID; ph.CreationDate = DateTime.Now; ph.Status = getStatus(objname); ph.Company = CompanyID; ph.CustomerID = CustomerID; ph.OrderFrom = "Mobile"; PTID = GetPTINStatus(orderID, objname, UserID); if (PTID == 0) { PTID = Inbound.SavetPutInHead(ph, profile.DBConnection._constr); } if (PTID > 0) { int save = 0; string[] srno = BulkData.Split('|'); decimal srcount = Convert.ToDecimal(srno.Length); save = SavePutInDetail(orderID, PTID, ProdID, LocID, srcount, Batch); for (int i = 0; i <= srcount - 1; i++) { SaveLottablePutIn(orderID, srno[i].ToString(), objname, PTID, ProdID, 1, CompanyID, CustomerID, UserID, LocID, Batch); } if (save > 0) { jsonString = jsonString + "\"status\": \"success\",\n"; jsonString = jsonString + "\"reason\": \"\"\n"; } else { jsonString = jsonString + "\"status\": \"failed\",\n"; jsonString = jsonString + "\"reason\": \"Server error occured\"\n"; } } } jsonString = jsonString + "}]\n"; jsonString = jsonString + "}\n"; /*json Loop End*/ context.Response.Write(jsonString); } catch (Exception ex) { Login.Profile.ErrorHandling(ex, "bulk_assign_location", "ProcessRequest"); } finally { } }
/// <summary> /// Creates a new instance of this class from code. Used to create a new catalog, but normal operation will have this created /// from deserializing a local file using <see cref="CreateFromFile"/> /// </summary> public CardCatalog(BulkData scryfallMetadata, List <Card> cards, DateTime?updateTime) { ScryfallMetadata = scryfallMetadata; _cards = cards; UpdateTime = updateTime; }
/// <summary> /// /// </summary> /// <param name="employees"></param> /// <returns></returns> public Dashboard GetDashBoardData(BulkData employees) { Dashboard dashboard = new Dashboard(); dashboard.TotalActive = employees.rows.Count(a => a.doc.IsDeleted == "false" && a.doc.Status == "Onboarded"); dashboard.TotalOnShore = employees.rows.Count(a => a.doc.IsDeleted == "false" && a.doc.Status == "Onboarded" && a.doc.LocationStatus == "Onshore"); dashboard.TotalOffShore = employees.rows.Count(a => a.doc.IsDeleted == "false" && a.doc.Status == "Onboarded" && a.doc.LocationStatus == "Offshore"); dashboard.OnShoreFemale = employees.rows.Count(a => a.doc.IsDeleted == "false" && a.doc.Status == "Onboarded" && a.doc.LocationStatus == "Onshore" && a.doc.Gender == "Female"); dashboard.OnShoreMale = employees.rows.Count(a => a.doc.IsDeleted == "false" && a.doc.Status == "Onboarded" && a.doc.LocationStatus == "Onshore" && a.doc.Gender == "Male"); dashboard.OffShoreFemale = employees.rows.Count(a => a.doc.IsDeleted == "false" && a.doc.Status == "Onboarded" && a.doc.LocationStatus == "Offshore" && a.doc.Gender == "Female"); dashboard.OffShoreMale = employees.rows.Count(a => a.doc.IsDeleted == "false" && a.doc.Status == "Onboarded" && a.doc.LocationStatus == "Offshore" && a.doc.Gender == "Male"); dashboard.Billable = employees.rows.Count(a => a.doc.IsDeleted == "false" && (a.doc.Status == "Onboarded") && (a.doc.Billable == "Y" || a.doc.Billable == "P")); dashboard.NonBillable = dashboard.TotalActive - dashboard.Billable; // band wise grouping and count var bandwise = (from e in employees.rows where !string.IsNullOrWhiteSpace(e.doc.CurrentBand) && e.doc.CurrentBand != "string" group e by e.doc.CurrentBand into g select new BandWise { band = g.Key, count = g.Count() }); dashboard.BandData = bandwise.ToArray(); //Latest 5 onboarding var Latestonboarding = (from e in employees.rows where e.doc.IsDeleted == "false" && !string.IsNullOrWhiteSpace(e.doc.AccountOnboardDate) && e.doc.AccountOnboardDate != "string" && e.doc.AccountOnboardDate != "TBC" orderby e.doc.AccountOnboardDate descending select e).Take(5); dashboard.onboard = Latestonboarding.ToArray(); //latest 5 offboarding var Latestoffboarding = (from e in employees.rows where e.doc.IsDeleted == "false" && !string.IsNullOrWhiteSpace(e.doc.AccountOffboardingOffboardedDate) && e.doc.AccountOffboardingOffboardedDate != "string" && e.doc.AccountOffboardingOffboardedDate != "TBC" orderby e.doc.AccountOffboardingOffboardedDate descending select e).Take(5); dashboard.offboard = Latestoffboarding.ToArray(); try { // Monthly Onboarding var MonthlyOnBoards = (from e in employees.rows where e.doc.IsDeleted == "false" && e.doc.Status == "Onboarded" //&& //!string.IsNullOrWhiteSpace(e.doc.CurrentBand) && e.doc.CurrentBand != "string" && !string.IsNullOrWhiteSpace(e.doc.AccountOnboardDate) && e.doc.AccountOnboardDate != "string" && e.doc.AccountOnboardDate != "Other" && e.doc.AccountOnboardDate != "TBC" //&& DateTime.TryParse(e.doc.AccountOnboardDate, new CultureInfo("en-GB"),DateTimeStyles.None, out resultdate) let dateValue = tryToGetDate(e.doc.AccountOnboardDate) where dateValue != null group e by new { Convert.ToDateTime(e.doc.AccountOnboardDate).Month, Convert.ToDateTime(e.doc.AccountOnboardDate).Year } into g select new CalenderWise() { month = g.Key.Month.ToString(), year = g.Key.Year.ToString(), count = g.Count() }); dashboard.calender_onboard = MonthlyOnBoards.ToArray(); } catch { } //// Monthly Offboarding //var MonthlyOffBoards = (from e in employees.rows // where // e.doc.IsDeleted == "false" && // !string.IsNullOrWhiteSpace(e.doc.CurrentBand) && e.doc.CurrentBand != "string" // && !string.IsNullOrWhiteSpace(e.doc.AccountOffboardingOffboardedDate) // && e.doc.AccountOffboardingOffboardedDate != "string" && e.doc.AccountOffboardingOffboardedDate != "Other" && e.doc.AccountOffboardingOffboardedDate != "TBC" // && DateTime.ParseExact(e.doc.AccountOffboardingOffboardedDate, "dd/MM/yyyy", culture) != null // group e by new // { // DateTime.ParseExact(e.doc.AccountOffboardingOffboardedDate, "dd/MM/yyyy", culture).Month, // DateTime.ParseExact(e.doc.AccountOffboardingOffboardedDate, "dd/MM/yyyy", culture).Year // } into g // select new CalenderWise() // { // month = g.Key.Month.ToString(), // year = g.Key.Year.ToString(), // count = g.Count() // }); //dashboard.calender_offboard = MonthlyOffBoards.ToArray(); var SquadWiseGenderOnShore = (from e in employees.rows where e.doc.IsDeleted == "false" && (e.doc.Status == "Onboarded") group e by new { e.doc.DGDCSquad, e.doc.Gender } into g select new SquadWise() { DGDCSquad = g.Key.DGDCSquad.ToString(), Gender = g.Key.Gender.ToString(), Count = g.Count() }); dashboard.SquadWiseGenderOnShore = SquadWiseGenderOnShore.ToArray(); var SquadWiseGenderOffShore = (from e in employees.rows where e.doc.IsDeleted == "false" && (e.doc.Status == "Offboarded") group e by new { e.doc.DGDCSquad, e.doc.Gender } into g select new SquadWise() { DGDCSquad = g.Key.DGDCSquad.ToString(), Gender = g.Key.Gender.ToString(), Count = g.Count() }); dashboard.SquadWiseGenderOffShore = SquadWiseGenderOffShore.ToArray(); return(dashboard); }
public async System.Threading.Tasks.Task ReadXmlAsync(Action <int> percentProgress) { string xmlPath = xmlFile; // Счетчик элементов int i = 0; // Инициализация XMLReader System.IO.FileStream sr = new System.IO.FileStream(xmlPath, System.IO.FileMode.Open, System.IO.FileAccess.Read); System.Xml.XmlReaderSettings _settings = new System.Xml.XmlReaderSettings() { Async = true }; System.Xml.XmlReader rdr = System.Xml.XmlReader.Create(sr, _settings); long lastPosition = 0; while (await rdr.ReadAsync()) { rdr.MoveToContent(); // Новая строка BulkData _pair = new BulkData(tableDefinition, typesList); // Чтение элемента while (rdr.MoveToNextAttribute()) { if (rdr.NodeType == System.Xml.XmlNodeType.Attribute) { _pair.InsertCell(rdr.Name.ToLower(), rdr.Value); } } i += 1; percentage = (int)Math.Round((double)(sr.Position / sr.Length), 2) * 100; if (lastPosition != sr.Position) { lastPosition = sr.Position; percentage = (int)(100.0 * lastPosition / sr.Length); percentProgress(percentage); } // Вставка CancellationTokenSource source = new CancellationTokenSource(); CancellationToken token = source.Token; await _wrt.WriteRowAsync(token, _pair.GetRow()); //Проверяем достигнут ли максимальный размер списка if (i == bulkSize) { await _wrt.CompleteAsync(); await _wrt.CloseAsync(); i = 0; _wrt = _conn.BeginBinaryImport(string.Format("COPY {0} ({1}) FROM STDIN (FORMAT BINARY)", _dbTableName, _dbColumns)); if (percentProgress != null) { percentProgress(percentage); } } } await _wrt.CompleteAsync(); if (percentProgress != null) { percentProgress(percentage); } await _wrt.CloseAsync(); await _conn.CloseAsync(); }