/// <summary> /// 穿上防具 /// </summary> void EquipProtector(Protector _protector) { //穿上防具,如果返回false代表無法防具 if (!_protector.Equip()) return; Equip(_protector, true);//穿上防具 }
////////////////////////////////////////////////////////////////防具///////////////////////////////////////////////////////////////////// /// <summary> /// 初始化防具 /// </summary> void InitProtector() { string[] protectorsStr = AttrsDic["Protectors"].Split(','); for (int i = 0; i < protectorsStr.Length; i++) { int protectorID = int.Parse(protectorsStr[i]); if (protectorID == 0) return; Protector protector = new Protector(protectorID); EquipProtector(protector); } }
/// <summary> /// 脫下防具 /// </summary> void TakeOffProtector(Protector _protector) { //穿上防具,如果返回false代表無法防具 if (!_protector.TakeOff()) return; Equip(_protector, false);//脫下防具 }
public async Task <ActionResultDto> Execute(ContextDto context) { GetListKhoPhieuChuyenByCriteriaBiz biz = new GetListKhoPhieuChuyenByCriteriaBiz(context); var result = new ActionResultDto(); try { var _draw = Protector.Int(draw); var _start = Protector.Int(start); var _length = Protector.Int(length); /* ========================= * fixed input * ========================= */ sortName = string.IsNullOrEmpty(sortName) ? "PhieuChuyenId" : sortName; sortDir = string.IsNullOrEmpty(sortDir) ? "asc" : sortDir; _length = _length < 1 ? 10 : _length; fields = string.IsNullOrEmpty(fields) ? "*" : fields; if (search != null && search != "") { try { if (search.Split('|')[0] != "" && search.Split('|')[0] != "__/__/____") { biz.START_DATE = DateTime.ParseExact(search.Split('|')[0], "dd/MM/yyyy", CultureInfo.GetCultureInfo("fr-FR")).ToString("yyyy-MM-dd"); } } catch { biz.START_DATE = ""; } try { if (search.Split('|')[1] != "" && search.Split('|')[1] != "__/__/____") { biz.END_DATE = DateTime.ParseExact(search.Split('|')[1], "dd/MM/yyyy", CultureInfo.GetCultureInfo("fr-FR")).ToString("yyyy-MM-dd"); } } catch { biz.END_DATE = ""; } biz.KHO_HANG = search.Split('|')[2]; biz.TRANG_THAI = search.Split('|')[3]; } var orderClause = sortName + " " + sortDir; var total = 0; biz.SEARCH_STRING = searchstring; biz.LOGIN_ID = LoginId; biz.FIELD = fields; biz.ORDER_CLAUSE = orderClause; biz.SKIP = _start; biz.TAKE = _length; IEnumerable <dynamic> listPhieuChuyen = await biz.Execute(); if (listPhieuChuyen.Count() > 0) { var obj = listPhieuChuyen.FirstOrDefault(); total = Protector.Int(obj.MAXCNT); } dynamic _metaData = new System.Dynamic.ExpandoObject(); _metaData.draw = _draw; _metaData.total = total; return(ActionHelper.returnActionResult(HttpStatusCode.OK, listPhieuChuyen, _metaData)); } catch (Exception ex) { result.ReturnCode = HttpStatusCode.InternalServerError; result.ReturnData = new { error = new { code = HttpStatusCode.InternalServerError, type = HttpStatusCode.InternalServerError.ToString(), message = ex.InnerException != null ? ex.InnerException.Message : ex.Message } }; return(result); } }
private void TransferFile(string jobName, DataSet dsDevices, DataTable dtPrintJobs, int rowCount) { string AUDITORSOURCE = "Print Job Status"; string ftpIPAddress = Session["ReleaseStationMFP"] as string; // Assign default values to the Ftp settings string ftpProtocol = string.Empty; string ftpPort = string.Empty; string ftpUserName = string.Empty; string ftpUserPassword = string.Empty; string userSource = Session["UserSource"] as string; string userId = Session["ReleaseStationUserID"] as string; try { if (dsDevices != null && dsDevices.Tables.Count > 0) { DataRow[] drDeviceDetails = dsDevices.Tables[0].Select(string.Format("MFP_IP='{0}'", ftpIPAddress)); if (drDeviceDetails != null && drDeviceDetails.Length > 0) { ftpProtocol = drDeviceDetails[0]["FTP_PROTOCOL"].ToString().ToLower(); ftpIPAddress = drDeviceDetails[0]["FTP_ADDRESS"].ToString(); ftpPort = drDeviceDetails[0]["FTP_PORT"].ToString(); ftpUserName = drDeviceDetails[0]["FTP_USER_ID"].ToString(); ftpUserPassword = drDeviceDetails[0]["FTP_USER_PASSWORD"].ToString(); if (!string.IsNullOrEmpty(ftpUserPassword)) { ftpUserPassword = Protector.ProvideDecryptedPassword(ftpUserPassword); } } } if (string.IsNullOrEmpty(ftpProtocol)) { ftpProtocol = "ftp"; } if (string.IsNullOrEmpty(ftpIPAddress)) { ftpIPAddress = Request.Params["REMOTE_ADDR"].ToString(); } if (string.IsNullOrEmpty(ftpPort)) { ftpPort = ConfigurationManager.AppSettings["MFPFTPPort"]; } string printJobsLocation = ConfigurationManager.AppSettings["PrintJobsLocation"]; string currentUserSource = userSource; if (currentUserSource == "DM") { currentUserSource = "AD"; } printJobsLocation = Path.Combine(printJobsLocation, userSource); if (userSource == "AD") { string domainName = Session["UserDomain"] as string; printJobsLocation = Path.Combine(printJobsLocation, domainName); } printJobsLocation = Path.Combine(printJobsLocation, userId); printJobsLocation = Path.Combine(printJobsLocation, jobName); string FTPAddress = string.Format("{0}://{1}:{2}", ftpProtocol, ftpIPAddress, ftpPort); FileInfo fileNew = new FileInfo(printJobsLocation); long jobFileSize = fileNew.Length; bool isDeleteFile = false; if (File.Exists(printJobsLocation)) { if (Session["IsSettingChanged"] != null) { if (Session["IsSettingChanged"] as string == "Yes") { isDeleteFile = true; } } } if (Session["deleteJobs"] != null) { isDeleteFile = true; } int maxFileSize = Convert.ToInt32(ConfigurationManager.AppSettings["BigPrintJobMinSize"]); string serviceName = "AccountingPlusPrimaryJobReleaser"; int megaByte = 1024 * 1024; if (jobFileSize <= 10 * megaByte) { serviceName = "AccountingPlusPrimaryJobReleaser"; } else if (jobFileSize > 10 * megaByte && jobFileSize <= 200 * megaByte) { serviceName = "AccountingPlusSecondaryJobReleaser"; } else { serviceName = "AccountingPlusTertiaryJobReleaser"; } DataTable printSettings = Session["NewPrintSettings"] as DataTable; string originalPrintSettings = ""; string newPrintSettings = ""; bool isReleaseWithNewSettings = false; if (printSettings != null) { printSettings.TableName = "JobSettings"; isReleaseWithNewSettings = true; newPrintSettings = DataTableToXML(printSettings); } string fileName = Path.GetFileName(jobName); if (fileName.Length >= 25) { fileName = fileName.Substring(0, 25) + ".prn"; } string deleteFile = "false"; if (isDeleteFile) { deleteFile = "true"; } string releaseWithSettings = "false"; if (isReleaseWithNewSettings) { releaseWithSettings = "true"; } string isSettingsChanged = "true"; if (!string.IsNullOrEmpty(originalPrintSettings)) { originalPrintSettings = originalPrintSettings.Replace("'", "''"); } if (!string.IsNullOrEmpty(newPrintSettings)) { newPrintSettings = newPrintSettings.Replace("'", "''"); } string currentDate = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"); string newJobName = jobName.Replace("'", "''"); string newPrintJobsLocation = printJobsLocation.Replace("'", "''"); string ftpPath = FTPAddress + "/" + fileName; string newFtpUserName = ftpUserName.Replace("'", "''"); string newFtpUserPassword = ftpUserPassword.Replace("'", "''"); string userDomainName = Session["UserDomain"] as string; dtPrintJobs.Rows.Add(rowCount, serviceName, userSource, userId, newJobName, newPrintJobsLocation, jobFileSize.ToString(), originalPrintSettings, newPrintSettings, isSettingsChanged, releaseWithSettings, ftpPath, newFtpUserName, newFtpUserPassword, "False", isDeleteFile, "False", "", "", "", currentDate, userDomainName); } catch (Exception ex) { string auditorFailureMessage = string.Format("Failed to submit print data to the device {0} by {1} ", deviceIPAddress, userId); string suggestionMessage = "Report to administrator"; LogManager.RecordMessage(deviceIPAddress, AUDITORSOURCE, LogManager.MessageType.Exception, auditorFailureMessage, suggestionMessage, ex.Message, ex.StackTrace); } }
public void TestRun() { try { var protector = new Protector(); /////////////////////////////// // // Memory Encryption - ProtectedMemory // /////////////////////////////// // Create the original data to be encrypted (The data length should be a multiple of 16). byte[] toEncrypt = UnicodeEncoding.ASCII.GetBytes("ThisIsSomeData16"); //Console.WriteLine("Original data: " + UnicodeEncoding.ASCII.GetString(toEncrypt)); //Console.WriteLine("Encrypting..."); // Encrypt the data in memory. protector.EncryptInMemoryData(toEncrypt, MemoryProtectionScope.SameLogon); //Console.WriteLine("Encrypted data: " + UnicodeEncoding.ASCII.GetString(toEncrypt)); //Console.WriteLine("Decrypting..."); // Decrypt the data in memory. protector.DecryptInMemoryData(toEncrypt, MemoryProtectionScope.SameLogon); //Console.WriteLine("Decrypted data: " + UnicodeEncoding.ASCII.GetString(toEncrypt)); /////////////////////////////// // // Data Encryption - ProtectedData // /////////////////////////////// // Create the original data to be encrypted toEncrypt = UnicodeEncoding.ASCII.GetBytes("This is some data of any length."); // Create a file. FileStream fStream = new FileStream("Data.dat", FileMode.OpenOrCreate); // Create some random entropy. byte[] entropy = protector.CreateRandomEntropy(); //Console.WriteLine(); //Console.WriteLine("Original data: " + UnicodeEncoding.ASCII.GetString(toEncrypt)); //Console.WriteLine("Encrypting and writing to disk..."); // Encrypt a copy of the data to the stream. int bytesWritten = protector.EncryptDataToStream(toEncrypt, entropy, DataProtectionScope.CurrentUser, fStream); fStream.Close(); //Console.WriteLine("Reading data from disk and decrypting..."); // Open the file. fStream = new FileStream("Data.dat", FileMode.Open); // Read from the stream and decrypt the data. byte[] decryptData = protector.DecryptDataFromStream(entropy, DataProtectionScope.CurrentUser, fStream, bytesWritten); fStream.Close(); //Console.WriteLine("Decrypted data: " + UnicodeEncoding.ASCII.GetString(decryptData)); } catch (Exception e) { Console.WriteLine("ERROR: " + e.Message); } }
/// <summary> /// Ham khoi tao gia tri mac dinh cho cac bien /// </summary> private void init() { _HocVanId = Protector.Int(HocVanId, 0); _CtrVersion = Protector.Int(CtrVersion, 0); _loginId = Protector.Int(loginId, 0); }
private void UpdateADSettings() { string auditorSuccessMessage = "AD settings updated successfully"; string auditorFailureMessage = "AD settings update failed"; string auditorSource = HostIP.GetHostIP(); string suggestionMessage = "Report to administrator"; bool isValuesChanged = false; string domainController = TextBoxDomainController.Text.Trim(); string domainName = TextBoxDomainName.Text.Trim(); string userName = TextBoxUserName.Text.Trim(); string textPassword = TextBoxPassword.Text.Trim(); string port = TextBoxPort.Text.Trim(); string attribute = DropDownListFullName.SelectedValue; bool isvaliduser = LdapStoreManager.Ldap.AuthenticateUser(domainName, userName, textPassword, port); if (isvaliduser) { if (oldDomainController != domainController || oldDomainName != domainName || oldDomainUserName != userName || oldDomainUserPassword != textPassword || oldDomainPort != port || oldDomainNameAttribute != attribute) { isValuesChanged = true; } else { BindActiveDirectorySettings(); string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "AD_SETTING_UPDATE_SUCCESS"); GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Success.ToString(), serverMessage.ToString(), null); try { LogManager.RecordMessage(auditorSource, AUDITORSOURCE, LogManager.MessageType.Success, auditorSuccessMessage); } catch (Exception) { // } return; } } else { string serverMessage = "Invalid AD Credentials or Domain name"; GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage.ToString(), null); } domainController = DataManager.Controller.FormatData.FormatSingleQuot(TextBoxDomainController.Text.Trim()); domainName = DataManager.Controller.FormatData.FormatSingleQuot(TextBoxDomainName.Text.Trim()); userName = DataManager.Controller.FormatData.FormatSingleQuot(TextBoxUserName.Text.Trim()); textPassword = DataManager.Controller.FormatData.FormatSingleQuot(TextBoxPassword.Text.Trim()); port = DataManager.Controller.FormatData.FormatSingleQuot(TextBoxPort.Text.Trim()); Dictionary <string, string> dcADSettings = new Dictionary <string, string>(); dcADSettings.Add("DOMAIN_CONTROLLER", domainController); dcADSettings.Add("DOMAIN_NAME", domainName); dcADSettings.Add("AD_USERNAME", userName); string password = Protector.ProvideEncryptedPassword(textPassword); dcADSettings.Add("AD_PASSWORD", password); dcADSettings.Add("AD_PORT", port); dcADSettings.Add("AD_FULLNAME", DropDownListFullName.SelectedValue); if (string.IsNullOrEmpty(DataManager.Controller.Settings.UpdateAcitiveDirectorySettingsNew(dcADSettings, domainName))) { // Clear the Cache upon successful database update if (isValuesChanged) { try { if (Cache["LDAP_GROUPS"] != null) { Cache.Remove("LDAP_GROUPS"); } //Cache["LDAP_GROUPS"] = null; if (Cache["ALL_USERS"] != null) { Cache.Remove("ALL_USERS"); } //Cache["ALL_USERS"] = null; } catch (Exception) { } } BindActiveDirectorySettings(); string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "AD_SETTING_UPDATE_SUCCESS"); GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Success.ToString(), serverMessage.ToString(), null); Application["JOBCONFIGURATION"] = ApplicationSettings.ProvideJobConfiguration(); try { LogManager.RecordMessage(auditorSource, AUDITORSOURCE, LogManager.MessageType.Success, auditorSuccessMessage); } catch (IOException exceptionMessage) { LogManager.RecordMessage(auditorSource, AUDITORSOURCE, LogManager.MessageType.Exception, auditorFailureMessage, suggestionMessage, exceptionMessage.Message, exceptionMessage.StackTrace); } catch (NullReferenceException exceptionMessage) { LogManager.RecordMessage(auditorSource, AUDITORSOURCE, LogManager.MessageType.Exception, auditorFailureMessage, suggestionMessage, exceptionMessage.Message, exceptionMessage.StackTrace); } catch (Exception exceptionMessage) { LogManager.RecordMessage(auditorSource, AUDITORSOURCE, LogManager.MessageType.Exception, auditorFailureMessage, suggestionMessage, exceptionMessage.Message, exceptionMessage.StackTrace); } return; } else { BindActiveDirectorySettings(); string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "AD_SETTING_UPDATE_FAILED"); GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage.ToString(), null); return; } }
public async Task <IHttpActionResult> PutFanProfile(int id, FanEditProfileBindingModel bm) { if (User == null) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != CurrentUser.UserId) { return(BadRequest()); } var usr = db.Users.Find(id); if (usr == null) { return(BadRequest()); } if (!string.IsNullOrEmpty(bm.UserName)) { usr.UserName = bm.UserName; } if (!string.IsNullOrEmpty(bm.Email)) { usr.Email = bm.Email; } if (!string.IsNullOrEmpty(bm.Password)) { usr.Password = Protector.Encrypt(bm.Password); } if (bm.Teams != null) { usr.TeamsFans.Clear(); foreach (var t in bm.Teams) { usr.TeamsFans.Add(new TeamsFan { TeamId = t.TeamId, UserId = usr.UserId, LeageId = t.LeagueId }); } } db.Entry(usr).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Ham khoi tao gia tri mac dinh cho cac bien /// </summary> private void Init() { _id = Protector.Int(id); }
/// <summary> /// Ham khoi tao gia tri mac dinh cho cac bien /// </summary> private void init() { _list = JsonConvert.DeserializeObject <List <dynamic> >(listPhieuChuyen); _LoginId = Protector.Int(LoginId, 0); }
public Account Get(string email, string password) { _log.LogInformation("GET => [%s]", email); return(_context.Accounts.FirstOrDefault(o => o.Email.Equals(email) && o.Password.Equals(Protector.HashPassword(password)))); }
/// <summary> /// Ham khoi tao gia tri mac dinh cho cac bien /// </summary> private void init() { _LoginId = Protector.Int(loginId, 0); }
public async Task <ActionResultDto> Execute(ContextDto context) { GetListKhoCongNoNCCChiTietByCriteriaBiz biz = new GetListKhoCongNoNCCChiTietByCriteriaBiz(context); var result = new ActionResultDto(); try { var _draw = Protector.Int(draw); var _start = Protector.Int(start); var _length = Protector.Int(length); /* ========================= * fixed input * ========================= */ sortName = string.IsNullOrEmpty(sortName) ? "HangHoaId" : sortName; sortDir = string.IsNullOrEmpty(sortDir) ? "asc" : sortDir; _length = _length < 1 ? 10 : _length; fields = string.IsNullOrEmpty(fields) ? "*" : fields; if (search != null && search != "") { try { if (search.Split('|')[0] != "" && search.Split('|')[0] != "__/__/____") { biz.TuNgay = DateTime.ParseExact(search.Split('|')[0], "dd/MM/yyyy", CultureInfo.GetCultureInfo("fr-FR")).ToString("yyyy-MM-dd"); } } catch { biz.TuNgay = ""; } try { if (search.Split('|')[1] != "" && search.Split('|')[1] != "__/__/____") { biz.DenNgay = DateTime.ParseExact(search.Split('|')[1], "dd/MM/yyyy", CultureInfo.GetCultureInfo("fr-FR")).ToString("yyyy-MM-dd"); } } catch { biz.DenNgay = ""; } biz.KhachHangId = search.Split('|')[2]; } var orderClause = sortName + " " + sortDir; var total = 0; biz.LoginId = LoginId; biz.FieldsField = fields; biz.OrderClause = orderClause; biz.Skip = _start; biz.Take = _length; IEnumerable <dynamic> listHangHoa = await biz.Execute(); if (listHangHoa.Count() > 0) { var obj = listHangHoa.FirstOrDefault(); total = Protector.Int(obj.MAXCNT); } dynamic _metaData = new System.Dynamic.ExpandoObject(); _metaData.draw = _draw; _metaData.total = total; return(ActionHelper.returnActionResult(HttpStatusCode.OK, listHangHoa, _metaData)); } catch (Exception ex) { result.ReturnCode = HttpStatusCode.InternalServerError; result.ReturnData = new { error = new { code = HttpStatusCode.InternalServerError, type = HttpStatusCode.InternalServerError.ToString(), message = ex.InnerException != null ? ex.InnerException.Message : ex.Message } }; return(result); } }