public static string SaveUploadedFileToFtp(ColumnField field, string strFileName, string contentType, System.IO.Stream stream) { if (!field.FtpUpload.Override && CheckIfFileExistInFtp(field, strFileName)) { throw new DuradosException(field.View.Database.Localizer.Translate("File with same name already exist")); } System.Net.FtpWebRequest request = CreateFtpRequest(field, strFileName); request.Method = System.Net.WebRequestMethods.Ftp.UploadFile; byte[] buffer = new byte[stream.Length]; //StreamReader sourceStream = new StreamReader(stream); //Only for text files !!! //byte[] fileContents = System.Text.Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());//Only for text files !!! int count = stream.Read(buffer, 0, buffer.Length); request.ContentLength = buffer.Length; using (Stream requestStream = request.GetRequestStream()) { requestStream.Write(buffer, 0, buffer.Length); } System.Net.FtpWebResponse response = (System.Net.FtpWebResponse)request.GetResponse(); response.Close(); return(string.Empty);//response.StatusCode / response.StatusDescription }
protected virtual string GetTemplateForNew(View view, Dictionary <string, object> values) { string templateFieldName; if (view.Name == CRMViews.Proposal.ToString()) { templateFieldName = Proposal.FK_Proposal_Template_Parent.ToString(); } else { templateFieldName = v_ProposalLast2Months.FK_Proposal_Template1_Parent.ToString(); } string templatePK = values[templateFieldName].ToString(); Durados.Web.Mvc.View templateView = GetView(CRMViews.Template.ToString()); string documentLocationFiledName = Template.DocumentLocation.ToString(); ColumnField documentLocationField = (ColumnField)templateView.Fields[documentLocationFiledName]; string virtualPath = documentLocationField.Upload.UploadVirtualPath; if (values[Proposal.WordDocument.ToString()].ToString() != string.Empty) { documentLocationFiledName = Proposal.WordDocument.ToString(); documentLocationField = (ColumnField)view.Fields[documentLocationFiledName]; virtualPath = documentLocationField.Upload.UploadVirtualPath; return(HttpContext.Server.MapPath(virtualPath + values[Proposal.WordDocument.ToString()].ToString())); } return(GetTemplate(templatePK, templateView, documentLocationFiledName, virtualPath)); }
protected virtual string GetTemplateForNew(View view, Dictionary <string, object> values) { string templateFieldName; //if (view.Name == CRMViews.Proposal.ToString()) if (view.Name == ProposalViewName) { //templateFieldName = Proposal.FK_Proposal_Template_Parent.ToString(); templateFieldName = Proposal_Template_Parent; } else { templateFieldName = Proposal_Last_Template_Parent; } //templateFieldName = v_ProposalLast2Months.FK_Proposal_Template1_Parent.ToString(); string templatePK = values[templateFieldName].ToString(); Durados.Web.Mvc.View templateView = GetView(TemplateViewName); //Durados.Web.Mvc.View templateView = GetView(CRMViews.Template.ToString()); string documentLocationFiledName = DocumentLocationFieldName; //string documentLocationFiledName = Template.DocumentLocation.ToString(); ColumnField documentLocationField = (ColumnField)templateView.Fields[documentLocationFiledName]; string virtualPath = documentLocationField.Upload.UploadVirtualPath; return(GetTemplate(templatePK, templateView, documentLocationFiledName, virtualPath)); }
public void Constructor1() { Field field = new Field("c"); ColumnField table = new ColumnField { Field = field }; Assert.AreSame(table.Field, field); }
private void listViewFields_SelectedIndexChanged(object sender, EventArgs e) { UpdateWindowState(); if (listViewFields.SelectedItems.Count > 0) { ColumnField columnField = (ColumnField)listViewFields.SelectedItems[0].Tag; textBoxWidth.Text = columnField.Width.ToString(); } }
protected virtual string GetTemplate(View view, DataRow dataRow) { string templatePK = dataRow[v_Proposal.Id.ToString()].ToString(); Durados.Web.Mvc.View templateView = GetView(ShadeViews.Template.ToString()); string documentLocationFiledName = v_Proposal.WordDocument.ToString(); ColumnField documentLocationField = (ColumnField)view.Fields[documentLocationFiledName]; string virtualPath = documentLocationField.Upload.UploadVirtualPath; return(GetTemplate(templatePK, view, v_Proposal.WordDocument.ToString(), virtualPath)); }
protected override System.Net.NetworkCredential GetFtpNetworkCredential(ColumnField field) { if (Maps.DemoFtpTempHost.Equals(field.FtpUpload.FtpHost)) { return(new System.Net.NetworkCredential(Maps.DemoFtpUser, Maps.DemoFtpPassword)); } else { return(base.GetFtpNetworkCredential(field)); } }
public async Task <HandleResult> MoveModelField([FromBody] JObject form) { string columnNum = form["columnNum"].ToStr(true); if (columnNum.IsEmpty()) { return(HandleResult.Error("请选择栏目")); } if (!(form["fieldNums"] is JArray jFieldNums) || jFieldNums.Count <= 0) { return(HandleResult.Error("请选择字段")); } var fields = await _modelFieldService.GetByNum(jFieldNums.Select(temp => temp.ToStr()).ToArray()); var columnNumStrings = columnNum.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); var modelFieldNum = new List <string>(); var columnFields = new List <ColumnField>(); foreach (var field in fields) { foreach (var columnNumString in columnNumStrings) { var info = new ColumnField { ColumnNum = columnNumString, Name = field.Name, ModelFieldNum = field.Num, Explain = field.Explain, OptionType = field.OptionType, DataType = field.DataType, Options = field.Options, }; info.Init(); columnFields.Add(info); modelFieldNum.Add(field.Num); } } if (columnNumStrings.Length <= 1) { var verify = await _service.GetByModelFieldNum(columnNumStrings[0], modelFieldNum); if (verify.Any()) { return(HandleResult.Error("选择的字段有的已存在")); } } return(await _service.Add(columnFields)); }
protected virtual string GetTemplateForEdit(View view, Dictionary <string, object> values) { string templatePK = values[Proposal.Id.ToString()].ToString(); Durados.Web.Mvc.View templateView = GetView(CRMViews.Template.ToString()); string documentLocationFiledName = Proposal.WordDocument.ToString(); ColumnField documentLocationField = (ColumnField)view.Fields[documentLocationFiledName]; string virtualPath = documentLocationField.Upload.UploadVirtualPath; return(GetTemplate(templatePK, view, Proposal.WordDocument.ToString(), virtualPath)); }
protected override string GetFtpUploadTarget(ColumnField field, string strFileName) { if (Maps.DemoFtpTempHost.Equals(field.FtpUpload.FtpHost)) { return("ftp://" + Maps.DemoFtpHost + ":" + Maps.DemoFtpPort + "/" + Maps.GetCurrentAppName() + field.FtpUpload.GetFtpBasePath(strFileName)); } else { return(base.GetFtpUploadTarget(field, strFileName)); } }
protected override bool FtpUploadValidSize(ColumnField field, float fileSize) { if (Maps.DemoFtpTempHost.Equals(field.FtpUpload.FtpHost)) { return(fileSize * 1024 < Maps.DemoFtpFileSizeLimitKb); } else { return(base.FtpUploadValidSize(field, fileSize)); } }
protected virtual string SaveUploadedFileToAzure(ColumnField field, string strFileName, string contentType, System.IO.Stream stream) { try { return(AzureHelper.SaveUploadedFileToAzure(field.FtpUpload.AzureAccountName, field.FtpUpload.GetDecryptedAzureAccountKey(Map.GetConfigDatabase()), field.FtpUpload.DirectoryBasePath, strFileName, contentType, stream)); } catch (Exception exception) { Map.Logger.Log(GetControllerNameForLog(this.ControllerContext), this.ControllerContext.RouteData.Values["action"].ToString(), exception.Source, exception, 1, null); throw new Durados.DuradosException(Map.Database.Localizer.Translate("Upload failed: " + exception.Message)); } }
protected virtual string SaveUploadedFileToFtp(ColumnField field, string strFileName, string contentType, System.IO.Stream stream) { try { return(FtpHelper.SaveUploadedFileToFtp(field, strFileName)); } catch (Exception exception) { Map.Logger.Log(GetControllerNameForLog(this.ControllerContext), this.ControllerContext.RouteData.Values["action"].ToString(), exception.Source, exception, 1, null); throw new Durados.DuradosException(Map.Database.Localizer.Translate("Operation failed" + ", " + exception.Message)); } }
public Json.ProductInfo GetProductInfo(string pk) { View productView = (View)Durados.Web.Mvc.Map.Database.Views[ShadeViews.Product.ToString()]; Json.ProductInfo productInfo = new Durados.Web.Mvc.Specifics.Shade.CRM.BusinessLogic.Json.ProductInfo(); DataRow productRow = productView.GetDataRow(pk); ColumnField descriptionField = (ColumnField)productView.Fields[Durados.Web.Mvc.Specifics.Shade.CRM.Product.Description.ToString()]; string description = descriptionField.GetValue(productRow); productInfo.Description = description; ParentField productPriceCategoryField = (ParentField)productView.Fields[Durados.Web.Mvc.Specifics.Shade.CRM.Product.FK_Product_ProductPriceCategory_Parent.ToString()]; string productPriceCategoryId = productPriceCategoryField.GetValue(productRow); View productPriceView = (Durados.Web.Mvc.View)Map.Database.Views[ShadeViews.ProductPrice.ToString()]; Dictionary <string, object> values = new Dictionary <string, object>(); values.Add(ProductPrice.FK_ProductPrice_ProductCategory_Parent.ToString(), productPriceCategoryId); Dictionary <string, SortDirection> sortColumns = new Dictionary <string, SortDirection>(); string sortColumn = ProductPrice.Width.ToString(); if (!string.IsNullOrEmpty(sortColumn)) { sortColumns.Add(sortColumn, SortDirection.Asc); } int rowCount = 0; DataView dataView = productPriceView.FillPage(1, 10000, values, false, sortColumns, out rowCount, null, null); List <Json.Price> prices = new List <Durados.Web.Mvc.Specifics.Shade.CRM.BusinessLogic.Json.Price>(); foreach (DataRow productPriceRow in dataView.Table.Rows) { double cost = Convert.ToDouble(productPriceRow[ProductPrice.Cost.ToString()]); double pprice = (productPriceRow[ProductPrice.Price.ToString()] == DBNull.Value) ? 0 : Convert.ToDouble(productPriceRow[ProductPrice.Price.ToString()]); double width = Convert.ToDouble(productPriceRow[ProductPrice.Width.ToString()]); double height = Convert.ToDouble(productPriceRow[ProductPrice.Height.ToString()]); bool seamed = Convert.ToBoolean(productPriceRow[ProductPrice.Seamed.ToString()]); prices.Add(new Json.Price() { Cost = cost, PPrice = pprice, Height = height, Width = width, Seamed = seamed }); } productInfo.Prices = prices.OrderBy(p => p.Width).OrderBy(p => p.Height).ToArray(); return(productInfo); }
protected string GetRadioLabel(ColumnField field, bool b) { string s = b ? field.View.Database.True : field.View.Database.False; if (Map.Database.Localization != null) { return(Map.Database.Localizer.Translate(s)); } else { return(s); } }
public virtual string GetFileName(Durados.View view, string documentFieldName, string fileName) { if (!view.Fields.ContainsKey(documentFieldName)) { throw new DuradosException("The view " + view.DisplayName + " does not contains the document field name " + documentFieldName); } ColumnField documentField = (ColumnField)view.Fields[documentFieldName]; string virtualPath = documentField.Upload.UploadVirtualPath; string path = HttpContext.Server.MapPath(virtualPath); return(path + fileName); }
protected virtual void LoadColumn(ColumnField columnField, DataRow row, DataRow xmlRow, DataTable table) { string attributeName = GetAttributeName(columnField); if (table.Columns.Contains(attributeName)) { Type attributeType = table.Columns[attributeName].DataType; xmlRow[attributeName] = GetValue(columnField, row, attributeType) ?? DBNull.Value; } else { // handle error } }
public void Init(ColumnField field, object filter) { if (this.field != null) { return; } System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Map.Database.DefaultCulture); this.field = field; System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Map.Database.DefaultCulture); //Bounds dates LowerBoundDate string filters = filter == null? "" : filter.ToString(); string lowerDate = string.Empty; string upperDate = string.Empty; if (filters.Contains("between") && filters.Contains("to")) { string[] words = System.Text.RegularExpressions.Regex.Split(filters.Trim(), "to"); lowerDate = words[0].Substring(7).Trim(); upperDate = words[1].Trim(); } if (lowerDate == string.Empty || lowerDate == string.Empty) { LowerBoundDate = new DateTime(DateTime.Today.Year, 1, 1); UpperBoundDate = new DateTime(DateTime.Today.Year, 12, 31); } else { LowerBoundDate = Durados.DateFormatsMapper.GetDateFromClient(lowerDate, field.Format); UpperBoundDate = Durados.DateFormatsMapper.GetDateFromClient(upperDate, field.Format); LowerBoundDate = new DateTime(LowerBoundDate.Year, LowerBoundDate.Month, 1); DateTime firstDay = new DateTime(UpperBoundDate.Year, UpperBoundDate.Month, 1); UpperBoundDate = firstDay.AddMonths(1).AddDays(-1); } this.FilterText = "between " + LowerBoundDate.ToString(field.Format) + " to " + UpperBoundDate.ToString(field.Format); totalGanttDays = 1 + new TimeSpan(UpperBoundDate.Ticks).Days - new TimeSpan(LowerBoundDate.Ticks).Days; }
private void textBoxWidth_TextChanged(object sender, EventArgs e) { if (listViewFields.SelectedItems.Count > 0) { ColumnField columnField = (ColumnField)listViewFields.SelectedItems[0].Tag; int width = 0; if (Int32.TryParse(textBoxWidth.Text, out width)) { columnField.Width = width; } listViewFields.SelectedItems[0].SubItems[1].Text = width.ToString(); } }
public virtual string GetTemplate(View view, string templateViewName, string templatePK, string documentFieldName, string templateViewFileNameFieldName) { Durados.Web.Mvc.View templateView = GetView(templateViewName); //ColumnField documentLocationField = (ColumnField)view.Fields[documentFieldName]; ColumnField documentLocationField = (ColumnField)templateView.Fields[templateViewFileNameFieldName]; if (documentLocationField.Upload == null) { throw new DuradosException("The field " + documentLocationField.DisplayName + " in view " + view.DisplayName + " must be an uplaod field."); } string virtualPath = documentLocationField.Upload.UploadVirtualPath; return(GetTemplate(templatePK, templateView, templateViewFileNameFieldName, virtualPath)); }
public virtual bool IsHoverEditIconEnabled(Field field, DataRow row, string guid) { bool isHoverEditIconEnabled = false; ColumnField columnField = field as ColumnField; if (columnField != null) { HtmlControlType htmlControlType = columnField.GetHtmlControlType(); if ((htmlControlType == HtmlControlType.Upload || htmlControlType == HtmlControlType.TextArea) && IsEditable(field, row, guid)) { isHoverEditIconEnabled = true; } } return(isHoverEditIconEnabled); }
public virtual ActionResult Send(string viewName, string pk, string body, string subject, string to, string cc, string bcc) { try { if (IsMultiRows(viewName, pk)) { return(RedirectToAction("SendMultiRows", new { viewName = viewName, pks = pk, body = body, subject = subject, to = to, cc = cc, bcc = bcc })); } //DataRow proposalRow = ProposalView.GetDataRow(pk); //Durados.Web.Mvc.ColumnField wordDocumentField = (Durados.Web.Mvc.ColumnField)ProposalView.Fields[Proposal.WordDocument.ToString()]; View view = GetView(viewName); DataRow dataRow = view.GetDataRow(pk); ColumnField attachmentField = GetAttachmentField(view, pk); string file = ""; if (attachmentField != null) { string fileVirtualPath = attachmentField.Upload.UploadVirtualPath; string path = HttpContext.Server.MapPath(fileVirtualPath); string fileName = attachmentField.GetValue(dataRow); file = path + fileName; PrepareAttachedFile(file, viewName, pk); } string userPk = GetUserPK(view, pk, dataRow); PrepareAttachedFile(file, viewName, pk); string from; string fromNick; GetEmailInfo(userPk, out from, out fromNick); if (bcc == null) { bcc = string.Empty; } SendProposalEmail(from, fromNick, to, cc, bcc, body, subject, file); //run after email send command to log messages if needed AfterEmailSent(subject, to, body, file, viewName, pk); return(PartialView("~/Views/Shared/Controls/TextArea.ascx", string.Empty)); } catch (Exception exception) { HandleSendException(viewName, pk, exception); return(PartialView("~/Views/Shared/Controls/ErrorMessage.ascx", FormatExceptionMessage(viewName, "Send", exception))); } }
private List <string> GetFields(ColumnField field, string[] s) { List <string> fields = new List <string>(); for (int i = 0; i < s.Length - 1; i = i + 2)//i++ { if (field.View.Fields.ContainsKey(s[i].ToString())) { fields.Add(s[i].ToString()); } else { fields.Add(string.Empty); } } return(fields); }
private void SaveDataGridColumnWidths() { // Spaltenbreiten auslesen int i = 0; SortedList <int, ColumnField> displayColumns = new SortedList <int, ColumnField>(); SortFieldCollection sfc = new SortFieldCollection(); bool firstColumn = true; foreach (DataGridColumn col in dataGrid.Columns) { // Erste Spalte überspringen (Play-Buttons) if (firstColumn) { firstColumn = false; continue; } ColumnField cf = new ColumnField(); cf.Width = (int)col.Width.DisplayValue; cf.Field = trackListFields[i].Field; displayColumns.Add(col.DisplayIndex, cf); i++; } ColumnFieldCollection cfc = new ColumnFieldCollection(); foreach (ColumnField cf in displayColumns.Values) { cfc.Add(cf); } trackListFields = cfc; cfc.SaveToRegistry("MyMusicTable"); if (ShowItemType == MainControls.ShowItemType.Directory) { trackListSort.SaveToRegistry("DirectoryTableSort"); } else { trackListSort.SaveToRegistry("MyMusicTableSort"); } }
private static System.Net.FtpWebRequest CreateFtpRequest(ColumnField field, string strFileName) { FtpUpload uploader = field.FtpUpload; string target = GetFtpUploadTarget(field, strFileName); System.Net.FtpWebRequest request = (System.Net.FtpWebRequest)System.Net.HttpWebRequest.Create(target); //request.Credentials = new System.Net.NetworkCredential(uploader.FtpUserName, uploader.FtpPassword); //request.Credentials = new System.Net.NetworkCredential(uploader.FtpUserName, uploader.GetDecryptedPassword(Map.GetConfigDatabase())); request.Credentials = GetFtpNetworkCredential(field); request.UsePassive = uploader.UsePassive; request.UseBinary = true; request.KeepAlive = false; return(request); }
protected virtual void CreatePdf(DataActionEventArgs e) { ColumnField wordField = (ColumnField)e.View.Fields[GetWordFieldName()]; string word = null; string sql = "select " + wordField.Name + " from " + e.View.Name + " where Id = " + e.PrimaryKey; word = (new SqlAccess()).ExecuteScalar(e.View.Database.ConnectionString, sql); string virtualPath = wordField.Upload.UploadVirtualPath; string path = HttpContext.Server.MapPath(virtualPath); if (!string.IsNullOrEmpty(word)) { CreatePdf(e, path, word); } }
public async Task <HandleResult> Edit([FromBody] ColumnField model) { if (model.Id <= 0) { return(HandleResult.Error("无效数据")); } var info = await _service.GetById(model.Id); if (info == null) { return(HandleResult.Error("无效数据")); } info.Explain = model.Explain; info.Options = model.Options; return(await _service.Update(info)); }
private List <DateTime?> GetDates(ColumnField field, List <string> fields, DataRow dataRow) { if (field == null) { throw new MissingFieldException("Field does not exists!"); } else { List <DateTime?> dates = new List <DateTime?>(); foreach (string fieldName in fields) { if (!field.View.Fields.ContainsKey(fieldName)) { dates.Add(null); } else { Durados.Field dateField = field.View.Fields[fieldName]; string strDate = dateField.GetValue(dataRow); DateTime date = new DateTime(); bool isValidDate = DateTime.TryParse(strDate, out date); if (isValidDate && date > NADate) { dates.Add(date); } else { dates.Add(null); } } } return(dates); } }
public Json.VendorInfo GetVendorInfo(string pk) { View vendorView = (View)Durados.Web.Mvc.Map.Database.Views[ShadeViews.V_Vendor.ToString()]; Json.VendorInfo vendorInfo = new Durados.Web.Mvc.Specifics.Projects.CRMShade.BusinessLogic.Json.VendorInfo(); DataRow vendorRow = vendorView.GetDataRow(pk); //ColumnField multiplyField = (ColumnField)vendorView.Fields[Durados.Web.Mvc.Specifics.Projects.CRMShade.Organization.Multiply.ToString()]; ColumnField multiplyField = (ColumnField)vendorView.Fields[V_Vendor.Multiply.ToString()]; string s = multiplyField.GetValue(vendorRow); double multiply = 1; if (!string.IsNullOrEmpty(s)) { multiply = Convert.ToDouble(s); } vendorInfo.Multiply = multiply; return(vendorInfo); }
private static string[] ValidateTextLength(View view, Dictionary <string, object> values) { List <string> names = new List <string>(); foreach (string name in values.Keys) { if (view.Fields.ContainsKey(name)) { Field field = view.Fields[name]; if (field.FieldType == FieldType.Column) { ColumnField columnField = (ColumnField)field; if (columnField.DataColumn.DataType == typeof(string) && values[name] != null && columnField.Max > 0 && values[name].ToString().Length > columnField.Max) { names.Add(name); } } } } return(names.ToArray()); }