コード例 #1
0
        public object GetJsonLink(DataSet dsresult)
        {
            if (dsresult != null && dsresult.Tables.Count == 1 && dsresult.Tables[0].Rows.Count > 0)
            {
                string JSONString = string.Empty;
                JSONString = JsonConvert.SerializeObject(dsresult.Tables[0]);

                StorageClient storageClient = new StorageClient();
                return storageClient.GetBlobLink(JSONString);
            }
            return null;
        }
コード例 #2
0
        public object GetCsvLink(DataSet dsresult)
        {
            StringBuilder sbData = new StringBuilder();
            if (dsresult != null && dsresult.Tables.Count == 1 && dsresult.Tables[0].Rows.Count > 0)
            {
                bool isFirst = true;
                foreach (DataColumn col in dsresult.Tables[0].Columns)
                {
                    if (isFirst)
                    {
                        sbData.Append(col.ColumnName);
                        isFirst = false;
                    }
                    else
                        sbData.Append(string.Format(",{0}", col.ColumnName));
                }
                int colCnt = dsresult.Tables[0].Columns.Count;
                foreach (DataRow row in dsresult.Tables[0].Rows)
                {
                    sbData.AppendLine();
                    isFirst = true;
                    for (int i = 0; i < colCnt; i++)
                    {
                        if (isFirst)
                        {
                            sbData.Append(row[i]);
                            isFirst = false;
                        }
                        else
                            sbData.Append(string.Format(",{0}", row[i]));
                    }
                }

                StorageClient storageClient = new StorageClient();
                string csvLink = storageClient.GetBlobLink(sbData);

                return csvLink;
            }
            return null;
        }