Microsoft.SqlServer.Management.Smo.Transfer() losing contraints - c#

I'm trying to copy SQL database from one server to another.
Please tell me how to use Transfer() method without loosing constraints in the target database.
I've tried different parameters including
CopySchema = true; // and
CopyAllSchemas = true; //and even
CopyAllObjects = true;
and still this damn thing is losing all the constraints.
Help me, pls!

Ok...
transfer.Options.DriAll = true;
helped. But now It's leaving all triggers behind

In options some flags for select the object to copy
transfer.Options.Triggers = true;
transfer.Options.Indexes = true;
transfer.Options.Statistics = true;

Related

Wuapi.dll Search() not returning all updates

Testing the functions of wuapi.dll I noticed that some updates are not listed in the results (obviously because they are visible from the update manager).
Code used(c#):
public ISearchResult CheckUpdates()
{
IUpdateSearcher uSearcher = uSession.CreateUpdateSearcher();
uSearcher.Online = true;
ISearchResult uResult = uSearcher.Search("Type='Software' and IsInstalled=0");
return uResult;
}
Also tried all possible filters combination.
Update Manager Screenshot
Anyone knows why?
Thanks.
Try adding this:
uSearcher.ServerSelection = ServerSelection.ssOthers;
uSearcher.ServiceID = "7971f918-a847-4430-9279-4a52d1efe18d";
And leave out the Type='Software' like Theo said.
Finally I found the right filter that worked for me: IsInstalled = 0 And DeploymentAction=*

ClosedXML and C#: How to collapse rows by Default?

I am trying to write code which produces excel report with pivot table. For accomplishing this task I am using ClosedXML library. The output looks like this:
The problem is that I have to get all groups of data collapsed by default, i.e. in the output I should see the following:
In other words, my output should contain collapsed rows and only summary should be displayed. How can I achieve this in code? Which method should I use?
pt.ShowRowStripes = true;
secondWorksheet.FirstRow().Hide();
secondWorksheet.TabActive = true;
secondWorksheet.CollapseRows(1);
secondWorksheet.Rows().Collapse();
pt.EnableShowDetails = false;
pt.ShowValuesRow = false;
secondWorksheet.PageSetup.ShowGridlines = true;
secondWorksheet.ShowGridLines = true;
workbook.PageOptions.ShowGridlines = true;
secondWorksheet.PivotTables.First().EnableShowDetails = false;
This is not currently supported by ClosedXML. Pivot tables are still very much work in progress.
Using ClosedXML.Signed version 0.94.2, this worked for me:
IXLPivotTable pivotTable = workbook.Worksheet("SheetContainingPivotTable").PivotTables.First();
pivotTable.ColumnLabels.ToList().ForEach(x => x.SetCollapsed(true));
pivotTable.RowLabels.ToList().ForEach(x => x.SetCollapsed(true));

NetSuite SuiteTalk TransactionSearchAdvanced: recordList equals null

I have a small C# console application who's sole purpose is to receive records from a "Saved Search" in NetSuite(via SuiteTalk). I've been able to successfully connect and receive records from NetSuite for my Saved Search(the search runs fine through the web interface too), however when I attempt to access the results of the "Saved Search" through my application, I am unable to view them because the search object that is returned does not contain any data in the "recordList" property:
//Connect
var dataCenterAwareNetSuiteService = new DataCenterAwareNetSuiteService("XXXXXX");
dataCenterAwareNetSuiteService.Timeout = 1000 * 60 * 60 * 2;
//Adds Credentials etc...
dataCenterAwareNetSuiteService.tokenPassport = createTokenPassport();
//Setup Preferences
var prefs = new Preferences();
prefs.warningAsErrorSpecified = true;
prefs.warningAsError = false;
dataCenterAwareNetSuiteService.preferences = prefs;
var searchPrefs = new SearchPreferences();
dataCenterAwareNetSuiteService.searchPreferences = searchPrefs;
dataCenterAwareNetSuiteService.searchPreferences.pageSize = 5;
dataCenterAwareNetSuiteService.searchPreferences.pageSizeSpecified = true;
dataCenterAwareNetSuiteService.searchPreferences.bodyFieldsOnly = false;
dataCenterAwareNetSuiteService.searchPreferences.returnSearchColumns = false;
//Search
var tranSearchAdv = new TransactionSearchAdvanced();
var tranSearchRow = new TransactionSearchRow();
var tranSearchRowBasic = new TransactionSearchRowBasic();
tranSearchAdv.savedSearchId = "XXXX";
tranSearchRowBasic.internalId =
new SearchColumnSelectField[] { new SearchColumnSelectField() };
tranSearchRowBasic.tranId =
new SearchColumnStringField[] { new SearchColumnStringField() };
tranSearchRowBasic.dateCreated =
new SearchColumnDateField[] { new SearchColumnDateField() };
tranSearchRowBasic.total =
new SearchColumnDoubleField[] { new SearchColumnDoubleField() };
tranSearchRowBasic.entity =
new SearchColumnSelectField[] { new SearchColumnSelectField() };
tranSearchRow.basic = tranSearchRowBasic;
tranSearchAdv.columns = tranSearchRow;
//No errors,
//this works correctly and returns the "Saved Search" with the correct "totalRecords"
//but results.recordList == null while results.totalRecords = 10000000+
var results = dataCenterAwareNetSuiteService.search(tranSearchAdv);
I appears to me that the "recordList" object is the principal way data is retrieved from the results of a search(Related Java Example, Another Here). This is also the way the example API does it.
I have run this on multiple "Saved Search's" with the same results. I don't understand how you can have more than one record in "totalRecords" and yet the "recordList" remains null? Is there some configuration option that has to be set to allow me to access this property. Or maybe it's a security thing, the API user I have setup should have full access, is there anything else that need to be granted access?
NetSuite SuiteTalk is not well documented, and most of the examples online are not in C#, and not dealing with the issues that I'm experiencing. These factors make it very difficult to determine why the previously mentioned behavior is occurring, or even, to discover any alternative methods for retrieving the resulting data from the source "Saved Search".
Does anyone have any insight into this behavior? Is this the correct method of retrieving results from SuiteTalk? Is there any configuration from the API or Web Side that needs to be changed?
Update 1
I've also tried using the alternative way of getting result data by accessing the "searchRowList" object from the "SearchResult" object(suggested by #AdolfoGarza) However it returns mostly empty fields(null) similar to the "recordList" property I do not see a way to retrieve "Saved Search" data from this method.
Try getting the results with results.searchRowList.searchRow , thats how it works in php.
I was able to resolve the issue by removing this line in the code:
tranSearchRow.basic = tranSearchRowBasic;
Then like #AdolfoGarza reccomended, retrieving the results from "basic" field in "results.searchRowList"
For some reason the template API that I was using was setting up a "TransactionSearchAdvanced" referencing a blank "TransactionSearchBasic" record, not sure why but this was causing the results from "searchRowList" to be null. After removing it I now get non-null values in the proper fields.
As for "recordList", it's still null, not sure why, but as I have my data I don't think I'll continue to dig into this.

Best way to check SVN revision changes of directory and return if changes are found

I have been looking for a while now about how to check the revision and return if there has been changes. What I have works but I am wondering if there is a better/ cleaner way:
bool needToUpdate = false;
Process process = new Process();
var info = new ProcessStartInfo("svn", string.Format(#"status -u {0}", directoryInto.FullName));
process.StartInfo = info;
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
{
if (!String.IsNullOrEmpty(e.Data))
{
string data = e.Data;
//This if statement is what I have an issue with.
if (data.Contains("!"))
needToUpdate = true;
}
});
As you can see I am checking the string to find a (!) in the string. Its not great practice, so I am seeing if anyone would be able to help me out with a better solution or a better way to receive the standard output from the SVN (I am not asking how to do it, I am asking a better way than I already have) I would greatly appreciate it!
Thanks!
EDIT Using SharpSVN
I am now using SharpSVN and I having a problem with IsRemoteUpdate, it seems to always be returning true:
bool needToUpdate = false;
using (SvnClient client = new SvnClient())
{
SvnStatusArgs statusArgs = new SvnStatusArgs();
statusArgs.RetrieveAllEntries = true;
statusArgs.RetrieveRemoteStatus = true;
client.GetStatus(directoryInto.FullName, statusArgs, out statuses);
for (int i = 0; i < statuses.Count(); i++)
{
if (statuses[i].IsRemoteUpdated)
{
needToUpdate = true;
break;
}
}
}
Could you tell me why this is always returning true, even when my directory is updated?
Edit #2
I have since added:
if (statuses[i].LocalContentStatus == SvnStatus.Missing || statuses[i].LocalContentStatus == SvnStatus.Modified)
is there a better way to do this?
There is a discussion on the SharpSVN forum about this: How to check if working copy is latest version? There they use similar solution, like you: get status, iterate through items, if any has IsRemoteUpdated, the SVN directory needs to be updated.

MaxDrillthroughRecords on IOLEDBConnection resets after changing Connection

I'm working with an IOLEDBConnection object, and changing the MaxDrillthoughRecords field works as expected. However, I also need to change the Connection field of the IOLEDBConnection and when I do this then the MaxDrillthroughRecords field gets set to 1000. I don't want this to happen.
IOLEDBConnection oleConnection = connection.OLEDBConnection;
try
{
this.SetMaxDrillthroughRecords();
var a = oleConnection.MaxDrillthroughRecords; // MaxDrillthroughRecords is 5 here.
oleConnection.Connection = new object[] { connection.ConnectionString };
a = oleConnection.MaxDrillthroughRecords; // MaxDrillthroughRecords is 1000 here.
}
finally { Marshal.ReleaseComObject(oleConnection); }
I tried to use Reflector to view the code in the Microsoft.Office.Interop.Excel assembly but was strangely unable to locate the interface. Is there some subtle behavior I'm missing here? Thanks for any help.

Categories