public void SetUp() {
            _strategy = A.Fake<IUploadProtocol>();
            A.CallTo(() => _strategy.Schemes)
                .Returns(new[] {"http"});

            var authProvider = A.Fake<IAuthProvider>();
            A.CallTo(() => authProvider.HandleUri(new Uri(TestUrl)))
                .Returns(new Uri(TestUrl));

            _uploader = new FileUploader(new[] {_strategy}, authProvider);
        }
示例#2
0
文件: Email.cs 项目: pkdevbox/Rock
 /// <summary>
 /// Initializes a new instance of the <see cref="Email" /> class.
 /// </summary>
 public Email()
 {
     tbFromName = new RockTextBox();
     tbFromAddress = new RockTextBox();
     tbReplyToAddress = new RockTextBox();
     tbSubject = new RockTextBox();
     htmlMessage = new HtmlEditor();
     tbTextMessage = new RockTextBox();
     hfAttachments = new HiddenField();
     fuAttachments = new FileUploader();
 }
        public async Task<JsonResult> Upload()
        {
            try
            {
                foreach (string file in Request.Files)
                {
                    var fileContent = Request.Files[file];
                    if (fileContent != null && fileContent.ContentLength > 0)
                    {
                        var uploader = new FileUploader(fileContent, "files");
                        var uploadedFile = await uploader.Upload();
                    }
                }
            }
            catch (Exception)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return Json("Upload failed");
            }

            return Json("File uploaded successfully");
        }
 protected void Upload(object sender, EventArgs e)
 {
     RobotTableAdapters.documents_attachmentTableAdapter robotAttachment = new RobotTableAdapters.documents_attachmentTableAdapter();
     string filename = new FileUploader().uploadFile(FileUpload1); int documentId = 0;
     int collateralId = Convert.ToInt32(Request.QueryString["collateralId"]); 
     int CollateralTypeId = Convert.ToInt32(Request.QueryString["CollateralTypeId"]);
     int CollateralDetailsId = Convert.ToInt32(hiddenDetailsId.Text);
     
     if ((hiddenDocID.Text) != null & (hiddenDocID.Text != ""))
     {
         //return;
         documentId = Convert.ToInt32(hiddenDocID.Text);
         //robotAttachment.Insert(filename, documentId, collateralId);
         robotAttachment.proc_AllocateFileToDocument(filename, documentId, collateralId, CollateralDetailsId, CollateralTypeId,Smart.GetEmployeeID());         
         
         TextBox1.Text = documentId.ToString();
     }
     else
     {
         
         robotAttachment.proc_AllocateFileToDocument(filename, Convert.ToInt32(TextBox1.Text), collateralId, CollateralDetailsId, CollateralTypeId, Smart.GetEmployeeID());
     } 
     UpdateDocumentCategory();
 docGrid.DataBind();
 }
    protected void Upload(object sender, EventArgs e)
    {
		RobotTableAdapters.documents_attachmentTableAdapter robotAttachment = new RobotTableAdapters.documents_attachmentTableAdapter();
        string filename = new FileUploader().uploadFile(FileUpload1); int documentId = 0;
        int collateralId = Convert.ToInt32(Request.QueryString["collateralId"]); 
        if ((hiddenDocID.Text) != null & (hiddenDocID.Text != ""))
        {
            //return;
            documentId = Convert.ToInt32(hiddenDocID.Text);
            robotAttachment.proc_AllocateFileToDocument(filename, documentId, collateralId);
            TextBox1.Text = documentId.ToString();
        }
        else
        {
            robotAttachment.proc_AllocateFileToDocument(filename, Convert.ToInt32(TextBox1.Text), collateralId);         
        } 
    }
