private void ConcurrencyUpdate(ConcurrencyMode concurrencyMode)
        {
            // 注意:为了方便设计代码生成, t1 为当前对象,t2 则为参考对象。
            _sb.AppendFormat("public static CPQuery ConcurrencyUpdate_{1}({0} t1, {0} t2, {0} t3){{\r\n",
                             _entityType.FullName, concurrencyMode.ToString());

            if (concurrencyMode == ConcurrencyMode.TimeStamp && IsTimeStampFieldNotExist())
            {
                return;
            }

            if (EnsureExistPrimaryField("更新"))
            {
                return;
            }

            //CheckPrimaryKeyValue("t1");
            CheckPrimaryKeyValue("t2");

            _sb.AppendLine("CPQuery query = UpdateSetFields(t1, t3 ?? s_Empty);");
            _sb.AppendLine("if( query == null ) return null;");

            if (concurrencyMode == ConcurrencyMode.TimeStamp)
            {
                _sb.AppendLine("WhereByTimeStamp(query, t2);");
            }
            else
            {
                _sb.AppendLine("WhereByOriginalValue(query, s_Empty, t2);");
            }


            _sb.AppendLine("return query;");
            _sb.AppendLine("}");
        }
示例#2
0
        private void ConcurrencyDelete(ConcurrencyMode concurrencyMode)
        {
            // 注意:为了方便设计代码生成, t1 为当前对象,t2 则为参考对象。
            _sb.AppendFormat("public static CPQuery ConcurrencyDelete_{1}({0} t2) {{\r\n",
                             _entityType.FullName, concurrencyMode.ToString());

            if (concurrencyMode == ConcurrencyMode.TimeStamp && IsTimeStampFieldNotExist())
            {
                return;
            }

            if (EnsureExistPrimaryField("删除"))
            {
                return;
            }

            //CheckPrimaryKeyValue("t1");
            CheckPrimaryKeyValue("t2");

            if (concurrencyMode == ConcurrencyMode.OriginalValue)
            {
                _sb.AppendFormat("{0} t1 = s_Empty;\r\n", _entityType.FullName);
            }

            //_sb.AppendFormat("CPQuery query = CPQuery.Create() + \"delete from [{0}] \"; \r\n", _tableInfo.DbName);
            _sb.AppendFormat("CPQuery query = CPQuery.Create() + \"delete from {0} \"; \r\n", _tableInfo.DbName);

            if (concurrencyMode == ConcurrencyMode.TimeStamp)
            {
                _sb.AppendLine("WhereByTimeStamp(query, t2);");
            }
            else
            {
                _sb.AppendLine("WhereByOriginalValue(query, t1, t2);");
            }

            _sb.AppendLine("return query;");
            _sb.AppendLine("}");
        }
示例#3
0
        public Job CreateJob(string SfObject, ContentType contentType, Operations operation, ConcurrencyMode mode, string ExternalIdFieldName)
        {
            string jobRequestXML = "";
            String externalField = String.Empty;

            if (String.IsNullOrWhiteSpace(ExternalIdFieldName) == false)
            {
                externalField = "<externalIdFieldName>" + ExternalIdFieldName + "</externalIdFieldName>";
            }
            if (contentType != ContentType.None)
            {
                jobRequestXML = String.Format(jobRequestXMLTemplate,
                                              operation.ToString(),
                                              SfObject,
                                              "<contentType>" + contentType.ToString() + "</contentType>",
                                              externalField,
                                              (operation == Operations.upsert ? "" : "<concurrencyMode>" + mode.ToString() + "</concurrencyMode>"));
            }
            else
            {
                jobRequestXML = String.Format(jobRequestXMLTemplate,
                                              operation.ToString(),
                                              SfObject,
                                              "",
                                              externalField,
                                              (operation == Operations.upsert ? "" : "<concurrencyMode>" + mode.ToString() + "</concurrencyMode>"));
            }

            String createJobUrl = "https://" + ApiEndPoint.Host + "/services/async/" + Version.ToString() + "/job";
            //String createJobUrl = "https://" + +"-api.salesforce.com/services/async/" + api + "/job";

            //jobRequestXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><jobInfo xmlns=\"http://www.force.com/2009/06/asyncapi/dataload\">  <operation>query</operation>   <object>Opportunity</object>   <concurrencyMode>Parallel</concurrencyMode>    <contentType>CSV</contentType> </jobInfo>";

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(jobRequestXML);

            String resultXML = invokeRestAPI(createJobUrl, doc.InnerXml);//, "POST", "application/xml; charset=UTF-8");

            return(Job.Create(resultXML));
        }
示例#4
0
 /// <summary>
 /// Returns a <see cref="System.String"/> that represents this
 /// instance.
 /// </summary>
 /// <returns>
 /// A <see cref="System.String"/> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return(type + "," + mode.ToString() + "," + width + "x" + height
            + "," + milliseconds);
 }