本文整理汇总了C#中Company类的典型用法代码示例。如果您正苦于以下问题:C# Company类的具体用法?C# Company怎么用?C# Company使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Company类属于命名空间,在下文中一共展示了Company类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExplicitFlushInsideSecondTransactionProblem
public void ExplicitFlushInsideSecondTransactionProblem()
{
var comp1 = new Company("comp1");
var comp2 = new Company("comp2");
using(new SessionScope())
{
comp1.Create();
comp2.Create();
}
using(new SessionScope(FlushAction.Never))
{
using(var tx = new TransactionScope(ondispose: OnDispose.Rollback))
{
var comp2a = Company.Find(comp2.Id);
comp2a.Name = "changed";
tx.VoteCommit();
}
using(var scope = new TransactionScope(ondispose: OnDispose.Rollback))
{
var changedCompanies = AR.FindAllByProperty<Company>("Name", "changed");
Assert.AreEqual(1, changedCompanies.Count());
var e2a = changedCompanies.First();
e2a.Delete();
scope.Flush();
Assert.AreEqual(0, AR.FindAllByProperty<Company>("Name", "changed").Count());
}
}
}
示例2: CompInput
public CompInput(string name, Company company, float price, string partInterface, int powerRequirement, float defectiveChance, int mouseDPI, int pollingRate, bool isMechanical)
: base(name, company, price, partInterface, powerRequirement, defectiveChance)
{
this.mouseDPI = mouseDPI;
this.pollingRate = pollingRate;
this.isMechanical = isMechanical;
}
示例3: WillAbortDeleteIfUserDoesNotHavePermissions
public void WillAbortDeleteIfUserDoesNotHavePermissions()
{
var company = new Company
{
Name = "Hibernating Rhinos"
};
using (var s = store.OpenSession())
{
s.Store(new AuthorizationUser
{
Id = UserId,
Name = "Ayende Rahien",
});
s.Store(company);
s.SetAuthorizationFor(company, new DocumentAuthorization());// deny everyone
s.SaveChanges();
}
using (var s = store.OpenSession())
{
s.SecureFor(UserId, "/Company/Rename");
Assert.Throws<InvalidOperationException>(() => s.DatabaseCommands.Delete(company.Id, null));
}
}
示例4: WillAbortWriteIfUserDoesNotHavePermissions
public void WillAbortWriteIfUserDoesNotHavePermissions()
{
var company = new Company
{
Name = "Hibernating Rhinos"
};
using (var s = store.OpenSession(DatabaseName))
{
s.Store(new client::Raven.Bundles.Authorization.Model.AuthorizationUser
{
Id = UserId,
Name = "Ayende Rahien",
});
s.Store(company);
client::Raven.Client.Authorization.AuthorizationClientExtensions.SetAuthorizationFor(s, company, new client::Raven.Bundles.Authorization.Model.DocumentAuthorization());// deny everyone
s.SaveChanges();
}
using (var s = store.OpenSession(DatabaseName))
{
client::Raven.Client.Authorization.AuthorizationClientExtensions.SecureFor(s, UserId, "Company/Rename");
company.Name = "Stampeding Rhinos";
s.Store(company);
var e = Assert.Throws<ErrorResponseException>(() => s.SaveChanges());
Assert.Contains("OperationVetoedException", e.Message);
Assert.Contains("PUT vetoed on document companies/1", e.Message);
Assert.Contains("Raven.Bundles.Authorization.Triggers.AuthorizationPutTrigger", e.Message);
Assert.Contains("Could not find any permissions for operation: Company/Rename on companies/1 for user Authorization/Users/Ayende", e.Message);
}
}
示例5: Create
public Company Create(Company company)
{
if (company == null)
throw new ArgumentNullException(nameof(company));
if (string.IsNullOrEmpty(company.CompanyName))
throw new ValidationException("Company name cannot be empty.");
if(company.CompanyName.Length > 200)
throw new ValidationException("Company name cannot exceed 200 characters.");
var existing = Get(company.CompanyName);
if (existing != null)
throw new ValidationException("Company with same name already exists.");
var result = new Company
{
CompanyName = company.CompanyName
};
_context.Companies.Add(result);
_context.SaveChanges();
return result;
}
示例6: saveCompany
public static void saveCompany(Company company)
{
try
{
using (db = new TIB_Model())
{
if (company.Id != 0)
{
db.Company.Attach(company);
db.Entry(company).State = EntityState.Modified;
}
else
{
db.Company.Add(company);
}
db.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
示例7: CannotReadDocumentWithoutPermissionToIt
public void CannotReadDocumentWithoutPermissionToIt()
{
var company = new Company
{
Name = "Hibernating Rhinos"
};
using (var s = store.OpenSession(DatabaseName))
{
s.Store(new client::Raven.Bundles.Authorization.Model.AuthorizationUser
{
Id = UserId,
Name = "Ayende Rahien",
});
s.Store(company);
client::Raven.Client.Authorization.AuthorizationClientExtensions.SetAuthorizationFor(s, company, new client::Raven.Bundles.Authorization.Model.DocumentAuthorization());// deny everyone
s.SaveChanges();
}
using (var s = store.OpenSession(DatabaseName))
{
client::Raven.Client.Authorization.AuthorizationClientExtensions.SecureFor(s, UserId, "Company/Bid");
var readVetoException = Assert.Throws<ReadVetoException>(() => s.Load<Company>(company.Id));
Assert.Equal(@"Document could not be read because of a read veto.
The read was vetoed by: Raven.Bundles.Authorization.Triggers.AuthorizationReadTrigger
Veto reason: Could not find any permissions for operation: Company/Bid on companies/1 for user Authorization/Users/Ayende.
No one may perform operation Company/Bid on companies/1
", readVetoException.Message);
}
}
示例8: DirtyCheckingTest
public void DirtyCheckingTest()
{
CompanyIdentification companyIdentification1 =
new CompanyIdentification
{
Identification = "1"
};
CompanyIdentification companyIdentification2 =
new CompanyIdentification
{
Identification = "2"
};
Company company =
new Company
{
Name = "Peopleware NV",
Identifications = new[] { companyIdentification1, companyIdentification2 }
};
Repository.Save(company);
Session.Evict(company);
/* Set Number to null (but Number is defined as int) */
/*
using (ISession session = NhConfigurator.SessionFactory.OpenSession())
{
using (ITransaction trans = session.BeginTransaction())
{
session.CreateQuery(@"update CompanyIdentification set Number = null").ExecuteUpdate();
trans.Commit();
}
}
*/
new DirtyChecking(NhConfigurator.Configuration, NhConfigurator.SessionFactory, Assert.Fail, Assert.Inconclusive).Test();
}
示例9: cmpRegister
protected void cmpRegister(object sender, EventArgs e)
{
Company cmp = new Company();
bool signed = false;
if (validator.checkCompanyEmail(registerEmail))
{
registerEmail.Attributes["placeholder"] = "This mail address is in use.";
return;
}
validateRegister();
if (confirmRegister)
{
cmp.CompanyName = registerCompanyName.Text;
cmp.Email = registerEmail.Text;
cmp.Password = registerPassword.Text;
cmp.Address = registerAddress.Text;
cmp.Phone = registerPhone.Text;
cmp.CityID = int.Parse(registerCity.SelectedValue);
signed = cmp.SignUp();
}
if (signed)
{
Session["Company"] = cmp;
Response.Redirect("Home.aspx");
}
}
示例10: GetDataForm
protected Company GetDataForm()
{
Company company = new Company();
if (!string.IsNullOrEmpty(txtName.Text))
{
company.Company_Name = txtName.Text;
}
else
{
return null;
}
company.Company_Phone = txtPhoneNumber.Text;
company.Company_Email = txtEmail.Text;
company.Company_Address = txtAddress.Text;
company.Company_Description = txtDescription.Text;
string filePath = "";
System.Drawing.Image image;
if (fuLogo.HasFile)
{
image = System.Drawing.Image.FromStream(fuLogo.PostedFile.InputStream);
}
else
{
filePath = WebHelper.Instance.GetWebsitePath() + "App_Themes/images/other/no_image.png";
image = System.Drawing.Image.FromFile(filePath);
}
String data = WebHelper.Instance.ImageToBase64(image, System.Drawing.Imaging.ImageFormat.Png);
company.Company_Logo = data;
return company;
}
示例11: saveUpdateCompany
public void saveUpdateCompany(Company company)
{
CompanyFrm cFrm = new CompanyFrm(company);
bool result = (bool)cFrm.ShowDialog();
cFrm.Close();
if (result)
{
try
{
Generic<Company> gen = new Generic<Company>();
if (company.Id == 0)
gen.Add(company);
else
gen.Update(company, company.Id);
gen.Dispose();
MessageBox.Show("The company was saved successfully", "Company saved", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
Console.Write(ex.ToString());
MessageBox.Show("There was a problem saving this company to the database. Please try again later or contact a sysadmin.", "Database Error", MessageBoxButton.OK, MessageBoxImage.Information);
}
// reload companies and refresh ListBox
loadCompanies();
}
}
示例12: Init
private void Init()
{
if (settings==null)
{
throw new ArgumentNullException("Please provide valid SAP Settings");
}
if(_company==null)
{
_company = new Company
{
language = BoSuppLangs.ln_English,
Server = settings.ServerName,
DbServerType =BoDataServerTypes.dst_MSSQL2008,//(BoDataServerTypes)Enum.Parse(typeof(BoDataServerTypes), settings.Servertype),
UseTrusted = false,
DbPassword = settings.DbPassword,
DbUserName = settings.Dbusrname,
UserName = settings.UserName,
Password = settings.Password,
CompanyDB = settings.CompanyName,
// LicenseServer = "10.0.0.2:3000"
};
ConnectToCompany();
return;
}
ConnectToCompany();
}
示例13: Will_limit_replication_history_size_on_items_marked_with_not_for_replication
public void Will_limit_replication_history_size_on_items_marked_with_not_for_replication()
{
var store1 = CreateStore();
using (var session = store1.OpenSession())
{
var entity = new Company {Name = "Hibernating Rhinos"};
session.Store(entity);
session.Advanced.GetMetadataFor(entity)["Raven-Not-For-Replication"] = "true";
session.SaveChanges();
}
for (int i = 0; i < 100; i++)
{
using (var session = store1.OpenSession())
{
var company = session.Load<Company>(1);
company.Name = i%2 == 0 ? "a" : "b";
session.SaveChanges();
}
}
using (var session = store1.OpenSession())
{
var company = session.Load<Company>(1);
var ravenJArray = session.Advanced.GetMetadataFor(company).Value<RavenJArray>(Constants.RavenReplicationHistory);
Assert.Equal(50, ravenJArray.Length);
}
}
示例14: SumUpSalaries
static double SumUpSalaries(Company c)
{
return
(from e in c.Query.Descendants<EmployeeType>()
select e.Salary
).Sum();
}
示例15: Get
/// <summary>
/// Get a security token
/// </summary>
/// <param name="company"></param>
/// <param name="scope"></param>
/// <param name="invalidateCache">if set to true, requests a new token even if a valid one is already in the cache</param>
/// <returns></returns>
public Token Get(Company company = null, string scope = "panoptix.read", bool invalidateCache = false)
{
var now = DateTime.UtcNow;
Token token;
// so that instances created by different applications (as indicated by id passed at construction) don't clobber each other
var cacheKey = String.Format("{0}:{1}:{2}", clientId, company == null ? string.Empty: company.Id, scope);
// check to see if we already have a token that will be valid for at least the next five minutes
if (!invalidateCache && Cache.ContainsKey(cacheKey) && Cache[cacheKey].ExpirationTime > now.AddMinutes(5))
{
token = Cache[cacheKey];
}
else
{
var contentList = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("grant_type", "client_credentials")
};
if (company != null && company.Id != null)
{
contentList.Add(new KeyValuePair<string, string>("jci_company_id", company.Id));
contentList.Add(new KeyValuePair<string, string>("scope", scope));
}
token = FetchToken(company, cacheKey, Cache, contentList);
}
return token;
}