示例#6
0
 private void FillFieldTypeOptions()
 {
     ContentTypeInfo contentTypeInfo = _contentTypeProvider.Select(ContentTypeId, ErrorList);
     if (contentTypeInfo != null)
     {
         FieldInfo info = FieldInfo.GetFieldArray(contentTypeInfo.FieldsXml).FirstOrDefault(x => x.Name == Id);
         pnlCustomControlOptions.Controls.Clear();
         switch (FormHelper.GetFieldTypeByCode(drlFieldType.SelectedValue))
         {
             case FormFieldType.TextBoxControl:
                 TextBoxControl control = new TextBoxControl();
                 control.ViewMode = FormControlViewMode.Development;
                 control.ID = FormFieldTypeCode.TEXTBOX;
                 if (info != null)
                     control.Value = info.Options;
                 pnlCustomControlOptions.Controls.Add(control);
                 break;
             case FormFieldType.DatePickerControl:
                 DatePicker datepicker = new DatePicker();
                 datepicker.ViewMode = FormControlViewMode.Development;
                 datepicker.ID = FormFieldTypeCode.DATEPICKER;
                 if (info != null)
                     datepicker.Value = info.Options;
                 pnlCustomControlOptions.Controls.Add(datepicker);
                 break;
             case FormFieldType.DateTimePickerControl:
                 DateTimePicker datetimepicker = new DateTimePicker();
                 datetimepicker.ViewMode = FormControlViewMode.Development;
                 datetimepicker.ID = FormFieldTypeCode.DATETIMEPICKER;
                 if (info != null)
                     datetimepicker.Value = info.Options;
                 pnlCustomControlOptions.Controls.Add(datetimepicker);
                 break;
             case FormFieldType.YesNoSelector:
                 YesNoSelector yesnoselector = new YesNoSelector();
                 yesnoselector.ViewMode = FormControlViewMode.Development;
                 yesnoselector.ID = FormFieldTypeCode.YESNOSELECTOR;
                 if (info != null)
                     yesnoselector.Value = info.Options;
                 pnlCustomControlOptions.Controls.Add(yesnoselector);
                 break;
             case FormFieldType.FileUpload:
                 FileUploader fuploader = new FileUploader();
                 fuploader.ViewMode = FormControlViewMode.Development;
                 fuploader.ID = FormFieldTypeCode.FILEUPLOAD;
                 if (info != null)
                     fuploader.Value = info.Options;
                 pnlCustomControlOptions.Controls.Add(fuploader);
                 break;
             case FormFieldType.YearSelector:
                 YearSelector yearselector = new YearSelector();
                 yearselector.ViewMode = FormControlViewMode.Development;
                 yearselector.ID = FormFieldTypeCode.YEARSELECTOR;
                 if (info != null)
                     yearselector.Value = info.Options;
                 pnlCustomControlOptions.Controls.Add(yearselector);
                 break;
             case FormFieldType.CaptchaControl:
                 AbstractBasicUserControl captcha =
                     (AbstractBasicUserControl)
                     this.Page.LoadControl("~/");
                 captcha.ViewMode = FormControlViewMode.Development;
                 captcha.ID = FormFieldTypeCode.CAPTCHA;
                 if (info != null)
                     captcha.Value = info.Options;
                 pnlCustomControlOptions.Controls.Add(captcha);
                 break;
             case FormFieldType.GuidGenerator:
                 GuidGeneratorControl guidcontrol = new GuidGeneratorControl();
                 guidcontrol.ViewMode = FormControlViewMode.Development;
                 pnlCustomControlOptions.Controls.Add(guidcontrol);
                 break;
             case FormFieldType.FckEditor:
                 FckEditorControl fckeditor = new FckEditorControl();
                 fckeditor.ID = FormFieldTypeCode.FCKEDITOR;
                 fckeditor.ViewMode = FormControlViewMode.Development;
                 if (info != null)
                     fckeditor.Value = info.Options;
                 pnlCustomControlOptions.Controls.Add(fckeditor);
                 break;
             case FormFieldType.ListLookUp:
                 ListLookUp listLookUp = new ListLookUp();
                 listLookUp.ViewMode = FormControlViewMode.Development;
                 listLookUp.ID = FormFieldTypeCode.LISTLOOKUP;
                 if (info != null)
                     listLookUp.Value = info.Options;
                 pnlCustomControlOptions.Controls.Add(listLookUp);
                 break;
             case FormFieldType.ContentTypeLookUp:
                 ContentTypeLookUp contentTypeLookUp = new ContentTypeLookUp();
                 contentTypeLookUp.ViewMode = FormControlViewMode.Development;
                 contentTypeLookUp.ID = FormFieldTypeCode.CONTENTTYPELOOKUP;
                 if (info != null)
                     contentTypeLookUp.Value = info.Options;
                 pnlCustomControlOptions.Controls.Add(contentTypeLookUp);
                 break;
             case FormFieldType.ParameterGetter:
                 ParameterGetterControl parameterGetterControl = new ParameterGetterControl();
                 parameterGetterControl.ID = FormFieldTypeCode.PARAMETERGETTER;
                 parameterGetterControl.ViewMode = FormControlViewMode.Development;
                 if (info != null)
                     parameterGetterControl.Value = info.Options;
                 pnlCustomControlOptions.Controls.Add(parameterGetterControl);
                 break;
             case FormFieldType.UserProfileGetter:
                 FromUserProfileControl userProfileControl = new FromUserProfileControl();
                 userProfileControl.ID = FormFieldTypeCode.USERPROFILEGETTER;
                 userProfileControl.ViewMode = FormControlViewMode.Development;
                 if (info != null)
                     userProfileControl.Value = info.Options;
                 pnlCustomControlOptions.Controls.Add(userProfileControl);
                 break;
             //Load Custom Form control
             default:
                 //AbstractBasicUserControl abstarctcontrol =
                 //    this.CreateCustomFormControl(ddlFieldType.SelectedItem.Value);
                 //abstarctcontrol.Value = info.Options;
                 //pnlCustomControlOptions.Controls.Add(abstarctcontrol);
                 break;
         }
     }
 }
