예제 #1
0
        public override int ExecuteNonQuery(ServiceCursorDef cursorDef, IDataParameterCollection parms, CommandBehavior behavior)
        {
            DataStoreHelperFabric.Query fabricQuery = cursorDef.Query as DataStoreHelperFabric.Query;
            if (fabricQuery != null)
            {
                Dictionary <String, String> tempParms = new Dictionary <string, string>();
                payLoad.Clear();
                foreach (KeyValuePair <String, String> kvp in fabricQuery.Parms)
                {
                    String parName = kvp.Value.ToString().Substring(1);
                    if (parms.Contains(parName))
                    {
                        IDataParameter m_par = ((IDataParameter)parms[parName]);
                        if (m_par.DbType == DbType.Date || m_par.DbType == DbType.DateTime || m_par.DbType == DbType.DateTime2)
                        {
                            tempParms.Add(kvp.Key, ((DateTime)m_par.Value).ToString("yyyy-MM-ddTHH:mm:ss.fff", CultureInfo.InvariantCulture));
                        }
                        else
                        {
                            tempParms.Add(kvp.Key, m_par.Value.ToString());
                        }
                    }
                }

                payLoad.Add("function", fabricQuery.Method);
                payLoad.Add("type", "invoke");
                payLoad.Add("param", tempParms);
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                string jsonPayLoad = serializer.Serialize((object)payLoad);

                if (SetServiceData(this.ConnectionString, restClient))
                {
                    restClient.AddString(jsonPayLoad);
                    restClient.Execute("POST", fabricQuery.TableName);
                    if (restClient.StatusCode == 200)
                    {
                        GXLogging.Info(log, restClient.ToString());
                        return(0);
                    }
                    else
                    {
                        if (processError(restClient.StatusCode, restClient.ToString(), out int statusCode, out string msg))
                        {
                            throw new FabricException(statusCode, msg);
                        }
                        else
                        {
                            throw new GxADODataException("Error executing: " + restClient.ToString());
                        }
                    }
                }