예제 #1
0
        /// <summary>
        /// This uploads a new dialog to the service.
        /// </summary>
        /// <param name="dialogName">The name of the dialog.</param>
        /// <param name="callback">The callback to receive the dialog ID.</param>
        /// <param name="dialogData">The raw byte data of the dialog.</param>
        /// <param name="dataFileName">This must be the filename including the extension so the dialog service knows how to parse the data.</param>
        /// <returns>Returns true if the upload was submitted.</returns>
        public bool UploadDialog(string dialogName, OnUploadDialog callback, byte [] dialogData, string dataFileName)
        {
            if (string.IsNullOrEmpty(dialogName))
            {
                throw new ArgumentNullException("dialogName");
            }
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            if (dialogData == null)
            {
                throw new ArgumentNullException("dialogData");
            }
            if (string.IsNullOrEmpty(dataFileName))
            {
                throw new ArgumentNullException("dataFileName");
            }

            RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, "/v1/dialogs");

            if (connector == null)
            {
                return(false);
            }

            UploadDialogReq req = new UploadDialogReq();

            req.Callback      = callback;
            req.OnResponse    = OnCreateDialogResp;
            req.Forms         = new Dictionary <string, RESTConnector.Form>();
            req.Forms["name"] = new RESTConnector.Form(dialogName);
            req.Forms["file"] = new RESTConnector.Form(dialogData, dataFileName);

            return(connector.Send(req));
        }