示例#7
0
文件: Email.cs 项目: Ganon11/Rock
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Controls.Clear();

            tbFromName = new RockTextBox();
            tbFromName.ID = string.Format( "tbFromName_{0}", this.ID );
            tbFromName.Label = "From Name";
            Controls.Add( tbFromName );

            tbFromAddress = new RockTextBox();
            tbFromAddress.ID = string.Format( "tbFromAddress_{0}", this.ID );
            tbFromAddress.Label = "From Address";
            Controls.Add( tbFromAddress );

            tbReplyToAddress = new RockTextBox();
            tbReplyToAddress.ID = string.Format( "tbReplyToAddress_{0}", this.ID );
            tbReplyToAddress.Label = "Reply To Address";
            Controls.Add( tbReplyToAddress );

            tbSubject = new RockTextBox();
            tbSubject.ID = string.Format( "tbSubject_{0}", this.ID );
            tbSubject.Label = "Subject";
            Controls.Add( tbSubject );

            htmlMessage = new HtmlEditor();
            htmlMessage.ID = string.Format( "htmlMessage_{0}", this.ID );
            htmlMessage.AdditionalConfigurations = "autoParagraph: false,";
            htmlMessage.MergeFields.Clear();
            htmlMessage.MergeFields.Add( "GlobalAttribute" );
            htmlMessage.MergeFields.Add( "Rock.Model.Person" );
            htmlMessage.MergeFields.Add( "UnsubscribeOption" );
            this.AdditionalMergeFields.ForEach( m => htmlMessage.MergeFields.Add( m ) );
            htmlMessage.Label = "Message";
            htmlMessage.Height = 600;
            Controls.Add( htmlMessage );

            tbTextMessage = new RockTextBox();
            tbTextMessage.ID = string.Format( "tbTextMessage_{0}", this.ID );
            tbTextMessage.Label = "Message (Text Version)";
            tbTextMessage.TextMode = TextBoxMode.MultiLine;
            tbTextMessage.Rows = 5;
            tbTextMessage.CssClass = "span12";
            Controls.Add( tbTextMessage );

            hfAttachments = new HiddenField();
            hfAttachments.ID = string.Format( "hfAttachments_{0}", this.ID );
            Controls.Add( hfAttachments );

            fuAttachments = new FileUploader();
            fuAttachments.ID = string.Format( "fuAttachments_{0}", this.ID );
            fuAttachments.Label = "Attachments";
            fuAttachments.FileUploaded += fuAttachments_FileUploaded;
            Controls.Add( fuAttachments );
        }
