Example #1
0
        public void SetValue(object targetResource, string propertyName, object propertyValue)
        {
            object obj;

            try
            {
                ChangeDescription changeDescription = (ChangeDescription)targetResource;
                if (!TableResourceContainer.IsUtilityTables(this.m_currentResourceContainer.Name))
                {
                    UtilityRow row = (UtilityRow)changeDescription.Row;
                    if (!propertyName.Equals("Timestamp"))
                    {
                        if (changeDescription.UpdateType != UpdateKind.Insert && changeDescription.UpdateType != UpdateKind.InsertOrMerge && changeDescription.UpdateType != UpdateKind.InsertOrReplace && (propertyName.Equals("PartitionKey") || propertyName.Equals("RowKey")))
                        {
                            throw new InvalidOperationException("Cannot update key values.");
                        }
                        if (!TableDataContextHelper.IsValidPropertyName(propertyName, this.ApiVersion))
                        {
                            throw new TableServiceGeneralException(TableServiceError.PropertyNameInvalid, null);
                        }
                        if (row.ColumnValues.TryGetValue(propertyName, out obj) && obj != null)
                        {
                            throw new XStoreArgumentException("Multiple entries for same property specified in the input");
                        }
                        row[propertyName] = propertyValue;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    UtilityTable utilityTable = (UtilityTable)changeDescription.Row;
                    if (changeDescription.UpdateType == UpdateKind.Insert)
                    {
                        utilityTable[propertyName] = propertyValue;
                        if (string.Equals(propertyName, "TableName"))
                        {
                            if (TableResourceContainer.IsUtilityTables(propertyValue as string))
                            {
                                throw new TableServiceArgumentException("Invalid table container name");
                            }
                            if (!Regex.IsMatch(propertyValue as string, "^[A-Za-z][A-Za-z0-9]{2,62}$"))
                            {
                                throw new InvalidResourceNameException("Invalid table name");
                            }
                        }
                    }
                }
            }
            catch (InvalidCastException invalidCastException1)
            {
                InvalidCastException invalidCastException = invalidCastException1;
                CultureInfo          invariantCulture     = CultureInfo.InvariantCulture;
                object[]             objArray             = new object[] { propertyName };
                throw new XStoreArgumentException(string.Format(invariantCulture, "Invalid data type for property {0}", objArray), invalidCastException);
            }
        }
Example #2
0
        private DataTable fetchPeriodPctChgTable()
        {
            DateTime  dtBegin = dateTimePicker1.Value;
            DateTime  dtEnd;
            DataTable dtIndustryPctChg;
            //DataTable dtIndustryVolume;

            string strWindCode = UtilityTable.getCodeStringFromDataTableCol(dtIndustryIndex, 1);

            if (UtilityCalendar.isAfterTradeHour(dateTimePicker1.Value))
            {
                dtBegin = dateTimePicker1.Value;
            }
            else
            {
                dtBegin = UtilityCalendar.fetchDayOffset(DateTime.Now.AddDays(-1), 0);
            }
            dtEnd = dtBegin;

            WindData wd = ConnWindData.fetchTimeSeriesSecInfo(strWindCode, "pct_chg", dtEnd, dtBegin);

            dtIndustryPctChg = ConnWindData.convertWindDatatoTable(wd);

            //wd = ConnWindData.fetchTimeSeriesSecInfo(strWindCode, "volume", dtEnd, dtBegin);
            //dtIndustryVolume = ConnWindData.convertWindDatatoTable(wd);

            dtIndustryPctChg.Columns.Add("Sector Name");
            dtIndustryPctChg.Columns.Add("Sector Code");
            dtIndustryPctChg.Columns.Add("PCT CHG", typeof(double));
            dtIndustryPctChg.Columns.Add("Volume", typeof(double));
            for (int i = 0; i < dtIndustryPctChg.Rows.Count; i++)
            {
                string strIndustryName = dtIndustryIndex.Rows[i][2].ToString();
                dtIndustryPctChg.Rows[i]["Sector Name"] = strIndustryName.Substring(0, strIndustryName.Length - 4);
                dtIndustryPctChg.Rows[i]["Sector Code"] = dtIndustryIndex.Rows[i][1];
                dtIndustryPctChg.Rows[i]["PCT CHG"]     = double.Parse(dtIndustryPctChg.Rows[i]["PCT_CHG"].ToString()) / 100;
                //dtIndustryPctChg.Rows[i]["Volume"] = double.Parse(dtIndustryVolume.Rows[i]["VOLUME"].ToString()) / 10000;
            }

            dtIndustryPctChg.Columns["PCT_CHG"].Dispose();
            DataView dv = dtIndustryPctChg.DefaultView;

            dv.Sort = "PCT CHG Asc";
            return(dv.ToTable());
        }
Example #3
0
        private void SaveTableChanges()
        {
            this.FailedCommandIndex = 0;
            if (this.changeDescriptionList == null || this.changeDescriptionList.Count != 1)
            {
                throw new XStoreArgumentException("Invalid number of table commands. Only a single table command is allowed.");
            }
            ChangeDescription changeDescription = this.changeDescriptionList.FirstOrDefault <ChangeDescription>();

            this.CheckPermission(changeDescription.TableName, true, false, changeDescription.UpdateType);
            if (changeDescription.UpdateType != UpdateKind.Insert)
            {
                if (changeDescription.UpdateType != UpdateKind.Delete)
                {
                    throw new NotSupportedException("Operation is not supported!");
                }
                UtilityTable utilityTable = this.ExecuteQuery <UtilityTable>(changeDescription);
                if (utilityTable == null)
                {
                    throw new DataServiceException(404, "Resource not found.");
                }
                changeDescription.Row = utilityTable;
                Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer sqlTableContainer = this.GetSqlTableContainer(((UtilityTable)changeDescription.Row).TableName);
                this.m_dbContext.TableContainers.DeleteOnSubmit(sqlTableContainer);
                this.m_dbContext.SubmitChanges();
                return;
            }
            Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer tableContainer = new Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer()
            {
                AccountName = changeDescription.AccountName
            };
            if (string.IsNullOrEmpty(((UtilityTable)changeDescription.Row).TableName))
            {
                throw new TableServiceGeneralException(TableServiceError.PropertiesNeedValue, null);
            }
            tableContainer.TableName = ((UtilityTable)changeDescription.Row).TableName.ToLowerInvariant();
            tableContainer.CasePreservedTableName = ((UtilityTable)changeDescription.Row).TableName;
            this.m_dbContext.TableContainers.InsertOnSubmit(tableContainer);
            this.m_dbContext.SubmitChanges();
        }
Example #4
0
        /// <summary>
        /// 单季度净利润下限
        /// </summary>
        /// <param name="strWindCode"></param>
        /// <param name="dtReportDater"></param>
        public static void PreannouncementConditionFilter(DataTable dtStock, DateTime dtReportDate)
        {
            DateTime dtPrevReportDate = UtilityCalendar.getSeasonReportDate(dtReportDate, 1);

            string    strWindCode = UtilityTable.getCodeStringFromDataTableCol(dtStock, 1);
            WindData  wd1         = windProfitNoticeNetProfitMin(strWindCode, dtReportDate);
            DataTable dtNPM       = ConnWindData.convertWindDatatoTable(wd1);

            dtEarningPositivePreannouncement.Columns.Add("DATETIME", Type.GetType("System.DateTime"));
            dtEarningPositivePreannouncement.Columns.Add("WINDCODE", typeof(String));
            dtEarningPositivePreannouncement.Columns.Add("COMNAME", typeof(String));
            dtEarningPositivePreannouncement.Columns.Add("PROFITNOTICE_NETPROFITMIN", typeof(Double));
            for (int i = 0; i < dtStock.Rows.Count; i++)
            {
                DataRow dr = dtEarningPositivePreannouncement.NewRow();
                dr["DATETIME"] = dtStock.Rows[i][0];
                dr["WINDCODE"] = dtStock.Rows[i][1];
                dr["COMNAME"]  = dtStock.Rows[i][2];
                double dPNNPM = double.Parse(dtNPM.Rows[i]["PROFITNOTICE_NETPROFITMIN"].ToString());
                if (dPNNPM > 10000000 && !Double.IsNaN(dPNNPM))
                {
                    dr["PROFITNOTICE_NETPROFITMIN"] = dPNNPM / 10000;
                    dtEarningPositivePreannouncement.Rows.Add(dr);
                }
            }

            String strSelectedWindCode = UtilityTable.getCodeStringFromDataTableCol(dtEarningPositivePreannouncement, 1);

            WindData  wd2        = windNetProfitBelongToParComSH(strSelectedWindCode, dtPrevReportDate);
            DataTable dtNPBTPCSH = ConnWindData.convertWindDatatoTable(wd2);

            dtEarningPositivePreannouncement.Columns.Add("SEASON_NETPROFITMIN", typeof(double));
            for (int i = dtEarningPositivePreannouncement.Rows.Count - 1; i >= 0; i--)
            {
                double dProfitNoticeNetProfit = Double.Parse(dtEarningPositivePreannouncement.Rows[i]["PROFITNOTICE_NETPROFITMIN"].ToString());
                double dNetPorfitBTParComSH   = Double.Parse(dtNPBTPCSH.Rows[i]["NP_BELONGTO_PARCOMSH"].ToString());
                if ((dProfitNoticeNetProfit - dNetPorfitBTParComSH) > 10000000)
                {
                    dtEarningPositivePreannouncement.Rows[i]["SEASON_NETPROFITMIN"] = (dProfitNoticeNetProfit - dNetPorfitBTParComSH) / 10000;
                }
                else
                {
                    dtEarningPositivePreannouncement.Rows[i].Delete();
                }
            }
            strSelectedWindCode = UtilityTable.getCodeStringFromDataTableCol(dtEarningPositivePreannouncement, 1);

            WindData  wd3 = windProfitNoticeChangeMin(strSelectedWindCode, dtReportDate);
            DataTable dtProfitNoticeChangeMin = ConnWindData.convertWindDatatoTable(wd3);

            dtEarningPositivePreannouncement.Columns.Add("PN_CHANGEMIN", typeof(double));
            for (int i = dtEarningPositivePreannouncement.Rows.Count - 1; i >= 0; i--)
            {
                double dChangeMin = double.Parse(dtProfitNoticeChangeMin.Rows[i]["PROFITNOTICE_CHANGEMIN"].ToString());
                if (dChangeMin > 0.7)
                {
                    dtEarningPositivePreannouncement.Rows[i]["PN_CHANGEMIN"] = dChangeMin;
                }
                else
                {
                    dtEarningPositivePreannouncement.Rows[i].Delete();
                }
            }
        }