working with pre existing code just a simple patch i added ontop
//first get the variables
bridge = namef & valuef
//a paranoid double check
if session("gap") = session("oldgap") then session("gap") = "null"
//the actual comparison
if bridge = session("gap") then
drawbridge = ""
else
drawbridge = inputscrubber("action")
end if
session("oldgap") = session ("gap")
session("gap") = namef & valuef
You should use the PRG (Post/Redirect/Get) pattern to avoid such issues.
The idea is that once the form is posted, you process it and redirect to a different page. The user at this point can refresh without any issue.
Related
I tried doing in but I get a blank project in return.
When I select a DBMS to be JSON, thats when I get a blank.
I dont know if theres another way around it?
It does not directly answer the question, but here is an example of scripting PowerDesigner from JavaScript (tested with NodeJS 14, NPM 7). You can then parse your JSON with JavaScript, and create objects (entities, tables...) on the fly through Automation.
"use strict";
// you can get these constants with a VBScript like this:
// option explicit
// dim lib,libname,cls,keep,x
// for each lib in application.metamodel.libraries
// libname = lcase(lib.publicname)
// if left(libname,2) = "pd" then libname = mid(libname,3)
// for each cls in lib.classes
// keep = cls.inheritsfrom(cls_NamedObject)
// if keep and cls.inheritsfrom(cls_BaseClassifierMapping) then keep = false
// if keep and cls.abstract then keep = false
// if keep and ((cls.flags and 1024) <> 0) then keep = false
// if keep then
// x = right("00000000" & hex(cls.kind), 8)
// output "const cls_"&libname&cls.publicname & " = 0x" & x & ";"
// end if
// next
// next
const cls_cdmModel = 0x1E597170;
const cls_cdmEntity = 0x1E597172;
console.log("... connecting");
let winax = require('winax');
let app = new ActiveXObject("PowerDesigner.Application");
console.log("... create model");
let model = app.CreateModel(cls_cdmModel);
let entt = model.CreateObject(cls_cdmEntity);
entt.Name = 'foo';
console.log("... save model");
model.Save('c:\\temp\\foo.cdm');
winax.release(model,entt);
// close Workspace without saving
app.ActiveWorkspace.Close(1);
winax.release(app);
console.log("... happily done");
Example :
1.When i using program start int x = 5;
2.Do something until x = 10
3.Closing program
4.When a relaunch program x will be equal to 10 (not 5)
Here the Application Setting will come into play.
Proiperties -> Settings
This will strore our data as XMl formatted.
Action can be applied through both programmatically and manually.
Programmatically:
Create:
SettingsProperty property = new SettingsProperty(nameofthesetting);
property.DefaultValue = "Default";
property.IsReadOnly = false;
property.PropertyType = typeof(bool);
property.Provider = Properties.Settings.Default.Providers["LocalFileSettingsProvider"];
property.Attributes.Add(typeof(UserScopedSettingAttribute), new UserScopedSettingAttribute());
Properties.Settings.Default.Properties.Add(property);
Properties.Settings.Default.Reload();
property.DefaultValue = HereYourValue;
Update :
Settings.Default.YourSettingsName=NewValue
Settings.Default.Save();
Settings.Default.Reload();
reference,
How do I get around application scope settings being read-only?
How to update appSettings in a WPF app?
I have two forms called fmMain and fmEmpl. Both have each TStatusBar called sbMain and sbEmpl. I have a TDataModule called dmData to store the database components.
I need to update the sbEmpl panels so it can displays actual values from the database when the cell grid is highlighted. I've been try to use the TClientDataSet's OnAfterScroll handler to handling this event but it just working on fmMain only, not with fmEmpl. It always raising error message if I try to update the sbEmpl panels. This is the message:
Access violation at address 00405337 in module 'SpeZet.exe'. Read of address 0000038C.
Whereas, I have including both header (.h) on dmData.
What going wrong with TStatusBar here?
Any idea?
Thank a lot in advance.
EDIT : Ok, here is the code:
void __fastcall TdmData::cdsEmplAfterScroll(TDataSet *DataSet)
{
vEmpl = "Name = " +
dmData->cdsEmpl->FieldByName("Name")->AsString +
" | idEmployee = " +
dmData->cdsEmpl->FieldByName("idEmployee")->AsInteger +
" | idJob = " +
dmData->cdsEmpl->FieldByName("idJob")->AsInteger;
fmMain->sbMain->SimplePanel = true;
fmMain->sbMain->SimpleText = vEmpl;
fmEmpl->sbEmpl->SimplePanel = true;
fmEmpl->sbEmpl->SimpleText = vEmpl;
}
The "Access Violation" message is raised at line:
fmEmpl->sbEmpl->SimplePanel = true;
fmEmpl->sbEmpl->SimpleText = vEmpl;
Most probably your datamodule doesn't have a valid pointer to your fbEmpl form.
Finally, based on this article, I have solve this problem.. I didn't notice that dmData is created before the fmEmpl so it will raising any "Access Violation" error message when I try to access the fmEmpl.
I make simple condition to check if fmEmpl was created or yet. This is the condition:
if (fmEmpl != NULL) {
sbEmpl->SimplePanel = true;
sbEmpl->SimpleText = sData;
}
Now, I can accessing and updating the sbEmpl directly from dmData.
Thanks.
I'm new to F# and trying to dive in first and do a more formal introduction later. I have the following code:
type Person =
{
Id: int
Name: string
}
let GetPeople() =
//seq {
use conn = new SQLiteConnection(connectionString)
use cmd = new SQLiteCommand(sql, conn)
cmd.CommandType <- CommandType.Text
conn.Open()
use reader = cmd.ExecuteReader()
let mutable x = {Id = 1; Name = "Mary"; }
while reader.Read() do
let y = 0
// breakpoint here
x <- {
Id = unbox<int>(reader.["id"])
Name = unbox<string>(reader.["name"])
}
x
//}
let y = GetPeople()
I plan to replace the loop body with a yield statement and clean up the code. But right now I'm just trying to make sure the data access works by debugging the code and looking at the datareader. Currently I'm getting a System.InvalidCastException. When I put a breakpoint at the point indicated by the commented line above, and then type in the immediate windows reader["name"] I get a valid value from the database so I know it's connecting to the db ok. However if I try to put reader["name"] (as opposed to reader.["name"]) in the source file I get "This value is not a function and cannot be applied" message.
Why can I use reader["name"] in the immediate window but not in my fsharp code? How can I use string indexing with the reader?
Update
Following Jack P.'s advice I split out the code into separate lines and now I see where the error occurs:
let id = reader.["id"]
let id_unboxed = unbox id // <--- error on this line
id has the type object {long} according to the debugger.
Jack already answered the question regarding different syntax for indexing in F# and in the immediate window or watches, so I'll skip that.
In my experience, the most common reason for getting System.InvalidCastException when reading data from a database is that the value returned by reader.["xyz"] is actually DbNull.Value instead of an actual string or integer. Casting DbNull.Value to integer or string will fail (because it is a special value), so if you're working with nullable columns, you need to check this explicitly:
let name = reader.["name"]
let name_unboxed : string =
if name = DbNull.Value then null else unbox name
You can make the code nicer by defining the ? operator which allows you to write reader?name to perform the lookup. If you're dealing with nulls you can also use reader?name defaultValue with the following definition:
let (?) (reader:IDataReader) (name:string) (def:'R) : 'R =
let v = reader.[name]
if Object.Equals(v, DBNull.Value) then def
else unbox v
The code then becomes:
let name = reader?name null
let id = reader?id -1
This should also simplify debugging as you can step into the implementation of ? and see what is going on.
You can use reader["name"] in the immediate window because the immediate window uses C# syntax, not F# syntax.
One thing to note: since F# is much more concise than C#, there can be a lot going on within a single line. In other words, setting a breakpoint on the line may not help you narrow down the problem. In those cases, I normally "expand" the expression into multiple let-bindings on multiple lines; doing this makes it easier to step through the expression and find the cause of the problem (at which point, you can just make the change to your original one-liner).
What happens if you pull the item accesses and unbox calls out into their own let-bindings? For example:
while reader.Read() do
let y = 0
// breakpoint here
let id = reader.["id"]
let id_unboxed : int = unbox id
let name = reader.["name"]
let name_unboxed : string = unbox name
x <- { Id = id_unboxed; Name = name_unboxed; }
x
I am new to SalesForce (3 months).
Thus far I have been able to create an application in C# that I can use to preform Inserts and Updates to the SalesForce database. These transactions are one at a time.
No I have the need to preform large scale transactions. For example updating thousands of records at a time. Doing them one by one would quickly put us over our allotted API calls per 24 hour period.
I want to utilize the available bulk transactions process to cut down on the number of API calls. Thus far I have not had much luck coding this nor have I found any such documentation.
If anyone could either provide some generic examples or steer me to reliable documentation on the subject I would greatly appreciate it.
FYI, the data I need to use to do the updates and inserts comes from an IBM Unidata database sitting on an AIX machine. So direct web services communication is not realy possible. Getting the data from Unidata has been my headache. I have that worked out. Now the bulk api to SalesForce is my new headache.
Thanks in advance.
Jeff
You don't mention which API you're currently using, but using the soap partner or enterprise APIs you can write records to salesforce 200 at a time. (the create/update/upsert calls all take an array of SObjects).
Using the bulk API you can send data in chunks of thousands of rows at a time.
You can find the documentation for both sets of APIs here
The answers already given are a good start; however, are you sure you need to actually write a custom app that uses the bulk API? The salesforce data loader is a pretty robust tool, includes a command line interface, and can use either the "normal" or bulk data API's. Unless you are needing to do fancy logic as part of your insert/updates, or some sort of more real-time / on-demand loading, the data loader is going to be a better option than a custom app.
(this is the SOAP code though, not the Salesforce "Bulk API" ; careful not to confuse the two)
Mighy be below code provide clear insight on how to do bulk insertion.
/// Demonstrates how to create one or more Account records via the API
public void CreateAccountSample()
{
Account account1 = new Account();
Account account2 = new Account();
// Set some fields on the account1 object. Name field is not set
// so this record should fail as it is a required field.
account1.BillingCity = "Wichita";
account1.BillingCountry = "US";
account1.BillingState = "KA";
account1.BillingStreet = "4322 Haystack Boulevard";
account1.BillingPostalCode = "87901";
// Set some fields on the account2 object
account2.Name = "Golden Straw";
account2.BillingCity = "Oakland";
account2.BillingCountry = "US";
account2.BillingState = "CA";
account2.BillingStreet = "666 Raiders Boulevard";
account2.BillingPostalCode = "97502";
// Create an array of SObjects to hold the accounts
sObject[] accounts = new sObject[2];
// Add the accounts to the SObject array
accounts[0] = account1;
accounts[1] = account2;
// Invoke the create() call
try
{
SaveResult[] saveResults = binding.create(accounts);
// Handle the results
for (int i = 0; i < saveResults.Length; i++)
{
// Determine whether create() succeeded or had errors
if (saveResults[i].success)
{
// No errors, so retrieve the Id created for this record
Console.WriteLine("An Account was created with Id: {0}",
saveResults[i].id);
}
else
{
Console.WriteLine("Item {0} had an error updating", i);
// Handle the errors
foreach (Error error in saveResults[i].errors)
{
Console.WriteLine("Error code is: {0}",
error.statusCode.ToString());
Console.WriteLine("Error message: {0}", error.message);
}
}
}
}
catch (SoapException e)
{
Console.WriteLine(e.Code);
Console.WriteLine(e.Message);
}
}
Please find the small code which may help you to insert the data into salesforce objects using c# and WSDL APIs. I stuck to much to write code in c#. I assigned using direct index after spiting you can use your ways.
I split the column using | (pipe sign). You may change this and also <br>, \n, etc. (row and column breaking)
Means you can enter N rows which are in your HTML/text file. I wrote the program to add order by my designers who put the order on other website and fetch the data from e-commerce website and who has no interface for the salesforce to add/view the order records. I created one object for the same. and add following columns in the object.
Your suggestions are welcome.
private SforceService binding; // declare the salesforce servive using your access credential
try
{
string stroppid = "111111111111111111";
System.Net.HttpWebRequest fr;
Uri targetUri = new Uri("http://abc.xyz.com/test.html");
fr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(targetUri);
if ((fr.GetResponse().ContentLength > 0))
{
System.IO.StreamReader str = new System.IO.StreamReader(fr.GetResponse().GetResponseStream());
string allrow = str.ReadToEnd();
string stringSeparators = "<br>";
string[] row1 = Regex.Split(allrow, stringSeparators);
CDI_Order_Data__c[] cord = new CDI_Order_Data__c[row1.Length - 1];
for (int i = 1; i < row1.Length-1; i++)
{
string colstr = row1[i].ToString();
string[] allcols = Regex.Split(colstr, "\\|");
cord[i] = new CDI_Order_Data__c(); // Very important to create object
cord[i].Opportunity_Job_Order__c = stroppid;
cord[i].jobid__c = stroppid;
cord[i].order__c = allcols[0].ToString();
cord[i].firstname__c = allcols[1].ToString();
cord[i].name__c = allcols[2].ToString();
DateTime dtDate = Convert.ToDateTime(allcols[3]);
cord[i].Date__c = new DateTime(Convert.ToInt32(dtDate.Year), Convert.ToInt32(dtDate.Month), Convert.ToInt32(dtDate.Day), 0, 0, 0); //sforcedate(allcols[3]); //XMLstringToDate(allcols[3]);
cord[i].clientpo__c = allcols[4].ToString();
cord[i].billaddr1__c = allcols[5].ToString();
cord[i].billaddr2__c = allcols[6].ToString();
cord[i].billcity__c = allcols[7].ToString();
cord[i].billstate__c = allcols[8].ToString();
cord[i].billzip__c = allcols[9].ToString();
cord[i].phone__c = allcols[10].ToString();
cord[i].fax__c = allcols[11].ToString();
cord[i].email__c = allcols[12].ToString();
cord[i].contact__c = allcols[13].ToString();
cord[i].lastname__c = allcols[15].ToString();
cord[i].Rep__c = allcols[16].ToString();
cord[i].sidemark__c = allcols[17].ToString();
cord[i].account__c = allcols[18].ToString();
cord[i].item__c = allcols[19].ToString();
cord[i].kmatid__c = allcols[20].ToString();
cord[i].qty__c = Convert.ToDouble(allcols[21]);
cord[i].Description__c = allcols[22].ToString();
cord[i].price__c = Convert.ToDouble(allcols[23]);
cord[i].installation__c = allcols[24].ToString();
cord[i].freight__c = allcols[25].ToString();
cord[i].discount__c = Convert.ToDouble(allcols[26]);
cord[i].salestax__c = Convert.ToDouble(allcols[27]);
cord[i].taxcode__c = allcols[28].ToString();
}
try {
SaveResult[] saveResults = binding.create(cord);
}
catch (Exception ce)
{
Response.Write("Buld order update errror" +ce.Message.ToString());
Response.End();
}
if (str != null) str.Close();
}