示例#8
0
文件: Email.cs 项目: NewSpring/Rock
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Controls.Clear();

            tbFromName = new RockTextBox();
            tbFromName.ID = string.Format( "tbFromName_{0}", this.ID );
            tbFromName.Label = "From Name";
            Controls.Add( tbFromName );

            lFromName = new RockLiteral();
            lFromName.ID = string.Format( "lFromName_{0}", this.ID );
            lFromName.Label = "From Name";
            Controls.Add( lFromName );

            ebFromAddress = new EmailBox();
            ebFromAddress.ID = string.Format( "ebFromAddress_{0}", this.ID );
            ebFromAddress.Label = "From Address";
            Controls.Add( ebFromAddress );

            lFromAddress = new RockLiteral();
            lFromAddress.ID = string.Format( "lFromAddress_{0}", this.ID );
            lFromAddress.Label = "From Address";
            Controls.Add( lFromAddress );

            ebReplyToAddress = new EmailBox();
            ebReplyToAddress.ID = string.Format( "ebReplyToAddress_{0}", this.ID );
            ebReplyToAddress.Label = "Reply To Address";
            Controls.Add( ebReplyToAddress );

            tbSubject = new RockTextBox();
            tbSubject.ID = string.Format( "tbSubject_{0}", this.ID );
            tbSubject.Label = "Subject";
            tbSubject.Help = "<span class='tip tip-lava'></span>";
            Controls.Add( tbSubject );

            htmlMessage = new HtmlEditor();
            htmlMessage.ID = string.Format( "htmlMessage_{0}", this.ID );
            //htmlMessage.AdditionalConfigurations = "autoParagraph: false,";
            htmlMessage.Help = "<span class='tip tip-lava'></span> <span class='tip tip-html'>";
            this.AdditionalMergeFields.ForEach( m => htmlMessage.MergeFields.Add( m ) );
            htmlMessage.Label = "Message";
            htmlMessage.Height = 600;
            Controls.Add( htmlMessage );

            tbTextMessage = new RockTextBox();
            tbTextMessage.ID = string.Format( "tbTextMessage_{0}", this.ID );
            tbTextMessage.Label = "Message (Text Version)";
            tbTextMessage.TextMode = TextBoxMode.MultiLine;
            tbTextMessage.Rows = 5;
            tbTextMessage.CssClass = "span12";
            Controls.Add( tbTextMessage );

            hfAttachments = new HiddenField();
            hfAttachments.ID = string.Format( "hfAttachments_{0}", this.ID );
            Controls.Add( hfAttachments );

            fuAttachments = new FileUploader();
            fuAttachments.ID = string.Format( "fuAttachments_{0}", this.ID );
            fuAttachments.Label = "Attachments";
            fuAttachments.FileUploaded += fuAttachments_FileUploaded;
            Controls.Add( fuAttachments );
        }
示例#9
0
        public bool AddVM(VMDetails VMData)
        {

            var FP = VMData.UtilFileLocation;
            var FU = new FileUploader();
            var blob = FU.UploadFileToStorage(FP, true);
            var comm = new MLCommunicator();
            var result = comm.GetUtilDataFromFile(blob);
            var d = result.Result;
            var UtilData = new UtilizationCalculator();
            var UD = UtilData.getUtilPattern(d);

            AddVMInDB(VMData, blob, UD);

            // now we need to insert this data in SQL Azure for the given VM

            foreach (var u in UD)
            {
                Console.WriteLine(u.UtilizationType);
                foreach (var tr in u.TimeRanges)
                {
                    Console.WriteLine("{0}, {1}", tr.StartTime, tr.StopTime);
                }
            }
            //  populateTreeView();
            return true;

            // return Json(true, JsonRequestBehavior.AllowGet);

        }